public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* A question on Linux SCSI low-level driver
@ 2004-05-07 21:28 Lee Xing
  2004-05-09  2:10 ` Douglas Gilbert
  0 siblings, 1 reply; 6+ messages in thread
From: Lee Xing @ 2004-05-07 21:28 UTC (permalink / raw)
  To: linux-scsi

Hi,

We are trying to write a low-level driver (no need for a perfect one at this time, just need to register the disks and do some simple I/Os).  I would sincerely appreciate it if some one could give me some information/suggestions/hints.

This low-level driver has indirect (via other layers) information on physical disks, so it can only provide mid-level driver with bus number, target number and lun number of the disks.  It will convert SCSI passthrough commands coming from the mid-level driver and send the converted command packages to the disks (again, via other layers).  It also sends the responses coming from physical disks (via other layers) back to the mid-level driver.  The "other layers" are SCSI-ready and can handle SCSI cmds/responses well.

My questions are: 

- is it (i.e. registering the disks with mid-level driver and doing some
  simple I/Os) doable if this low-level driver only provides mid-level with
  bus/target/lun numbers (without any hardware-related information)?
- what can be the potential problems (if nay)?

Best Regards,


Lee


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: A question on Linux SCSI low-level driver
  2004-05-07 21:28 Lee Xing
@ 2004-05-09  2:10 ` Douglas Gilbert
  0 siblings, 0 replies; 6+ messages in thread
From: Douglas Gilbert @ 2004-05-09  2:10 UTC (permalink / raw)
  To: Lee Xing; +Cc: linux-scsi

Lee Xing wrote:
> Hi,
> 
> We are trying to write a low-level driver (no need for a perfect one at this time, just need to register the disks and do some simple I/Os).  I would sincerely appreciate it if some one could give me some information/suggestions/hints.
> 
> This low-level driver has indirect (via other layers) information on physical disks, so it can only provide mid-level driver with bus number, target number and lun number of the disks.  It will convert SCSI passthrough commands coming from the mid-level driver and send the converted command packages to the disks (again, via other layers).  It also sends the responses coming from physical disks (via other layers) back to the mid-level driver.  The "other layers" are SCSI-ready and can handle SCSI cmds/responses well.
> 
> My questions are: 
> 
> - is it (i.e. registering the disks with mid-level driver and doing some
>   simple I/Os) doable if this low-level driver only provides mid-level with
>   bus/target/lun numbers (without any hardware-related information)?

Lee,
See the scsi_debug driver (either in the lk 2.4 or lk 2.6
series). It is a scsi subsystem LLD that is basically a
ram disk so there is no "hardware" information to exchange
with the mid level.

Doug Gilbert

> - what can be the potential problems (if nay)?
> 
> Best Regards,


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: A question on Linux SCSI low-level driver
@ 2004-05-10 17:55 Lee Xing
  0 siblings, 0 replies; 6+ messages in thread
From: Lee Xing @ 2004-05-10 17:55 UTC (permalink / raw)
  To: dougg; +Cc: linux-scsi

Thanks for the information, Doug.  It helps a lot!

I downloaded scsi_debug from the Internet.  scsi_debug.c and scsi_debug.h also exist under RH Linux 9 /usr/src/linux-2.4.20-8/drivers/scsi/.  I tried to compile it as a module but got errors like this:

