Date: Tue, 16 Mar 1999 11:47:54 -0700 (MST) From: "Kenneth D. Merry" <ken@plutotech.com> To: amobbs@allstor-sw.co.uk Cc: freebsd-scsi@FreeBSD.ORG Subject: Re: Userland CAM drivers Message-ID: <199903161847.LAA27060@panzer.plutotech.com> In-Reply-To: <80256736.0063A310.00@mail.plasmon.co.uk> from "amobbs@allstor-sw.co.uk" at "Mar 16, 1999 6: 8:17 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
amobbs@allstor-sw.co.uk wrote... > > I'm trying to write a userland driver using camlib to do fairly > straightforward device control and I/O on a passthrough driver. > > So far, I've had no problem with control type commands (test unit ready, > mode sense/select etc.) but read and write are giving me problems. > > Just using read(2)/write(2) on the fd in the cam_device seemed to cause > serious problems, and I'm not sure that even using scsi_read_write followed > by a cam_send_ccb is working. (I'm getting constent Device in Reset > Sequence with that, but I'm willing to believe that that's a bug in my > code.) You can't use read or write on the pass devices. (which is what is behind the file descriptor in the cam_device structure) That is an ioctl-only interface. > So my questions: > > Do I have to use scsi_read_write followed by cam_send_ccb rather than > read/write on the fd? In general, how should I do I/O through a passthrough > device? scsi_read_write(), scsi_test_unit_ready() and other functions like that only serve to setup a CCB. They don't do any actual I/O to the device. Once you've setup the CCB with one of the helper functions, or with cam_fill_csio() (for generic SCSI CCBs), you then use cam_send_ccb() to send the CCB. cam_send_ccb() is just a wrapper to the CAMIOCOMMAND ioctl. > Is there an documentation on this sort of thing, even that written in C? I > used camcontrol.c to get the control side working, but the I/O side seems > to only be done by kernel drivers, which use scsi_read_write followed by > xpt_action which doesn't appear to be available to me. Well, the equivalent of xpt_action for you is cam_send_ccb(). You should be able to setup read and write CCBs and read from and write to the device using scsi_read_write() and cam_send_ccb(). I know that this works, because we (i.e. my employer) has a very large application that does just that. As far as documentation written in C on this, camcontrol is the main example. But, really, doing an inquiry is no different than doing a read. In both cases, you call a helper function (scsi_inquiry() or scsi_read_write()). In both cases, you supply a buffer and a length and some other parameters. Once that is setup, you just pass the CCB into cam_send_ccb(). Anyway, hopefully this explains things. If you've got more questions, don't hesitate to ask. I wrote most of that code (userland code, passthrough driver, etc.), so I can certainly explain how it works. Ken -- Kenneth Merry ken@plutotech.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-scsi" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199903161847.LAA27060>