2007-07-24 15:35:02 +00:00
|
|
|
/*-
|
2012-04-13 18:21:56 +00:00
|
|
|
* Copyright (c) 2005-2011 Daniel Braniss <danny@cs.huji.ac.il>
|
2007-07-24 15:35:02 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/*
|
2010-08-09 12:36:36 +00:00
|
|
|
| $Id: iscsi.c 752 2009-08-20 11:23:28Z danny $
|
2007-07-24 15:35:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
#include "opt_iscsi_initiator.h"
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
2011-08-11 12:30:23 +00:00
|
|
|
#include <sys/capability.h>
|
2007-07-24 15:35:02 +00:00
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/ctype.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/uio.h>
|
|
|
|
#include <sys/socketvar.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/protosw.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/ioccom.h>
|
|
|
|
#include <sys/queue.h>
|
|
|
|
#include <sys/kthread.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <vm/uma.h>
|
2010-08-09 12:36:36 +00:00
|
|
|
#include <sys/sx.h>
|
2007-07-24 15:35:02 +00:00
|
|
|
|
|
|
|
#include <dev/iscsi/initiator/iscsi.h>
|
|
|
|
#include <dev/iscsi/initiator/iscsivar.h>
|
2012-04-13 18:21:56 +00:00
|
|
|
static char *iscsi_driver_version = "2.3.1";
|
2007-07-24 15:35:02 +00:00
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
static struct isc_softc *isc;
|
2007-07-24 15:35:02 +00:00
|
|
|
|
|
|
|
MALLOC_DEFINE(M_ISCSI, "iSCSI", "iSCSI driver");
|
2010-08-09 12:36:36 +00:00
|
|
|
MALLOC_DEFINE(M_ISCSIBUF, "iSCbuf", "iSCSI buffers");
|
2011-11-07 06:44:47 +00:00
|
|
|
static MALLOC_DEFINE(M_TMP, "iSCtmp", "iSCSI tmp");
|
2007-07-24 15:35:02 +00:00
|
|
|
|
|
|
|
#ifdef ISCSI_INITIATOR_DEBUG
|
|
|
|
int iscsi_debug = ISCSI_INITIATOR_DEBUG;
|
|
|
|
SYSCTL_INT(_debug, OID_AUTO, iscsi_initiator, CTLFLAG_RW, &iscsi_debug, 0,
|
|
|
|
"iSCSI driver debug flag");
|
|
|
|
|
|
|
|
struct mtx iscsi_dbg_mtx;
|
|
|
|
#endif
|
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
static int max_sessions = MAX_SESSIONS;
|
|
|
|
SYSCTL_INT(_net, OID_AUTO, iscsi_initiator_max_sessions, CTLFLAG_RDTUN, &max_sessions, MAX_SESSIONS,
|
|
|
|
"Max sessions allowed");
|
|
|
|
static int max_pdus = MAX_PDUS;
|
|
|
|
SYSCTL_INT(_net, OID_AUTO, iscsi_initiator_max_pdus, CTLFLAG_RDTUN, &max_pdus, MAX_PDUS,
|
|
|
|
"Max pdu pool");
|
2007-07-24 15:35:02 +00:00
|
|
|
|
|
|
|
static char isid[6+1] = {
|
|
|
|
0x80,
|
|
|
|
'D',
|
|
|
|
'I',
|
|
|
|
'B',
|
|
|
|
'0',
|
|
|
|
'0',
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
static int i_create_session(struct cdev *dev, int *ndev);
|
|
|
|
|
|
|
|
static int i_ping(struct cdev *dev);
|
|
|
|
static int i_send(struct cdev *dev, caddr_t arg, struct thread *td);
|
|
|
|
static int i_recv(struct cdev *dev, caddr_t arg, struct thread *td);
|
|
|
|
static int i_setsoc(isc_session_t *sp, int fd, struct thread *td);
|
2010-08-09 12:36:36 +00:00
|
|
|
static int i_fullfeature(struct cdev *dev, int flag);
|
2007-07-24 15:35:02 +00:00
|
|
|
|
|
|
|
static d_open_t iscsi_open;
|
|
|
|
static d_close_t iscsi_close;
|
|
|
|
static d_ioctl_t iscsi_ioctl;
|
|
|
|
#ifdef ISCSI_INITIATOR_DEBUG
|
|
|
|
static d_read_t iscsi_read;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static struct cdevsw iscsi_cdevsw = {
|
|
|
|
.d_version = D_VERSION,
|
|
|
|
.d_open = iscsi_open,
|
|
|
|
.d_close = iscsi_close,
|
|
|
|
.d_ioctl = iscsi_ioctl,
|
|
|
|
#ifdef ISCSI_INITIATOR_DEBUG
|
|
|
|
.d_read = iscsi_read,
|
|
|
|
#endif
|
|
|
|
.d_name = "iSCSI",
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
iscsi_open(struct cdev *dev, int flags, int otype, struct thread *td)
|
|
|
|
{
|
|
|
|
debug_called(8);
|
|
|
|
|
2008-09-27 08:51:18 +00:00
|
|
|
debug(7, "dev=%d", dev2unit(dev));
|
2007-07-24 15:35:02 +00:00
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
if(dev2unit(dev) > max_sessions) {
|
2007-07-24 15:35:02 +00:00
|
|
|
// should not happen
|
|
|
|
return ENODEV;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
iscsi_close(struct cdev *dev, int flag, int otyp, struct thread *td)
|
|
|
|
{
|
|
|
|
isc_session_t *sp;
|
|
|
|
|
|
|
|
debug_called(8);
|
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
debug(3, "session=%d flag=%x", dev2unit(dev), flag);
|
2007-07-24 15:35:02 +00:00
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
if(dev2unit(dev) == max_sessions) {
|
2007-07-24 15:35:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2010-08-09 12:36:36 +00:00
|
|
|
sp = dev->si_drv2;
|
2007-07-24 15:35:02 +00:00
|
|
|
if(sp != NULL) {
|
2010-08-09 12:36:36 +00:00
|
|
|
sdebug(3, "sp->flags=%x", sp->flags );
|
2007-07-24 15:35:02 +00:00
|
|
|
/*
|
|
|
|
| if still in full phase, this probably means
|
|
|
|
| that something went realy bad.
|
|
|
|
| it could be a result from 'shutdown', in which case
|
|
|
|
| we will ignore it (so buffers can be flushed).
|
|
|
|
| the problem is that there is no way of differentiating
|
|
|
|
| between a shutdown procedure and 'iscontrol' dying.
|
|
|
|
*/
|
|
|
|
if(sp->flags & ISC_FFPHASE)
|
|
|
|
// delay in case this is a shutdown.
|
|
|
|
tsleep(sp, PRIBIO, "isc-cls", 60*hz);
|
|
|
|
ism_stop(sp);
|
|
|
|
}
|
|
|
|
debug(2, "done");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
iscsi_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int mode, struct thread *td)
|
|
|
|
{
|
2010-08-09 12:36:36 +00:00
|
|
|
struct isc_softc *sc;
|
2007-07-24 15:35:02 +00:00
|
|
|
isc_session_t *sp;
|
|
|
|
isc_opt_t *opt;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
debug_called(8);
|
|
|
|
|
|
|
|
error = 0;
|
2010-08-09 12:36:36 +00:00
|
|
|
if(dev2unit(dev) == max_sessions) {
|
2007-07-24 15:35:02 +00:00
|
|
|
/*
|
|
|
|
| non Session commands
|
|
|
|
*/
|
2010-08-09 12:36:36 +00:00
|
|
|
sc = dev->si_drv1;
|
2007-07-24 15:35:02 +00:00
|
|
|
if(sc == NULL)
|
|
|
|
return ENXIO;
|
|
|
|
|
|
|
|
switch(cmd) {
|
|
|
|
case ISCSISETSES:
|
|
|
|
error = i_create_session(dev, (int *)arg);
|
|
|
|
if(error == 0)
|
2010-08-09 12:36:36 +00:00
|
|
|
break;
|
2007-07-24 15:35:02 +00:00
|
|
|
|
|
|
|
default:
|
2010-08-09 12:36:36 +00:00
|
|
|
error = ENXIO;
|
2007-07-24 15:35:02 +00:00
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
| session commands
|
|
|
|
*/
|
2010-08-09 12:36:36 +00:00
|
|
|
sp = dev->si_drv2;
|
2007-07-24 15:35:02 +00:00
|
|
|
if(sp == NULL)
|
|
|
|
return ENXIO;
|
|
|
|
|
2008-09-27 08:51:18 +00:00
|
|
|
sdebug(6, "dev=%d cmd=%d", dev2unit(dev), (int)(cmd & 0xff));
|
2007-07-24 15:35:02 +00:00
|
|
|
|
|
|
|
switch(cmd) {
|
|
|
|
case ISCSISETSOC:
|
|
|
|
error = i_setsoc(sp, *(u_int *)arg, td);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISCSISETOPT:
|
|
|
|
opt = (isc_opt_t *)arg;
|
|
|
|
error = i_setopt(sp, opt);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISCSISEND:
|
|
|
|
error = i_send(dev, arg, td);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISCSIRECV:
|
|
|
|
error = i_recv(dev, arg, td);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISCSIPING:
|
|
|
|
error = i_ping(dev);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISCSISTART:
|
2010-08-09 12:36:36 +00:00
|
|
|
error = sp->soc == NULL? ENOTCONN: i_fullfeature(dev, 1);
|
2007-07-24 15:35:02 +00:00
|
|
|
if(error == 0) {
|
|
|
|
sp->proc = td->td_proc;
|
2011-01-12 19:53:56 +00:00
|
|
|
SYSCTL_ADD_INT(&sp->clist, SYSCTL_CHILDREN(sp->oid),
|
2012-04-13 18:21:56 +00:00
|
|
|
OID_AUTO, "pid", CTLFLAG_RD,
|
|
|
|
&sp->proc->p_pid, sizeof(pid_t), "control process id");
|
2007-07-24 15:35:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ISCSIRESTART:
|
2010-08-09 12:36:36 +00:00
|
|
|
error = sp->soc == NULL? ENOTCONN: i_fullfeature(dev, 2);
|
2007-07-24 15:35:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ISCSISTOP:
|
2010-08-09 12:36:36 +00:00
|
|
|
error = i_fullfeature(dev, 0);
|
2007-07-24 15:35:02 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ISCSISIGNAL: {
|
|
|
|
int sig = *(int *)arg;
|
|
|
|
|
|
|
|
if(sig < 0 || sig > _SIG_MAXSIG)
|
|
|
|
error = EINVAL;
|
|
|
|
else
|
|
|
|
sp->signal = sig;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case ISCSIGETCAM: {
|
|
|
|
iscsi_cam_t *cp = (iscsi_cam_t *)arg;
|
|
|
|
|
|
|
|
error = ic_getCamVals(sp, cp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
error = ENOIOCTL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
iscsi_read(struct cdev *dev, struct uio *uio, int ioflag)
|
|
|
|
{
|
|
|
|
#ifdef ISCSI_INITIATOR_DEBUG
|
|
|
|
struct isc_softc *sc;
|
|
|
|
isc_session_t *sp;
|
|
|
|
pduq_t *pq;
|
|
|
|
char buf[1024];
|
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
sc = dev->si_drv1;
|
|
|
|
sp = dev->si_drv2;
|
|
|
|
if(dev2unit(dev) == max_sessions) {
|
2007-07-24 15:35:02 +00:00
|
|
|
sprintf(buf, "/----- Session ------/\n");
|
|
|
|
uiomove(buf, strlen(buf), uio);
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
TAILQ_FOREACH(sp, &sc->isc_sess, sp_link) {
|
|
|
|
if(uio->uio_resid == 0)
|
|
|
|
return 0;
|
|
|
|
sprintf(buf, "%03d] '%s' '%s'\n", i++, sp->opt.targetAddress, sp->opt.targetName);
|
|
|
|
uiomove(buf, strlen(buf), uio);
|
|
|
|
}
|
2012-04-13 18:21:56 +00:00
|
|
|
sprintf(buf, "free npdu_alloc=%d, npdu_max=%d\n", sc->npdu_alloc, sc->npdu_max);
|
2008-11-25 07:17:11 +00:00
|
|
|
uiomove(buf, strlen(buf), uio);
|
2007-07-24 15:35:02 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
int i = 0;
|
|
|
|
struct socket *so = sp->soc;
|
|
|
|
#define pukeit(i, pq) do {\
|
2010-08-11 16:56:38 +00:00
|
|
|
sprintf(buf, "%03d] %06x %02x %06x %06x %jd\n",\
|
2010-08-09 12:36:36 +00:00
|
|
|
i, ntohl(pq->pdu.ipdu.bhs.CmdSN),\
|
2007-07-24 15:35:02 +00:00
|
|
|
pq->pdu.ipdu.bhs.opcode, ntohl(pq->pdu.ipdu.bhs.itt),\
|
2010-08-09 12:36:36 +00:00
|
|
|
ntohl(pq->pdu.ipdu.bhs.ExpStSN),\
|
2010-08-11 16:56:38 +00:00
|
|
|
(intmax_t)pq->ts.sec);\
|
2007-07-24 15:35:02 +00:00
|
|
|
} while(0)
|
|
|
|
|
|
|
|
sprintf(buf, "%d/%d /---- hld -----/\n", sp->stats.nhld, sp->stats.max_hld);
|
|
|
|
uiomove(buf, strlen(buf), uio);
|
|
|
|
TAILQ_FOREACH(pq, &sp->hld, pq_link) {
|
|
|
|
if(uio->uio_resid == 0)
|
|
|
|
return 0;
|
|
|
|
pukeit(i, pq); i++;
|
|
|
|
uiomove(buf, strlen(buf), uio);
|
|
|
|
}
|
|
|
|
sprintf(buf, "%d/%d /---- rsp -----/\n", sp->stats.nrsp, sp->stats.max_rsp);
|
|
|
|
uiomove(buf, strlen(buf), uio);
|
|
|
|
i = 0;
|
|
|
|
TAILQ_FOREACH(pq, &sp->rsp, pq_link) {
|
|
|
|
if(uio->uio_resid == 0)
|
|
|
|
return 0;
|
|
|
|
pukeit(i, pq); i++;
|
|
|
|
uiomove(buf, strlen(buf), uio);
|
|
|
|
}
|
|
|
|
sprintf(buf, "%d/%d /---- csnd -----/\n", sp->stats.ncsnd, sp->stats.max_csnd);
|
|
|
|
i = 0;
|
|
|
|
uiomove(buf, strlen(buf), uio);
|
|
|
|
TAILQ_FOREACH(pq, &sp->csnd, pq_link) {
|
|
|
|
if(uio->uio_resid == 0)
|
|
|
|
return 0;
|
|
|
|
pukeit(i, pq); i++;
|
|
|
|
uiomove(buf, strlen(buf), uio);
|
|
|
|
}
|
|
|
|
sprintf(buf, "%d/%d /---- wsnd -----/\n", sp->stats.nwsnd, sp->stats.max_wsnd);
|
|
|
|
i = 0;
|
|
|
|
uiomove(buf, strlen(buf), uio);
|
|
|
|
TAILQ_FOREACH(pq, &sp->wsnd, pq_link) {
|
|
|
|
if(uio->uio_resid == 0)
|
|
|
|
return 0;
|
|
|
|
pukeit(i, pq); i++;
|
|
|
|
uiomove(buf, strlen(buf), uio);
|
|
|
|
}
|
|
|
|
sprintf(buf, "%d/%d /---- isnd -----/\n", sp->stats.nisnd, sp->stats.max_isnd);
|
|
|
|
i = 0;
|
|
|
|
uiomove(buf, strlen(buf), uio);
|
|
|
|
TAILQ_FOREACH(pq, &sp->isnd, pq_link) {
|
|
|
|
if(uio->uio_resid == 0)
|
|
|
|
return 0;
|
|
|
|
pukeit(i, pq); i++;
|
|
|
|
uiomove(buf, strlen(buf), uio);
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(buf, "/---- Stats ---/\n");
|
|
|
|
uiomove(buf, strlen(buf), uio);
|
|
|
|
|
|
|
|
sprintf(buf, "recv=%d sent=%d\n", sp->stats.nrecv, sp->stats.nsent);
|
|
|
|
uiomove(buf, strlen(buf), uio);
|
|
|
|
|
|
|
|
sprintf(buf, "flags=%x pdus: alloc=%d max=%d\n",
|
|
|
|
sp->flags, sc->npdu_alloc, sc->npdu_max);
|
|
|
|
uiomove(buf, strlen(buf), uio);
|
|
|
|
|
|
|
|
sprintf(buf, "cws=%d last cmd=%x exp=%x max=%x stat=%x itt=%x\n",
|
|
|
|
sp->cws, sp->sn.cmd, sp->sn.expCmd, sp->sn.maxCmd, sp->sn.stat, sp->sn.itt);
|
|
|
|
uiomove(buf, strlen(buf), uio);
|
|
|
|
|
|
|
|
sprintf(buf, "/---- socket -----/\nso_count=%d so_state=%x\n", so->so_count, so->so_state);
|
|
|
|
uiomove(buf, strlen(buf), uio);
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
i_ping(struct cdev *dev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
| low level I/O
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
i_setsoc(isc_session_t *sp, int fd, struct thread *td)
|
|
|
|
{
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
if(sp->soc != NULL)
|
|
|
|
isc_stop_receiver(sp);
|
|
|
|
|
2011-08-11 12:30:23 +00:00
|
|
|
error = fget(td, fd, CAP_SOCK_ALL, &sp->fp);
|
2007-07-24 15:35:02 +00:00
|
|
|
if(error)
|
|
|
|
return error;
|
|
|
|
|
2011-08-11 12:30:23 +00:00
|
|
|
if((error = fgetsock(td, fd, CAP_SOCK_ALL, &sp->soc, 0)) == 0) {
|
2007-07-24 15:35:02 +00:00
|
|
|
sp->td = td;
|
|
|
|
isc_start_receiver(sp);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fdrop(sp->fp, td);
|
|
|
|
sp->fp = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
i_send(struct cdev *dev, caddr_t arg, struct thread *td)
|
|
|
|
{
|
2010-08-09 12:36:36 +00:00
|
|
|
isc_session_t *sp = dev->si_drv2;
|
2007-07-24 15:35:02 +00:00
|
|
|
caddr_t bp;
|
|
|
|
pduq_t *pq;
|
|
|
|
pdu_t *pp;
|
|
|
|
int n, error;
|
|
|
|
|
|
|
|
debug_called(8);
|
|
|
|
|
|
|
|
if(sp->soc == NULL)
|
|
|
|
return ENOTCONN;
|
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
if((pq = pdu_alloc(sp->isc, M_NOWAIT)) == NULL)
|
2007-07-24 15:35:02 +00:00
|
|
|
return EAGAIN;
|
|
|
|
pp = &pq->pdu;
|
|
|
|
pq->pdu = *(pdu_t *)arg;
|
|
|
|
if((error = i_prepPDU(sp, pq)) != 0)
|
2008-11-25 07:17:11 +00:00
|
|
|
goto out;
|
2007-07-24 15:35:02 +00:00
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
bp = NULL;
|
|
|
|
if((pq->len - sizeof(union ipdu_u)) > 0) {
|
|
|
|
pq->buf = bp = malloc(pq->len - sizeof(union ipdu_u), M_ISCSIBUF, M_NOWAIT);
|
|
|
|
if(pq->buf == NULL) {
|
|
|
|
error = EAGAIN;
|
|
|
|
goto out;
|
|
|
|
}
|
2008-11-25 07:17:11 +00:00
|
|
|
}
|
2010-08-09 12:36:36 +00:00
|
|
|
else
|
|
|
|
pq->buf = NULL; // just in case?
|
|
|
|
|
|
|
|
sdebug(2, "len=%d ahs_len=%d ds_len=%d buf=%zu@%p",
|
|
|
|
pq->len, pp->ahs_len, pp->ds_len, pq->len - sizeof(union ipdu_u), bp);
|
|
|
|
|
2007-07-24 15:35:02 +00:00
|
|
|
if(pp->ahs_len) {
|
2010-08-09 12:36:36 +00:00
|
|
|
// XXX: never tested, looks suspicious
|
2007-07-24 15:35:02 +00:00
|
|
|
n = pp->ahs_len;
|
2010-08-09 12:36:36 +00:00
|
|
|
error = copyin(pp->ahs_addr, bp, n);
|
2008-11-25 07:17:11 +00:00
|
|
|
if(error != 0) {
|
|
|
|
sdebug(3, "copyin ahs: error=%d", error);
|
|
|
|
goto out;
|
|
|
|
}
|
2010-08-09 12:36:36 +00:00
|
|
|
pp->ahs_addr = (ahs_t *)bp;
|
2007-07-24 15:35:02 +00:00
|
|
|
bp += n;
|
|
|
|
}
|
|
|
|
if(pp->ds_len) {
|
|
|
|
n = pp->ds_len;
|
2010-08-09 12:36:36 +00:00
|
|
|
error = copyin(pp->ds_addr, bp, n);
|
2008-11-25 07:17:11 +00:00
|
|
|
if(error != 0) {
|
|
|
|
sdebug(3, "copyin ds: error=%d", error);
|
|
|
|
goto out;
|
|
|
|
}
|
2010-08-09 12:36:36 +00:00
|
|
|
pp->ds_addr = bp;
|
2007-07-24 15:35:02 +00:00
|
|
|
bp += n;
|
|
|
|
while(n & 03) {
|
|
|
|
n++;
|
|
|
|
*bp++ = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
error = isc_qout(sp, pq);
|
2008-11-25 07:17:11 +00:00
|
|
|
if(error == 0)
|
|
|
|
wakeup(&sp->flags); // XXX: to 'push' proc_out ...
|
|
|
|
out:
|
|
|
|
if(error)
|
2010-08-09 12:36:36 +00:00
|
|
|
pdu_free(sp->isc, pq);
|
2007-07-24 15:35:02 +00:00
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
i_recv(struct cdev *dev, caddr_t arg, struct thread *td)
|
|
|
|
{
|
2010-08-09 12:36:36 +00:00
|
|
|
isc_session_t *sp = dev->si_drv2;
|
2007-07-24 15:35:02 +00:00
|
|
|
pduq_t *pq;
|
|
|
|
pdu_t *pp, *up;
|
|
|
|
caddr_t bp;
|
|
|
|
int error, mustfree, cnt;
|
|
|
|
size_t need, have, n;
|
|
|
|
|
|
|
|
debug_called(8);
|
|
|
|
|
|
|
|
if(sp == NULL)
|
|
|
|
return EIO;
|
|
|
|
|
|
|
|
if(sp->soc == NULL)
|
|
|
|
return ENOTCONN;
|
|
|
|
cnt = 6; // XXX: maybe the user can request a time out?
|
|
|
|
mtx_lock(&sp->rsp_mtx);
|
|
|
|
while((pq = TAILQ_FIRST(&sp->rsp)) == NULL) {
|
|
|
|
msleep(&sp->rsp, &sp->rsp_mtx, PRIBIO, "isc_rsp", hz*10);
|
|
|
|
if(cnt-- == 0) break; // XXX: for now, needs work
|
|
|
|
}
|
|
|
|
if(pq != NULL) {
|
|
|
|
sp->stats.nrsp--;
|
|
|
|
TAILQ_REMOVE(&sp->rsp, pq, pq_link);
|
|
|
|
}
|
|
|
|
mtx_unlock(&sp->rsp_mtx);
|
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
sdebug(6, "cnt=%d", cnt);
|
2007-07-24 15:35:02 +00:00
|
|
|
|
|
|
|
if(pq == NULL) {
|
|
|
|
error = ENOTCONN;
|
|
|
|
sdebug(3, "error=%d sp->flags=%x ", error, sp->flags);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
up = (pdu_t *)arg;
|
|
|
|
pp = &pq->pdu;
|
|
|
|
up->ipdu = pp->ipdu;
|
|
|
|
n = 0;
|
|
|
|
up->ds_len = 0;
|
|
|
|
up->ahs_len = 0;
|
|
|
|
error = 0;
|
|
|
|
|
|
|
|
if(pq->mp) {
|
|
|
|
u_int len;
|
|
|
|
|
|
|
|
// Grr...
|
|
|
|
len = 0;
|
|
|
|
if(pp->ahs_len) {
|
|
|
|
len += pp->ahs_len;
|
|
|
|
}
|
|
|
|
if(pp->ds_len) {
|
|
|
|
len += pp->ds_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
mustfree = 0;
|
|
|
|
if(len > pq->mp->m_len) {
|
|
|
|
mustfree++;
|
2010-08-09 12:36:36 +00:00
|
|
|
bp = malloc(len, M_TMP, M_WAITOK);
|
2007-07-24 15:35:02 +00:00
|
|
|
sdebug(4, "need mbufcopy: %d", len);
|
|
|
|
i_mbufcopy(pq->mp, bp, len);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bp = mtod(pq->mp, caddr_t);
|
|
|
|
|
|
|
|
if(pp->ahs_len) {
|
|
|
|
need = pp->ahs_len;
|
|
|
|
n = MIN(up->ahs_size, need);
|
2010-08-09 12:36:36 +00:00
|
|
|
error = copyout(bp, (caddr_t)up->ahs_addr, n);
|
2007-07-24 15:35:02 +00:00
|
|
|
up->ahs_len = n;
|
|
|
|
bp += need;
|
|
|
|
}
|
|
|
|
if(!error && pp->ds_len) {
|
|
|
|
need = pp->ds_len;
|
|
|
|
if((have = up->ds_size) == 0) {
|
|
|
|
have = up->ahs_size - n;
|
2010-08-09 12:36:36 +00:00
|
|
|
up->ds_addr = (caddr_t)up->ahs_addr + n;
|
2007-07-24 15:35:02 +00:00
|
|
|
}
|
|
|
|
n = MIN(have, need);
|
2010-08-09 12:36:36 +00:00
|
|
|
error = copyout(bp, (caddr_t)up->ds_addr, n);
|
2007-07-24 15:35:02 +00:00
|
|
|
up->ds_len = n;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(mustfree)
|
2010-08-09 12:36:36 +00:00
|
|
|
free(bp, M_TMP);
|
2007-07-24 15:35:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sdebug(6, "len=%d ahs_len=%d ds_len=%d", pq->len, pp->ahs_len, pp->ds_len);
|
|
|
|
|
|
|
|
pdu_free(sp->isc, pq);
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
static int
|
|
|
|
i_fullfeature(struct cdev *dev, int flag)
|
|
|
|
{
|
|
|
|
isc_session_t *sp = dev->si_drv2;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
sdebug(2, "flag=%d", flag);
|
|
|
|
|
|
|
|
error = 0;
|
|
|
|
switch(flag) {
|
|
|
|
case 0: // stop
|
|
|
|
sp->flags &= ~ISC_FFPHASE;
|
|
|
|
break;
|
|
|
|
case 1: // start
|
|
|
|
sp->flags |= ISC_FFPHASE;
|
|
|
|
error = ic_init(sp);
|
|
|
|
break;
|
|
|
|
case 2: // restart
|
|
|
|
sp->flags |= ISC_FFPHASE;
|
|
|
|
ism_restart(sp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2007-07-24 15:35:02 +00:00
|
|
|
static int
|
|
|
|
i_create_session(struct cdev *dev, int *ndev)
|
|
|
|
{
|
2010-08-09 12:36:36 +00:00
|
|
|
struct isc_softc *sc = dev->si_drv1;
|
2007-07-24 15:35:02 +00:00
|
|
|
isc_session_t *sp;
|
|
|
|
int error, n;
|
|
|
|
|
|
|
|
debug_called(8);
|
2010-08-09 12:36:36 +00:00
|
|
|
|
|
|
|
sp = malloc(sizeof(isc_session_t), M_ISCSI, M_WAITOK | M_ZERO);
|
2007-07-24 15:35:02 +00:00
|
|
|
if(sp == NULL)
|
|
|
|
return ENOMEM;
|
2010-08-09 12:36:36 +00:00
|
|
|
|
|
|
|
sx_xlock(&sc->unit_sx);
|
|
|
|
if((n = alloc_unr(sc->unit)) < 0) {
|
|
|
|
sx_unlock(&sc->unit_sx);
|
2007-07-24 15:35:02 +00:00
|
|
|
free(sp, M_ISCSI);
|
2010-08-09 12:36:36 +00:00
|
|
|
xdebug("too many sessions!");
|
2007-07-24 15:35:02 +00:00
|
|
|
return EPERM;
|
|
|
|
}
|
2010-08-09 12:36:36 +00:00
|
|
|
sx_unlock(&sc->unit_sx);
|
|
|
|
|
|
|
|
mtx_lock(&sc->isc_mtx);
|
2007-07-24 15:35:02 +00:00
|
|
|
TAILQ_INSERT_TAIL(&sc->isc_sess, sp, sp_link);
|
2010-08-09 12:36:36 +00:00
|
|
|
isc->nsess++;
|
|
|
|
mtx_unlock(&sc->isc_mtx);
|
2007-07-24 15:35:02 +00:00
|
|
|
|
|
|
|
sp->dev = make_dev(&iscsi_cdevsw, n, UID_ROOT, GID_WHEEL, 0600, "iscsi%d", n);
|
|
|
|
*ndev = sp->sid = n;
|
|
|
|
sp->isc = sc;
|
|
|
|
sp->dev->si_drv1 = sc;
|
|
|
|
sp->dev->si_drv2 = sp;
|
|
|
|
|
|
|
|
sp->opt.maxRecvDataSegmentLength = 8192;
|
|
|
|
sp->opt.maxXmitDataSegmentLength = 8192;
|
|
|
|
sp->opt.maxBurstLength = 65536; // 64k
|
2010-08-09 12:36:36 +00:00
|
|
|
sp->opt.maxluns = ISCSI_MAX_LUNS;
|
2007-07-24 15:35:02 +00:00
|
|
|
|
|
|
|
error = ism_start(sp);
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef notused
|
|
|
|
static void
|
|
|
|
iscsi_counters(isc_session_t *sp)
|
|
|
|
{
|
|
|
|
int h, r, s;
|
|
|
|
pduq_t *pq;
|
|
|
|
|
|
|
|
#define _puke(i, pq) do {\
|
|
|
|
debug(2, "%03d] %06x %02x %x %ld %jd %x\n",\
|
|
|
|
i, ntohl( pq->pdu.ipdu.bhs.CmdSN), \
|
|
|
|
pq->pdu.ipdu.bhs.opcode, ntohl(pq->pdu.ipdu.bhs.itt),\
|
|
|
|
(long)pq->ts.sec, pq->ts.frac, pq->flags);\
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
h = r = s = 0;
|
|
|
|
TAILQ_FOREACH(pq, &sp->hld, pq_link) {
|
|
|
|
_puke(h, pq);
|
|
|
|
h++;
|
|
|
|
}
|
|
|
|
TAILQ_FOREACH(pq, &sp->rsp, pq_link) r++;
|
|
|
|
TAILQ_FOREACH(pq, &sp->csnd, pq_link) s++;
|
|
|
|
TAILQ_FOREACH(pq, &sp->wsnd, pq_link) s++;
|
|
|
|
TAILQ_FOREACH(pq, &sp->isnd, pq_link) s++;
|
|
|
|
debug(2, "hld=%d rsp=%d snd=%d", h, r, s);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static void
|
|
|
|
iscsi_shutdown(void *v)
|
|
|
|
{
|
2010-08-09 12:36:36 +00:00
|
|
|
struct isc_softc *sc = v;
|
2007-07-24 15:35:02 +00:00
|
|
|
isc_session_t *sp;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
debug_called(8);
|
|
|
|
if(sc == NULL) {
|
|
|
|
xdebug("sc is NULL!");
|
|
|
|
return;
|
|
|
|
}
|
2010-08-09 12:36:36 +00:00
|
|
|
#ifdef DO_EVENTHANDLER
|
2007-07-24 15:35:02 +00:00
|
|
|
if(sc->eh == NULL)
|
2008-11-25 07:17:11 +00:00
|
|
|
debug(2, "sc->eh is NULL");
|
2007-07-24 15:35:02 +00:00
|
|
|
else {
|
|
|
|
EVENTHANDLER_DEREGISTER(shutdown_pre_sync, sc->eh);
|
|
|
|
debug(2, "done n=%d", sc->nsess);
|
|
|
|
}
|
2010-08-09 12:36:36 +00:00
|
|
|
#endif
|
2007-07-24 15:35:02 +00:00
|
|
|
n = 0;
|
|
|
|
TAILQ_FOREACH(sp, &sc->isc_sess, sp_link) {
|
|
|
|
debug(2, "%2d] sp->flags=0x%08x", n, sp->flags);
|
|
|
|
n++;
|
|
|
|
}
|
2008-11-25 07:17:11 +00:00
|
|
|
debug(2, "done");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
free_pdus(struct isc_softc *sc)
|
|
|
|
{
|
|
|
|
debug_called(8);
|
|
|
|
|
|
|
|
if(sc->pdu_zone != NULL) {
|
|
|
|
uma_zdestroy(sc->pdu_zone);
|
|
|
|
sc->pdu_zone = NULL;
|
|
|
|
}
|
2007-07-24 15:35:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
iscsi_start(void)
|
|
|
|
{
|
|
|
|
debug_called(8);
|
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
TUNABLE_INT_FETCH("net.iscsi_initiator.max_sessions", &max_sessions);
|
|
|
|
TUNABLE_INT_FETCH("net.iscsi_initiator.max_pdus", &max_pdus);
|
2007-07-24 15:35:02 +00:00
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
isc = malloc(sizeof(struct isc_softc), M_ISCSI, M_ZERO|M_WAITOK);
|
|
|
|
isc->dev = make_dev(&iscsi_cdevsw, max_sessions, UID_ROOT, GID_WHEEL, 0600, "iscsi");
|
|
|
|
isc->dev->si_drv1 = isc;
|
|
|
|
mtx_init(&isc->isc_mtx, "iscsi", NULL, MTX_DEF);
|
2007-07-24 15:35:02 +00:00
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
TAILQ_INIT(&isc->isc_sess);
|
|
|
|
/*
|
|
|
|
| now init the free pdu list
|
|
|
|
*/
|
|
|
|
isc->pdu_zone = uma_zcreate("pdu", sizeof(pduq_t),
|
|
|
|
NULL, NULL, NULL, NULL,
|
|
|
|
0, 0);
|
|
|
|
if(isc->pdu_zone == NULL) {
|
|
|
|
xdebug("iscsi_initiator: uma_zcreate failed");
|
|
|
|
// XXX: should fail...
|
|
|
|
}
|
|
|
|
uma_zone_set_max(isc->pdu_zone, max_pdus);
|
|
|
|
isc->unit = new_unrhdr(0, max_sessions-1, NULL);
|
|
|
|
sx_init(&isc->unit_sx, "iscsi sx");
|
2008-11-25 07:17:11 +00:00
|
|
|
|
|
|
|
#ifdef DO_EVENTHANDLER
|
2010-08-09 12:36:36 +00:00
|
|
|
if((isc->eh = EVENTHANDLER_REGISTER(shutdown_pre_sync, iscsi_shutdown,
|
2007-07-24 15:35:02 +00:00
|
|
|
sc, SHUTDOWN_PRI_DEFAULT-1)) == NULL)
|
|
|
|
xdebug("shutdown event registration failed\n");
|
2008-11-25 07:17:11 +00:00
|
|
|
#endif
|
2007-07-24 15:35:02 +00:00
|
|
|
/*
|
|
|
|
| sysctl stuff
|
|
|
|
*/
|
2010-08-09 12:36:36 +00:00
|
|
|
sysctl_ctx_init(&isc->clist);
|
|
|
|
isc->oid = SYSCTL_ADD_NODE(&isc->clist,
|
2007-07-24 15:35:02 +00:00
|
|
|
SYSCTL_STATIC_CHILDREN(_net),
|
|
|
|
OID_AUTO,
|
2010-08-09 12:36:36 +00:00
|
|
|
"iscsi_initiator",
|
2007-07-24 15:35:02 +00:00
|
|
|
CTLFLAG_RD,
|
|
|
|
0,
|
|
|
|
"iSCSI Subsystem");
|
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
SYSCTL_ADD_STRING(&isc->clist,
|
|
|
|
SYSCTL_CHILDREN(isc->oid),
|
2007-07-24 15:35:02 +00:00
|
|
|
OID_AUTO,
|
|
|
|
"driver_version",
|
|
|
|
CTLFLAG_RD,
|
|
|
|
iscsi_driver_version,
|
|
|
|
0,
|
|
|
|
"iscsi driver version");
|
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
SYSCTL_ADD_STRING(&isc->clist,
|
|
|
|
SYSCTL_CHILDREN(isc->oid),
|
2007-07-24 15:35:02 +00:00
|
|
|
OID_AUTO,
|
|
|
|
"isid",
|
|
|
|
CTLFLAG_RW,
|
|
|
|
isid,
|
|
|
|
6+1,
|
|
|
|
"initiator part of the Session Identifier");
|
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
SYSCTL_ADD_INT(&isc->clist,
|
|
|
|
SYSCTL_CHILDREN(isc->oid),
|
2007-07-24 15:35:02 +00:00
|
|
|
OID_AUTO,
|
|
|
|
"sessions",
|
|
|
|
CTLFLAG_RD,
|
2010-08-09 12:36:36 +00:00
|
|
|
&isc->nsess,
|
|
|
|
sizeof(isc->nsess),
|
2007-07-24 15:35:02 +00:00
|
|
|
"number of active session");
|
2008-11-25 07:17:11 +00:00
|
|
|
|
2012-04-13 18:21:56 +00:00
|
|
|
#ifdef ISCSI_INITIATOR_DEBUG
|
|
|
|
mtx_init(&iscsi_dbg_mtx, "iscsi_dbg", NULL, MTX_DEF);
|
|
|
|
#endif
|
|
|
|
|
2008-11-25 07:17:11 +00:00
|
|
|
printf("iscsi: version %s\n", iscsi_driver_version);
|
2007-07-24 15:35:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
| Notes:
|
|
|
|
| unload SHOULD fail if there is activity
|
|
|
|
| activity: there is/are active session/s
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
iscsi_stop(void)
|
|
|
|
{
|
|
|
|
isc_session_t *sp, *sp_tmp;
|
|
|
|
|
|
|
|
debug_called(8);
|
|
|
|
|
|
|
|
/*
|
|
|
|
| go through all the sessions
|
|
|
|
| Note: close should have done this ...
|
|
|
|
*/
|
2010-08-09 12:36:36 +00:00
|
|
|
TAILQ_FOREACH_SAFE(sp, &isc->isc_sess, sp_link, sp_tmp) {
|
2007-07-24 15:35:02 +00:00
|
|
|
//XXX: check for activity ...
|
|
|
|
ism_stop(sp);
|
2010-08-09 12:36:36 +00:00
|
|
|
if(sp->cam_sim != NULL)
|
|
|
|
ic_destroy(sp);
|
2007-07-24 15:35:02 +00:00
|
|
|
}
|
2010-08-09 12:36:36 +00:00
|
|
|
mtx_destroy(&isc->isc_mtx);
|
|
|
|
sx_destroy(&isc->unit_sx);
|
2007-07-24 15:35:02 +00:00
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
free_pdus(isc);
|
2007-07-24 15:35:02 +00:00
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
if(isc->dev)
|
|
|
|
destroy_dev(isc->dev);
|
2007-07-24 15:35:02 +00:00
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
if(sysctl_ctx_free(&isc->clist))
|
2007-07-24 15:35:02 +00:00
|
|
|
xdebug("sysctl_ctx_free failed");
|
2008-11-25 07:17:11 +00:00
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
iscsi_shutdown(isc); // XXX: check EVENTHANDLER_ ...
|
2012-04-13 18:21:56 +00:00
|
|
|
|
|
|
|
#ifdef ISCSI_INITIATOR_DEBUG
|
|
|
|
mtx_destroy(&iscsi_dbg_mtx);
|
|
|
|
#endif
|
|
|
|
|
2010-08-09 12:36:36 +00:00
|
|
|
free(isc, M_ISCSI);
|
2007-07-24 15:35:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
iscsi_modevent(module_t mod, int what, void *arg)
|
|
|
|
{
|
|
|
|
debug_called(8);
|
|
|
|
|
|
|
|
switch(what) {
|
|
|
|
case MOD_LOAD:
|
|
|
|
iscsi_start();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MOD_QUIESCE:
|
2010-08-09 12:36:36 +00:00
|
|
|
if(isc->nsess) {
|
|
|
|
xdebug("iscsi module busy(nsess=%d), cannot unload", isc->nsess);
|
2007-07-24 15:35:02 +00:00
|
|
|
log(LOG_ERR, "iscsi module busy, cannot unload");
|
|
|
|
}
|
2010-08-09 12:36:36 +00:00
|
|
|
return isc->nsess;
|
|
|
|
|
2007-07-24 15:35:02 +00:00
|
|
|
case MOD_SHUTDOWN:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MOD_UNLOAD:
|
|
|
|
iscsi_stop();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2008-11-25 07:17:11 +00:00
|
|
|
|
2007-07-24 15:35:02 +00:00
|
|
|
moduledata_t iscsi_mod = {
|
2012-10-10 08:36:38 +00:00
|
|
|
"iscsi",
|
|
|
|
(modeventhand_t) iscsi_modevent,
|
|
|
|
0
|
2007-07-24 15:35:02 +00:00
|
|
|
};
|
|
|
|
|
2008-11-25 07:17:11 +00:00
|
|
|
#ifdef ISCSI_ROOT
|
|
|
|
static void
|
|
|
|
iscsi_rootconf(void)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
nfs_setup_diskless();
|
|
|
|
if (nfs_diskless_valid)
|
|
|
|
rootdevnames[0] = "nfs:";
|
|
|
|
#endif
|
|
|
|
printf("** iscsi_rootconf **\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
SYSINIT(cpu_rootconf1, SI_SUB_ROOT_CONF, SI_ORDER_FIRST, iscsi_rootconf, NULL)
|
|
|
|
#endif
|
|
|
|
|
2007-07-24 15:35:02 +00:00
|
|
|
DECLARE_MODULE(iscsi, iscsi_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
|
2008-04-20 15:56:59 +00:00
|
|
|
MODULE_DEPEND(iscsi, cam, 1, 1, 1);
|