libcxgbi.c (75b61250bf687c686ba6850c34eccc1303b0b827) libcxgbi.c (e0f8e8cf3bf9305f36155a5ac6e16b3b910e6cec)
1/*
2 * libcxgbi.c: Chelsio common library for T3/T4 iSCSI driver.
3 *
4 * Copyright (c) 2010-2015 Chelsio Communications, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation.

--- 853 unchanged lines hidden (view full) ---

862static void need_active_close(struct cxgbi_sock *csk)
863{
864 int data_lost;
865 int close_req = 0;
866
867 log_debug(1 << CXGBI_DBG_SOCK, "csk 0x%p,%u,0x%lx,%u.\n",
868 csk, (csk)->state, (csk)->flags, (csk)->tid);
869 spin_lock_bh(&csk->lock);
1/*
2 * libcxgbi.c: Chelsio common library for T3/T4 iSCSI driver.
3 *
4 * Copyright (c) 2010-2015 Chelsio Communications, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation.

--- 853 unchanged lines hidden (view full) ---

862static void need_active_close(struct cxgbi_sock *csk)
863{
864 int data_lost;
865 int close_req = 0;
866
867 log_debug(1 << CXGBI_DBG_SOCK, "csk 0x%p,%u,0x%lx,%u.\n",
868 csk, (csk)->state, (csk)->flags, (csk)->tid);
869 spin_lock_bh(&csk->lock);
870 dst_confirm(csk->dst);
870 if (csk->dst)
871 dst_confirm(csk->dst);
871 data_lost = skb_queue_len(&csk->receive_queue);
872 __skb_queue_purge(&csk->receive_queue);
873
874 if (csk->state == CTP_ACTIVE_OPEN)
875 cxgbi_sock_set_flag(csk, CTPF_ACTIVE_CLOSE_NEEDED);
876 else if (csk->state == CTP_ESTABLISHED) {
877 close_req = 1;
878 cxgbi_sock_set_state(csk, CTP_ACTIVE_CLOSE);
879 } else if (csk->state == CTP_PASSIVE_CLOSE) {
880 close_req = 1;
881 cxgbi_sock_set_state(csk, CTP_CLOSE_WAIT_2);
882 }
883
884 if (close_req) {
872 data_lost = skb_queue_len(&csk->receive_queue);
873 __skb_queue_purge(&csk->receive_queue);
874
875 if (csk->state == CTP_ACTIVE_OPEN)
876 cxgbi_sock_set_flag(csk, CTPF_ACTIVE_CLOSE_NEEDED);
877 else if (csk->state == CTP_ESTABLISHED) {
878 close_req = 1;
879 cxgbi_sock_set_state(csk, CTP_ACTIVE_CLOSE);
880 } else if (csk->state == CTP_PASSIVE_CLOSE) {
881 close_req = 1;
882 cxgbi_sock_set_state(csk, CTP_CLOSE_WAIT_2);
883 }
884
885 if (close_req) {
885 if (data_lost)
886 if (!cxgbi_sock_flag(csk, CTPF_LOGOUT_RSP_RCVD) ||
887 data_lost)
886 csk->cdev->csk_send_abort_req(csk);
887 else
888 csk->cdev->csk_send_close_req(csk);
889 }
890
891 spin_unlock_bh(&csk->lock);
892}
893

--- 287 unchanged lines hidden (view full) ---

1181 skb->next = NULL;
1182 cxgbi_skcb_set_flag(skb, SKCBF_TX_NEED_HDR);
1183 cxgbi_sock_skb_entail(csk, skb);
1184 copied += skb->len;
1185 csk->write_seq += skb->len +
1186 cxgbi_ulp_extra_len(cxgbi_skcb_ulp_mode(skb));
1187 skb = next;
1188 }
888 csk->cdev->csk_send_abort_req(csk);
889 else
890 csk->cdev->csk_send_close_req(csk);
891 }
892
893 spin_unlock_bh(&csk->lock);
894}
895

--- 287 unchanged lines hidden (view full) ---

1183 skb->next = NULL;
1184 cxgbi_skcb_set_flag(skb, SKCBF_TX_NEED_HDR);
1185 cxgbi_sock_skb_entail(csk, skb);
1186 copied += skb->len;
1187 csk->write_seq += skb->len +
1188 cxgbi_ulp_extra_len(cxgbi_skcb_ulp_mode(skb));
1189 skb = next;
1190 }
1189done:
1191
1190 if (likely(skb_queue_len(&csk->write_queue)))
1191 cdev->csk_push_tx_frames(csk, 1);
1192 if (likely(skb_queue_len(&csk->write_queue)))
1193 cdev->csk_push_tx_frames(csk, 1);
1194done:
1192 spin_unlock_bh(&csk->lock);
1193 return copied;
1194
1195out_err:
1196 if (copied == 0 && err == -EPIPE)
1197 copied = csk->err ? csk->err : -EPIPE;
1198 else
1199 copied = err;

--- 363 unchanged lines hidden (view full) ---

1563 return bytes_read;
1564 default:
1565 pr_info("skb 0x%p, off %u, %d, invalid status %d.\n",
1566 skb, offset, offloaded, status);
1567 return -EINVAL;
1568 }
1569}
1570
1195 spin_unlock_bh(&csk->lock);
1196 return copied;
1197
1198out_err:
1199 if (copied == 0 && err == -EPIPE)
1200 copied = csk->err ? csk->err : -EPIPE;
1201 else
1202 copied = err;

--- 363 unchanged lines hidden (view full) ---

1566 return bytes_read;
1567 default:
1568 pr_info("skb 0x%p, off %u, %d, invalid status %d.\n",
1569 skb, offset, offloaded, status);
1570 return -EINVAL;
1571 }
1572}
1573
1571static int skb_read_pdu_bhs(struct iscsi_conn *conn, struct sk_buff *skb)
1574static int
1575skb_read_pdu_bhs(struct cxgbi_sock *csk, struct iscsi_conn *conn,
1576 struct sk_buff *skb)
1572{
1573 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1577{
1578 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1579 int err;
1574
1575 log_debug(1 << CXGBI_DBG_PDU_RX,
1576 "conn 0x%p, skb 0x%p, len %u, flag 0x%lx.\n",
1577 conn, skb, skb->len, cxgbi_skcb_flags(skb));
1578
1579 if (!iscsi_tcp_recv_segment_is_hdr(tcp_conn)) {
1580 pr_info("conn 0x%p, skb 0x%p, not hdr.\n", conn, skb);
1581 iscsi_conn_failure(conn, ISCSI_ERR_PROTO);

--- 21 unchanged lines hidden (view full) ---

1603 skb->data)->datasn);
1604 if (task && task->sc) {
1605 struct iscsi_tcp_task *tcp_task = task->dd_data;
1606
1607 tcp_task->exp_datasn = data_sn;
1608 }
1609 }
1610
1580
1581 log_debug(1 << CXGBI_DBG_PDU_RX,
1582 "conn 0x%p, skb 0x%p, len %u, flag 0x%lx.\n",
1583 conn, skb, skb->len, cxgbi_skcb_flags(skb));
1584
1585 if (!iscsi_tcp_recv_segment_is_hdr(tcp_conn)) {
1586 pr_info("conn 0x%p, skb 0x%p, not hdr.\n", conn, skb);
1587 iscsi_conn_failure(conn, ISCSI_ERR_PROTO);

--- 21 unchanged lines hidden (view full) ---

1609 skb->data)->datasn);
1610 if (task && task->sc) {
1611 struct iscsi_tcp_task *tcp_task = task->dd_data;
1612
1613 tcp_task->exp_datasn = data_sn;
1614 }
1615 }
1616
1611 return read_pdu_skb(conn, skb, 0, 0);
1617 err = read_pdu_skb(conn, skb, 0, 0);
1618 if (likely(err >= 0)) {
1619 struct iscsi_hdr *hdr = (struct iscsi_hdr *)skb->data;
1620 u8 opcode = hdr->opcode & ISCSI_OPCODE_MASK;
1621
1622 if (unlikely(opcode == ISCSI_OP_LOGOUT_RSP))
1623 cxgbi_sock_set_flag(csk, CTPF_LOGOUT_RSP_RCVD);
1624 }
1625
1626 return err;
1612}
1613
1614static int skb_read_pdu_data(struct iscsi_conn *conn, struct sk_buff *lskb,
1615 struct sk_buff *skb, unsigned int offset)
1616{
1617 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1618 bool offloaded = 0;
1619 int opcode = tcp_conn->in.hdr->opcode & ISCSI_OPCODE_MASK;

--- 88 unchanged lines hidden (view full) ---

1708
1709 read += cxgbi_skcb_rx_pdulen(skb);
1710 log_debug(1 << CXGBI_DBG_PDU_RX,
1711 "csk 0x%p, skb 0x%p,%u,f 0x%lx, pdu len %u.\n",
1712 csk, skb, skb->len, cxgbi_skcb_flags(skb),
1713 cxgbi_skcb_rx_pdulen(skb));
1714
1715 if (cxgbi_skcb_test_flag(skb, SKCBF_RX_COALESCED)) {
1627}
1628
1629static int skb_read_pdu_data(struct iscsi_conn *conn, struct sk_buff *lskb,
1630 struct sk_buff *skb, unsigned int offset)
1631{
1632 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
1633 bool offloaded = 0;
1634 int opcode = tcp_conn->in.hdr->opcode & ISCSI_OPCODE_MASK;

--- 88 unchanged lines hidden (view full) ---

1723
1724 read += cxgbi_skcb_rx_pdulen(skb);
1725 log_debug(1 << CXGBI_DBG_PDU_RX,
1726 "csk 0x%p, skb 0x%p,%u,f 0x%lx, pdu len %u.\n",
1727 csk, skb, skb->len, cxgbi_skcb_flags(skb),
1728 cxgbi_skcb_rx_pdulen(skb));
1729
1730 if (cxgbi_skcb_test_flag(skb, SKCBF_RX_COALESCED)) {
1716 err = skb_read_pdu_bhs(conn, skb);
1731 err = skb_read_pdu_bhs(csk, conn, skb);
1717 if (err < 0) {
1718 pr_err("coalesced bhs, csk 0x%p, skb 0x%p,%u, "
1719 "f 0x%lx, plen %u.\n",
1720 csk, skb, skb->len,
1721 cxgbi_skcb_flags(skb),
1722 cxgbi_skcb_rx_pdulen(skb));
1723 goto skb_done;
1724 }
1725 err = skb_read_pdu_data(conn, skb, skb,
1726 err + cdev->skb_rx_extra);
1727 if (err < 0)
1728 pr_err("coalesced data, csk 0x%p, skb 0x%p,%u, "
1729 "f 0x%lx, plen %u.\n",
1730 csk, skb, skb->len,
1731 cxgbi_skcb_flags(skb),
1732 cxgbi_skcb_rx_pdulen(skb));
1733 } else {
1732 if (err < 0) {
1733 pr_err("coalesced bhs, csk 0x%p, skb 0x%p,%u, "
1734 "f 0x%lx, plen %u.\n",
1735 csk, skb, skb->len,
1736 cxgbi_skcb_flags(skb),
1737 cxgbi_skcb_rx_pdulen(skb));
1738 goto skb_done;
1739 }
1740 err = skb_read_pdu_data(conn, skb, skb,
1741 err + cdev->skb_rx_extra);
1742 if (err < 0)
1743 pr_err("coalesced data, csk 0x%p, skb 0x%p,%u, "
1744 "f 0x%lx, plen %u.\n",
1745 csk, skb, skb->len,
1746 cxgbi_skcb_flags(skb),
1747 cxgbi_skcb_rx_pdulen(skb));
1748 } else {
1734 err = skb_read_pdu_bhs(conn, skb);
1749 err = skb_read_pdu_bhs(csk, conn, skb);
1735 if (err < 0) {
1736 pr_err("bhs, csk 0x%p, skb 0x%p,%u, "
1737 "f 0x%lx, plen %u.\n",
1738 csk, skb, skb->len,
1739 cxgbi_skcb_flags(skb),
1740 cxgbi_skcb_rx_pdulen(skb));
1741 goto skb_done;
1742 }

--- 996 unchanged lines hidden ---
1750 if (err < 0) {
1751 pr_err("bhs, csk 0x%p, skb 0x%p,%u, "
1752 "f 0x%lx, plen %u.\n",
1753 csk, skb, skb->len,
1754 cxgbi_skcb_flags(skb),
1755 cxgbi_skcb_rx_pdulen(skb));
1756 goto skb_done;
1757 }

--- 996 unchanged lines hidden ---