]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/lib/iscsi/task.h
4 * Copyright (C) 2008-2012 Daisuke Aoyama <aoyama@peach.ne.jp>.
5 * Copyright (c) Intel Corporation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #ifndef SPDK_ISCSI_TASK_H
36 #define SPDK_ISCSI_TASK_H
38 #include "iscsi/iscsi.h"
39 #include "spdk/scsi.h"
41 struct spdk_iscsi_task
{
42 struct spdk_scsi_task scsi
;
44 struct spdk_iscsi_pdu
*pdu
;
45 uint32_t outstanding_r2t
;
48 * Tracks the current offset of large read io.
50 uint32_t current_datain_offset
;
53 * next_expected_r2t_offset is used when we receive
56 uint32_t next_expected_r2t_offset
;
59 * Tracks the length of the R2T that is in progress.
60 * Used to check that an R2T burst does not exceed
63 uint32_t current_r2t_length
;
66 * next_r2t_offset is used when we are sending the
67 * R2T packet to keep track of next offset of r2t.
69 uint32_t next_r2t_offset
;
71 uint32_t r2t_datasn
; /* record next datasn for a r2tsn*/
72 uint32_t acked_r2tsn
; /* next r2tsn to be acked */
73 uint32_t datain_datasn
;
74 uint32_t acked_data_sn
; /* next expected datain datasn */
77 TAILQ_ENTRY(spdk_iscsi_task
) link
;
81 spdk_iscsi_task_put(struct spdk_iscsi_task
*task
)
83 spdk_scsi_task_put(&task
->scsi
);
86 static inline struct spdk_iscsi_pdu
*
87 spdk_iscsi_task_get_pdu(struct spdk_iscsi_task
*task
)
93 spdk_iscsi_task_set_pdu(struct spdk_iscsi_task
*task
, struct spdk_iscsi_pdu
*pdu
)
98 static inline struct iscsi_bhs
*
99 spdk_iscsi_task_get_bhs(struct spdk_iscsi_task
*task
)
101 return &spdk_iscsi_task_get_pdu(task
)->bhs
;
105 spdk_iscsi_task_associate_pdu(struct spdk_iscsi_task
*task
, struct spdk_iscsi_pdu
*pdu
)
107 spdk_iscsi_task_set_pdu(task
, pdu
);
112 spdk_iscsi_task_disassociate_pdu(struct spdk_iscsi_task
*task
)
114 if (spdk_iscsi_task_get_pdu(task
)) {
115 spdk_put_pdu(spdk_iscsi_task_get_pdu(task
));
116 spdk_iscsi_task_set_pdu(task
, NULL
);
121 spdk_iscsi_task_is_immediate(struct spdk_iscsi_task
*task
)
123 struct iscsi_bhs_scsi_req
*scsi_req
;
125 scsi_req
= (struct iscsi_bhs_scsi_req
*)spdk_iscsi_task_get_bhs(task
);
126 return (scsi_req
->immediate
== 1);
130 spdk_iscsi_task_is_read(struct spdk_iscsi_task
*task
)
132 struct iscsi_bhs_scsi_req
*scsi_req
;
134 scsi_req
= (struct iscsi_bhs_scsi_req
*)spdk_iscsi_task_get_bhs(task
);
135 return (scsi_req
->read
== 1);
138 static inline uint32_t
139 spdk_iscsi_task_get_cmdsn(struct spdk_iscsi_task
*task
)
141 return spdk_iscsi_task_get_pdu(task
)->cmd_sn
;
144 struct spdk_iscsi_task
*spdk_iscsi_task_get(uint32_t *owner_task_ctr
,
145 struct spdk_iscsi_task
*parent
);
147 static inline struct spdk_iscsi_task
*
148 spdk_iscsi_task_get_primary(struct spdk_iscsi_task
*task
)
150 struct spdk_scsi_task
*scsi_task
;
151 struct spdk_scsi_task
*scsi_primary_task
;
153 scsi_task
= &task
->scsi
;
154 scsi_primary_task
= spdk_scsi_task_get_primary(scsi_task
);
155 return (struct spdk_iscsi_task
*)scsi_primary_task
;
158 #endif /* SPDK_ISCSI_TASK_H */