Technical article 100768

SCSI host adapter Scatter/Gather information.

OpenServer 5.0.0

Written · Last revised

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".

From the Xinuos technical article database, record 100768. Reproduced with permission. The original is at www.sco.com/ta/100768, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.