]> bbs.cooldavid.org Git - net-next-2.6.git/blame - include/scsi/libiscsi_tcp.h
tg3: use dma_alloc_coherent() instead of pci_alloc_consistent()
[net-next-2.6.git] / include / scsi / libiscsi_tcp.h
CommitLineData
a081c13e
MC
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
26struct iscsi_tcp_conn;
27struct iscsi_segment;
28struct sk_buff;
29struct hash_desc;
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 hash_desc *hash;
2856830b 42 unsigned char padbuf[ISCSI_PAD_LEN];
a081c13e
MC
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
51 iscsi_segment_done_fn_t *done;
52};
53
54/* Socket connection recieve helper */
55struct iscsi_tcp_recv {
56 struct iscsi_hdr *hdr;
57 struct iscsi_segment segment;
58
59 /* Allocate buffer for BHS + AHS */
60 uint32_t hdr_buf[64];
61
62 /* copied and flipped values */
63 int datalen;
64};
65
66struct iscsi_tcp_conn {
67 struct iscsi_conn *iscsi_conn;
68 void *dd_data;
69 int stop_stage; /* conn_stop() flag: *
70 * stop to recover, *
71 * stop to terminate */
72 /* control data */
73 struct iscsi_tcp_recv in; /* TCP receive context */
74 /* CRC32C (Rx) LLD should set this is they do not offload */
75 struct hash_desc *rx_hash;
76};
77
78struct iscsi_tcp_task {
79 uint32_t exp_datasn; /* expected target's R2TSN/DataSN */
80 int data_offset;
81 struct iscsi_r2t_info *r2t; /* in progress solict R2T */
82 struct iscsi_pool r2tpool;
45465487 83 struct kfifo r2tqueue;
a081c13e
MC
84 void *dd_data;
85};
86
87enum {
88 ISCSI_TCP_SEGMENT_DONE, /* curr seg has been processed */
89 ISCSI_TCP_SKB_DONE, /* skb is out of data */
90 ISCSI_TCP_CONN_ERR, /* iscsi layer has fired a conn err */
91 ISCSI_TCP_SUSPENDED, /* conn is suspended */
92};
93
94extern void iscsi_tcp_hdr_recv_prep(struct iscsi_tcp_conn *tcp_conn);
95extern int iscsi_tcp_recv_skb(struct iscsi_conn *conn, struct sk_buff *skb,
96 unsigned int offset, bool offloaded, int *status);
97extern void iscsi_tcp_cleanup_task(struct iscsi_task *task);
98extern int iscsi_tcp_task_init(struct iscsi_task *task);
99extern int iscsi_tcp_task_xmit(struct iscsi_task *task);
100
101/* segment helpers */
102extern int iscsi_tcp_recv_segment_is_hdr(struct iscsi_tcp_conn *tcp_conn);
6df19a79
MC
103extern int iscsi_tcp_segment_done(struct iscsi_tcp_conn *tcp_conn,
104 struct iscsi_segment *segment, int recv,
a081c13e
MC
105 unsigned copied);
106extern void iscsi_tcp_segment_unmap(struct iscsi_segment *segment);
107
108extern void iscsi_segment_init_linear(struct iscsi_segment *segment,
109 void *data, size_t size,
110 iscsi_segment_done_fn_t *done,
111 struct hash_desc *hash);
112extern int
113iscsi_segment_seek_sg(struct iscsi_segment *segment,
114 struct scatterlist *sg_list, unsigned int sg_count,
115 unsigned int offset, size_t size,
116 iscsi_segment_done_fn_t *done, struct hash_desc *hash);
117
118/* digest helpers */
119extern void iscsi_tcp_dgst_header(struct hash_desc *hash, const void *hdr,
120 size_t hdrlen,
121 unsigned char digest[ISCSI_DIGEST_SIZE]);
122extern struct iscsi_cls_conn *
123iscsi_tcp_conn_setup(struct iscsi_cls_session *cls_session, int dd_data_size,
124 uint32_t conn_idx);
125extern void iscsi_tcp_conn_teardown(struct iscsi_cls_conn *cls_conn);
126
127/* misc helpers */
128extern int iscsi_tcp_r2tpool_alloc(struct iscsi_session *session);
129extern void iscsi_tcp_r2tpool_free(struct iscsi_session *session);
130
131extern void iscsi_tcp_conn_get_stats(struct iscsi_cls_conn *cls_conn,
132 struct iscsi_stats *stats);
133#endif /* LIBISCSI_TCP_H */