Writing Device Drivers

scsi_hba_tran Structure

Each instance of an HBA driver must allocate a scsi_hba_tran(9S) structure using scsi_hba_tran_alloc(9F) in the attach(9E) entry point. scsi_hba_tran_alloc(9S) initializes the scsi_hba_tran(9S) structure before it returns. The HBA driver must initialize specific vectors in the transport structure to point to entry points within the HBA driver. Once initialized, the HBA driver exports the transport structure to SCSA by calling scsi_hba_attach_setup(9F).


Caution - Caution -

Because SCSA keeps a pointer to the transport structure in the driver-private field on the dev_info(9S) structure, HBA drivers must not use ddi_set_driver_private(9F). They may, however, use ddi_get_driver_private(9F) to retrieve the pointer to the transport structure.


The scsi_hba_tran(9S) structure contains the following fields:

	
		dev_info_t		*tran_hba_dip;					/* HBA dev_info_t ptr */
 	void		*tran_hba_private;					/* HBA softstate */
 	void		*tran_tgt_private;					/* target-specific info */
 	struct 		scsi_device	*tran_sd;		 	/* scsi_device, if clone */
 	int		(*tran_tgt_init)();					/* target initialization */
 	int		(*tran_tgt_probe)();				/* target probing */
 	void		(*tran_tgt_free)();					/* target free */
 	int		(*tran_start)();		 				/* command transport */
 	int		(*tran_reset)();						/* target/bus reset */
 	int		(*tran_abort)();						/* command abort */
 	int		(*tran_getcap)();						/* get capability */
 	int		(*tran_setcap)();						/* set capability */
 	struct 	scsi_pkt	*(*tran_init_pkt)();	/* allocate scsi pkt */
 	void		(*tran_destroy_pkt)();				/* free scsi pkt */
 	void		(*tran_dmafree)();					/* free dma resources */
 	void		(*tran_sync_pkt)();					/* sync data after dma */
 	void		(*tran_reset_notify)();			/* bus reset notification */

Note -

Code fragments presented subsequently in this chapter use these fields to describe practical HBA driver operations. See "SCSA HBA Entry Points" for more information.


tran_hba_dip is a pointer to the HBA device instance dev_info structure. The function scsi_hba_attach_setup(9F) sets this field.

tran_hba_private is a pointer to private data maintained by the HBA driver. Usually, tran_hba_private contains a pointer to the state structure of the HBA driver.

tran_tgt_private is a pointer to private data maintained by the HBA driver when using cloning. By specifying SCSI_HBA_TRAN_CLONE when calling scsi_hba_attach_setup(9F), the scsi_hba_tran(9S) structure is cloned once per target, permitting the HBA to initialize this field to point to a per-target instance data structure in the tran_tgt_init(9E) entry point. If SCSI_HBA_TRAN_CLONE is not specified, tran_tgt_private is NULL and must not be referenced. See "Transport Structure Cloning (optional)" for more information.

tran_sd is a pointer to a per-target instance scsi_device(9S) structure used when cloning. If SCSI_HBA_TRAN_CLONE is passed to scsi_hba_attach_setup(9F), tran_sd is initialized to point to the per-target scsi_device structure before any HBA functions are called on behalf of that target. If SCSI_HBA_TRAN_CLONE is not specified, tran_sd is NULL and must not be referenced. See "Transport Structure Cloning (optional)" for more information.

tran_tgt_init is a pointer to the HBA driver entry point called when initializing a target device instance. If no per-target initialization is required, the HBA may leave tran_tgt_init set to NULL.

tran_tgt_probe is a pointer to the HBA driver entry point called when a target driver instance calls scsi_probe(9F) to probe for the existence of a target device. If no target probing customization is required for this HBA, the HBA should set tran_tgt_probe to scsi_hba_probe(9F).

tran_tgt_free is a pointer to the HBA driver entry point called when a target device instance is destroyed. If no per-target deallocation is necessary, the HBA may leave tran_tgt_free set to NULL.

tran_start is a pointer to the HBA driver entry point called when a target driver calls scsi_transport(9F).

tran_reset is a pointer to the HBA driver entry point called when a target driver calls scsi_reset(9F).

tran_abort is a pointer to the HBA driver entry point called when a target driver calls scsi_abort(9F).

tran_getcap is a pointer to the HBA driver entry point called when a target driver calls scsi_getcap(9F).

tran_setcap is a pointer to the HBA driver entry point called when a target driver calls scsi_setcap(9F).

tran_init_pkt is a pointer to the HBA driver entry point called when a target driver calls scsi_init_pkt(9F).

tran_destroy_pkt is a pointer to the HBA driver entry point called when a target driver calls scsi_destroy_pkt(9F).

tran_dmafree is a pointer to the HBA driver entry point called when a target driver calls scsi_dmafree(9F).

tran_sync_pkt is a pointer to the HBA driver entry point called when a target driver calls scsi_sync_pkt(9F).

tran_reset_notify is a pointer to the HBA driver entry point called when a target driver calls tran_reset_notify(9F).