--- scsi_device.9s.orig Tue Oct 21 19:12:37 2008 +++ scsi_device.9s Tue Oct 28 08:55:51 2008 @@ -8,39 +8,52 @@ INTERFACE LEVEL Solaris DDI specific (Solaris DDI). DESCRIPTION - The scsi_device structure stores common information about - each SCSI logical unit, including pointers to areas that - contain both generic and device specific information. There - is one scsi_device structure for each logical unit attached - to the system. The host adapter driver initializes part of - this structure prior to probe(9E) and destroys this struc- - ture after a probe failure or successful detach(9E). + The scsi_device structure stores common information about a + target device logical unit function, including pointers to areas + that contain both generic and device specific information. There + is one scsi_device structure for each device unit-address attached + to the system, and one SCSI target driver instance (e.g. sd(7D), + st(7D), sgen(7D)) that provides access to the function. The device + unit-address is represented by the scsi_address(9S) structure + embedded in the scsi_device structure. + + The scsi_device structures is allocated and freed by the SCSA + library code. The host adapter driver can initialize part of + this structure in tran_tgt_init(9E) prior to probe(9E) and + destroy its initialization in tran_tgt_free(9E) on probe failure or + after successful detach(9E). STRUCTURE MEMBERS struct scsi_address sd_address; /* Routing information */ dev_info_t *sd_dev; /* Cross-reference */ /* to our dev_info_t */ kmutex_t sd_mutex; /* Mutex for this device */ struct scsi_inquiry *sd_inq; /* scsi_inquiry data structure */ struct scsi_extended_sense *sd_sense; /* Optional request */ /* sense buffer ptr */ - caddr_t sd_private; /* Target drivers private data */ + void *sd_private; /* Target drivers private data */ + void *sd_hba_private; /* HBA drivers private data */ - - sd_address contains the routing information that the target - driver normally copies into a scsi_pkt(9S) structure using - the collection of makecom(9F) functions. The SCSA library - routines use this information to determine which host - adapter, SCSI bus, and target/logical unit number (lun) a - command is intended for. This structure is initialized by - the host adapter driver. + sd_address contains the host routing and scsi_device unit-address + information necessary to reference a specific SCSI target device + logical unit function. + + A SCSI_HBA_ADDR_COMPLEX host adapter, as defined by + scsi_hba_attach_setup(9F) flags, can use + scsi_device_hba_private_set(9F) during tran_tgt_init(9E) to save a + pointer to per-scsi_device HBA private data. , and free that + allocation in its tran_tgt_free(9E) implementation. The HBA + driver can access per-scsi_device HBA private data during + tran_start(9E) by using scsi_address_device(9F) and + scsi_device_hba_private_get(9F). Any established per-scsi_device + HBA private data should be freed during tran_tgt_fini(9E). sd_dev is a pointer to the corresponding dev_info structure. - This pointer is initialized by the host adapter driver. + This pointer is initialized by the SCSA library code. sd_mutex is a mutual exclusion lock for this device. It is used to serialize access to a device. The host adapter driver initializes this mutex. See mutex(9F). @@ -51,14 +64,21 @@ sd_sense is initially NULL (zero). If the target driver wants to use this field for storing REQUEST SENSE data, it should allocate an scsi_extended_sense(9S) buffer and set this field to the address of this buffer. - sd_private is reserved for the use of target drivers and - should generally be used to point to target specific data - structures. + sd_private is reserved for the use of scsi_device target + drivers and should generally be used to point to target + specific data structures. + + sd_hba_private is reserved for the use by the SCSA library code + and its implementation of scsi_device_hba_private_get(9F) and + scsi_hba_device_private_set(9F). SEE ALSO detach(9E), probe(9E), makecom(9F), mutex(9F), - scsi_probe(9F), scsi_extended_sense(9S), scsi_pkt(9S) + scsi_address(9S), + scsi_probe(9F), scsi_extended_sense(9S), scsi_pkt(9S), + scsi_hba_attach_setup(9F), + scsi_device_hba_private_get(9F) Writing Device Drivers