aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/ctl/ctl_frontend_iscsi.c
diff options
context:
space:
mode:
authorEdward Tomasz Napierala <trasz@FreeBSD.org>2015-02-08 19:15:14 +0000
committerEdward Tomasz Napierala <trasz@FreeBSD.org>2015-02-08 19:15:14 +0000
commit7a03d007cfcd2dba45cbe1bc1affe938fd375af6 (patch)
treefc0ea50d80a9c715504559e0d2434de35ceb71bb /sys/cam/ctl/ctl_frontend_iscsi.c
parenta840d2f5b82741d3415e81f9bf00223f70ac0f3d (diff)
downloadsrc-7a03d007cfcd2dba45cbe1bc1affe938fd375af6.tar.gz
src-7a03d007cfcd2dba45cbe1bc1affe938fd375af6.zip
Extend ICL to add receive offload methods. For software ICL backend
they are no-ops. MFC after: 1 month Sponsored by: The FreeBSD Foundation
Notes
Notes: svn path=/head/; revision=278397
Diffstat (limited to 'sys/cam/ctl/ctl_frontend_iscsi.c')
-rw-r--r--sys/cam/ctl/ctl_frontend_iscsi.c68
1 files changed, 57 insertions, 11 deletions
diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c
index 4b8b4923d304..29054725d5ea 100644
--- a/sys/cam/ctl/ctl_frontend_iscsi.c
+++ b/sys/cam/ctl/ctl_frontend_iscsi.c
@@ -164,6 +164,12 @@ static void cfiscsi_pdu_handle_task_request(struct icl_pdu *request);
static void cfiscsi_pdu_handle_data_out(struct icl_pdu *request);
static void cfiscsi_pdu_handle_logout_request(struct icl_pdu *request);
static void cfiscsi_session_terminate(struct cfiscsi_session *cs);
+static struct cfiscsi_data_wait *cfiscsi_data_wait_new(
+ struct cfiscsi_session *cs, union ctl_io *io,
+ uint32_t initiator_task_tag,
+ uint32_t *target_transfer_tagp);
+static void cfiscsi_data_wait_free(struct cfiscsi_session *cs,
+ struct cfiscsi_data_wait *cdw);
static struct cfiscsi_target *cfiscsi_target_find(struct cfiscsi_softc
*softc, const char *name, uint16_t tag);
static struct cfiscsi_target *cfiscsi_target_find_or_create(
@@ -929,7 +935,7 @@ cfiscsi_pdu_handle_data_out(struct icl_pdu *request)
CFISCSI_SESSION_UNLOCK(cs);
done = (io->scsiio.ext_data_filled != cdw->cdw_r2t_end ||
io->scsiio.ext_data_filled == io->scsiio.kern_data_len);
- uma_zfree(cfiscsi_data_wait_zone, cdw);
+ cfiscsi_data_wait_free(cs, cdw);
if (done)
io->scsiio.be_move_done(io);
else
@@ -1067,6 +1073,45 @@ cfiscsi_callout(void *context)
cfiscsi_pdu_queue(cp);
}
+static struct cfiscsi_data_wait *
+cfiscsi_data_wait_new(struct cfiscsi_session *cs, union ctl_io *io,
+ uint32_t initiator_task_tag, uint32_t *target_transfer_tagp)
+{
+ struct cfiscsi_data_wait *cdw;
+ int error;
+
+ cdw = uma_zalloc(cfiscsi_data_wait_zone, M_NOWAIT | M_ZERO);
+ if (cdw == NULL) {
+ CFISCSI_SESSION_WARN(cs,
+ "failed to allocate %zd bytes", sizeof(*cdw));
+ return (NULL);
+ }
+
+ error = icl_conn_transfer_setup(cs->cs_conn, io, target_transfer_tagp,
+ &cdw->cdw_icl_prv);
+ if (error != 0) {
+ CFISCSI_SESSION_WARN(cs,
+ "icl_conn_transfer_setup() failed with error %d", error);
+ uma_zfree(cfiscsi_data_wait_zone, cdw);
+ return (NULL);
+ }
+
+ cdw->cdw_ctl_io = io;
+ cdw->cdw_target_transfer_tag = *target_transfer_tagp;
+ cdw->cdw_initiator_task_tag = initiator_task_tag;
+
+ return (cdw);
+}
+
+static void
+cfiscsi_data_wait_free(struct cfiscsi_session *cs,
+ struct cfiscsi_data_wait *cdw)
+{
+
+ icl_conn_transfer_done(cs->cs_conn, cdw->cdw_icl_prv);
+ uma_zfree(cfiscsi_data_wait_zone, cdw);
+}
+
static void
cfiscsi_session_terminate_tasks(struct cfiscsi_session *cs)
{
@@ -1106,7 +1151,7 @@ cfiscsi_session_terminate_tasks(struct cfiscsi_session *cs)
*/
cdw->cdw_ctl_io->scsiio.io_hdr.port_status = 42;
cdw->cdw_ctl_io->scsiio.be_move_done(cdw->cdw_ctl_io);
- uma_zfree(cfiscsi_data_wait_zone, cdw);
+ cfiscsi_data_wait_free(cs, cdw);
CFISCSI_SESSION_LOCK(cs);
}
CFISCSI_SESSION_UNLOCK(cs);
@@ -2600,13 +2645,8 @@ cfiscsi_datamove_out(union ctl_io *io)
target_transfer_tag =
atomic_fetchadd_32(&cs->cs_target_transfer_tag, 1);
-
-#if 0
- CFISCSI_SESSION_DEBUG(cs, "expecting Data-Out with initiator "
- "task tag 0x%x, target transfer tag 0x%x",
- bhssc->bhssc_initiator_task_tag, target_transfer_tag);
-#endif
- cdw = uma_zalloc(cfiscsi_data_wait_zone, M_NOWAIT | M_ZERO);
+ cdw = cfiscsi_data_wait_new(cs, io, bhssc->bhssc_initiator_task_tag,
+ &target_transfer_tag);
if (cdw == NULL) {
CFISCSI_SESSION_WARN(cs, "failed to "
"allocate memory; dropping connection");
@@ -2615,6 +2655,12 @@ cfiscsi_datamove_out(union ctl_io *io)
cfiscsi_session_terminate(cs);
return;
}
+#if 0
+ CFISCSI_SESSION_DEBUG(cs, "expecting Data-Out with initiator "
+ "task tag 0x%x, target transfer tag 0x%x",
+ bhssc->bhssc_initiator_task_tag, target_transfer_tag);
+#endif
+
cdw->cdw_ctl_io = io;
cdw->cdw_target_transfer_tag = target_transfer_tag;
cdw->cdw_initiator_task_tag = bhssc->bhssc_initiator_task_tag;
@@ -2651,7 +2697,7 @@ cfiscsi_datamove_out(union ctl_io *io)
icl_pdu_data_segment_length(request)) {
done = cfiscsi_handle_data_segment(request, cdw);
if (done) {
- uma_zfree(cfiscsi_data_wait_zone, cdw);
+ cfiscsi_data_wait_free(cs, cdw);
io->scsiio.be_move_done(io);
return;
}
@@ -2854,7 +2900,7 @@ cfiscsi_task_management_done(union ctl_io *io)
TAILQ_REMOVE(&cs->cs_waiting_for_data_out,
cdw, cdw_next);
cdw->cdw_ctl_io->scsiio.be_move_done(cdw->cdw_ctl_io);
- uma_zfree(cfiscsi_data_wait_zone, cdw);
+ cfiscsi_data_wait_free(cs, cdw);
}
CFISCSI_SESSION_UNLOCK(cs);
}