Module Name: othersrc Committed By: riz Date: Tue Jun 7 23:47:51 UTC 2011
Modified Files: othersrc/external/bsd/iscsi/sys/dev/iscsi: files.iscsi iscsi_globals.h iscsi_ioctl.c iscsi_main.c iscsi_send.c iscsi_text.c iscsi_utils.c Added Files: othersrc/external/bsd/iscsi/sys/modules/iscsi: Makefile Removed Files: othersrc/external/bsd/iscsi/sys/lkm/dev/iscsi: Makefile iscsi_lkm.c iscsi_post.sh Log Message: Update in-kernel initiator so it builds on -current as a module. XXX there is an spl bug which causes it to crash when DIAGNOSTIC which needs to be fixed, though on a non-DIAGNOSTIC kernel I can mount a volume from a local target and read files successfully under -current. Lots of code cleanup is needed before moving into src, but this is a step. To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r1.2 \ othersrc/external/bsd/iscsi/sys/dev/iscsi/files.iscsi \ othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_globals.h \ othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_ioctl.c \ othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_main.c \ othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_send.c \ othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_text.c \ othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_utils.c cvs rdiff -u -r1.1.1.1 -r0 \ othersrc/external/bsd/iscsi/sys/lkm/dev/iscsi/Makefile \ othersrc/external/bsd/iscsi/sys/lkm/dev/iscsi/iscsi_lkm.c \ othersrc/external/bsd/iscsi/sys/lkm/dev/iscsi/iscsi_post.sh cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/iscsi/sys/modules/iscsi/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: othersrc/external/bsd/iscsi/sys/dev/iscsi/files.iscsi diff -u othersrc/external/bsd/iscsi/sys/dev/iscsi/files.iscsi:1.1.1.1 othersrc/external/bsd/iscsi/sys/dev/iscsi/files.iscsi:1.2 --- othersrc/external/bsd/iscsi/sys/dev/iscsi/files.iscsi:1.1.1.1 Mon May 2 07:01:09 2011 +++ othersrc/external/bsd/iscsi/sys/dev/iscsi/files.iscsi Tue Jun 7 23:47:51 2011 @@ -1,8 +1,8 @@ -# $NetBSD: files.iscsi,v 1.1.1.1 2011/05/02 07:01:09 agc Exp $ +# $NetBSD: files.iscsi,v 1.2 2011/06/07 23:47:51 riz Exp $ # # Configuration file for iSCSI initiator -defpseudo iscsi : scsi +defpseudodev iscsi : scsi defflag ISCSI_DEBUG defflag ISCSI_PERFTEST Index: othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_globals.h diff -u othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_globals.h:1.1.1.1 othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_globals.h:1.2 --- othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_globals.h:1.1.1.1 Mon May 2 07:01:10 2011 +++ othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_globals.h Tue Jun 7 23:47:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsi_globals.h,v 1.1.1.1 2011/05/02 07:01:10 agc Exp $ */ +/* $NetBSD: iscsi_globals.h,v 1.2 2011/06/07 23:47:51 riz Exp $ */ /*- * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc. @@ -380,8 +380,8 @@ session_t *session; /* back pointer to the owning session */ - struct proc *rcvproc; /* receive thread */ - struct proc *sendproc; /* send thread */ + struct lwp *rcvproc; /* receive thread */ + struct lwp *sendproc; /* send thread */ uint32_t terminating; /* if closing down: status */ @@ -546,7 +546,7 @@ connection_list_t cleanup_list; /* connections to clean up */ boolean_t detaching; /* signal to cleanup thread it should exit */ -struct proc *cleanproc; /* pointer to cleanup proc */ +struct lwp *cleanproc; /* pointer to cleanup proc */ uint32_t num_send_threads; /* the number of active send threads */ Index: othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_ioctl.c diff -u othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_ioctl.c:1.1.1.1 othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_ioctl.c:1.2 --- othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_ioctl.c:1.1.1.1 Mon May 2 07:01:10 2011 +++ othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_ioctl.c Tue Jun 7 23:47:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsi_ioctl.c,v 1.1.1.1 2011/05/02 07:01:10 agc Exp $ */ +/* $NetBSD: iscsi_ioctl.c,v 1.2 2011/06/07 23:47:51 riz Exp $ */ /*- * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc. @@ -305,7 +305,6 @@ * Get the file pointer from the socket handle passed into login. * * Parameter: - * p IN: The proc pointer of the owner * fdes IN: The socket handle * fpp OUT: The pointer to the resulting file pointer * @@ -314,11 +313,11 @@ */ STATIC int -get_socket(struct proc *p, int fdes, struct file **fpp) +get_socket(int fdes, struct file **fpp) { struct file *fp; - if ((fp = fd_getfile(p->p_fd, fdes)) == NULL) { + if ((fp = fd_getfile(fdes)) == NULL) { return EBADF; } if (fp->f_type != DTYPE_SOCKET) { @@ -612,28 +611,29 @@ TAILQ_INIT(&connection->pdus_to_send); TAILQ_INIT(&connection->pdu_pool); - callout_init(&connection->timeout); + callout_init(&connection->timeout, 0); callout_setfunc(&connection->timeout, connection_timeout, connection); connection->idle_timeout_val = CONNECTION_IDLE_TIMEOUT; create_pdus(connection); - if ((rc = get_socket(PROCP(p), par->socket, &connection->sock)) != 0) { + if ((rc = get_socket(par->socket, &connection->sock)) != 0) { DEBOUT(("Invalid socket %d\n", par->socket)); free(connection, M_DEVBUF); par->status = ISCSI_STATUS_INVALID_SOCKET; return rc; } - DEBC(connection, 1, ("get_socket: procp=%x, par_sock=%d, fdesc=%x\n", - (int)PROCP(p), par->socket, (int)connection->sock)); + DEBC(connection, 1, ("get_socket: par_sock=%d, fdesc=%x\n", + par->socket, (int)connection->sock)); connection->threadobj = p; connection->login_par = par; /*DEBOUT (("Creating receive thread\n")); */ - if ((rc = kthread_create1(iscsi_rcv_thread, connection, - &connection->rcvproc, "ConnRcv")) != 0) { + if ((rc = kthread_create(PRI_NONE, 0, NULL, iscsi_rcv_thread, + connection, &connection->rcvproc, + "ConnRcv")) != 0) { DEBOUT(("Can't create rcv thread (rc %d)\n", rc)); free(connection, M_DEVBUF); @@ -641,8 +641,9 @@ return rc; } /*DEBOUT (("Creating send thread\n")); */ - if ((rc = kthread_create1(iscsi_send_thread, connection, - &connection->sendproc, "ConnSend")) != 0) { + if ((rc = kthread_create(PRI_NONE, 0, NULL, iscsi_send_thread, + connection, &connection->sendproc, + "ConnSend")) != 0) { DEBOUT(("Can't create send thread (rc %d)\n", rc)); connection->terminating = TRUE; @@ -654,13 +655,13 @@ DEBC(connection, 1, ("Closing Socket %x\n", (int)connection->sock)); #if __NetBSD_Version__ > 500000000 - mutex_enter(&connection->sock->f_slock); + mutex_enter(&connection->sock->f_lock); connection->sock->f_count += 1; - mutex_exit(&connection->sock->f_slock); + mutex_exit(&connection->sock->f_lock); #else FILE_USE(connection->sock); #endif - closef(connection->sock, p); + closef(connection->sock); /* give receive thread time to exit */ tsleep(connection, PWAIT, "settle", 20); @@ -737,7 +738,7 @@ return EIO; } - if ((rc = get_socket(PROCP(p), par->socket, &connection->sock)) != 0) { + if ((rc = get_socket(par->socket, &connection->sock)) != 0) { DEBOUT(("Invalid socket %d\n", par->socket)); par->status = ISCSI_STATUS_INVALID_SOCKET; return rc; @@ -844,11 +845,13 @@ } for (i = 0, n = 0; i < par->auth_info.auth_number; i++) { +#if 0 if (par->auth_info.auth_type[i] < ISCSI_AUTH_None) { DEBOUT(("Auth type invalid: %d\n", par->auth_info.auth_type[i])); return ISCSI_STATUS_PARAMETER_INVALID; } +#endif if (par->auth_info.auth_type[i] > ISCSI_AUTH_CHAP) { DEBOUT(("Auth type invalid: %d\n", par->auth_info.auth_type[i])); @@ -1115,7 +1118,7 @@ datalen = (datalen + offs + PAGE_MASK) & ~PAGE_MASK; /* Do some magic to the vm space reference count (copied from "copyin_proc") */ - if ((p->p_flag & P_WEXIT) || (p->p_vmspace->vm_refcnt < 1)) { + if ((p->p_sflag & PS_WEXIT) || (p->p_vmspace->vm_refcnt < 1)) { return ISCSI_STATUS_NO_RESOURCES; } p->p_vmspace->vm_refcnt++; Index: othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_main.c diff -u othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_main.c:1.1.1.1 othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_main.c:1.2 --- othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_main.c:1.1.1.1 Mon May 2 07:01:11 2011 +++ othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_main.c Tue Jun 7 23:47:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsi_main.c,v 1.1.1.1 2011/05/02 07:01:11 agc Exp $ */ +/* $netBSD: iscsi_main.c,v 1.1.1.1 2011/05/02 07:01:11 agc Exp $ */ /*- * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc. @@ -54,7 +54,7 @@ /* connections to clean up */ connection_list_t cleanup_list = TAILQ_HEAD_INITIALIZER(cleanup_list); boolean_t detaching = FALSE; -struct proc *cleanproc = NULL; +struct lwp *cleanproc = NULL; /* the number of active send threads (for cleanup thread) */ uint32_t num_send_threads = 0; @@ -84,8 +84,8 @@ struct cdevsw iscsi_cdevsw = { iscsiopen, iscsiclose, - 0, 0, - iscsiioctl, 0 + noread, nowrite, + iscsiioctl, nostop, notty, nopoll, nommap, nokqfilter, D_OTHER }; /******************************************************************************/ @@ -133,19 +133,6 @@ return 1; } -/* - * Create cleanup thread (delayed) - */ - -static void -iscsi_thread_create(void *par) -{ - if (kthread_create1(iscsi_cleanup_thread, NULL, &cleanproc, - "Cleanup") != 0) { - panic("Can't create cleanup thread!"); - } -} - /* * iscsiattach: @@ -161,7 +148,10 @@ (int) self, (int) aux)); sc = (iscsi_softc_t *) self; dev = &sc->sc_dev; - kthread_create(iscsi_thread_create, NULL); + if (kthread_create(PRI_NONE, 0, NULL, iscsi_cleanup_thread, + NULL, &cleanproc, "Cleanup") != 0) { + panic("Can't create cleanup thread!"); + } } /* @@ -207,7 +197,7 @@ { "Unknown", 7, "unknown", 7, 0 }, - { NULL, 0, 0 } + { NULL, 0, NULL, 0, 0 } }; /* loop through the quirktab looking for a match on target name */ @@ -451,3 +441,87 @@ free_ccb(ccb); } + +/* Kernel Module support */ +#ifdef _MODULE + +#include <sys/module.h> + +MODULE(MODULE_CLASS_DRIVER, iscsi, NULL); +static const struct cfiattrdata ibescsi_info = { "scsi", 1, + {{"channel", "-1", -1},} +}; +static const struct cfiattrdata *const iscsi_attrs[] = { &ibescsi_info, NULL }; + +CFDRIVER_DECL(iscsi, DV_DULL, iscsi_attrs); + +static struct cfdata iscsi_cfdata = { + .cf_name = "iscsi", + .cf_atname = "iscsi", + .cf_unit = 0, /* Only unit 0 is ever used */ + .cf_fstate = FSTATE_NOTFOUND, + .cf_loc = NULL, + .cf_flags = 0, + .cf_pspec = NULL, +}; + +static int +iscsi_modcmd(modcmd_t cmd, void *arg) +{ + devmajor_t cmajor = NODEVMAJOR, bmajor = NODEVMAJOR; + int error; + + switch (cmd) { + case MODULE_CMD_INIT: + error = config_cfdriver_attach(&iscsi_cd); + if (error) { + return error; + } + + error = config_cfattach_attach(iscsi_cd.cd_name, &iscsi_ca); + if (error) { + config_cfdriver_detach(&iscsi_cd); + aprint_error("%s: unable to register cfattach\n", + iscsi_cd.cd_name); + return error; + } + + error = devsw_attach(iscsi_cd.cd_name, NULL, &bmajor, + &iscsi_cdevsw, &cmajor); + if (error) { + config_cfattach_detach(iscsi_cd.cd_name, &iscsi_ca); + config_cfdriver_detach(&iscsi_cd); + aprint_error("%s: unable to register devsw\n", + iscsi_cd.cd_name); + return error; + } + + if (config_attach_pseudo(&iscsi_cfdata) == NULL) { + aprint_error("%s: config_attach_pseudo failed\n", + iscsi_cd.cd_name); + config_cfattach_detach(iscsi_cd.cd_name, &iscsi_ca); + config_cfdriver_detach(&iscsi_cd); + return ENXIO; + } + + return 0; + break; + + case MODULE_CMD_FINI: + error = config_cfdata_detach(&iscsi_cfdata); + if (error) + return error; + + config_cfattach_detach(iscsi_cd.cd_name, &iscsi_ca); + config_cfdriver_detach(&iscsi_cd); + devsw_detach(NULL, &iscsi_cdevsw); + + return 0; + break; + + default: + return ENOTTY; + break; + } +} +#endif /* _MODULE */ Index: othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_send.c diff -u othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_send.c:1.1.1.1 othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_send.c:1.2 --- othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_send.c:1.1.1.1 Mon May 2 07:01:12 2011 +++ othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_send.c Tue Jun 7 23:47:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsi_send.c,v 1.1.1.1 2011/05/02 07:01:12 agc Exp $ */ +/* $NetBSD: iscsi_send.c,v 1.2 2011/06/07 23:47:51 riz Exp $ */ /*- * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc. @@ -346,17 +346,20 @@ * We must close the socket here to force the receive * thread to wake up */ + solock((struct socket *) fp->f_data); soshutdown((struct socket *) fp->f_data, SHUT_RDWR); + sounlock((struct socket *) fp->f_data); #if __NetBSD_Version__ > 500000000 - mutex_enter(&fp->f_slock); + mutex_enter(&fp->f_lock); fp->f_count += 1; - mutex_exit(&fp->f_slock); + mutex_exit(&fp->f_lock); + closef(fp); #else simple_lock(&fp->f_slock); FILE_USE(fp); -#endif closef(fp, NULL); +#endif /* wake up any non-reassignable waiting CCBs */ for (ccb = TAILQ_FIRST(&conn->ccbs_waiting); ccb != NULL; ccb = nccb) { Index: othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_text.c diff -u othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_text.c:1.1.1.1 othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_text.c:1.2 --- othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_text.c:1.1.1.1 Mon May 2 07:01:14 2011 +++ othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_text.c Tue Jun 7 23:47:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsi_text.c,v 1.1.1.1 2011/05/02 07:01:14 agc Exp $ */ +/* $NetBSD: iscsi_text.c,v 1.2 2011/06/07 23:47:51 riz Exp $ */ /*- * Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc. @@ -131,7 +131,7 @@ typedef struct { - uint8_t *name; /* the key name */ + const uint8_t *name; /* the key name */ val_kind_t val; /* the value type */ uint32_t defval; /* default value */ } key_entry_t; @@ -607,7 +607,7 @@ */ static __inline unsigned -my_strcpy(uint8_t *dest, uint8_t *src) +my_strcpy(uint8_t *dest, const uint8_t *src) { unsigned cc; @@ -635,7 +635,7 @@ { int i; unsigned cc; - uint8_t *sp; + const uint8_t *sp; if (par->key > MAX_KEY) { return snprintf(buf, len, "%s=NotUnderstood", par->val.sval); Index: othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_utils.c diff -u othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_utils.c:1.1.1.1 othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_utils.c:1.2 --- othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_utils.c:1.1.1.1 Mon May 2 07:01:15 2011 +++ othersrc/external/bsd/iscsi/sys/dev/iscsi/iscsi_utils.c Tue Jun 7 23:47:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsi_utils.c,v 1.1.1.1 2011/05/02 07:01:15 agc Exp $ */ +/* $NetBSD: iscsi_utils.c,v 1.2 2011/06/07 23:47:51 riz Exp $ */ /*- * Copyright (c) 2004,2005,2006,2008 The NetBSD Foundation, Inc. @@ -304,7 +304,7 @@ ccb->ITT = i | sid; ccb->session = sess; - callout_init(&ccb->timeout); + callout_init(&ccb->timeout, 0); #if (__NetBSD_Version__ >= 106000000) callout_setfunc(&ccb->timeout, ccb_timeout, ccb); #endif Added files: Index: othersrc/external/bsd/iscsi/sys/modules/iscsi/Makefile diff -u /dev/null othersrc/external/bsd/iscsi/sys/modules/iscsi/Makefile:1.1 --- /dev/null Tue Jun 7 23:47:51 2011 +++ othersrc/external/bsd/iscsi/sys/modules/iscsi/Makefile Tue Jun 7 23:47:51 2011 @@ -0,0 +1,11 @@ +# $NetBSD: Makefile,v 1.1 2011/06/07 23:47:51 riz Exp $ + +.include "../Makefile.inc" + +.PATH: ${S}/dev/iscsi + +KMOD= iscsi +SRCS= base64.c iscsi_ioctl.c iscsi_main.c iscsi_profile.c iscsi_rcv.c +SRCS+= iscsi_send.c iscsi_test.c iscsi_text.c iscsi_utils.c + +.include <bsd.kmodule.mk>