[3382] in linux-scsi channel archive

home help back first fref pref prev next nref lref last post

Re: How are the commands queued

daemon@ATHENA.MIT.EDU (Marc SCHAEFER)
Sun Feb 22 02:59:29 1998

From: Marc SCHAEFER <schaefer@alphanet.ch>
Date: 	22 Feb 1998 08:40:56 +0100
Apparently-To: linux-scsi@vger.rutgers.edu
To: ;@unlisted-recipients (no To-header on input)

Manjunath.J.J <manjujj@cdc.bflsl.soft.net> wrote:
> 	To build a command list I need to read all the requests queued
> in the buffer. Can someone tell me how the requests for read/write are

You get in your xxx_queuecommand() function a Scsi_Cmnd *Cmnd structure which
contains
   - the SCSI command itself to pass in the command phase
   - a few bookkeeping structures
   - either ONE buffer or a list of buffer (depending on Cmnd->use_sg)

Pseudo-code (supposing that for some reason I put the Cmnd into my
proprietary cmd structure).

      if (Cmnd->use_sg) {
         sg = (struct scatterlist *) Cmnd->request_buffer;
         ds = cmd->dataseg;
         cmd->segment_cnt = Cmnd->use_sg;

         for (sg_count = 0; sg_count < Cmnd->use_sg; sg_count++) {
            ds->d_base = (void *) virt_to_bus(sg->address);
            ds->d_count = sg->length;
            sg++;
            ds++;
         }
      }
      else {
         cmd->dataseg[0].d_base = (void *) virt_to_bus(Cmnd->request_buffer);
         cmd->dataseg[0].d_count = Cmnd->request_bufflen;
         cmd->segment_cnt = 1;
      }

If there is something wrong, feel free to fix it for me :-)

home help back first fref pref prev next nref lref last post