diff options
Diffstat (limited to 'drivers/scsi/iscsi_tcp.h')
-rw-r--r-- | drivers/scsi/iscsi_tcp.h | 75 |
1 files changed, 15 insertions, 60 deletions
diff --git a/drivers/scsi/iscsi_tcp.h b/drivers/scsi/iscsi_tcp.h index d49d87611e82..893cd2e1701e 100644 --- a/drivers/scsi/iscsi_tcp.h +++ b/drivers/scsi/iscsi_tcp.h | |||
@@ -24,35 +24,18 @@ | |||
24 | 24 | ||
25 | #include <scsi/libiscsi.h> | 25 | #include <scsi/libiscsi.h> |
26 | 26 | ||
27 | /* xmit state machine */ | ||
28 | #define XMSTATE_IDLE 0x0 | ||
29 | #define XMSTATE_CMD_HDR_INIT 0x1 | ||
30 | #define XMSTATE_CMD_HDR_XMIT 0x2 | ||
31 | #define XMSTATE_IMM_HDR 0x4 | ||
32 | #define XMSTATE_IMM_DATA 0x8 | ||
33 | #define XMSTATE_UNS_INIT 0x10 | ||
34 | #define XMSTATE_UNS_HDR 0x20 | ||
35 | #define XMSTATE_UNS_DATA 0x40 | ||
36 | #define XMSTATE_SOL_HDR 0x80 | ||
37 | #define XMSTATE_SOL_DATA 0x100 | ||
38 | #define XMSTATE_W_PAD 0x200 | ||
39 | #define XMSTATE_W_RESEND_PAD 0x400 | ||
40 | #define XMSTATE_W_RESEND_DATA_DIGEST 0x800 | ||
41 | #define XMSTATE_IMM_HDR_INIT 0x1000 | ||
42 | #define XMSTATE_SOL_HDR_INIT 0x2000 | ||
43 | |||
44 | #define ISCSI_SG_TABLESIZE SG_ALL | 27 | #define ISCSI_SG_TABLESIZE SG_ALL |
45 | #define ISCSI_TCP_MAX_CMD_LEN 16 | 28 | #define ISCSI_TCP_MAX_CMD_LEN 16 |
46 | 29 | ||
47 | struct crypto_hash; | 30 | struct crypto_hash; |
48 | struct socket; | 31 | struct socket; |
49 | struct iscsi_tcp_conn; | 32 | struct iscsi_tcp_conn; |
50 | struct iscsi_chunk; | 33 | struct iscsi_segment; |
51 | 34 | ||
52 | typedef int iscsi_chunk_done_fn_t(struct iscsi_tcp_conn *, | 35 | typedef int iscsi_segment_done_fn_t(struct iscsi_tcp_conn *, |
53 | struct iscsi_chunk *); | 36 | struct iscsi_segment *); |
54 | 37 | ||
55 | struct iscsi_chunk { | 38 | struct iscsi_segment { |
56 | unsigned char *data; | 39 | unsigned char *data; |
57 | unsigned int size; | 40 | unsigned int size; |
58 | unsigned int copied; | 41 | unsigned int copied; |
@@ -67,16 +50,14 @@ struct iscsi_chunk { | |||
67 | struct scatterlist *sg; | 50 | struct scatterlist *sg; |
68 | void *sg_mapped; | 51 | void *sg_mapped; |
69 | unsigned int sg_offset; | 52 | unsigned int sg_offset; |
70 | unsigned int sg_index; | ||
71 | unsigned int sg_count; | ||
72 | 53 | ||
73 | iscsi_chunk_done_fn_t *done; | 54 | iscsi_segment_done_fn_t *done; |
74 | }; | 55 | }; |
75 | 56 | ||
76 | /* Socket connection recieve helper */ | 57 | /* Socket connection recieve helper */ |
77 | struct iscsi_tcp_recv { | 58 | struct iscsi_tcp_recv { |
78 | struct iscsi_hdr *hdr; | 59 | struct iscsi_hdr *hdr; |
79 | struct iscsi_chunk chunk; | 60 | struct iscsi_segment segment; |
80 | 61 | ||
81 | /* Allocate buffer for BHS + AHS */ | 62 | /* Allocate buffer for BHS + AHS */ |
82 | uint32_t hdr_buf[64]; | 63 | uint32_t hdr_buf[64]; |
@@ -88,11 +69,8 @@ struct iscsi_tcp_recv { | |||
88 | /* Socket connection send helper */ | 69 | /* Socket connection send helper */ |
89 | struct iscsi_tcp_send { | 70 | struct iscsi_tcp_send { |
90 | struct iscsi_hdr *hdr; | 71 | struct iscsi_hdr *hdr; |
91 | struct iscsi_chunk chunk; | 72 | struct iscsi_segment segment; |
92 | struct iscsi_chunk data_chunk; | 73 | struct iscsi_segment data_segment; |
93 | |||
94 | /* Allocate buffer for BHS + AHS */ | ||
95 | uint32_t hdr_buf[64]; | ||
96 | }; | 74 | }; |
97 | 75 | ||
98 | struct iscsi_tcp_conn { | 76 | struct iscsi_tcp_conn { |
@@ -118,29 +96,19 @@ struct iscsi_tcp_conn { | |||
118 | uint32_t sendpage_failures_cnt; | 96 | uint32_t sendpage_failures_cnt; |
119 | uint32_t discontiguous_hdr_cnt; | 97 | uint32_t discontiguous_hdr_cnt; |
120 | 98 | ||
121 | ssize_t (*sendpage)(struct socket *, struct page *, int, size_t, int); | 99 | int error; |
122 | }; | ||
123 | 100 | ||
124 | struct iscsi_buf { | 101 | ssize_t (*sendpage)(struct socket *, struct page *, int, size_t, int); |
125 | struct scatterlist sg; | ||
126 | unsigned int sent; | ||
127 | char use_sendmsg; | ||
128 | }; | 102 | }; |
129 | 103 | ||
130 | struct iscsi_data_task { | 104 | struct iscsi_data_task { |
131 | struct iscsi_data hdr; /* PDU */ | 105 | struct iscsi_data hdr; /* PDU */ |
132 | char hdrext[ISCSI_DIGEST_SIZE];/* Header-Digest */ | 106 | char hdrext[ISCSI_DIGEST_SIZE];/* Header-Digest */ |
133 | struct iscsi_buf digestbuf; /* digest buffer */ | ||
134 | uint32_t digest; /* data digest */ | ||
135 | }; | 107 | }; |
136 | 108 | ||
137 | struct iscsi_tcp_mgmt_task { | 109 | struct iscsi_tcp_mgmt_task { |
138 | struct iscsi_hdr hdr; | 110 | struct iscsi_hdr hdr; |
139 | char hdrext[ISCSI_DIGEST_SIZE]; /* Header-Digest */ | 111 | char hdrext[ISCSI_DIGEST_SIZE]; /* Header-Digest */ |
140 | int xmstate; /* mgmt xmit progress */ | ||
141 | struct iscsi_buf headbuf; /* header buffer */ | ||
142 | struct iscsi_buf sendbuf; /* in progress buffer */ | ||
143 | int sent; | ||
144 | }; | 112 | }; |
145 | 113 | ||
146 | struct iscsi_r2t_info { | 114 | struct iscsi_r2t_info { |
@@ -148,13 +116,10 @@ struct iscsi_r2t_info { | |||
148 | __be32 exp_statsn; /* copied from R2T */ | 116 | __be32 exp_statsn; /* copied from R2T */ |
149 | uint32_t data_length; /* copied from R2T */ | 117 | uint32_t data_length; /* copied from R2T */ |
150 | uint32_t data_offset; /* copied from R2T */ | 118 | uint32_t data_offset; /* copied from R2T */ |
151 | struct iscsi_buf headbuf; /* Data-Out Header Buffer */ | ||
152 | struct iscsi_buf sendbuf; /* Data-Out in progress buffer*/ | ||
153 | int sent; /* R2T sequence progress */ | 119 | int sent; /* R2T sequence progress */ |
154 | int data_count; /* DATA-Out payload progress */ | 120 | int data_count; /* DATA-Out payload progress */ |
155 | struct scatterlist *sg; /* per-R2T SG list */ | ||
156 | int solicit_datasn; | 121 | int solicit_datasn; |
157 | struct iscsi_data_task dtask; /* which data task */ | 122 | struct iscsi_data_task dtask; /* Data-Out header buf */ |
158 | }; | 123 | }; |
159 | 124 | ||
160 | struct iscsi_tcp_cmd_task { | 125 | struct iscsi_tcp_cmd_task { |
@@ -163,24 +128,14 @@ struct iscsi_tcp_cmd_task { | |||
163 | char hdrextbuf[ISCSI_MAX_AHS_SIZE + | 128 | char hdrextbuf[ISCSI_MAX_AHS_SIZE + |
164 | ISCSI_DIGEST_SIZE]; | 129 | ISCSI_DIGEST_SIZE]; |
165 | } hdr; | 130 | } hdr; |
166 | char pad[ISCSI_PAD_LEN]; | 131 | |
167 | int pad_count; /* padded bytes */ | ||
168 | struct iscsi_buf headbuf; /* header buf (xmit) */ | ||
169 | struct iscsi_buf sendbuf; /* in progress buffer*/ | ||
170 | int xmstate; /* xmit xtate machine */ | ||
171 | int sent; | 132 | int sent; |
172 | struct scatterlist *sg; /* per-cmd SG list */ | 133 | uint32_t exp_datasn; /* expected target's R2TSN/DataSN */ |
173 | struct scatterlist *bad_sg; /* assert statement */ | ||
174 | int sg_count; /* SG's to process */ | ||
175 | uint32_t exp_datasn; /* expected target's R2TSN/DataSN */ | ||
176 | int data_offset; | 134 | int data_offset; |
177 | struct iscsi_r2t_info *r2t; /* in progress R2T */ | 135 | struct iscsi_r2t_info *r2t; /* in progress R2T */ |
178 | struct iscsi_pool r2tpool; | 136 | struct iscsi_pool r2tpool; |
179 | struct kfifo *r2tqueue; | 137 | struct kfifo *r2tqueue; |
180 | int digest_count; | 138 | struct iscsi_data_task unsol_dtask; /* Data-Out header buf */ |
181 | uint32_t immdigest; /* for imm data */ | ||
182 | struct iscsi_buf immbuf; /* for imm data digest */ | ||
183 | struct iscsi_data_task unsol_dtask; /* unsol data task */ | ||
184 | }; | 139 | }; |
185 | 140 | ||
186 | #endif /* ISCSI_H */ | 141 | #endif /* ISCSI_H */ |