Subject: Re: Explicit enabling of disk caches
To: Jason R Thorpe <thorpej@wasabisystems.com>
From: Matthew Jacob <mjacob@feral.com>
List: tech-kern
Date: 09/02/2001 15:49:12
On Sun, 2 Sep 2001, Jason R Thorpe wrote:

> On Sun, Sep 02, 2001 at 01:54:36PM -0700, Matthew Jacob wrote:
> 
>  > > BTW, I'm planning to add "format media" and "verify media" ioctls and
>  > > associated stuff in dkctl(8), as well...
>  > 
>  > "write check" is "verify media"
> 
> Ah, gotcha.
> 
> Ok, SCSI question -- SCSI-2 says that when you MODE SENSE with a CHANGEABLE
> page control field, you get a "mask denoting those mode parameters that
> are changeable." (X3T9.2/375R revision 10L, page 116, ss 8.2.10.2)
> 
> It isn't terribly clear on exactly which bit in the mask means.. I am
> guessing that it's a variable-length bitmask, each bit indicating
> field number like so:
> 
>         struct page_caching {
>                 u_int8_t pg_code;       /* page code (should be 8) */
>                 u_int8_t pg_length;     /* page length (should be 0x0a) */
>                 u_int8_t flags;         /* cache parameter flags */
> #define CACHING_RCD     0x01            /* read cache disable */ 
> #define CACHING_MF      0x02            /* multiplcation factor */
> #define CACHING_WCE     0x04            /* write cache enable (write-back) */
>                 u_int8_t ret_prio;      /* retention priority */
> #define READ_RET_PRIO_SHIFT 4
> #define RET_PRIO_DONT_DISTINGUISH       0x0
> #define RET_PRIO_REPLACE_READ_WRITE     0x1
> #define RET_PRIO_REPLACE_PREFETCH       0xf
>                 u_int8_t dis_prefetch_xfer_len[2]; 
>                 u_int8_t min_prefetch[2];
>                 u_int8_t max_prefetch[2];
>                 u_int8_t max_prefetch_ceiling[2];
>         } caching_params;
> 
> byte 0 bit 0:		flags
> byte 0 bit 1:		ret_prio
> byte 0 bit 2:		dis_prefetch_xfer_len
> byte 0 bit 3:		dis_prefetch_xfer_len
> byte 0 bit 4:		min_prefetch
> byte 0 bit 5:		max_prefetch
> byte 0 bit 6:		max_prefetch_ceiling
> 
> ...and "byte 0" means "byte immediately following pg_length field".
> 
> Have I got that right (isn't this more or less how the `offset' works in
> the INVALID FIELD IN PARAMETER LIST error works, as well)?
> 
> 

I don't think so- it means CHANGEABLE means all bits that are changeable,
in the same byte and bit order as all of the parameters.

See 8.2.10.2-

	A PC field value of 1h requsts that the target return a mask denoting
	those mode parameters that are changeable. In the mas, the fields of
	the mode parameters that are changeable shall be set to all one bits
	and the fields of the mode paramaters that are non-changeable (i.e.,
	defined by the target) thall be set to all zero bits.


A current parameters read for da0 on a FreeBSD machine:

peachy.nas.nasa.gov > root camcontrol modepage da0 -m 8
IC:  0
ABPF:  0
CAP:  0
DISC:  1
SIZE:  0
WCE:  1
MF:  0
RCD:  0
Demand Retention Priority:  0
Write Retention Priority:  0
Disable Pre-fetch Transfer Length:  65535
Minimum Pre-fetch:  0
Maximum Pre-fetch:  65535
Maximum Pre-fetch Ceiling:  65535

Changeable:

peachy.nas.nasa.gov > root camcontrol modepage da0 -m 8 -P 1
IC:  1
ABPF:  0
CAP:  1
DISC:  1
SIZE:  0
WCE:  1
MF:  0
RCD:  1
Demand Retention Priority:  0
Write Retention Priority:  0
Disable Pre-fetch Transfer Length:  65535
Minimum Pre-fetch:  65535
Maximum Pre-fetch:  65535
Maximum Pre-fetch Ceiling:  0


So, of flags, IC, CAP, DISC, WCE and RCD are changeable. The current
operating parameters has DISC and WCE enabled.

It turns out that all bits set for the Pre-Fetch goop are the same
as the current settings (0xffff).

-matt