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 */
};

where:

pkt_ha_private

Pointer to per-command HBA-driver private data.

pkt_address

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

pkt_private

Pointer to per-packet target-driver private data.

pkt_comp

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

pkt_flags

Flags for the command.

pkt_time

Specifies the completion timeout in seconds for the command.

pkt_scbp

Pointer to the status completion block for the command.

pkt_cdbp

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

pkt_resid

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.

pkt_state

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

pkt_statistics

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

pkt_reason

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