Lines Matching +full:libiscsi +full:- +full:dev

4  * Copyright (c) 2010-2015 Chelsio Communications, Inc.
41 #define DRV_MODULE_VERSION "0.9.1-ko"
54 MODULE_PARM_DESC(dbg_level, "libiscsi debug level (default=0)");
78 struct cxgbi_ports_map *pmap = &cdev->pmap; in cxgbi_device_portmap_create()
80 pmap->port_csk = kvzalloc(array_size(max_conn, in cxgbi_device_portmap_create()
83 if (!pmap->port_csk) { in cxgbi_device_portmap_create()
85 return -ENOMEM; in cxgbi_device_portmap_create()
88 pmap->max_connect = max_conn; in cxgbi_device_portmap_create()
89 pmap->sport_base = base; in cxgbi_device_portmap_create()
90 spin_lock_init(&pmap->lock); in cxgbi_device_portmap_create()
97 struct cxgbi_ports_map *pmap = &cdev->pmap; in cxgbi_device_portmap_cleanup()
101 for (i = 0; i < pmap->max_connect; i++) { in cxgbi_device_portmap_cleanup()
102 if (pmap->port_csk[i]) { in cxgbi_device_portmap_cleanup()
103 csk = pmap->port_csk[i]; in cxgbi_device_portmap_cleanup()
104 pmap->port_csk[i] = NULL; in cxgbi_device_portmap_cleanup()
108 spin_lock_bh(&csk->lock); in cxgbi_device_portmap_cleanup()
111 spin_unlock_bh(&csk->lock); in cxgbi_device_portmap_cleanup()
121 "cdev 0x%p, p# %u.\n", cdev, cdev->nports); in cxgbi_device_destroy()
124 if (cdev->cdev2ppm) in cxgbi_device_destroy()
125 cxgbi_ppm_release(cdev->cdev2ppm(cdev)); in cxgbi_device_destroy()
126 if (cdev->pmap.max_connect) in cxgbi_device_destroy()
127 kvfree(cdev->pmap.port_csk); in cxgbi_device_destroy()
144 cdev->ports = (struct net_device **)(cdev + 1); in cxgbi_device_register()
145 cdev->hbas = (struct cxgbi_hba **)(((char*)cdev->ports) + nports * in cxgbi_device_register()
148 cdev->dd_data = ((char *)cdev->hbas) + in cxgbi_device_register()
150 spin_lock_init(&cdev->pmap.lock); in cxgbi_device_register()
153 list_add_tail(&cdev->list_head, &cdev_list); in cxgbi_device_register()
157 list_add_tail_rcu(&cdev->rcu_node, &cdev_rcu_list); in cxgbi_device_register()
170 cdev, cdev->nports, cdev->nports ? cdev->ports[0]->name : ""); in cxgbi_device_unregister()
173 list_del(&cdev->list_head); in cxgbi_device_unregister()
177 list_del_rcu(&cdev->rcu_node); in cxgbi_device_unregister()
191 if ((cdev->flags & flag) == flag) { in cxgbi_device_unregister_all()
207 if (cdev->lldev == lldev) { in cxgbi_device_find_by_lldev()
231 "vlan dev %s -> %s.\n", vdev->name, ndev->name); in cxgbi_device_find_by_netdev()
236 for (i = 0; i < cdev->nports; i++) { in cxgbi_device_find_by_netdev()
237 if (ndev == cdev->ports[i]) { in cxgbi_device_find_by_netdev()
238 cdev->hbas[i]->vdev = vdev; in cxgbi_device_find_by_netdev()
248 "ndev 0x%p, %s, NO match found.\n", ndev, ndev->name); in cxgbi_device_find_by_netdev()
263 pr_info("vlan dev %s -> %s.\n", vdev->name, ndev->name); in cxgbi_device_find_by_netdev_rcu()
268 for (i = 0; i < cdev->nports; i++) { in cxgbi_device_find_by_netdev_rcu()
269 if (ndev == cdev->ports[i]) { in cxgbi_device_find_by_netdev_rcu()
270 cdev->hbas[i]->vdev = vdev; in cxgbi_device_find_by_netdev_rcu()
281 "ndev 0x%p, %s, NO match found.\n", ndev, ndev->name); in cxgbi_device_find_by_netdev_rcu()
296 pr_info("vlan dev %s -> %s.\n", vdev->name, ndev->name); in cxgbi_device_find_by_mac()
301 for (i = 0; i < cdev->nports; i++) { in cxgbi_device_find_by_mac()
302 if (!memcmp(ndev->dev_addr, cdev->ports[i]->dev_addr, in cxgbi_device_find_by_mac()
304 cdev->hbas[i]->vdev = vdev; in cxgbi_device_find_by_mac()
315 ndev, ndev->name); in cxgbi_device_find_by_mac()
325 "cdev 0x%p, p#%u.\n", cdev, cdev->nports); in cxgbi_hbas_remove()
327 for (i = 0; i < cdev->nports; i++) { in cxgbi_hbas_remove()
328 chba = cdev->hbas[i]; in cxgbi_hbas_remove()
330 cdev->hbas[i] = NULL; in cxgbi_hbas_remove()
331 iscsi_host_remove(chba->shost, false); in cxgbi_hbas_remove()
332 pci_dev_put(cdev->pdev); in cxgbi_hbas_remove()
333 iscsi_host_free(chba->shost); in cxgbi_hbas_remove()
347 log_debug(1 << CXGBI_DBG_DEV, "cdev 0x%p, p#%u.\n", cdev, cdev->nports); in cxgbi_hbas_add()
349 for (i = 0; i < cdev->nports; i++) { in cxgbi_hbas_add()
353 cdev, i, cdev->ports[i]->name); in cxgbi_hbas_add()
354 err = -ENOMEM; in cxgbi_hbas_add()
358 shost->transportt = stt; in cxgbi_hbas_add()
359 shost->max_lun = max_lun; in cxgbi_hbas_add()
360 shost->max_id = max_conns - 1; in cxgbi_hbas_add()
361 shost->max_channel = 0; in cxgbi_hbas_add()
362 shost->max_cmd_len = SCSI_MAX_VARLEN_CDB_SIZE; in cxgbi_hbas_add()
365 chba->cdev = cdev; in cxgbi_hbas_add()
366 chba->ndev = cdev->ports[i]; in cxgbi_hbas_add()
367 chba->shost = shost; in cxgbi_hbas_add()
369 shost->can_queue = sht->can_queue - ISCSI_MGMT_CMDS_MAX; in cxgbi_hbas_add()
373 cdev, i, cdev->ports[i]->name, chba); in cxgbi_hbas_add()
375 pci_dev_get(cdev->pdev); in cxgbi_hbas_add()
376 err = iscsi_host_add(shost, &cdev->pdev->dev); in cxgbi_hbas_add()
379 cdev, i, cdev->ports[i]->name); in cxgbi_hbas_add()
380 pci_dev_put(cdev->pdev); in cxgbi_hbas_add()
385 cdev->hbas[i] = chba; in cxgbi_hbas_add()
399 * - source port management
414 struct cxgbi_ports_map *pmap = &cdev->pmap; in find_sock_on_port()
418 if (!pmap->max_connect || !pmap->used) in find_sock_on_port()
421 spin_lock_bh(&pmap->lock); in find_sock_on_port()
422 used = pmap->used; in find_sock_on_port()
423 for (i = 0; used && i < pmap->max_connect; i++) { in find_sock_on_port()
424 struct cxgbi_sock *csk = pmap->port_csk[i]; in find_sock_on_port()
427 if (csk->port_id == port_id) { in find_sock_on_port()
428 spin_unlock_bh(&pmap->lock); in find_sock_on_port()
431 used--; in find_sock_on_port()
434 spin_unlock_bh(&pmap->lock); in find_sock_on_port()
441 struct cxgbi_device *cdev = csk->cdev; in sock_get_port()
442 struct cxgbi_ports_map *pmap = &cdev->pmap; in sock_get_port()
447 if (!pmap->max_connect) { in sock_get_port()
449 cdev, csk->port_id, cdev->ports[csk->port_id]->name); in sock_get_port()
450 return -EADDRNOTAVAIL; in sock_get_port()
453 if (csk->csk_family == AF_INET) in sock_get_port()
454 port = &csk->saddr.sin_port; in sock_get_port()
456 port = &csk->saddr6.sin6_port; in sock_get_port()
459 pr_err("source port NON-ZERO %u.\n", in sock_get_port()
461 return -EADDRINUSE; in sock_get_port()
464 spin_lock_bh(&pmap->lock); in sock_get_port()
465 if (pmap->used >= pmap->max_connect) { in sock_get_port()
466 spin_unlock_bh(&pmap->lock); in sock_get_port()
468 cdev, csk->port_id, cdev->ports[csk->port_id]->name); in sock_get_port()
469 return -EADDRNOTAVAIL; in sock_get_port()
472 start = idx = pmap->next; in sock_get_port()
474 if (++idx >= pmap->max_connect) in sock_get_port()
476 if (!pmap->port_csk[idx]) { in sock_get_port()
477 pmap->used++; in sock_get_port()
478 *port = htons(pmap->sport_base + idx); in sock_get_port()
479 pmap->next = idx; in sock_get_port()
480 pmap->port_csk[idx] = csk; in sock_get_port()
481 spin_unlock_bh(&pmap->lock); in sock_get_port()
485 cdev, csk->port_id, in sock_get_port()
486 cdev->ports[csk->port_id]->name, in sock_get_port()
487 pmap->sport_base + idx, pmap->next); in sock_get_port()
491 spin_unlock_bh(&pmap->lock); in sock_get_port()
495 cdev, csk->port_id, cdev->ports[csk->port_id]->name, in sock_get_port()
496 pmap->next); in sock_get_port()
497 return -EADDRNOTAVAIL; in sock_get_port()
502 struct cxgbi_device *cdev = csk->cdev; in sock_put_port()
503 struct cxgbi_ports_map *pmap = &cdev->pmap; in sock_put_port()
506 if (csk->csk_family == AF_INET) in sock_put_port()
507 port = &csk->saddr.sin_port; in sock_put_port()
509 port = &csk->saddr6.sin6_port; in sock_put_port()
512 int idx = ntohs(*port) - pmap->sport_base; in sock_put_port()
515 if (idx < 0 || idx >= pmap->max_connect) { in sock_put_port()
517 cdev, csk->port_id, in sock_put_port()
518 cdev->ports[csk->port_id]->name, in sock_put_port()
523 spin_lock_bh(&pmap->lock); in sock_put_port()
524 pmap->port_csk[idx] = NULL; in sock_put_port()
525 pmap->used--; in sock_put_port()
526 spin_unlock_bh(&pmap->lock); in sock_put_port()
530 cdev, csk->port_id, cdev->ports[csk->port_id]->name, in sock_put_port()
531 pmap->sport_base + idx); in sock_put_port()
542 if (csk->cpl_close) { in cxgbi_sock_free_cpl_skbs()
543 kfree_skb(csk->cpl_close); in cxgbi_sock_free_cpl_skbs()
544 csk->cpl_close = NULL; in cxgbi_sock_free_cpl_skbs()
546 if (csk->cpl_abort_req) { in cxgbi_sock_free_cpl_skbs()
547 kfree_skb(csk->cpl_abort_req); in cxgbi_sock_free_cpl_skbs()
548 csk->cpl_abort_req = NULL; in cxgbi_sock_free_cpl_skbs()
550 if (csk->cpl_abort_rpl) { in cxgbi_sock_free_cpl_skbs()
551 kfree_skb(csk->cpl_abort_rpl); in cxgbi_sock_free_cpl_skbs()
552 csk->cpl_abort_rpl = NULL; in cxgbi_sock_free_cpl_skbs()
566 if (cdev->csk_alloc_cpls(csk) < 0) { in cxgbi_sock_create()
572 spin_lock_init(&csk->lock); in cxgbi_sock_create()
573 kref_init(&csk->refcnt); in cxgbi_sock_create()
574 skb_queue_head_init(&csk->receive_queue); in cxgbi_sock_create()
575 skb_queue_head_init(&csk->write_queue); in cxgbi_sock_create()
576 timer_setup(&csk->retry_timer, NULL, 0); in cxgbi_sock_create()
577 init_completion(&csk->cmpl); in cxgbi_sock_create()
578 rwlock_init(&csk->callback_lock); in cxgbi_sock_create()
579 csk->cdev = cdev; in cxgbi_sock_create()
580 csk->flags = 0; in cxgbi_sock_create()
618 rt = find_route_ipv4(&fl4, 0, daddr->sin_addr.s_addr, 0, in cxgbi_check_route()
619 daddr->sin_port, 0, ifindex); in cxgbi_check_route()
622 be32_to_cpu(daddr->sin_addr.s_addr), in cxgbi_check_route()
623 be16_to_cpu(daddr->sin_port)); in cxgbi_check_route()
624 err = -ENETUNREACH; in cxgbi_check_route()
627 dst = &rt->dst; in cxgbi_check_route()
628 n = dst_neigh_lookup(dst, &daddr->sin_addr.s_addr); in cxgbi_check_route()
630 err = -ENODEV; in cxgbi_check_route()
633 ndev = n->dev; in cxgbi_check_route()
635 if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) { in cxgbi_check_route()
636 pr_info("multi-cast route %pI4, port %u, dev %s.\n", in cxgbi_check_route()
637 &daddr->sin_addr.s_addr, ntohs(daddr->sin_port), in cxgbi_check_route()
638 ndev->name); in cxgbi_check_route()
639 err = -ENETUNREACH; in cxgbi_check_route()
643 if (ndev->flags & IFF_LOOPBACK) { in cxgbi_check_route()
644 ndev = ip_dev_find(&init_net, daddr->sin_addr.s_addr); in cxgbi_check_route()
646 err = -ENETUNREACH; in cxgbi_check_route()
649 mtu = ndev->mtu; in cxgbi_check_route()
650 pr_info("rt dev %s, loopback -> %s, mtu %u.\n", in cxgbi_check_route()
651 n->dev->name, ndev->name, mtu); in cxgbi_check_route()
654 if (!(ndev->flags & IFF_UP) || !netif_carrier_ok(ndev)) { in cxgbi_check_route()
655 pr_info("%s interface not up.\n", ndev->name); in cxgbi_check_route()
656 err = -ENETDOWN; in cxgbi_check_route()
665 &daddr->sin_addr.s_addr, ndev->name); in cxgbi_check_route()
666 err = -ENETUNREACH; in cxgbi_check_route()
671 &daddr->sin_addr.s_addr, ntohs(daddr->sin_port), in cxgbi_check_route()
672 port, ndev->name, cdev); in cxgbi_check_route()
676 err = -ENOMEM; in cxgbi_check_route()
679 csk->cdev = cdev; in cxgbi_check_route()
680 csk->port_id = port; in cxgbi_check_route()
681 csk->mtu = mtu; in cxgbi_check_route()
682 csk->dst = dst; in cxgbi_check_route()
684 csk->csk_family = AF_INET; in cxgbi_check_route()
685 csk->daddr.sin_addr.s_addr = daddr->sin_addr.s_addr; in cxgbi_check_route()
686 csk->daddr.sin_port = daddr->sin_port; in cxgbi_check_route()
687 csk->daddr.sin_family = daddr->sin_family; in cxgbi_check_route()
688 csk->saddr.sin_family = daddr->sin_family; in cxgbi_check_route()
689 csk->saddr.sin_addr.s_addr = fl4.saddr; in cxgbi_check_route()
734 rt = find_route_ipv6(NULL, &daddr6->sin6_addr, ifindex); in cxgbi_check_route6()
738 daddr6->sin6_addr.s6_addr, in cxgbi_check_route6()
739 be16_to_cpu(daddr6->sin6_port)); in cxgbi_check_route6()
740 err = -ENETUNREACH; in cxgbi_check_route6()
744 dst = &rt->dst; in cxgbi_check_route6()
746 n = dst_neigh_lookup(dst, &daddr6->sin6_addr); in cxgbi_check_route6()
750 daddr6->sin6_addr.s6_addr, in cxgbi_check_route6()
751 be16_to_cpu(daddr6->sin6_port)); in cxgbi_check_route6()
752 err = -ENETUNREACH; in cxgbi_check_route6()
755 ndev = n->dev; in cxgbi_check_route6()
757 if (!(ndev->flags & IFF_UP) || !netif_carrier_ok(ndev)) { in cxgbi_check_route6()
758 pr_info("%s interface not up.\n", ndev->name); in cxgbi_check_route6()
759 err = -ENETDOWN; in cxgbi_check_route6()
763 if (ipv6_addr_is_multicast(&daddr6->sin6_addr)) { in cxgbi_check_route6()
764 pr_info("multi-cast route %pI6 port %u, dev %s.\n", in cxgbi_check_route6()
765 daddr6->sin6_addr.s6_addr, in cxgbi_check_route6()
766 ntohs(daddr6->sin6_port), ndev->name); in cxgbi_check_route6()
767 err = -ENETUNREACH; in cxgbi_check_route6()
776 daddr6->sin6_addr.s6_addr, ndev->name); in cxgbi_check_route6()
777 err = -ENETUNREACH; in cxgbi_check_route6()
782 daddr6->sin6_addr.s6_addr, ntohs(daddr6->sin6_port), port, in cxgbi_check_route6()
783 ndev->name, cdev); in cxgbi_check_route6()
787 err = -ENOMEM; in cxgbi_check_route6()
790 csk->cdev = cdev; in cxgbi_check_route6()
791 csk->port_id = port; in cxgbi_check_route6()
792 csk->mtu = mtu; in cxgbi_check_route6()
793 csk->dst = dst; in cxgbi_check_route6()
799 err = ipv6_dev_get_saddr(&init_net, idev ? idev->dev : NULL, in cxgbi_check_route6()
800 &daddr6->sin6_addr, 0, &pref_saddr); in cxgbi_check_route6()
803 &daddr6->sin6_addr); in cxgbi_check_route6()
808 csk->csk_family = AF_INET6; in cxgbi_check_route6()
809 csk->daddr6.sin6_addr = daddr6->sin6_addr; in cxgbi_check_route6()
810 csk->daddr6.sin6_port = daddr6->sin6_port; in cxgbi_check_route6()
811 csk->daddr6.sin6_family = daddr6->sin6_family; in cxgbi_check_route6()
812 csk->saddr6.sin6_family = daddr6->sin6_family; in cxgbi_check_route6()
813 csk->saddr6.sin6_addr = pref_saddr; in cxgbi_check_route6()
833 csk->write_seq = csk->snd_nxt = csk->snd_una = snd_isn; in cxgbi_sock_established()
834 dst_confirm(csk->dst); in cxgbi_sock_established()
844 csk, csk->state, csk->flags, csk->user_data); in cxgbi_inform_iscsi_conn_closing()
846 if (csk->state != CTP_ESTABLISHED) { in cxgbi_inform_iscsi_conn_closing()
847 read_lock_bh(&csk->callback_lock); in cxgbi_inform_iscsi_conn_closing()
848 if (csk->user_data) in cxgbi_inform_iscsi_conn_closing()
849 iscsi_conn_failure(csk->user_data, in cxgbi_inform_iscsi_conn_closing()
851 read_unlock_bh(&csk->callback_lock); in cxgbi_inform_iscsi_conn_closing()
858 csk, (csk)->state, (csk)->flags, (csk)->tid); in cxgbi_sock_closed()
860 if (csk->state == CTP_ACTIVE_OPEN || csk->state == CTP_CLOSED) in cxgbi_sock_closed()
862 if (csk->saddr.sin_port) in cxgbi_sock_closed()
864 if (csk->dst) in cxgbi_sock_closed()
865 dst_release(csk->dst); in cxgbi_sock_closed()
866 csk->cdev->csk_release_offload_resources(csk); in cxgbi_sock_closed()
879 csk, (csk)->state, (csk)->flags, (csk)->tid); in need_active_close()
880 spin_lock_bh(&csk->lock); in need_active_close()
881 if (csk->dst) in need_active_close()
882 dst_confirm(csk->dst); in need_active_close()
883 data_lost = skb_queue_len(&csk->receive_queue); in need_active_close()
884 __skb_queue_purge(&csk->receive_queue); in need_active_close()
886 if (csk->state == CTP_ACTIVE_OPEN) in need_active_close()
888 else if (csk->state == CTP_ESTABLISHED) { in need_active_close()
891 } else if (csk->state == CTP_PASSIVE_CLOSE) { in need_active_close()
899 csk->cdev->csk_send_abort_req(csk); in need_active_close()
901 csk->cdev->csk_send_close_req(csk); in need_active_close()
904 spin_unlock_bh(&csk->lock); in need_active_close()
909 pr_info("csk 0x%p,%u,%lx, %pI4:%u-%pI4:%u, err %d.\n", in cxgbi_sock_fail_act_open()
910 csk, csk->state, csk->flags, in cxgbi_sock_fail_act_open()
911 &csk->saddr.sin_addr.s_addr, csk->saddr.sin_port, in cxgbi_sock_fail_act_open()
912 &csk->daddr.sin_addr.s_addr, csk->daddr.sin_port, in cxgbi_sock_fail_act_open()
916 csk->err = errno; in cxgbi_sock_fail_act_open()
923 struct cxgbi_sock *csk = (struct cxgbi_sock *)skb->sk; in cxgbi_sock_act_open_req_arp_failure()
924 struct module *owner = csk->cdev->owner; in cxgbi_sock_act_open_req_arp_failure()
927 csk, (csk)->state, (csk)->flags, (csk)->tid); in cxgbi_sock_act_open_req_arp_failure()
929 spin_lock_bh(&csk->lock); in cxgbi_sock_act_open_req_arp_failure()
930 if (csk->state == CTP_ACTIVE_OPEN) in cxgbi_sock_act_open_req_arp_failure()
931 cxgbi_sock_fail_act_open(csk, -EHOSTUNREACH); in cxgbi_sock_act_open_req_arp_failure()
932 spin_unlock_bh(&csk->lock); in cxgbi_sock_act_open_req_arp_failure()
943 spin_lock_bh(&csk->lock); in cxgbi_sock_rcv_abort_rpl()
950 csk, csk->state, csk->flags, csk->tid); in cxgbi_sock_rcv_abort_rpl()
954 spin_unlock_bh(&csk->lock); in cxgbi_sock_rcv_abort_rpl()
962 csk, (csk)->state, (csk)->flags, (csk)->tid); in cxgbi_sock_rcv_peer_close()
964 spin_lock_bh(&csk->lock); in cxgbi_sock_rcv_peer_close()
969 switch (csk->state) { in cxgbi_sock_rcv_peer_close()
983 csk, csk->state, csk->flags, csk->tid); in cxgbi_sock_rcv_peer_close()
987 spin_unlock_bh(&csk->lock); in cxgbi_sock_rcv_peer_close()
995 csk, (csk)->state, (csk)->flags, (csk)->tid); in cxgbi_sock_rcv_close_conn_rpl()
997 spin_lock_bh(&csk->lock); in cxgbi_sock_rcv_close_conn_rpl()
999 csk->snd_una = snd_nxt - 1; in cxgbi_sock_rcv_close_conn_rpl()
1003 switch (csk->state) { in cxgbi_sock_rcv_close_conn_rpl()
1015 csk, csk->state, csk->flags, csk->tid); in cxgbi_sock_rcv_close_conn_rpl()
1018 spin_unlock_bh(&csk->lock); in cxgbi_sock_rcv_close_conn_rpl()
1028 csk, csk->state, csk->flags, csk->tid, credits, in cxgbi_sock_rcv_wr_ack()
1029 csk->wr_cred, csk->wr_una_cred, snd_una, seq_chk); in cxgbi_sock_rcv_wr_ack()
1031 spin_lock_bh(&csk->lock); in cxgbi_sock_rcv_wr_ack()
1033 csk->wr_cred += credits; in cxgbi_sock_rcv_wr_ack()
1034 if (csk->wr_una_cred > csk->wr_max_cred - csk->wr_cred) in cxgbi_sock_rcv_wr_ack()
1035 csk->wr_una_cred = csk->wr_max_cred - csk->wr_cred; in cxgbi_sock_rcv_wr_ack()
1042 csk, csk->state, csk->flags, csk->tid, credits, in cxgbi_sock_rcv_wr_ack()
1043 csk->wr_cred, csk->wr_una_cred); in cxgbi_sock_rcv_wr_ack()
1047 if (unlikely(credits < p->csum)) { in cxgbi_sock_rcv_wr_ack()
1049 csk, csk->state, csk->flags, csk->tid, in cxgbi_sock_rcv_wr_ack()
1050 credits, csk->wr_cred, csk->wr_una_cred, in cxgbi_sock_rcv_wr_ack()
1051 p->csum); in cxgbi_sock_rcv_wr_ack()
1052 p->csum -= credits; in cxgbi_sock_rcv_wr_ack()
1056 credits -= p->csum; in cxgbi_sock_rcv_wr_ack()
1064 if (unlikely(before(snd_una, csk->snd_una))) { in cxgbi_sock_rcv_wr_ack()
1066 csk, csk->state, csk->flags, csk->tid, snd_una, in cxgbi_sock_rcv_wr_ack()
1067 csk->snd_una); in cxgbi_sock_rcv_wr_ack()
1071 if (csk->snd_una != snd_una) { in cxgbi_sock_rcv_wr_ack()
1072 csk->snd_una = snd_una; in cxgbi_sock_rcv_wr_ack()
1073 dst_confirm(csk->dst); in cxgbi_sock_rcv_wr_ack()
1077 if (skb_queue_len(&csk->write_queue)) { in cxgbi_sock_rcv_wr_ack()
1078 if (csk->cdev->csk_push_tx_frames(csk, 0)) in cxgbi_sock_rcv_wr_ack()
1083 spin_unlock_bh(&csk->lock); in cxgbi_sock_rcv_wr_ack()
1092 while (i < csk->cdev->nmtus - 1 && csk->cdev->mtus[i + 1] <= mtu) in cxgbi_sock_find_best_mtu()
1101 struct dst_entry *dst = csk->dst; in cxgbi_sock_select_mss()
1103 csk->advmss = dst_metric_advmss(dst); in cxgbi_sock_select_mss()
1105 if (csk->advmss > pmtu - 40) in cxgbi_sock_select_mss()
1106 csk->advmss = pmtu - 40; in cxgbi_sock_select_mss()
1107 if (csk->advmss < csk->cdev->mtus[0] - 40) in cxgbi_sock_select_mss()
1108 csk->advmss = csk->cdev->mtus[0] - 40; in cxgbi_sock_select_mss()
1109 idx = cxgbi_sock_find_best_mtu(csk, csk->advmss + 40); in cxgbi_sock_select_mss()
1117 cxgbi_skcb_tcp_seq(skb) = csk->write_seq; in cxgbi_sock_skb_entail()
1118 __skb_queue_tail(&csk->write_queue, skb); in cxgbi_sock_skb_entail()
1135 if (unlikely(csk->wr_cred + pending != csk->wr_max_cred)) in cxgbi_sock_check_wr_invariants()
1137 csk, csk->tid, csk->wr_cred, pending, csk->wr_max_cred); in cxgbi_sock_check_wr_invariants()
1146 struct scsi_data_buffer *sdb = prot ? scsi_prot(sc) : &sc->sdb; in scmd_get_params()
1148 *sgl = sdb->table.sgl; in scmd_get_params()
1149 *sgcnt = sdb->table.nents; in scmd_get_params()
1150 *dlen = sdb->length; in scmd_get_params()
1151 /* Caution: for protection sdb, sdb->length is invalid */ in scmd_get_params()
1164 memcpy(ppod, &ttinfo->hdr, sizeof(struct cxgbi_pagepod_hdr)); in cxgbi_ddp_set_one_ppod()
1173 ppod->addr[i] = cpu_to_be64(addr + offset); in cxgbi_ddp_set_one_ppod()
1175 if (offset == (len + sg->offset)) { in cxgbi_ddp_set_one_ppod()
1184 ppod->addr[i] = 0ULL; in cxgbi_ddp_set_one_ppod()
1205 ppod->addr[i] = sg ? cpu_to_be64(addr + offset) : 0ULL; in cxgbi_ddp_set_one_ppod()
1210 * APIs interacting with open-iscsi libraries
1219 int err = cxgbi_ppm_init(ppm_pp, cdev->ports[0], cdev->pdev, in cxgbi_ddp_ppm_setup()
1220 cdev->lldev, tformat, iscsi_size, llimit, start, in cxgbi_ddp_ppm_setup()
1226 if (ppm->ppmax < 1024 || in cxgbi_ddp_ppm_setup()
1227 ppm->tformat.pgsz_idx_dflt >= DDP_PGIDX_MAX) in cxgbi_ddp_ppm_setup()
1228 cdev->flags |= CXGBI_FLAG_DDP_OFF; in cxgbi_ddp_ppm_setup()
1231 cdev->flags |= CXGBI_FLAG_DDP_OFF; in cxgbi_ddp_ppm_setup()
1241 int last_sgidx = nents - 1; in cxgbi_ddp_sgl_check()
1245 unsigned int len = sg->length + sg->offset; in cxgbi_ddp_sgl_check()
1247 if ((sg->offset & 0x3) || (i && sg->offset) || in cxgbi_ddp_sgl_check()
1251 i, nents, sg->offset, sg->length); in cxgbi_ddp_sgl_check()
1257 return -EINVAL; in cxgbi_ddp_sgl_check()
1264 struct cxgbi_sock *csk = cconn->cep->csk; in cxgbi_ddp_reserve()
1265 struct cxgbi_device *cdev = csk->cdev; in cxgbi_ddp_reserve()
1266 struct cxgbi_ppm *ppm = cdev->cdev2ppm(cdev); in cxgbi_ddp_reserve()
1267 struct cxgbi_task_tag_info *ttinfo = &tdata->ttinfo; in cxgbi_ddp_reserve()
1268 struct scatterlist *sgl = ttinfo->sgl; in cxgbi_ddp_reserve()
1269 unsigned int sgcnt = ttinfo->nents; in cxgbi_ddp_reserve()
1270 unsigned int sg_offset = sgl->offset; in cxgbi_ddp_reserve()
1273 if (cdev->flags & CXGBI_FLAG_DDP_OFF) { in cxgbi_ddp_reserve()
1276 return -EINVAL; in cxgbi_ddp_reserve()
1280 ppm->tformat.pgsz_idx_dflt >= DDP_PGIDX_MAX) { in cxgbi_ddp_reserve()
1283 ppm, ppm ? ppm->tformat.pgsz_idx_dflt : DDP_PGIDX_MAX, in cxgbi_ddp_reserve()
1284 xferlen, ttinfo->nents); in cxgbi_ddp_reserve()
1285 return -EINVAL; in cxgbi_ddp_reserve()
1290 return -EINVAL; in cxgbi_ddp_reserve()
1292 ttinfo->nr_pages = (xferlen + sgl->offset + (1 << PAGE_SHIFT) - 1) >> in cxgbi_ddp_reserve()
1297 * the itt generated by libiscsi is saved in the ppm and can be in cxgbi_ddp_reserve()
1300 err = cxgbi_ppm_ppods_reserve(ppm, ttinfo->nr_pages, 0, &ttinfo->idx, in cxgbi_ddp_reserve()
1301 &ttinfo->tag, (unsigned long)sw_tag); in cxgbi_ddp_reserve()
1303 cconn->ddp_full++; in cxgbi_ddp_reserve()
1306 ttinfo->npods = err; in cxgbi_ddp_reserve()
1309 sgl->offset = 0; in cxgbi_ddp_reserve()
1310 err = dma_map_sg(&ppm->pdev->dev, sgl, sgcnt, DMA_FROM_DEVICE); in cxgbi_ddp_reserve()
1311 sgl->offset = sg_offset; in cxgbi_ddp_reserve()
1317 if (err != ttinfo->nr_pages) { in cxgbi_ddp_reserve()
1323 ttinfo->flags |= CXGBI_PPOD_INFO_FLAG_MAPPED; in cxgbi_ddp_reserve()
1324 ttinfo->cid = csk->port_id; in cxgbi_ddp_reserve()
1326 cxgbi_ppm_make_ppod_hdr(ppm, ttinfo->tag, csk->tid, sgl->offset, in cxgbi_ddp_reserve()
1327 xferlen, &ttinfo->hdr); in cxgbi_ddp_reserve()
1329 if (cdev->flags & CXGBI_FLAG_USE_PPOD_OFLDQ) { in cxgbi_ddp_reserve()
1331 ttinfo->flags |= CXGBI_PPOD_INFO_FLAG_VALID; in cxgbi_ddp_reserve()
1334 err = cdev->csk_ddp_set_map(ppm, csk, ttinfo); in cxgbi_ddp_reserve()
1342 cxgbi_ppm_ppod_release(ppm, ttinfo->idx); in cxgbi_ddp_reserve()
1344 if (ttinfo->flags & CXGBI_PPOD_INFO_FLAG_MAPPED) { in cxgbi_ddp_reserve()
1345 ttinfo->flags &= ~CXGBI_PPOD_INFO_FLAG_MAPPED; in cxgbi_ddp_reserve()
1346 dma_unmap_sg(&ppm->pdev->dev, sgl, sgcnt, DMA_FROM_DEVICE); in cxgbi_ddp_reserve()
1348 return -EINVAL; in cxgbi_ddp_reserve()
1353 struct scsi_cmnd *sc = task->sc; in task_release_itt()
1354 struct iscsi_tcp_conn *tcp_conn = task->conn->dd_data; in task_release_itt()
1355 struct cxgbi_conn *cconn = tcp_conn->dd_data; in task_release_itt()
1356 struct cxgbi_device *cdev = cconn->chba->cdev; in task_release_itt()
1357 struct cxgbi_ppm *ppm = cdev->cdev2ppm(cdev); in task_release_itt()
1363 if (sc && sc->sc_data_direction == DMA_FROM_DEVICE && in task_release_itt()
1366 struct cxgbi_task_tag_info *ttinfo = &tdata->ttinfo; in task_release_itt()
1368 if (!(cdev->flags & CXGBI_FLAG_USE_PPOD_OFLDQ)) in task_release_itt()
1369 cdev->csk_ddp_clear_map(cdev, ppm, ttinfo); in task_release_itt()
1370 cxgbi_ppm_ppod_release(ppm, ttinfo->idx); in task_release_itt()
1371 dma_unmap_sg(&ppm->pdev->dev, ttinfo->sgl, ttinfo->nents, in task_release_itt()
1384 struct scsi_cmnd *sc = task->sc; in task_reserve_itt()
1385 struct iscsi_conn *conn = task->conn; in task_reserve_itt()
1386 struct iscsi_session *sess = conn->session; in task_reserve_itt()
1387 struct iscsi_tcp_conn *tcp_conn = conn->dd_data; in task_reserve_itt()
1388 struct cxgbi_conn *cconn = tcp_conn->dd_data; in task_reserve_itt()
1389 struct cxgbi_device *cdev = cconn->chba->cdev; in task_reserve_itt()
1390 struct cxgbi_ppm *ppm = cdev->cdev2ppm(cdev); in task_reserve_itt()
1391 u32 sw_tag = cxgbi_build_sw_tag(task->itt, sess->age); in task_reserve_itt()
1393 int err = -EINVAL; in task_reserve_itt()
1395 if (sc && sc->sc_data_direction == DMA_FROM_DEVICE) { in task_reserve_itt()
1397 struct cxgbi_task_tag_info *ttinfo = &tdata->ttinfo; in task_reserve_itt()
1399 scmd_get_params(sc, &ttinfo->sgl, &ttinfo->nents, in task_reserve_itt()
1400 &tdata->dlen, 0); in task_reserve_itt()
1401 err = cxgbi_ddp_reserve(cconn, tdata, sw_tag, tdata->dlen); in task_reserve_itt()
1403 tag = ttinfo->tag; in task_reserve_itt()
1407 cconn->cep->csk, task, tdata->dlen, in task_reserve_itt()
1408 ttinfo->nents); in task_reserve_itt()
1416 /* the itt need to sent in big-endian order */ in task_reserve_itt()
1420 "cdev 0x%p, task 0x%p, 0x%x(0x%x,0x%x)->0x%x/0x%x.\n", in task_reserve_itt()
1421 cdev, task, sw_tag, task->itt, sess->age, tag, *hdr_itt); in task_reserve_itt()
1427 struct iscsi_tcp_conn *tcp_conn = conn->dd_data; in cxgbi_parse_pdu_itt()
1428 struct cxgbi_conn *cconn = tcp_conn->dd_data; in cxgbi_parse_pdu_itt()
1429 struct cxgbi_device *cdev = cconn->chba->cdev; in cxgbi_parse_pdu_itt()
1430 struct cxgbi_ppm *ppm = cdev->cdev2ppm(cdev); in cxgbi_parse_pdu_itt()
1445 "cdev 0x%p, tag 0x%x/0x%x, -> 0x%x(0x%x,0x%x).\n", in cxgbi_parse_pdu_itt()
1453 struct iscsi_conn *conn = csk->user_data; in cxgbi_conn_tx_open()
1457 "csk 0x%p, cid %d.\n", csk, conn->id); in cxgbi_conn_tx_open()
1479 return -EIO; in read_pdu_skb()
1484 /* no transfer - just have caller flush queue */ in read_pdu_skb()
1494 return -EFAULT; in read_pdu_skb()
1503 return -EINVAL; in read_pdu_skb()
1511 struct iscsi_tcp_conn *tcp_conn = conn->dd_data; in skb_read_pdu_bhs()
1516 conn, skb, skb->len, cxgbi_skcb_flags(skb)); in skb_read_pdu_bhs()
1521 return -EIO; in skb_read_pdu_bhs()
1524 if (conn->hdrdgst_en && in skb_read_pdu_bhs()
1528 return -EIO; in skb_read_pdu_bhs()
1535 * task->exp_datasn to the datasn in completion in skb_read_pdu_bhs()
1539 itt_t itt = ((struct iscsi_data *)skb->data)->itt; in skb_read_pdu_bhs()
1542 skb->data)->datasn); in skb_read_pdu_bhs()
1543 if (task && task->sc) { in skb_read_pdu_bhs()
1544 struct iscsi_tcp_task *tcp_task = task->dd_data; in skb_read_pdu_bhs()
1546 tcp_task->exp_datasn = data_sn; in skb_read_pdu_bhs()
1552 struct iscsi_hdr *hdr = (struct iscsi_hdr *)skb->data; in skb_read_pdu_bhs()
1553 u8 opcode = hdr->opcode & ISCSI_OPCODE_MASK; in skb_read_pdu_bhs()
1565 struct iscsi_tcp_conn *tcp_conn = conn->dd_data; in skb_read_pdu_data()
1567 int opcode = tcp_conn->in.hdr->opcode & ISCSI_OPCODE_MASK; in skb_read_pdu_data()
1571 conn, skb, skb->len, cxgbi_skcb_flags(skb)); in skb_read_pdu_data()
1573 if (conn->datadgst_en && in skb_read_pdu_data()
1578 return -EIO; in skb_read_pdu_data()
1585 if (lskb == skb && conn->hdrdgst_en) in skb_read_pdu_data()
1594 skb, opcode, ntohl(tcp_conn->in.hdr->itt), in skb_read_pdu_data()
1595 tcp_conn->in.datalen, offloaded ? "is" : "not"); in skb_read_pdu_data()
1602 struct cxgbi_device *cdev = csk->cdev; in csk_return_rx_credits()
1608 csk, csk->state, csk->flags, csk->tid, csk->copied_seq, in csk_return_rx_credits()
1609 csk->rcv_wup, cdev->rx_credit_thres, in csk_return_rx_credits()
1610 csk->rcv_win); in csk_return_rx_credits()
1612 if (!cdev->rx_credit_thres) in csk_return_rx_credits()
1615 if (csk->state != CTP_ESTABLISHED) in csk_return_rx_credits()
1618 credits = csk->copied_seq - csk->rcv_wup; in csk_return_rx_credits()
1621 must_send = credits + 16384 >= csk->rcv_win; in csk_return_rx_credits()
1622 if (must_send || credits >= cdev->rx_credit_thres) in csk_return_rx_credits()
1623 csk->rcv_wup += cdev->csk_send_rx_credits(csk, credits); in csk_return_rx_credits()
1628 struct cxgbi_device *cdev = csk->cdev; in cxgbi_conn_pdu_ready()
1629 struct iscsi_conn *conn = csk->user_data; in cxgbi_conn_pdu_ready()
1637 if (unlikely(!conn || test_bit(ISCSI_CONN_FLAG_SUSPEND_RX, &conn->flags))) { in cxgbi_conn_pdu_ready()
1640 csk, conn, conn ? conn->id : 0xFF, in cxgbi_conn_pdu_ready()
1641 conn ? conn->flags : 0xFF); in cxgbi_conn_pdu_ready()
1646 skb = skb_peek(&csk->receive_queue); in cxgbi_conn_pdu_ready()
1655 __skb_unlink(skb, &csk->receive_queue); in cxgbi_conn_pdu_ready()
1660 csk, skb, skb->len, cxgbi_skcb_flags(skb), in cxgbi_conn_pdu_ready()
1668 csk, skb, skb->len, in cxgbi_conn_pdu_ready()
1674 err + cdev->skb_rx_extra); in cxgbi_conn_pdu_ready()
1678 csk, skb, skb->len, in cxgbi_conn_pdu_ready()
1686 csk, skb, skb->len, in cxgbi_conn_pdu_ready()
1695 dskb = skb_peek(&csk->receive_queue); in cxgbi_conn_pdu_ready()
1699 csk, skb, skb->len, in cxgbi_conn_pdu_ready()
1702 err = -EIO; in cxgbi_conn_pdu_ready()
1705 __skb_unlink(dskb, &csk->receive_queue); in cxgbi_conn_pdu_ready()
1712 csk, skb, skb->len, in cxgbi_conn_pdu_ready()
1715 dskb, dskb->len); in cxgbi_conn_pdu_ready()
1729 csk->copied_seq += read; in cxgbi_conn_pdu_ready()
1731 conn->rxdata_octets += read; in cxgbi_conn_pdu_ready()
1750 if (offset < sg->length) { in sgl_seek_offset()
1755 offset -= sg->length; in sgl_seek_offset()
1757 return -EFAULT; in sgl_seek_offset()
1766 unsigned int sglen = sg->length - sgoffset; in sgl_read_to_frags()
1779 return -EINVAL; in sgl_read_to_frags()
1782 sglen = sg->length; in sgl_read_to_frags()
1787 if (i && page == frags[i - 1].page && in sgl_read_to_frags()
1788 sgoffset + sg->offset == in sgl_read_to_frags()
1789 frags[i - 1].offset + frags[i - 1].size) { in sgl_read_to_frags()
1790 frags[i - 1].size += copy; in sgl_read_to_frags()
1795 *dlimit = dlen - datalen; in sgl_read_to_frags()
1796 return -EINVAL; in sgl_read_to_frags()
1800 frags[i].offset = sg->offset + sgoffset; in sgl_read_to_frags()
1804 datalen -= copy; in sgl_read_to_frags()
1806 sglen -= copy; in sgl_read_to_frags()
1814 struct scsi_cmnd *sc = task->sc; in cxgbi_task_data_sgl_check()
1820 tdata->flags = CXGBI_TASK_SGL_CHECKED; in cxgbi_task_data_sgl_check()
1824 scmd_get_params(sc, &sgl, &sgcnt, &tdata->dlen, 0); in cxgbi_task_data_sgl_check()
1826 tdata->flags |= CXGBI_TASK_SGL_COPY; in cxgbi_task_data_sgl_check()
1832 tdata->flags |= CXGBI_TASK_SGL_COPY; in cxgbi_task_data_sgl_check()
1842 struct scsi_cmnd *sc = task->sc; in cxgbi_task_data_sgl_read()
1857 err = sgl_seek_offset(sgl, sgcnt, offset, &tdata->sgoffset, &sg); in cxgbi_task_data_sgl_read()
1860 sgcnt, offset, tdata->dlen); in cxgbi_task_data_sgl_read()
1863 err = sgl_read_to_frags(sg, tdata->sgoffset, count, in cxgbi_task_data_sgl_read()
1864 tdata->frags, MAX_SKB_FRAGS, dlimit); in cxgbi_task_data_sgl_read()
1868 sgcnt, offset, count, tdata->dlen, *dlimit); in cxgbi_task_data_sgl_read()
1871 tdata->offset = offset; in cxgbi_task_data_sgl_read()
1872 tdata->count = count; in cxgbi_task_data_sgl_read()
1873 tdata->nr_frags = err; in cxgbi_task_data_sgl_read()
1874 tdata->total_count = count; in cxgbi_task_data_sgl_read()
1875 tdata->total_offset = offset; in cxgbi_task_data_sgl_read()
1880 __func__, offset, count, err, tdata->total_count, tdata->total_offset); in cxgbi_task_data_sgl_read()
1887 struct iscsi_conn *conn = task->conn; in cxgbi_conn_alloc_pdu()
1888 struct iscsi_session *session = task->conn->session; in cxgbi_conn_alloc_pdu()
1889 struct iscsi_tcp_conn *tcp_conn = conn->dd_data; in cxgbi_conn_alloc_pdu()
1890 struct cxgbi_conn *cconn = tcp_conn->dd_data; in cxgbi_conn_alloc_pdu()
1891 struct cxgbi_device *cdev = cconn->chba->cdev; in cxgbi_conn_alloc_pdu()
1892 struct cxgbi_sock *csk = cconn->cep ? cconn->cep->csk : NULL; in cxgbi_conn_alloc_pdu()
1893 struct iscsi_tcp_task *tcp_task = task->dd_data; in cxgbi_conn_alloc_pdu()
1895 struct scsi_cmnd *sc = task->sc; in cxgbi_conn_alloc_pdu()
1897 u32 max_txdata_len = conn->max_xmit_dlength; in cxgbi_conn_alloc_pdu()
1905 return -ENOMEM; in cxgbi_conn_alloc_pdu()
1909 return -EPIPE; in cxgbi_conn_alloc_pdu()
1914 tcp_task->dd_data = tdata; in cxgbi_conn_alloc_pdu()
1915 task->hdr = NULL; in cxgbi_conn_alloc_pdu()
1917 last_tdata_count = tdata->count; in cxgbi_conn_alloc_pdu()
1918 last_tdata_offset = tdata->offset; in cxgbi_conn_alloc_pdu()
1922 (sc->sc_data_direction == DMA_TO_DEVICE))) { in cxgbi_conn_alloc_pdu()
1927 /* Preserve conn->max_xmit_dlength because it can get updated to in cxgbi_conn_alloc_pdu()
1930 if (task->state == ISCSI_TASK_PENDING) in cxgbi_conn_alloc_pdu()
1931 tdata->max_xmit_dlength = conn->max_xmit_dlength; in cxgbi_conn_alloc_pdu()
1933 if (!tdata->offset) in cxgbi_conn_alloc_pdu()
1937 tdata->dlen - tdata->offset - tdata->count; in cxgbi_conn_alloc_pdu()
1940 max_txdata_len = tdata->max_xmit_dlength; in cxgbi_conn_alloc_pdu()
1942 "tdata->dlen %u, remaining to send %u " in cxgbi_conn_alloc_pdu()
1943 "conn->max_xmit_dlength %u, " in cxgbi_conn_alloc_pdu()
1944 "tdata->max_xmit_dlength %u\n", in cxgbi_conn_alloc_pdu()
1945 tdata->dlen, remaining_data_tosend, in cxgbi_conn_alloc_pdu()
1946 conn->max_xmit_dlength, tdata->max_xmit_dlength); in cxgbi_conn_alloc_pdu()
1948 if (cdev->skb_iso_txhdr && !csk->disable_iso && in cxgbi_conn_alloc_pdu()
1949 (remaining_data_tosend > tdata->max_xmit_dlength) && in cxgbi_conn_alloc_pdu()
1954 session->initial_r2t_en) in cxgbi_conn_alloc_pdu()
1957 max_pdu_size = tdata->max_xmit_dlength + in cxgbi_conn_alloc_pdu()
1960 csk->advmss); in cxgbi_conn_alloc_pdu()
1964 tdata->max_xmit_dlength - 1) / in cxgbi_conn_alloc_pdu()
1965 tdata->max_xmit_dlength; in cxgbi_conn_alloc_pdu()
1970 conn->max_xmit_dlength = tdata->max_xmit_dlength * num_pdu; in cxgbi_conn_alloc_pdu()
1971 max_txdata_len = conn->max_xmit_dlength; in cxgbi_conn_alloc_pdu()
1972 iso_tx_rsvd = cdev->skb_iso_txhdr; in cxgbi_conn_alloc_pdu()
1984 tdata->offset + tdata->count, in cxgbi_conn_alloc_pdu()
1994 tdata->max_xmit_dlength); in cxgbi_conn_alloc_pdu()
2000 conn->max_xmit_dlength = remaining_data_tosend; in cxgbi_conn_alloc_pdu()
2010 if ((tdata->flags & CXGBI_TASK_SGL_COPY) || in cxgbi_conn_alloc_pdu()
2011 (tdata->nr_frags > MAX_SKB_FRAGS)) in cxgbi_conn_alloc_pdu()
2012 headroom += conn->max_xmit_dlength; in cxgbi_conn_alloc_pdu()
2015 tdata->skb = alloc_skb(local_iso_info + cdev->skb_tx_rsvd + in cxgbi_conn_alloc_pdu()
2017 if (!tdata->skb) { in cxgbi_conn_alloc_pdu()
2018 tdata->count = last_tdata_count; in cxgbi_conn_alloc_pdu()
2019 tdata->offset = last_tdata_offset; in cxgbi_conn_alloc_pdu()
2020 err = -ENOMEM; in cxgbi_conn_alloc_pdu()
2024 skb_reserve(tdata->skb, local_iso_info + cdev->skb_tx_rsvd + in cxgbi_conn_alloc_pdu()
2027 if (task->sc) { in cxgbi_conn_alloc_pdu()
2028 task->hdr = (struct iscsi_hdr *)tdata->skb->data; in cxgbi_conn_alloc_pdu()
2030 task->hdr = kzalloc(SKB_TX_ISCSI_PDU_HEADER_MAX, GFP_ATOMIC); in cxgbi_conn_alloc_pdu()
2031 if (!task->hdr) { in cxgbi_conn_alloc_pdu()
2032 __kfree_skb(tdata->skb); in cxgbi_conn_alloc_pdu()
2033 tdata->skb = NULL; in cxgbi_conn_alloc_pdu()
2034 return -ENOMEM; in cxgbi_conn_alloc_pdu()
2038 task->hdr_max = SKB_TX_ISCSI_PDU_HEADER_MAX; in cxgbi_conn_alloc_pdu()
2041 cxgbi_skcb_set_flag(tdata->skb, SKCBF_TX_ISO); in cxgbi_conn_alloc_pdu()
2045 task_reserve_itt(task, &task->hdr->itt); in cxgbi_conn_alloc_pdu()
2049 task, op, tdata->skb, cdev->skb_tx_rsvd, headroom, in cxgbi_conn_alloc_pdu()
2050 conn->max_xmit_dlength, be32_to_cpu(task->hdr->itt)); in cxgbi_conn_alloc_pdu()
2055 conn->max_xmit_dlength = tdata->max_xmit_dlength; in cxgbi_conn_alloc_pdu()
2064 struct cxgbi_iso_info *iso_info = (struct cxgbi_iso_info *)skb->head; in cxgbi_prep_iso_info()
2067 struct iscsi_conn *conn = task->conn; in cxgbi_prep_iso_info()
2068 struct iscsi_session *session = conn->session; in cxgbi_prep_iso_info()
2069 struct iscsi_tcp_task *tcp_task = task->dd_data; in cxgbi_prep_iso_info()
2071 u32 max_pdu_len = tdata->max_xmit_dlength; in cxgbi_prep_iso_info()
2080 if (task->hdr->opcode == ISCSI_OP_SCSI_CMD && session->imm_data_en) { in cxgbi_prep_iso_info()
2081 iso_info->flags |= CXGBI_ISO_INFO_IMM_ENABLE; in cxgbi_prep_iso_info()
2085 dlength = ntoh24(task->hdr->dlength); in cxgbi_prep_iso_info()
2087 hton24(task->hdr->dlength, dlength); in cxgbi_prep_iso_info()
2089 num_pdu = (count + max_pdu_len - 1) / max_pdu_len; in cxgbi_prep_iso_info()
2092 r2t = &task->unsol_r2t; in cxgbi_prep_iso_info()
2094 r2t = tcp_task->r2t; in cxgbi_prep_iso_info()
2098 "count %u, tdata->count %u, num_pdu %u," in cxgbi_prep_iso_info()
2099 "task->hdr_len %u, r2t->data_length %u, r2t->sent %u\n", in cxgbi_prep_iso_info()
2100 count, tdata->count, num_pdu, task->hdr_len, in cxgbi_prep_iso_info()
2101 r2t->data_length, r2t->sent); in cxgbi_prep_iso_info()
2103 r2t_dlength = r2t->data_length - r2t->sent; in cxgbi_prep_iso_info()
2104 segment_offset = r2t->sent; in cxgbi_prep_iso_info()
2105 r2t->datasn += num_pdu - 1; in cxgbi_prep_iso_info()
2108 if (!r2t || !r2t->sent) in cxgbi_prep_iso_info()
2109 iso_info->flags |= CXGBI_ISO_INFO_FSLICE; in cxgbi_prep_iso_info()
2111 if (task->hdr->flags & ISCSI_FLAG_CMD_FINAL) in cxgbi_prep_iso_info()
2112 iso_info->flags |= CXGBI_ISO_INFO_LSLICE; in cxgbi_prep_iso_info()
2114 task->hdr->flags &= ~ISCSI_FLAG_CMD_FINAL; in cxgbi_prep_iso_info()
2116 iso_info->op = task->hdr->opcode; in cxgbi_prep_iso_info()
2117 iso_info->ahs = task->hdr->hlength; in cxgbi_prep_iso_info()
2118 iso_info->num_pdu = num_pdu; in cxgbi_prep_iso_info()
2119 iso_info->mpdu = max_pdu_len; in cxgbi_prep_iso_info()
2120 iso_info->burst_size = (burst_size + r2t_dlength) >> 2; in cxgbi_prep_iso_info()
2121 iso_info->len = count + task->hdr_len; in cxgbi_prep_iso_info()
2122 iso_info->segment_offset = segment_offset; in cxgbi_prep_iso_info()
2124 cxgbi_skcb_tx_iscsi_hdrlen(skb) = task->hdr_len; in cxgbi_prep_iso_info()
2147 struct iscsi_conn *conn = task->conn; in cxgbi_conn_init_pdu()
2148 struct iscsi_tcp_task *tcp_task = task->dd_data; in cxgbi_conn_init_pdu()
2151 struct scsi_cmnd *sc = task->sc; in cxgbi_conn_init_pdu()
2158 if (!tcp_task || (tcp_task->dd_data != tdata)) { in cxgbi_conn_init_pdu()
2160 task, task->sc, tcp_task, in cxgbi_conn_init_pdu()
2161 tcp_task ? tcp_task->dd_data : NULL, tdata); in cxgbi_conn_init_pdu()
2162 return -EINVAL; in cxgbi_conn_init_pdu()
2164 skb = tdata->skb; in cxgbi_conn_init_pdu()
2168 task, task->sc, skb, (*skb->data) & ISCSI_OPCODE_MASK, in cxgbi_conn_init_pdu()
2169 be32_to_cpu(task->cmdsn), be32_to_cpu(task->hdr->itt), offset, count); in cxgbi_conn_init_pdu()
2171 skb_put(skb, task->hdr_len); in cxgbi_conn_init_pdu()
2172 tx_skb_setmode(skb, conn->hdrdgst_en, datalen ? conn->datadgst_en : 0); in cxgbi_conn_init_pdu()
2174 tdata->count = count; in cxgbi_conn_init_pdu()
2175 tdata->offset = offset; in cxgbi_conn_init_pdu()
2176 tdata->nr_frags = 0; in cxgbi_conn_init_pdu()
2177 tdata->total_offset = 0; in cxgbi_conn_init_pdu()
2178 tdata->total_count = 0; in cxgbi_conn_init_pdu()
2179 if (tdata->max_xmit_dlength) in cxgbi_conn_init_pdu()
2180 conn->max_xmit_dlength = tdata->max_xmit_dlength; in cxgbi_conn_init_pdu()
2186 "data->total_count %u, tdata->total_offset %u\n", in cxgbi_conn_init_pdu()
2187 tdata->total_count, tdata->total_offset); in cxgbi_conn_init_pdu()
2189 expected_count = tdata->total_count; in cxgbi_conn_init_pdu()
2190 expected_offset = tdata->total_offset; in cxgbi_conn_init_pdu()
2197 "dlimit %u, sgl err %d.\n", task, task->sc, in cxgbi_conn_init_pdu()
2198 tcp_task, tcp_task ? tcp_task->dd_data : NULL, in cxgbi_conn_init_pdu()
2204 /* Restore original value of conn->max_xmit_dlength because in cxgbi_conn_init_pdu()
2207 conn->max_xmit_dlength = tdata->max_xmit_dlength; in cxgbi_conn_init_pdu()
2210 struct page_frag *frag = tdata->frags; in cxgbi_conn_init_pdu()
2212 if ((tdata->flags & CXGBI_TASK_SGL_COPY) || in cxgbi_conn_init_pdu()
2213 (tdata->nr_frags > MAX_SKB_FRAGS) || in cxgbi_conn_init_pdu()
2214 (padlen && (tdata->nr_frags == in cxgbi_conn_init_pdu()
2216 char *dst = skb->data + task->hdr_len; in cxgbi_conn_init_pdu()
2219 for (i = 0; i < tdata->nr_frags; i++, frag++) { in cxgbi_conn_init_pdu()
2220 char *src = kmap_atomic(frag->page); in cxgbi_conn_init_pdu()
2222 memcpy(dst, src + frag->offset, frag->size); in cxgbi_conn_init_pdu()
2223 dst += frag->size; in cxgbi_conn_init_pdu()
2233 for (i = 0; i < tdata->nr_frags; i++, frag++) { in cxgbi_conn_init_pdu()
2234 get_page(frag->page); in cxgbi_conn_init_pdu()
2235 skb_fill_page_desc(skb, i, frag->page, in cxgbi_conn_init_pdu()
2236 frag->offset, frag->size); in cxgbi_conn_init_pdu()
2239 skb->len += count; in cxgbi_conn_init_pdu()
2240 skb->data_len += count; in cxgbi_conn_init_pdu()
2241 skb->truesize += count; in cxgbi_conn_init_pdu()
2244 pg = virt_to_head_page(task->data); in cxgbi_conn_init_pdu()
2247 task->data - (char *)page_address(pg), in cxgbi_conn_init_pdu()
2249 skb->len += count; in cxgbi_conn_init_pdu()
2250 skb->data_len += count; in cxgbi_conn_init_pdu()
2251 skb->truesize += count; in cxgbi_conn_init_pdu()
2256 skb_fill_page_desc(skb, skb_shinfo(skb)->nr_frags, in cxgbi_conn_init_pdu()
2259 skb->data_len += padlen; in cxgbi_conn_init_pdu()
2260 skb->truesize += padlen; in cxgbi_conn_init_pdu()
2261 skb->len += padlen; in cxgbi_conn_init_pdu()
2264 if (likely(count > tdata->max_xmit_dlength)) in cxgbi_conn_init_pdu()
2275 struct cxgbi_device *cdev = csk->cdev; in cxgbi_sock_tx_queue_up()
2277 u32 frags = skb_shinfo(skb)->nr_frags; in cxgbi_sock_tx_queue_up()
2281 if (csk->state != CTP_ESTABLISHED) { in cxgbi_sock_tx_queue_up()
2284 csk, csk->state, csk->flags, csk->tid); in cxgbi_sock_tx_queue_up()
2285 return -EPIPE; in cxgbi_sock_tx_queue_up()
2288 if (csk->err) { in cxgbi_sock_tx_queue_up()
2291 csk, csk->state, csk->flags, csk->tid, csk->err); in cxgbi_sock_tx_queue_up()
2292 return -EPIPE; in cxgbi_sock_tx_queue_up()
2295 if ((cdev->flags & CXGBI_FLAG_DEV_T3) && in cxgbi_sock_tx_queue_up()
2296 before((csk->snd_win + csk->snd_una), csk->write_seq)) { in cxgbi_sock_tx_queue_up()
2298 "csk 0x%p,%u,0x%lx,%u, FULL %u-%u >= %u.\n", in cxgbi_sock_tx_queue_up()
2299 csk, csk->state, csk->flags, csk->tid, csk->write_seq, in cxgbi_sock_tx_queue_up()
2300 csk->snd_una, csk->snd_win); in cxgbi_sock_tx_queue_up()
2301 return -ENOBUFS; in cxgbi_sock_tx_queue_up()
2305 iso_tx_rsvd = cdev->skb_iso_txhdr; in cxgbi_sock_tx_queue_up()
2307 if (unlikely(skb_headroom(skb) < (cdev->skb_tx_rsvd + iso_tx_rsvd))) { in cxgbi_sock_tx_queue_up()
2309 csk, skb_headroom(skb), cdev->skb_tx_rsvd); in cxgbi_sock_tx_queue_up()
2310 return -EINVAL; in cxgbi_sock_tx_queue_up()
2313 if (skb->len != skb->data_len) in cxgbi_sock_tx_queue_up()
2318 csk, skb_shinfo(skb)->nr_frags, skb->len, in cxgbi_sock_tx_queue_up()
2319 skb->data_len, (unsigned int)SKB_WR_LIST_SIZE); in cxgbi_sock_tx_queue_up()
2320 return -EINVAL; in cxgbi_sock_tx_queue_up()
2330 iso_cpl = (struct cxgbi_iso_info *)skb->head; in cxgbi_sock_tx_queue_up()
2331 num_pdu = iso_cpl->num_pdu; in cxgbi_sock_tx_queue_up()
2334 num_pdu) + (hdr_len * (num_pdu - 1)); in cxgbi_sock_tx_queue_up()
2337 csk->write_seq += (skb->len + extra_len); in cxgbi_sock_tx_queue_up()
2344 struct cxgbi_device *cdev = csk->cdev; in cxgbi_sock_send_skb()
2345 int len = skb->len; in cxgbi_sock_send_skb()
2348 spin_lock_bh(&csk->lock); in cxgbi_sock_send_skb()
2351 spin_unlock_bh(&csk->lock); in cxgbi_sock_send_skb()
2355 if (likely(skb_queue_len(&csk->write_queue))) in cxgbi_sock_send_skb()
2356 cdev->csk_push_tx_frames(csk, 0); in cxgbi_sock_send_skb()
2357 spin_unlock_bh(&csk->lock); in cxgbi_sock_send_skb()
2363 struct iscsi_tcp_conn *tcp_conn = task->conn->dd_data; in cxgbi_conn_xmit_pdu()
2364 struct cxgbi_conn *cconn = tcp_conn->dd_data; in cxgbi_conn_xmit_pdu()
2365 struct iscsi_tcp_task *tcp_task = task->dd_data; in cxgbi_conn_xmit_pdu()
2367 struct cxgbi_task_tag_info *ttinfo = &tdata->ttinfo; in cxgbi_conn_xmit_pdu()
2374 if (!tcp_task || (tcp_task->dd_data != tdata)) { in cxgbi_conn_xmit_pdu()
2376 task, task->sc, tcp_task, in cxgbi_conn_xmit_pdu()
2377 tcp_task ? tcp_task->dd_data : NULL, tdata); in cxgbi_conn_xmit_pdu()
2378 return -EINVAL; in cxgbi_conn_xmit_pdu()
2381 skb = tdata->skb; in cxgbi_conn_xmit_pdu()
2388 if (cconn && cconn->cep) in cxgbi_conn_xmit_pdu()
2389 csk = cconn->cep->csk; in cxgbi_conn_xmit_pdu()
2394 return -EPIPE; in cxgbi_conn_xmit_pdu()
2397 tdata->skb = NULL; in cxgbi_conn_xmit_pdu()
2398 datalen = skb->data_len; in cxgbi_conn_xmit_pdu()
2401 if (ttinfo->flags & CXGBI_PPOD_INFO_FLAG_VALID) { in cxgbi_conn_xmit_pdu()
2402 struct cxgbi_ppm *ppm = csk->cdev->cdev2ppm(csk->cdev); in cxgbi_conn_xmit_pdu()
2404 ttinfo->flags &= ~CXGBI_PPOD_INFO_FLAG_VALID; in cxgbi_conn_xmit_pdu()
2405 if (csk->cdev->csk_ddp_set_map(ppm, csk, ttinfo) < 0) in cxgbi_conn_xmit_pdu()
2411 if (!task->sc) in cxgbi_conn_xmit_pdu()
2412 memcpy(skb->data, task->hdr, SKB_TX_ISCSI_PDU_HEADER_MAX); in cxgbi_conn_xmit_pdu()
2419 task, task->sc, err); in cxgbi_conn_xmit_pdu()
2421 if (task->conn->hdrdgst_en) in cxgbi_conn_xmit_pdu()
2424 if (datalen && task->conn->datadgst_en) in cxgbi_conn_xmit_pdu()
2427 task->conn->txdata_octets += pdulen; in cxgbi_conn_xmit_pdu()
2430 if (time_after(jiffies, csk->prev_iso_ts + HZ)) { in cxgbi_conn_xmit_pdu()
2431 csk->disable_iso = false; in cxgbi_conn_xmit_pdu()
2432 csk->prev_iso_ts = 0; in cxgbi_conn_xmit_pdu()
2441 if (err == -EAGAIN || err == -ENOBUFS) { in cxgbi_conn_xmit_pdu()
2444 task, skb, skb->len, skb->data_len, err); in cxgbi_conn_xmit_pdu()
2446 tdata->skb = skb; in cxgbi_conn_xmit_pdu()
2449 (csk->no_tx_credits++ >= 2)) { in cxgbi_conn_xmit_pdu()
2450 csk->disable_iso = true; in cxgbi_conn_xmit_pdu()
2451 csk->prev_iso_ts = jiffies; in cxgbi_conn_xmit_pdu()
2454 csk, csk->prev_iso_ts); in cxgbi_conn_xmit_pdu()
2462 task->itt, skb, skb->len, skb->data_len, err); in cxgbi_conn_xmit_pdu()
2464 iscsi_conn_printk(KERN_ERR, task->conn, "xmit err %d.\n", err); in cxgbi_conn_xmit_pdu()
2465 iscsi_conn_failure(task->conn, ISCSI_ERR_XMIT_FAILED); in cxgbi_conn_xmit_pdu()
2472 struct iscsi_tcp_task *tcp_task = task->dd_data; in cxgbi_cleanup_task()
2475 if (!tcp_task || (tcp_task->dd_data != tdata)) { in cxgbi_cleanup_task()
2477 task, task->sc, tcp_task, in cxgbi_cleanup_task()
2478 tcp_task ? tcp_task->dd_data : NULL, tdata); in cxgbi_cleanup_task()
2484 task, tdata->skb, task->hdr_itt); in cxgbi_cleanup_task()
2486 tcp_task->dd_data = NULL; in cxgbi_cleanup_task()
2488 if (!task->sc) in cxgbi_cleanup_task()
2489 kfree(task->hdr); in cxgbi_cleanup_task()
2490 task->hdr = NULL; in cxgbi_cleanup_task()
2493 if (tdata->skb) { in cxgbi_cleanup_task()
2494 __kfree_skb(tdata->skb); in cxgbi_cleanup_task()
2495 tdata->skb = NULL; in cxgbi_cleanup_task()
2498 task_release_itt(task, task->hdr_itt); in cxgbi_cleanup_task()
2508 struct iscsi_conn *conn = cls_conn->dd_data; in cxgbi_get_conn_stats()
2510 stats->txdata_octets = conn->txdata_octets; in cxgbi_get_conn_stats()
2511 stats->rxdata_octets = conn->rxdata_octets; in cxgbi_get_conn_stats()
2512 stats->scsicmd_pdus = conn->scsicmd_pdus_cnt; in cxgbi_get_conn_stats()
2513 stats->dataout_pdus = conn->dataout_pdus_cnt; in cxgbi_get_conn_stats()
2514 stats->scsirsp_pdus = conn->scsirsp_pdus_cnt; in cxgbi_get_conn_stats()
2515 stats->datain_pdus = conn->datain_pdus_cnt; in cxgbi_get_conn_stats()
2516 stats->r2t_pdus = conn->r2t_pdus_cnt; in cxgbi_get_conn_stats()
2517 stats->tmfcmd_pdus = conn->tmfcmd_pdus_cnt; in cxgbi_get_conn_stats()
2518 stats->tmfrsp_pdus = conn->tmfrsp_pdus_cnt; in cxgbi_get_conn_stats()
2519 stats->digest_err = 0; in cxgbi_get_conn_stats()
2520 stats->timeout_err = 0; in cxgbi_get_conn_stats()
2521 stats->custom_length = 1; in cxgbi_get_conn_stats()
2522 strcpy(stats->custom[0].desc, "eh_abort_cnt"); in cxgbi_get_conn_stats()
2523 stats->custom[0].value = conn->eh_abort_cnt; in cxgbi_get_conn_stats()
2529 struct iscsi_tcp_conn *tcp_conn = conn->dd_data; in cxgbi_conn_max_xmit_dlength()
2530 struct cxgbi_conn *cconn = tcp_conn->dd_data; in cxgbi_conn_max_xmit_dlength()
2531 struct cxgbi_device *cdev = cconn->chba->cdev; in cxgbi_conn_max_xmit_dlength()
2532 unsigned int headroom = SKB_MAX_HEAD(cdev->skb_tx_rsvd); in cxgbi_conn_max_xmit_dlength()
2536 max = min(cconn->chba->cdev->tx_max_size, max); in cxgbi_conn_max_xmit_dlength()
2537 if (conn->max_xmit_dlength) in cxgbi_conn_max_xmit_dlength()
2538 conn->max_xmit_dlength = min(conn->max_xmit_dlength, max); in cxgbi_conn_max_xmit_dlength()
2540 conn->max_xmit_dlength = max; in cxgbi_conn_max_xmit_dlength()
2541 cxgbi_align_pdu_size(conn->max_xmit_dlength); in cxgbi_conn_max_xmit_dlength()
2548 struct iscsi_tcp_conn *tcp_conn = conn->dd_data; in cxgbi_conn_max_recv_dlength()
2549 struct cxgbi_conn *cconn = tcp_conn->dd_data; in cxgbi_conn_max_recv_dlength()
2550 unsigned int max = cconn->chba->cdev->rx_max_size; in cxgbi_conn_max_recv_dlength()
2554 if (conn->max_recv_dlength) { in cxgbi_conn_max_recv_dlength()
2555 if (conn->max_recv_dlength > max) { in cxgbi_conn_max_recv_dlength()
2557 conn->max_recv_dlength, max); in cxgbi_conn_max_recv_dlength()
2558 return -EINVAL; in cxgbi_conn_max_recv_dlength()
2560 conn->max_recv_dlength = min(conn->max_recv_dlength, max); in cxgbi_conn_max_recv_dlength()
2561 cxgbi_align_pdu_size(conn->max_recv_dlength); in cxgbi_conn_max_recv_dlength()
2563 conn->max_recv_dlength = max; in cxgbi_conn_max_recv_dlength()
2571 struct iscsi_conn *conn = cls_conn->dd_data; in cxgbi_set_conn_param()
2572 struct iscsi_tcp_conn *tcp_conn = conn->dd_data; in cxgbi_set_conn_param()
2573 struct cxgbi_conn *cconn = tcp_conn->dd_data; in cxgbi_set_conn_param()
2574 struct cxgbi_sock *csk = cconn->cep->csk; in cxgbi_set_conn_param()
2584 if (!err && conn->hdrdgst_en) in cxgbi_set_conn_param()
2585 err = csk->cdev->csk_ddp_setup_digest(csk, csk->tid, in cxgbi_set_conn_param()
2586 conn->hdrdgst_en, in cxgbi_set_conn_param()
2587 conn->datadgst_en); in cxgbi_set_conn_param()
2591 if (!err && conn->datadgst_en) in cxgbi_set_conn_param()
2592 err = csk->cdev->csk_ddp_setup_digest(csk, csk->tid, in cxgbi_set_conn_param()
2593 conn->hdrdgst_en, in cxgbi_set_conn_param()
2594 conn->datadgst_en); in cxgbi_set_conn_param()
2618 struct cxgbi_endpoint *cep = ep->dd_data; in cxgbi_get_ep_param()
2628 return -ENOTCONN; in cxgbi_get_ep_param()
2630 csk = cep->csk; in cxgbi_get_ep_param()
2632 return -ENOTCONN; in cxgbi_get_ep_param()
2635 &csk->daddr, param, buf); in cxgbi_get_ep_param()
2639 return -ENOSYS; in cxgbi_get_ep_param()
2655 conn = cls_conn->dd_data; in cxgbi_create_conn()
2656 tcp_conn = conn->dd_data; in cxgbi_create_conn()
2657 cconn = tcp_conn->dd_data; in cxgbi_create_conn()
2658 cconn->iconn = conn; in cxgbi_create_conn()
2672 struct iscsi_conn *conn = cls_conn->dd_data; in cxgbi_bind_conn()
2673 struct iscsi_tcp_conn *tcp_conn = conn->dd_data; in cxgbi_bind_conn()
2674 struct cxgbi_conn *cconn = tcp_conn->dd_data; in cxgbi_bind_conn()
2683 return -EINVAL; in cxgbi_bind_conn()
2686 cep = ep->dd_data; in cxgbi_bind_conn()
2687 csk = cep->csk; in cxgbi_bind_conn()
2689 ppm = csk->cdev->cdev2ppm(csk->cdev); in cxgbi_bind_conn()
2690 err = csk->cdev->csk_ddp_setup_pgidx(csk, csk->tid, in cxgbi_bind_conn()
2691 ppm->tformat.pgsz_idx_dflt); in cxgbi_bind_conn()
2697 err = -EINVAL; in cxgbi_bind_conn()
2702 cconn->task_idx_bits = (__ilog2_u32(conn->session->cmds_max - 1)) + 1; in cxgbi_bind_conn()
2704 write_lock_bh(&csk->callback_lock); in cxgbi_bind_conn()
2705 csk->user_data = conn; in cxgbi_bind_conn()
2706 cconn->chba = cep->chba; in cxgbi_bind_conn()
2707 cconn->cep = cep; in cxgbi_bind_conn()
2708 cep->cconn = cconn; in cxgbi_bind_conn()
2709 write_unlock_bh(&csk->callback_lock); in cxgbi_bind_conn()
2741 cep = ep->dd_data; in cxgbi_create_session()
2742 chba = cep->chba; in cxgbi_create_session()
2743 shost = chba->shost; in cxgbi_create_session()
2747 cls_session = iscsi_session_setup(chba->cdev->itp, shost, in cxgbi_create_session()
2755 session = cls_session->dd_data; in cxgbi_create_session()
2774 iscsi_tcp_r2tpool_free(cls_session->dd_data); in cxgbi_destroy_session()
2784 if (!chba->ndev) { in cxgbi_set_host_param()
2787 return -ENODEV; in cxgbi_set_host_param()
2792 shost, chba, chba->ndev->name, param, buflen, buf); in cxgbi_set_host_param()
2799 "hba %s, req. ipv4 %pI4.\n", chba->ndev->name, &addr); in cxgbi_set_host_param()
2818 if (!chba->ndev) { in cxgbi_get_host_param()
2821 return -ENODEV; in cxgbi_get_host_param()
2826 shost, chba, chba->ndev->name, param); in cxgbi_get_host_param()
2830 len = sysfs_format_mac(buf, chba->ndev->dev_addr, 6); in cxgbi_get_host_param()
2833 len = sprintf(buf, "%s\n", chba->ndev->name); in cxgbi_get_host_param()
2837 struct cxgbi_sock *csk = find_sock_on_port(chba->cdev, in cxgbi_get_host_param()
2838 chba->port_id); in cxgbi_get_host_param()
2841 (struct sockaddr *)&csk->saddr); in cxgbi_get_host_param()
2844 "hba %s, addr %s.\n", chba->ndev->name, buf); in cxgbi_get_host_param()
2864 int err = -EINVAL; in cxgbi_ep_connect()
2879 if (dst_addr->sa_family == AF_INET) { in cxgbi_ep_connect()
2882 } else if (dst_addr->sa_family == AF_INET6) { in cxgbi_ep_connect()
2887 dst_addr->sa_family); in cxgbi_ep_connect()
2888 err = -EAFNOSUPPORT; in cxgbi_ep_connect()
2897 hba = csk->cdev->hbas[csk->port_id]; in cxgbi_ep_connect()
2898 else if (hba != csk->cdev->hbas[csk->port_id]) { in cxgbi_ep_connect()
2899 if (ifindex != hba->ndev->ifindex) { in cxgbi_ep_connect()
2902 ifindex = hba->ndev->ifindex; in cxgbi_ep_connect()
2908 shost->host_no, hba, in cxgbi_ep_connect()
2909 csk->cdev->hbas[csk->port_id], csk->port_id); in cxgbi_ep_connect()
2910 err = -ENOSPC; in cxgbi_ep_connect()
2919 err = csk->cdev->csk_init_act_open(csk); in cxgbi_ep_connect()
2924 err = -ENOSPC; in cxgbi_ep_connect()
2931 err = -ENOMEM; in cxgbi_ep_connect()
2936 cep = ep->dd_data; in cxgbi_ep_connect()
2937 cep->csk = csk; in cxgbi_ep_connect()
2938 cep->chba = hba; in cxgbi_ep_connect()
2942 ep, cep, csk, hba, hba->ndev->name); in cxgbi_ep_connect()
2955 struct cxgbi_endpoint *cep = ep->dd_data; in cxgbi_ep_poll()
2956 struct cxgbi_sock *csk = cep->csk; in cxgbi_ep_poll()
2966 struct cxgbi_endpoint *cep = ep->dd_data; in cxgbi_ep_disconnect()
2967 struct cxgbi_conn *cconn = cep->cconn; in cxgbi_ep_disconnect()
2968 struct cxgbi_sock *csk = cep->csk; in cxgbi_ep_disconnect()
2972 ep, cep, cconn, csk, csk->state, csk->flags); in cxgbi_ep_disconnect()
2974 if (cconn && cconn->iconn) { in cxgbi_ep_disconnect()
2975 write_lock_bh(&csk->callback_lock); in cxgbi_ep_disconnect()
2976 cep->csk->user_data = NULL; in cxgbi_ep_disconnect()
2977 cconn->cep = NULL; in cxgbi_ep_disconnect()
2978 write_unlock_bh(&csk->callback_lock); in cxgbi_ep_disconnect()
2982 if (likely(csk->state >= CTP_ESTABLISHED)) in cxgbi_ep_disconnect()
2997 itp->name, itp); in cxgbi_iscsi_init()
2998 return -ENODEV; in cxgbi_iscsi_init()
3002 itp->name, stt); in cxgbi_iscsi_init()
3012 "de-register transport 0x%p, %s, stt 0x%p.\n", in cxgbi_iscsi_cleanup()
3013 itp, itp->name, *stt); in cxgbi_iscsi_cleanup()
3084 return -ENOMEM; in libcxgbi_init_module()