]>
git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - include/scsi/libiscsi_tcp.h
2 * iSCSI over TCP/IP Data-Path lib
4 * Copyright (C) 2008 Mike Christie
5 * Copyright (C) 2008 Red Hat, Inc. All rights reserved.
6 * maintained by open-iscsi@googlegroups.com
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published
10 * by the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * See the file COPYING included with this distribution for more details.
21 #ifndef LIBISCSI_TCP_H
22 #define LIBISCSI_TCP_H
24 #include <scsi/libiscsi.h>
26 struct iscsi_tcp_conn
;
31 typedef int iscsi_segment_done_fn_t(struct iscsi_tcp_conn
*,
32 struct iscsi_segment
*);
34 struct iscsi_segment
{
38 unsigned int total_size
;
39 unsigned int total_copied
;
41 struct hash_desc
*hash
;
42 unsigned char padbuf
[ISCSI_PAD_LEN
];
43 unsigned char recv_digest
[ISCSI_DIGEST_SIZE
];
44 unsigned char digest
[ISCSI_DIGEST_SIZE
];
45 unsigned int digest_len
;
47 struct scatterlist
*sg
;
49 unsigned int sg_offset
;
52 iscsi_segment_done_fn_t
*done
;
55 /* Socket connection receive helper */
56 struct iscsi_tcp_recv
{
57 struct iscsi_hdr
*hdr
;
58 struct iscsi_segment segment
;
60 /* Allocate buffer for BHS + AHS */
63 /* copied and flipped values */
67 struct iscsi_tcp_conn
{
68 struct iscsi_conn
*iscsi_conn
;
70 int stop_stage
; /* conn_stop() flag: *
72 * stop to terminate */
74 struct iscsi_tcp_recv in
; /* TCP receive context */
75 /* CRC32C (Rx) LLD should set this is they do not offload */
76 struct hash_desc
*rx_hash
;
79 struct iscsi_tcp_task
{
80 uint32_t exp_datasn
; /* expected target's R2TSN/DataSN */
82 struct iscsi_r2t_info
*r2t
; /* in progress solict R2T */
83 struct iscsi_pool r2tpool
;
84 struct kfifo r2tqueue
;
86 spinlock_t pool2queue
;
87 spinlock_t queue2pool
;
91 ISCSI_TCP_SEGMENT_DONE
, /* curr seg has been processed */
92 ISCSI_TCP_SKB_DONE
, /* skb is out of data */
93 ISCSI_TCP_CONN_ERR
, /* iscsi layer has fired a conn err */
94 ISCSI_TCP_SUSPENDED
, /* conn is suspended */
97 extern void iscsi_tcp_hdr_recv_prep(struct iscsi_tcp_conn
*tcp_conn
);
98 extern int iscsi_tcp_recv_skb(struct iscsi_conn
*conn
, struct sk_buff
*skb
,
99 unsigned int offset
, bool offloaded
, int *status
);
100 extern void iscsi_tcp_cleanup_task(struct iscsi_task
*task
);
101 extern int iscsi_tcp_task_init(struct iscsi_task
*task
);
102 extern int iscsi_tcp_task_xmit(struct iscsi_task
*task
);
104 /* segment helpers */
105 extern int iscsi_tcp_recv_segment_is_hdr(struct iscsi_tcp_conn
*tcp_conn
);
106 extern int iscsi_tcp_segment_done(struct iscsi_tcp_conn
*tcp_conn
,
107 struct iscsi_segment
*segment
, int recv
,
109 extern void iscsi_tcp_segment_unmap(struct iscsi_segment
*segment
);
111 extern void iscsi_segment_init_linear(struct iscsi_segment
*segment
,
112 void *data
, size_t size
,
113 iscsi_segment_done_fn_t
*done
,
114 struct hash_desc
*hash
);
116 iscsi_segment_seek_sg(struct iscsi_segment
*segment
,
117 struct scatterlist
*sg_list
, unsigned int sg_count
,
118 unsigned int offset
, size_t size
,
119 iscsi_segment_done_fn_t
*done
, struct hash_desc
*hash
);
122 extern void iscsi_tcp_dgst_header(struct hash_desc
*hash
, const void *hdr
,
124 unsigned char digest
[ISCSI_DIGEST_SIZE
]);
125 extern struct iscsi_cls_conn
*
126 iscsi_tcp_conn_setup(struct iscsi_cls_session
*cls_session
, int dd_data_size
,
128 extern void iscsi_tcp_conn_teardown(struct iscsi_cls_conn
*cls_conn
);
131 extern int iscsi_tcp_r2tpool_alloc(struct iscsi_session
*session
);
132 extern void iscsi_tcp_r2tpool_free(struct iscsi_session
*session
);
133 extern int iscsi_tcp_set_max_r2t(struct iscsi_conn
*conn
, char *buf
);
134 extern void iscsi_tcp_conn_get_stats(struct iscsi_cls_conn
*cls_conn
,
135 struct iscsi_stats
*stats
);
136 #endif /* LIBISCSI_TCP_H */