[root@localhost scsi]# pwd
/usr/src/linux-2.4.20-8/drivers/scsi
[root@localhost scsi]#
[root@localhost scsi]# make modules
make -C aic7xxx modules
make[1]: Entering directory `/usr/src/linux-2.4.20-8/drivers/scsi/aic7xxx'
make[1]: Nothing to be done for `modules'.
make[1]: Leaving directory `/usr/src/linux-2.4.20-8/drivers/scsi/aic7xxx'
[root@localhost scsi]#
[root@localhost scsi]#
[root@localhost scsi]# make
make -C aic7xxx
make[1]: Entering directory `/usr/src/linux-2.4.20-8/drivers/scsi/aic7xxx'
make all_targets
make[2]: Entering directory `/usr/src/linux-2.4.20-8/drivers/scsi/aic7xxx'
make[2]: Nothing to be done for `all_targets'.
make[2]: Leaving directory `/usr/src/linux-2.4.20-8/drivers/scsi/aic7xxx'
make[1]: Leaving directory `/usr/src/linux-2.4.20-8/drivers/scsi/aic7xxx'
make all_targets
make[1]: Entering directory `/usr/src/linux-2.4.20-8/drivers/scsi'
make[1]: Nothing to be done for `all_targets'.
make[1]: Leaving directory `/usr/src/linux-2.4.20-8/drivers/scsi'
[root@localhost scsi]#
[root@localhost scsi]#

I'm not familiar with the process.  What did I miss and how to compile each low-level driver under /usr/src/linux-2.4.20-8/drivers/scsi as a module from the command line?

Thanks,


Lee


======================================

> 
> My questions are: 
> 
> - is it (i.e. registering the disks with mid-level driver and doing some
>   simple I/Os) doable if this low-level driver only provides mid-level with
>   bus/target/lun numbers (without any hardware-related information)?

Lee,
See the scsi_debug driver (either in the lk 2.4 or lk 2.6
series). It is a scsi subsystem LLD that is basically a
ram disk so there is no "hardware" information to exchange
with the mid level.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: A question on Linux SCSI low-level driver
@ 2004-05-18 22:27 Lee Xing
  2004-05-19  3:52 ` Douglas Gilbert
  0 siblings, 1 reply; 6+ messages in thread
From: Lee Xing @ 2004-05-18 22:27 UTC (permalink / raw)
  To: dougg; +Cc: linux-scsi

Thanks for the information.  scsi_debug is very helpful for me.

Two questions on scsi_debug/low-level driver:

- Has anyone ever created a patch for scsi_debug to support ioctl calls in lk 2.4?  If not, is it possible for some one to kindly create it or a template/part of it?

- Do SCSI passthrough ioctl calls sent to both sd and sg devices share/use the same ioctl routine defined in scsi_debug/low-level driver?  In other words, ioctl routine defined in scsi_debug/low-level drivers can not tell and do not care from which type of device (sd or sg) the SCSI passthrough call comes in, correct?

Thanks,


Lee


-----Original Message-----
From: Douglas Gilbert [mailto:dougg@torque.net]
Sent: Saturday, May 08, 2004 9:11 PM
To: Lee Xing
Cc: linux-scsi@vger.kernel.org
Subject: Re: A question on Linux SCSI low-level driver


Lee Xing wrote:
> Hi,
> 
> We are trying to write a low-level driver (no need for a perfect one at this time, just need to register the disks and do some simple I/Os).  I would sincerely appreciate it if some one could give me
some information/suggestions/hints.
> 
> This low-level driver has indirect (via other layers) information on physical disks, so it can only provide mid-level driver with bus number, target number and lun number of the disks.  It will convert
SCSI passthrough commands coming from the mid-level driver and send the converted command packages to the disks (again, via other layers).  It also sends the responses coming from physical disks (via other
layers) back to the mid-level driver.  The "other layers" are SCSI-ready and can handle
SCSI cmds/responses well.
> 
> My questions are: 
> 
> - is it (i.e. registering the disks with mid-level driver and doing some
>   simple I/Os) doable if this low-level driver only provides mid-level with
>   bus/target/lun numbers (without any hardware-related information)?

Lee,
See the scsi_debug driver (either in the lk 2.4 or lk 2.6
series). It is a scsi subsystem LLD that is basically a
ram disk so there is no "hardware" information to exchange
with the mid level.

Doug Gilbert

> - what can be the potential problems (if nay)?
> 
> Best Regards,


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: A question on Linux SCSI low-level driver
  2004-05-18 22:27 A question on Linux SCSI low-level driver Lee Xing
