1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#ifndef LIBISCSI_TCP_H
22#define LIBISCSI_TCP_H
23
24#include <scsi/libiscsi.h>
25
26struct iscsi_tcp_conn;
27struct iscsi_segment;
28struct sk_buff;
29struct ahash_request;
30
31typedef int iscsi_segment_done_fn_t(struct iscsi_tcp_conn *,
32 struct iscsi_segment *);
33
34struct iscsi_segment {
35 unsigned char *data;
36 unsigned int size;
37 unsigned int copied;
38 unsigned int total_size;
39 unsigned int total_copied;
40
41 struct ahash_request *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;
46
47 struct scatterlist *sg;
48 void *sg_mapped;
49 unsigned int sg_offset;
50 bool atomic_mapped;
51
52 iscsi_segment_done_fn_t *done;
53};
54
55
56struct iscsi_tcp_recv {
57 struct iscsi_hdr *hdr;
58 struct iscsi_segment segment;
59
60
61 uint32_t hdr_buf[64];
62
63
64 int datalen;
65};
66
67struct iscsi_tcp_conn {
68 struct iscsi_conn *iscsi_conn;
69 void *dd_data;
70 int stop_stage;
71
72
73
74 struct iscsi_tcp_recv in;
75
76 struct ahash_request *rx_hash;
77};
78
79struct iscsi_tcp_task {
80 uint32_t exp_datasn;
81 int data_offset;
82 struct iscsi_r2t_info *r2t;
83 struct iscsi_pool r2tpool;
84 struct kfifo r2tqueue;
85 void *dd_data;
86 spinlock_t pool2queue;
87 spinlock_t queue2pool;
88};
89
90enum {
91 ISCSI_TCP_SEGMENT_DONE,
92 ISCSI_TCP_SKB_DONE,
93 ISCSI_TCP_CONN_ERR,
94 ISCSI_TCP_SUSPENDED,
95};
96
97extern void iscsi_tcp_hdr_recv_prep(struct iscsi_tcp_conn *tcp_conn);
98extern int iscsi_tcp_recv_skb(struct iscsi_conn *conn, struct sk_buff *skb,
99 unsigned int offset, bool offloaded, int *status);
100extern void iscsi_tcp_cleanup_task(struct iscsi_task *task);
101extern int iscsi_tcp_task_init(struct iscsi_task *task);
102extern int iscsi_tcp_task_xmit(struct iscsi_task *task);
103
104
105extern int iscsi_tcp_recv_segment_is_hdr(struct iscsi_tcp_conn *tcp_conn);
106extern int iscsi_tcp_segment_done(struct iscsi_tcp_conn *tcp_conn,
107 struct iscsi_segment *segment, int recv,
108 unsigned copied);
109extern void iscsi_tcp_segment_unmap(struct iscsi_segment *segment);
110
111extern void iscsi_segment_init_linear(struct iscsi_segment *segment,
112 void *data, size_t size,
113 iscsi_segment_done_fn_t *done,
114 struct ahash_request *hash);
115extern int
116iscsi_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,
120 struct ahash_request *hash);
121
122
123extern void iscsi_tcp_dgst_header(struct ahash_request *hash, const void *hdr,
124 size_t hdrlen,
125 unsigned char digest[ISCSI_DIGEST_SIZE]);
126extern struct iscsi_cls_conn *
127iscsi_tcp_conn_setup(struct iscsi_cls_session *cls_session, int dd_data_size,
128 uint32_t conn_idx);
129extern void iscsi_tcp_conn_teardown(struct iscsi_cls_conn *cls_conn);
130
131
132extern int iscsi_tcp_r2tpool_alloc(struct iscsi_session *session);
133extern void iscsi_tcp_r2tpool_free(struct iscsi_session *session);
134extern int iscsi_tcp_set_max_r2t(struct iscsi_conn *conn, char *buf);
135extern void iscsi_tcp_conn_get_stats(struct iscsi_cls_conn *cls_conn,
136 struct iscsi_stats *stats);
137#endif
138