Writing Device Drivers

scsi_hba_tran() Structure

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


Caution – Caution –

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


The SCSA interfaces require the HBA driver to supply a number of entry points that are callable through the scsi_hba_tran structure. See Entry Points for SCSA HBA Drivers for more information.

The scsi_hba_tran structure contains the following fields:

struct scsi_hba_tran {
    dev_info_t          *tran_hba_dip;          /* HBAs dev_info pointer */
    void                *tran_hba_private;      /* HBA softstate */
    void                *tran_tgt_private;      /* HBA target private pointer */
    struct scsi_device  *tran_sd;               /* scsi_device */
    int                 (*tran_tgt_init)();     /* Transport target */
                                                /* Initialization */
    int                 (*tran_tgt_probe)();    /* Transport target probe */
    void                (*tran_tgt_free)();     /* Transport target free */
    int                 (*tran_start)();        /* Transport start */
    int                 (*tran_reset)();        /* Transport reset */
    int                 (*tran_abort)();        /* Transport abort */
    int                 (*tran_getcap)();       /* Capability retrieval */
    int                 (*tran_setcap)();       /* Capability establishment */
    struct scsi_pkt     *(*tran_init_pkt)();    /* Packet and DMA allocation */
    void                (*tran_destroy_pkt)();  /* Packet and DMA */
                                                /* Deallocation */
    void                (*tran_dmafree)();      /* DMA deallocation */
    void                (*tran_sync_pkt)();     /* Sync DMA */
    void                (*tran_reset_notify)(); /* Bus reset notification */
    int                 (*tran_bus_reset)();    /* Reset bus only */
    int                 (*tran_quiesce)();      /* Quiesce a bus */
    int                 (*tran_unquiesce)();    /* Unquiesce a bus */
    int                 tran_interconnect_type; /* transport interconnect */
};

The following descriptions give more information about these scsi_hba_tran structure fields:

tran_hba_dip

Pointer to the HBA device instance dev_info structure. The function scsi_hba_attach_setup(9F) sets this field.

tran_hba_private

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

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. This approach enables 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 tran_tgt_private must not be referenced. See Transport Structure Cloning for more information.

tran_sd

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. This initialization takes place before any HBA functions are called on behalf of that target. If SCSI_HBA_TRAN_CLONE is not specified, tran_sd is NULL, and tran_sd must not be referenced. See Transport Structure Cloning for more information.

tran_tgt_init

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

tran_tgt_probe

Pointer to the HBA driver entry point that is called when a target driver instance calls scsi_probe(9F). This routine is called 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

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

tran_start

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

tran_reset

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

tran_abort

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

tran_getcap

Pointer to the HBA driver entry point that is called when a target driver calls scsi_ifgetcap(9F).

tran_setcap

Pointer to the HBA driver entry point that is called when a target driver calls scsi_ifsetcap(9F).

tran_init_pkt

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

tran_destroy_pkt

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

tran_dmafree

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

tran_sync_pkt

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

tran_reset_notify

Pointer to the HBA driver entry point that is called when a target driver calls tran_reset_notify(9E).

tran_bus_reset

The function entry that resets the SCSI bus without resetting targets.

tran_quiesce

The function entry that waits for all outstanding commands to complete and blocks (or queues) any I/O requests issued.

tran_unquiesce

The function entry that allows I/O activities to resume on the SCSI bus.

tran_interconnect_type

Integer value denoting interconnect type of the transport as defined in the services.h header file.