@ 2004-05-19  3:52 ` Douglas Gilbert
  0 siblings, 0 replies; 6+ messages in thread
From: Douglas Gilbert @ 2004-05-19  3:52 UTC (permalink / raw)
  To: Lee Xing; +Cc: linux-scsi

Lee Xing wrote:
> Thanks for the information.  scsi_debug is very helpful for me.
> 
> Two questions on scsi_debug/low-level driver:
> 
> - Has anyone ever created a patch for scsi_debug to support ioctl calls in lk 2.4?  

Yes, me and it is in the last 8 (at least) versions of the
lk 2.4 series. See scsi_debug_ioctl().

It doesn't do anything other than report it has been called
but a "template" it is.

The ioctl model is "trickle down". So if the block layer
(in the case of sd), the sd driver (or sg driver) and the
SCSI mid level do _not_ recognize the ioctl() 'request' [an
integer and the second argument given to the ioctl invocation
in the user space] _then_ the ioctl "tickles down" to the
corresponding LLD ioctl routine (if there is one).

If not, is it possible for some one to kindly create it or a 
template/part of it?
> 
> - Do SCSI passthrough ioctl calls sent to both sd and sg devices share/use the same ioctl routine defined in scsi_debug/low-level driver?  In other words, ioctl routine defined in scsi_debug/low-level drivers can not tell and do not care from which type of device (sd or sg) the SCSI passthrough call comes in, correct?

The SCSI subsystem does not convey SCSI commands between the
mid level and LLDs via ioctl calls. ioctl()s defined in LLDs
are for very special, typically hardware specific, reasons.
For example the LLD of a RAID controller might use ioctls
to do RAID specific management functions.

Doug Gilbert



^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: A question on Linux SCSI low-level driver
@ 2004-05-19 16:14 Lee Xing
  0 siblings, 0 replies; 6+ messages in thread
From: Lee Xing @ 2004-05-19 16:14 UTC (permalink / raw)
  To: dougg; +Cc: linux-scsi

> - Has anyone ever created a patch for scsi_debug to support 
> ioctl calls in lk 2.4?

>>Yes, me and it is in the last 8 (at least) versions of the
>>lk 2.4 series. See scsi_debug_ioctl().

>>It doesn't do anything other than report it has been called
>>but a "template" it is.

Thanks for creating/maintaining the nice-and-helpful scsi_debug code.  Yes, I found scsi_debug_ioctl() from the latest patch of scsi_debug for lk 2.4.  As long as the answer to the next question is "Yes", then I probably don't need to define ioctl function in the low-level driver we are working on.

>>The SCSI subsystem does not convey SCSI commands between the
>>mid level and LLDs via ioctl calls. ioctl()s defined in LLDs
>>are for very special, typically hardware specific, reasons.
>>For example the LLD of a RAID controller might use ioctls
>>to do RAID specific management functions.

Is queuecommand() defined in low-level driver/scsi_debug the only function processing the incoming common SCSI tasks?  Is it also true no matter we send SCSI passthrough ioctl calls (with all common SCSI commands such as INQUIRY, READ, WRITE, MODE SELECT/SENSE, PERSISTENT RESERVATION IN/OUT, RESERVE, RELEASE, etc.) to sd devices (by using SCSI_IOCTL_SEND_COMMAND) or sg devices (by using either SCSI_IOCTL_SEND_COMMAND or SG_IO), or send non-passthrough commands (such as system calls read, write, etc.) to sd devices?

Thanks,


Lee

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-05-19 16:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-18 22:27 A question on Linux SCSI low-level driver Lee Xing
2004-05-19  3:52 ` Douglas Gilbert
  -- strict thread matches above, loose matches on Subject: below --
2004-05-19 16:14 Lee Xing
2004-05-10 17:55 Lee Xing
2004-05-07 21:28 Lee Xing
2004-05-09  2:10 ` Douglas Gilbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox