diff options
author | Mike Christie <michaelc@cs.wisc.edu> | 2008-12-02 01:32:11 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-12-29 12:24:22 -0500 |
commit | a081c13e39b5c17052a7b46fafa61019c4c110ff (patch) | |
tree | d00093d2e869b825d4e6aea62ff3b69b0c38c7b9 /include/scsi/libiscsi_tcp.h | |
parent | 30b4915015c112547e930cadf734d875aec8438d (diff) |
[SCSI] iscsi_tcp: split module into lib and lld
As explained in the previous mails, cxgb3i needs iscsi_tcp's
r2t/data_out and data_in procesing so this just moves functions
that both drivers want to use to a new module libiscsi_tcp. The
next patch will hook iscsi_tcp in.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'include/scsi/libiscsi_tcp.h')
-rw-r--r-- | include/scsi/libiscsi_tcp.h | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/include/scsi/libiscsi_tcp.h b/include/scsi/libiscsi_tcp.h new file mode 100644 index 000000000000..e6bf8ef276bb --- /dev/null +++ b/include/scsi/libiscsi_tcp.h | |||
@@ -0,0 +1,131 @@ | |||
1 | /* | ||
2 | * iSCSI over TCP/IP Data-Path lib | ||
3 | * | ||
4 | * Copyright (C) 2008 Mike Christie | ||
5 | * Copyright (C) 2008 Red Hat, Inc. All rights reserved. | ||
6 | * maintained by open-iscsi@googlegroups.com | ||
7 | * | ||
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. | ||
12 | * | ||
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. | ||
17 | * | ||
18 | * See the file COPYING included with this distribution for more details. | ||
19 | */ | ||
20 | |||
21 | #ifndef LIBISCSI_TCP_H | ||
22 | #define LIBISCSI_TCP_H | ||
23 | |||
24 | #include <scsi/libiscsi.h> | ||
25 | |||
26 | struct iscsi_tcp_conn; | ||
27 | struct iscsi_segment; | ||
28 | struct sk_buff; | ||
29 | struct hash_desc; | ||
30 | |||
31 | typedef int iscsi_segment_done_fn_t(struct iscsi_tcp_conn *, | ||
32 | struct iscsi_segment *); | ||
33 | |||
34 | struct 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 hash_desc *hash; | ||
42 | unsigned char recv_digest[ISCSI_DIGEST_SIZE]; | ||
43 | unsigned char digest[ISCSI_DIGEST_SIZE]; | ||
44 | unsigned int digest_len; | ||
45 | |||
46 | struct scatterlist *sg; | ||
47 | void *sg_mapped; | ||
48 | unsigned int sg_offset; | ||
49 | |||
50 | iscsi_segment_done_fn_t *done; | ||
51 | }; | ||
52 | |||
53 | /* Socket connection recieve helper */ | ||
54 | struct iscsi_tcp_recv { | ||
55 | struct iscsi_hdr *hdr; | ||
56 | struct iscsi_segment segment; | ||
57 | |||
58 | /* Allocate buffer for BHS + AHS */ | ||
59 | uint32_t hdr_buf[64]; | ||
60 | |||
61 | /* copied and flipped values */ | ||
62 | int datalen; | ||
63 | }; | ||
64 | |||
65 | struct iscsi_tcp_conn { | ||
66 | struct iscsi_conn *iscsi_conn; | ||
67 | void *dd_data; | ||
68 | int stop_stage; /* conn_stop() flag: * | ||
69 | * stop to recover, * | ||
70 | * stop to terminate */ | ||
71 | /* control data */ | ||
72 | struct iscsi_tcp_recv in; /* TCP receive context */ | ||
73 | /* CRC32C (Rx) LLD should set this is they do not offload */ | ||
74 | struct hash_desc *rx_hash; | ||
75 | }; | ||
76 | |||
77 | struct iscsi_tcp_task { | ||
78 | uint32_t exp_datasn; /* expected target's R2TSN/DataSN */ | ||
79 | int data_offset; | ||
80 | struct iscsi_r2t_info *r2t; /* in progress solict R2T */ | ||
81 | struct iscsi_pool r2tpool; | ||
82 | struct kfifo *r2tqueue; | ||
83 | void *dd_data; | ||
84 | }; | ||
85 | |||
86 | enum { | ||
87 | ISCSI_TCP_SEGMENT_DONE, /* curr seg has been processed */ | ||
88 | ISCSI_TCP_SKB_DONE, /* skb is out of data */ | ||
89 | ISCSI_TCP_CONN_ERR, /* iscsi layer has fired a conn err */ | ||
90 | ISCSI_TCP_SUSPENDED, /* conn is suspended */ | ||
91 | }; | ||
92 | |||
93 | extern void iscsi_tcp_hdr_recv_prep(struct iscsi_tcp_conn *tcp_conn); | ||
94 | extern int iscsi_tcp_recv_skb(struct iscsi_conn *conn, struct sk_buff *skb, | ||
95 | unsigned int offset, bool offloaded, int *status); | ||
96 | extern void iscsi_tcp_cleanup_task(struct iscsi_task *task); | ||
97 | extern int iscsi_tcp_task_init(struct iscsi_task *task); | ||
98 | extern int iscsi_tcp_task_xmit(struct iscsi_task *task); | ||
99 | |||
100 | /* segment helpers */ | ||
101 | extern int iscsi_tcp_recv_segment_is_hdr(struct iscsi_tcp_conn *tcp_conn); | ||
102 | extern int iscsi_tcp_segment_done(struct iscsi_segment *segment, int recv, | ||
103 | unsigned copied); | ||
104 | extern void iscsi_tcp_segment_unmap(struct iscsi_segment *segment); | ||
105 | |||
106 | extern void iscsi_segment_init_linear(struct iscsi_segment *segment, | ||
107 | void *data, size_t size, | ||
108 | iscsi_segment_done_fn_t *done, | ||
109 | struct hash_desc *hash); | ||
110 | extern int | ||
111 | iscsi_segment_seek_sg(struct iscsi_segment *segment, | ||
112 | struct scatterlist *sg_list, unsigned int sg_count, | ||
113 | unsigned int offset, size_t size, | ||
114 | iscsi_segment_done_fn_t *done, struct hash_desc *hash); | ||
115 | |||
116 | /* digest helpers */ | ||
117 | extern void iscsi_tcp_dgst_header(struct hash_desc *hash, const void *hdr, | ||
118 | size_t hdrlen, | ||
119 | unsigned char digest[ISCSI_DIGEST_SIZE]); | ||
120 | extern struct iscsi_cls_conn * | ||
121 | iscsi_tcp_conn_setup(struct iscsi_cls_session *cls_session, int dd_data_size, | ||
122 | uint32_t conn_idx); | ||
123 | extern void iscsi_tcp_conn_teardown(struct iscsi_cls_conn *cls_conn); | ||
124 | |||
125 | /* misc helpers */ | ||
126 | extern int iscsi_tcp_r2tpool_alloc(struct iscsi_session *session); | ||
127 | extern void iscsi_tcp_r2tpool_free(struct iscsi_session *session); | ||
128 | |||
129 | extern void iscsi_tcp_conn_get_stats(struct iscsi_cls_conn *cls_conn, | ||
130 | struct iscsi_stats *stats); | ||
131 | #endif /* LIBISCSI_TCP_H */ | ||