From: Luben Tuikov <tluben@rogers.com>
To: Matthew Dharm <mdharm-scsi@one-eyed-alien.net>
Cc: James Bottomley <James.Bottomley@steeleye.com>,
Andries.Brouwer@cwi.nl, greg@kroah.com,
SCSI Mailing List <linux-scsi@vger.kernel.org>,
linux-usb-devel@lists.sourceforge.net
Subject: Re: [example PATCH - not for applying] exclude certain commands
Date: Mon, 28 Apr 2003 15:05:42 -0400 [thread overview]
Message-ID: <3EAD7B86.8060300@rogers.com> (raw)
In-Reply-To: <20030427125237.A23693@one-eyed-alien.net>
Matthew Dharm wrote:
> On Sun, Apr 27, 2003 at 10:41:45AM -0500, James Bottomley wrote:
>
>>So the algorithm is quite simple: you get the command length from the
>>group (using a table with one exception for the 32 byte commands), and
>>then extract the transfer length from the command
>
>
> I'm with you up to about this point.
>
> So tell me how many bytes my command wanted to move? READ_10 specifies the
> transfer length is 'blocks'. How many bytes are in a block is
> device-dependent.
>
> Some commands (i.e. INQUIRY) specify transfer length in bytes. Others
> (i.e. READ_10) specify it in blocks, and the size of a block is not known
> based simply on the current command.
Matt,
You cannot really constrict yourself to the CDB only.
As a transport/interconnect (what a LLDD is, as well as USB Storage)
you get an Execute Command remote procedure call, in SCSI Core this
is represented by struct scsi_cmnd.
Execute Command rpc contains all that the transport/ic needs in order
to deliver the command to the device server (who will execute the
CDB) and perform (the interconnect) the data transfer.
The reference you want to take a peek at is SAM-3r6, 5.1 --
this is what USB storage is working with, not just the CDB.
Now, you've been talking about the Data-Out buffer size.
This is either ALLOCATION LENGTH (normally bytes), or
TRANFER LENGTH (READ/WRITE, normally blocks).
The reference here is SPC3r12, 4.3.4.4 Transfer Length and
4.3.4.6 Allocation Length.
Please note that Data-Out buffer size *is* the
Expected (maxumum) Data Tranfer Length, the device
server may tranfer less data, (request_bufflen, bufflen).
This is what the standards specify, and what SCSI Core
sets it to. The actual memory buffer may be bigger.
The device server may transfer less data, but not more.
The device server will NOT modify the returned data
to reflect the insufficient data-in buffer.
So to repeat what the standards say and what SCSI Core
does: sr_bufflen, request_buflen, buflen *is* the
Expected (maxumum) Data Tranfer Length:
- when it means Allocation Length it is the
maximum available space (e.g. IQUIRY, Request Sense),
(The transport CANNOT write more data than this!)
- when it means Transfer Length it is the
Expected Data Transfer Length (READ/WRITE), and I say
``expected'' less any End Of Media or similar errors pop up,
(i.e. number of blocks from CDB * block_size = this value).
I.e. the _actual_ buffer size *is* IRRELEVANT to LLDD and
the Transport/IC -- since it maybe an offset to another yet
bigger buffer and SCSI Core/Appl. Client maybe requesting
part of some data (see SAM-3r6, 5.4.3).
Some transports provide an Overflow and Underflow bits in
the transport protocol to let the Initiator port (LLDD)
know about any residuals -- SCSI Core struct scsi_cmnd supports
only an underflow residual (bytes that were not transferred out
of the number of bytes that were expected to be transferred).
I don't know much about USB Storage, but what do you think
about this: add an unsigned overflow_resid to struct scsi_cmnd,
and set it to an applicable value when a USB storage device
provided more data to be transferred, but the buffer was too small.
(I can see how this will not work, if you need a large enough ptr
to just write the data to...)
--
Luben
next prev parent reply other threads:[~2003-04-28 18:53 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-26 21:44 [example PATCH - not for applying] exclude certain commands Andries.Brouwer
2003-04-26 22:13 ` Matthew Dharm
2003-04-26 22:43 ` James Bottomley
2003-04-27 1:34 ` Matthew Dharm
2003-04-27 2:15 ` James Bottomley
2003-04-27 9:35 ` Matthew Dharm
2003-04-27 15:41 ` James Bottomley
2003-04-27 18:52 ` Kai Makisara
2003-04-27 19:52 ` Matthew Dharm
2003-04-28 19:05 ` Luben Tuikov [this message]
2003-04-28 19:12 ` Luben Tuikov
2003-04-28 20:19 ` Matthew Dharm
2003-04-28 21:33 ` Luben Tuikov
2003-04-26 22:29 ` James Bottomley
2003-04-27 0:24 ` Patrick Mansfield
2003-04-27 1:39 ` Matthew Dharm
2003-04-27 14:04 ` [linux-usb-devel] " Alan Stern
-- strict thread matches above, loose matches on Subject: below --
2003-04-27 2:29 Andries.Brouwer
2003-04-27 4:32 ` James Bottomley
2003-04-25 0:43 Andries.Brouwer
2003-04-25 2:12 ` Matthew Dharm
2003-04-25 14:32 ` Alan Stern
2003-04-25 15:12 ` Oliver Neukum
2003-04-26 0:58 ` Alan Stern
2003-04-26 8:24 ` Oliver Neukum
2003-04-26 15:22 ` Alan Stern
2003-04-24 18:59 Andries.Brouwer
2003-04-24 19:14 ` Matthew Dharm
2003-04-24 20:20 ` James Bottomley
2003-04-24 20:59 ` Matthew Dharm
2003-04-24 21:43 ` Patrick Mansfield
2003-04-24 15:21 Andries.Brouwer
2003-04-24 15:56 ` Pete
2003-04-24 21:33 ` Stelian Pop
2003-04-24 9:46 Andries.Brouwer
2003-04-24 9:56 ` Stelian Pop
2003-04-24 14:05 ` Alan Stern
2003-04-24 14:26 ` James Bottomley
2003-04-24 14:46 ` Alan Stern
2003-04-24 15:26 ` James Bottomley
2003-04-24 9:08 Andries.Brouwer
2003-04-24 18:22 ` Matthew Dharm
2003-04-23 22:39 Andries.Brouwer
2003-04-24 0:10 ` Matthew Dharm
2003-04-24 8:05 ` André Cruz
2003-04-24 9:15 ` Stelian Pop
2003-04-24 9:22 ` Stelian Pop
2003-04-24 11:45 ` Mike Bursell
2003-04-24 12:44 ` James Bottomley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3EAD7B86.8060300@rogers.com \
--to=tluben@rogers.com \
--cc=Andries.Brouwer@cwi.nl \
--cc=James.Bottomley@steeleye.com \
--cc=greg@kroah.com \
--cc=linux-scsi@vger.kernel.org \
--cc=linux-usb-devel@lists.sourceforge.net \
--cc=mdharm-scsi@one-eyed-alien.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox