Writing Device Drivers

scsi_pkt Structure (HBA)

To execute SCSI commands, a target driver must first allocate a scsi_pkt(9S) structure for the command. The target driver must then specify its own private data area length, the command status, and the command length. The HBA driver is responsible for implementing the packet allocation in the tran_init_pkt(9E) entry point. The HBA driver is also responsible for freeing the packet in its tran_destroy_pkt(9E) entry point. See scsi_pkt Structure (Target Drivers) for more information.

The scsi_pkt(9S) structure contains these fields:

struct scsi_pkt {
    opaque_t pkt_ha_private;             /* private data for host adapter */
    struct scsi_address pkt_address;     /* destination address */
    opaque_t pkt_private;                /* private data for target driver */
    void (*pkt_comp)(struct scsi_pkt *); /* completion routine */
    uint_t  pkt_flags;                   /* flags */
    int     pkt_time;                    /* time allotted to complete command */
    uchar_t *pkt_scbp;                   /* pointer to status block */
    uchar_t *pkt_cdbp;                   /* pointer to command block */
    ssize_t pkt_resid;                   /* data bytes not transferred */
    uint_t  pkt_state;                   /* state of command */
    uint_t  pkt_statistics;              /* statistics */
    uchar_t pkt_reason;                  /* reason completion called */



Pointer to per-command HBA-driver private data.


Pointer to the scsi_address(9S) structure providing address information for this command.


Pointer to per-packet target-driver private data.


Pointer to the target-driver completion routine called by the HBA driver when the transport layer has completed this command.


Flags for the command.


Specifies the completion timeout in seconds for the command.


Pointer to the status completion block for the command.


Pointer to the command descriptor block (CDB) for the command.


Count of the data bytes that were not transferred when the command completed. This field can also be used to specify the amount of data for which resources have not been allocated. The HBA must modify this field during transport.


State of the command. The HBA must modify this field during transport.


Provides a history of the events that the command experienced while in the transport layer. The HBA must modify this field during transport.


Reason for command completion. The HBA must modify this field during transport.