[7204] in linux-scsi channel archive

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

Re: Fixing SCSI Layer

daemon@ATHENA.MIT.EDU (Tony Chung)
Fri Sep 10 16:29:09 1999

Date:   Fri, 10 Sep 1999 13:10:08 -0700
From:   Tony Chung <chungto@ampex.com>
To:     "Kenneth D. Merry" <ken@kdm.org>
CC:     linux-scsi@vger.rutgers.edu


--------------5ECC97C402BFA5E869A73995
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

"Kenneth D. Merry" wrote:

> Tony Chung wrote...
> >
> >
> > >
> > > 1 - Add a 'direction' field to the scsi command structure that can be
> > >     filled with the following values:
> > >       DIR_INPUT, DIR_OUTPUT, DIR_NONE and DIR_UNKNOWN=0
> > >       Set this field to DIR_UNKNOWN=0 by default.
> > >
> >
> > >From Digital Unix  /usr/include/io/cam.h:
> >
> > /* Defines for the CAM flags field in the CCB header. */
> >
> > #define CAM_DIR_RESV       0x00000000   /* Data direction (00: reserved) */
> > #define CAM_DIR_IN         0x00000040   /* Data direction (01: DATA IN) */
> > #define CAM_DIR_OUT        0x00000080   /* Data direction (10: DATA OUT) */
> > #define CAM_DIR_NONE       0x000000C0   /* Data direction (11: no data) */
> >
> > While UDI scsi spec has:
> > #define UDI_SCSI_DATA_IN   (1U<<0)
> > #define UDI_SCSI_DATA_OUT (1U<<1)
> >
> > Basically, it can't be UNKNOWN because the Peripheral Driver must specify the
> > buffer address and total transfer size. Any  inconsistencies should return error
> >
> > or let the host adaptor card simply return data overrun or data underrun.
> >
> >
> > I found CAM_DIR_NONE is potential hazard because
> > if some one specify CAM_DIR_NONE, another person
> > may mistakenly check for:
> >         If (flags & CAM_DIR_OUT) ...../* condition true and do something wrong
> > */
>
> In FreeBSD/CAM, we added a mask:
>
>         CAM_DIR_RESV            = 0x00000000,/* Data direction (00:reserved)  */
>         CAM_DIR_IN              = 0x00000040,/* Data direction (01:DATA IN)   */
>         CAM_DIR_OUT             = 0x00000080,/* Data direction (10:DATA OUT)  */
>         CAM_DIR_NONE            = 0x000000C0,/* Data direction (11:no data)   */
>         CAM_DIR_MASK            = 0x000000C0,/* Data direction Mask           */
>
> So to determine the data direction:
>
> if ((flags & CAM_DIR_MASK) == CAM_DIR_OUT)
>         ...

I think CAM_DIR_MASK is a workaround for the original design flaw.

Comparing to UDI, only two defines versus five defines in CAM.

And one "&" operation versus two operations (&,==) in CAM.

Obviously, UDI is better at least here :-).

--
=============================
Tony Chung



--------------5ECC97C402BFA5E869A73995
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
"Kenneth D. Merry" wrote:
<blockquote TYPE=CITE>Tony Chung wrote...
<br>>
<br>>
<br>> >
<br>> > 1 - Add a 'direction' field to the scsi command structure that
can be
<br>> >&nbsp;&nbsp;&nbsp;&nbsp; filled with the following values:
<br>> >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DIR_INPUT, DIR_OUTPUT, DIR_NONE
and DIR_UNKNOWN=0
<br>> >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set this field to DIR_UNKNOWN=0
by default.
<br>> >
<br>>
<br>> >From Digital Unix&nbsp; /usr/include/io/cam.h:
<br>>
<br>> /* Defines for the CAM flags field in the CCB header. */
<br>>
<br>> #define CAM_DIR_RESV&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x00000000&nbsp;&nbsp;
/* Data direction (00: reserved) */
<br>> #define CAM_DIR_IN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
0x00000040&nbsp;&nbsp; /* Data direction (01: DATA IN) */
<br>> #define CAM_DIR_OUT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x00000080&nbsp;&nbsp;
/* Data direction (10: DATA OUT) */
<br>> #define CAM_DIR_NONE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0x000000C0&nbsp;&nbsp;
/* Data direction (11: no data) */
<br>>
<br>> While UDI scsi spec has:
<br>> #define UDI_SCSI_DATA_IN&nbsp;&nbsp; (1U&lt;&lt;0)
<br>> #define UDI_SCSI_DATA_OUT (1U&lt;&lt;1)
<br>>
<br>> Basically, it can't be UNKNOWN because the Peripheral Driver must
specify the
<br>> buffer address and total transfer size. Any&nbsp; inconsistencies
should return error
<br>>
<br>> or let the host adaptor card simply return data overrun or data underrun.
<br>>
<br>>
<br>> I found CAM_DIR_NONE is potential hazard because
<br>> if some one specify CAM_DIR_NONE, another person
<br>> may mistakenly check for:
<br>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If (flags &amp; CAM_DIR_OUT)
...../* condition true and do something wrong
<br>> */
<p>In FreeBSD/CAM, we added a mask:
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CAM_DIR_RESV&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
= 0x00000000,/* Data direction (00:reserved)&nbsp; */
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CAM_DIR_IN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
= 0x00000040,/* Data direction (01:DATA IN)&nbsp;&nbsp; */
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CAM_DIR_OUT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
= 0x00000080,/* Data direction (10:DATA OUT)&nbsp; */
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CAM_DIR_NONE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
= 0x000000C0,/* Data direction (11:no data)&nbsp;&nbsp; */
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CAM_DIR_MASK&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
= 0x000000C0,/* Data direction Mask&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
*/
<p>So to determine the data direction:
<p>if ((flags &amp; CAM_DIR_MASK) == CAM_DIR_OUT)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...</blockquote>

<pre>I think CAM_DIR_MASK is a workaround for the original design flaw.</pre>

<pre>Comparing to UDI, only two defines versus five defines in CAM.</pre>

<pre>And one "&amp;" operation versus two operations (&amp;,==) in CAM.</pre>

<pre>Obviously, UDI is better at least here :-).</pre>

<pre>--&nbsp;
=============================
Tony Chung</pre>
&nbsp;</html>

--------------5ECC97C402BFA5E869A73995--


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.rutgers.edu

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