Problem
I am developing a SCSI host adapter driver and want to
implement scatter/gather capabilities. How do I make Sdsk
aware of this capability and how does the Sdsk peripheral
driver make a scatter/gather request to my host adapter
driver? Solution
Take these steps:- Make sure Sdsk_no_sg is set to 0 in /etc/conf/pack.d/Sdsk/space.c.
- Set the correct version number in the scsi_disk_info structure. (See another article: "My SCSI host adapter driver never receives a SCSI_INFO command" in this database.)
- When the adapter driver's xx_entry function is called
with the req_type field of the scsi_io_req structure
set to SCSI_INFO, your driver needs to set the correct
bits in the scsi_ha_info bitfield structure. For a
driver capable of scatter/gather the do_sg bit must be
set (see also <sys/scsi.h>).- When the peripheral driver (Sdsk) sends a scatter/gather command it will set the req_type field to SCSI_SG.
For a scatter/gather command, this is what the fields of the scsi_io_req structure contain:
paddr_t data_len: This is the total length in bytes of all scatter/gather requests added together.
paddr_t data_ptr: This points to an array of data pointers. The array is of type long and each element points to the physical address to or from which the data will be transferred.
paddr_t link_ptr: This points to an array of data lengths. The array is of type long and each element contains the length of each i/o request.
The other fields in the scsi_io_req structure are used as
in a SCSI_SEND command. For more information, read the
Device Driver's Guide Supplement.Your host adapter driver's XX_entry routine should perform similar code to the following:
/*
* XX_entry(req_p)
* register REQ_IO *req_p;
* HAINFO info;
* info.do_sg=1; this should be set in xx_init if your driver
* also supports non sg capable adapters.
*
*/switch (req_p->req_type) {case SCSI_INIT:
if (req_p->ext_p) {
scsi_disk_info *sdi_p;
sdi_p = (scsi_disk_info *) req_p->ext_p->data;
sdi_p->magic = SCSI_V3_MAGIC;
sdi_p->v_maj = SCSI_V3_VERSION;
sdi_p->v_min = 0;
}
switch (req_p->hacmd) {/*
* process SCSI_DISK_INFO, etc. requests here
*/}
break; /* End of SCSI_INIT */case SCSI_INFO:
bcopy(&info,
ptok(req_p->data_ptr),
req_p->data_len);
break; /* End of SCSI_INFO *//*
* process SCSI_SEND, SCSI_SG, etc.
* req_types here
*/} /* End of SWITCH */ See also
Another article titled "My SCSI host adapter driver never receives a SCSI_INFO command".