add extra inquiry byte 56 data to struct scsi_device
PATCH 1/1 add extra inquiry byte 56 data to struct scsi_device
The idea here is to get a full range of device capabilites in the scsi_device structure so there's absolutely no need at all for drivers to snoop the inquiry data.
The missing parameters were:
dt_only - means the device only supports DT transfers (not ST) ius - means the device supports information unit (IU) transfers qas - means the device supports the Quick Arbitration and Selection protocol
Our rather misnamed ones are:
ppr - means the device does DT (DT negotiation may only be done via PPR) wdtr - means the device does wide
sdtr - means the device does sync
James
===== drivers/scsi/scsi_scan.c 1.127 vs edited =====
drivers/scsi/scsi_scan.c +10 -3
@@ -576,9 +576,16 @@ sdev->lockable = sdev->removable; sdev->soft_reset = (inq_result[7 ] &1 ) && ((inq_result[3 ] &7 ) ==2 ); -if (sdev->scsi_level >=SCSI_3 || (sdev->inquiry_len >56 && - inq_result[56 ] &0x04 )) - sdev->ppr =1 ; +if (sdev->inquiry_len >56 ) { +if (inq_result[56 ] &0x04 ) + sdev->ppr =1 ; +if ((inq_result[56 ] &0x0c ) ==0x04 ) + sdev->dt_only =1 ; +if (inq_result[56 ] &0x01 ) + sdev->ius =1 ; +if (inq_result[56 ] &0x02 ) + sdev->qas =1 ; + }if (inq_result[7 ] &0x60 ) sdev->wdtr =1 ;if (inq_result[7 ] &0x10 )
===== include/scsi/scsi_device.h 1.19 vs edited =====
include/scsi/scsi_device.h +4 -0
@@ -89,6 +92,10 @@ unsigned sdtr:1; /* Device supports SDTR messages */ unsigned wdtr:1; /* Device supports WDTR messages */ unsigned ppr:1; /* Device supports PPR messages */ + unsigned dt_only:1; /* Device only supports DT */ + unsigned ius:1; /* Device Supports IUs */ + unsigned qas:1; /* Device Support Quick Arbitration +* and Selection */ unsigned tagged_supported:1; /* Supports SCSI-II tagged queuing */ unsigned simple_tags:1; /* simple queue tag messages are enabled */ unsigned ordered_tags:1;/* ordered queue tag messages are enabled */
drivers/scsi/scsi_scan.c line 588
Quoted 10 lines · James Bottomley
drivers/scsi/scsi_scan.c +10
-0+if (sdev->inquiry_len >56 ) { +if (inq_result[56 ] &0x04 ) + sdev->ppr =1 ; +if ((inq_result[56 ] &0x0c ) ==0x04 ) + sdev->dt_only =1 ; +if (inq_result[56 ] &0x01 ) + sdev->ius =1 ; +if (inq_result[56 ] &0x02 ) + sdev->qas =1 ; + }
Do you forsee ever adding more feature bits like this?
It seems to me that a more maintainable approach is to cache relevant INQUIRY data in a buffer, and then create accessor macros for programmers' use.
That way you don't have to keep adding members (really, mnemonics) to a data structure, and associated initialization code, each time the mid-layer or some low-level drivers want to test a new feature bit. Initialization via memcpy is easy and automatic.
Jeff
Quoted 1 line · Jeff Garzik
Do you forsee ever adding more feature bits like this?
Never say never, but the standard looks now to be fixed. The only waiting extension of SPI5 was fast-360, which doesn't look like being realised.
Quoted 8 lines
It seems to me that a more maintainable approach is to cache relevant INQUIRY data in a buffer, and then create accessor macros for programmers' use.
That way you don't have to keep adding members (really, mnemonics) to a data structure, and associated initialization code, each time the mid-layer or some low-level drivers want to test a new feature bit. Initialization via memcpy is easy and automatic.
Only if someone else converts all the drivers...but yet, if more bits come along, that's probably what we should do.
James
Quoted 8 lines · Jeff Garzik
It seems to me that a more maintainable approach is to cache relevant INQUIRY data in a buffer, and then create accessor macros for programmers' use.
That way you don't have to keep adding members (really, mnemonics) to a data structure, and associated initialization code, each time the mid-layer or some low-level drivers want to test a new feature bit. Initialization via memcpy is easy and automatic.
Actually, given the fact that we cache the inquiry data anyway, this seems to be phenomenally easy to do.
James
===== include/scsi/scsi_device.h 1.19 vs edited =====
include/scsi/scsi_device.h +32 -0
@@ -191,5 +194,37 @@static inline int scsi_device_online (struct scsi_device *sdev) {return sdev->sdev_state !=SDEV_OFFLINE ; +} + +/* accessor functions for the SCSI parameters */ +static inline int scsi_device_sync (struct scsi_device *sdev) +{ +return sdev->sdtr; +} +static inline int scsi_device_wide (struct scsi_device *sdev) +{ +return sdev->wdtr; +} +static inline int scsi_device_dt (struct scsi_device *sdev) +{ +return sdev->ppr; +} +static inline int scsi_device_dt_only (struct scsi_device *sdev) +{ +if (sdev->inquiry_len <57 ) +return 0 ; +return (sdev->inquiry[56 ] &0x0c ) ==0x04 ; +} +static inline int scsi_device_ius (struct scsi_device *sdev) +{ +if (sdev->inquiry_len <57 ) +return 0 ; +return sdev->inquiry[56 ] &0x01 ; +} +static inline int scsi_device_qas (struct scsi_device *sdev) +{ +if (sdev->inquiry_len <57 ) +return 0 ; +return sdev->inquiry[56 ] &0x02 ; }#endif /* _SCSI_SCSI_DEVICE_H */
Quoted 20 lines · James Bottomley
include/scsi/scsi_device.h +20
-0+/* accessor functions for the SCSI parameters */ +static inline int scsi_device_sync (struct scsi_device *sdev) +{ +return sdev->sdtr; +} +static inline int scsi_device_wide (struct scsi_device *sdev) +{ +return sdev->wdtr; +} +static inline int scsi_device_dt (struct scsi_device *sdev) +{ +return sdev->ppr; +} +static inline int scsi_device_dt_only (struct scsi_device *sdev) +{ +if (sdev->inquiry_len <57 ) +return 0 ; +return (sdev->inquiry[56 ] &0x0c ) ==0x04 ; +} +static inline int scsi_device_ius (struct scsi_device *sdev)
include/scsi/scsi_device.h line 228
Quoted 10 lines
include/scsi/scsi_device.h +10
-0+{ +if (sdev->inquiry_len <57 ) +return 0 ; +return sdev->inquiry[56 ] &0x01 ; +} +static inline int scsi_device_qas (struct scsi_device *sdev) +{ +if (sdev->inquiry_len <57 ) +return 0 ; +return sdev->inquiry[56 ] &0x02 ;
Very nice. Two nits (of course),
* my fingers would prefer scsidev_foo or scsi_inq_foo
* might as well take the opportunity to kill sdtr/wdtr/ppr :)
On Fri, 20 Aug 2004 23:21:48 -0400 Jeff Garzik wrote:
| James Bottomley wrote:
| > + if (sdev->inquiry_len > 56) {
| > + if (inq_result[56] & 0x04)
| > + sdev->ppr = 1;
| > + if ((inq_result[56] & 0x0c) == 0x04)
| > + sdev->dt_only = 1;
| > + if (inq_result[56] & 0x01)
| > + sdev->ius = 1;
| > + if (inq_result[56] & 0x02)
| > + sdev->qas = 1;
| > + }
|
|
| Do you forsee ever adding more feature bits like this?
|
| It seems to me that a more maintainable approach is to cache relevant
| INQUIRY data in a buffer, and then create accessor macros for
| programmers' use.
|
| That way you don't have to keep adding members (really, mnemonics) to a Mnemonics would be names, not numbers. (hint hint)
| data structure, and associated initialization code, each time the | mid-layer or some low-level drivers want to test a new feature bit. | Initialization via memcpy is easy and automatic.
--
~Randy
Quoted 23 lines · Randy.Dunlap
On Fri, 20 Aug 2004 23:21:48 -0400 Jeff Garzik wrote:
| James Bottomley wrote: | > + if (sdev->inquiry_len > 56) { | > + if (inq_result[56] & 0x04) | > + sdev->ppr = 1; | > + if ((inq_result[56] & 0x0c) == 0x04) | > + sdev->dt_only = 1; | > + if (inq_result[56] & 0x01) | > + sdev->ius = 1; | > + if (inq_result[56] & 0x02) | > + sdev->qas = 1; | > + } | | | Do you forsee ever adding more feature bits like this? | | It seems to me that a more maintainable approach is to cache relevant | INQUIRY data in a buffer, and then create accessor macros for | programmers' use. | | That way you don't have to keep adding members (really, mnemonics) to a
Quoted 1 line
Mnemonics would be names, not numbers.
Nod. I was referring to the names being added to the struct.
Jeff
Quoted 11 lines · James Bottomley
The idea here is to get a full range of device capabilites in the
scsi_devicestructure so there's absolutely no need at all for drivers to snoop the inquiry data.The missing parameters were:
dt_only- means the device only supports DT transfers (not ST) ius - means the device supports information unit (IU) transfers qas - means the device supports the Quick Arbitration and Selection protocol
Quoted 5 lines
Our rather misnamed ones are:
ppr - means the device does DT (DT negotiation may only be done via PPR) wdtr - means the device does wide
sdtr - means the device does sync
James,
What you are proposing is only relevant for the SPI transport. Maybe the accessors should be placed in scsi_tranport_spi.c and struct scsi_device get a a transport dependent "hang on". Then some of that older SPI stuff could get migrated out of struct scsi_device so it stops growing.
Doug Gilbert
Quoted 6 lines · Douglas Gilbert
What you are proposing is only relevant for the SPI transport. Maybe the accessors should be placed in
scsi_tranport_spi.cand structscsi_deviceget a a transport dependent "hang on". Then some of that older SPI stuff could get migrated out of structscsi_deviceso it stops growing.
Perhaps as a long term goal. However, getting inquiry snooping out of the drivers is currently more important than converting all the SPI drivers over to using the transport class.
James