Home | History | Annotate | Line # | Download | only in ic
isp_tpublic.h revision 1.15
      1  1.15  mjacob /* $NetBSD: isp_tpublic.h,v 1.15 2007/05/24 21:30:43 mjacob Exp $ */
      2   1.4  mjacob /*
      3  1.15  mjacob  * Copyright (c) 1997-2006 by Matthew Jacob
      4   1.1  mjacob  * All rights reserved.
      5   1.1  mjacob  *
      6   1.1  mjacob  * Redistribution and use in source and binary forms, with or without
      7   1.1  mjacob  * modification, are permitted provided that the following conditions
      8   1.1  mjacob  * are met:
      9  1.15  mjacob  *
     10   1.1  mjacob  * 1. Redistributions of source code must retain the above copyright
     11  1.15  mjacob  *    notice, this list of conditions and the following disclaimer.
     12  1.15  mjacob  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.15  mjacob  *    notice, this list of conditions and the following disclaimer in the
     14  1.15  mjacob  *    documentation and/or other materials provided with the distribution.
     15  1.15  mjacob  *
     16  1.15  mjacob  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     17   1.1  mjacob  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18   1.1  mjacob  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19  1.15  mjacob  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
     20  1.15  mjacob  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21   1.1  mjacob  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22   1.1  mjacob  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23   1.1  mjacob  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24   1.1  mjacob  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25   1.1  mjacob  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26   1.1  mjacob  * SUCH DAMAGE.
     27   1.1  mjacob  */
     28  1.15  mjacob /*
     29  1.15  mjacob  * Host Adapter Public Target Interface Structures && Routines
     30  1.15  mjacob  */
     31  1.15  mjacob 
     32  1.15  mjacob #ifndef    _ISP_TPUBLIC_H
     33  1.15  mjacob #define    _ISP_TPUBLIC_H    1
     34  1.15  mjacob 
     35  1.15  mjacob /*
     36  1.15  mjacob  * Action codes set by the MD target driver for
     37  1.15  mjacob  * the external layer to figure out what to do with.
     38  1.15  mjacob  */
     39  1.15  mjacob typedef enum {
     40  1.15  mjacob     QOUT_HBA_REG=0,     /* the argument is a pointer to a hba_register_t */
     41  1.15  mjacob     QOUT_ENABLE,        /* the argument is a pointer to a enadis_t */
     42  1.15  mjacob     QOUT_DISABLE,       /* the argument is a pointer to a enadis_t */
     43  1.15  mjacob     QOUT_TMD_START,     /* the argument is a pointer to a tmd_cmd_t */
     44  1.15  mjacob     QOUT_TMD_DONE,      /* the argument is a pointer to a tmd_cmd_t */
     45  1.15  mjacob     QOUT_NOTIFY,        /* the argument is a pointer to a tmd_notify_t */
     46  1.15  mjacob     QOUT_HBA_UNREG      /* the argument is a pointer to a hba_register_t */
     47  1.15  mjacob } tact_e;
     48  1.15  mjacob 
     49  1.15  mjacob /*
     50  1.15  mjacob  * Action codes set by the external layer for the
     51  1.15  mjacob  * MD driver to figure out what to do with.
     52  1.15  mjacob  */
     53  1.15  mjacob typedef enum {
     54  1.15  mjacob     QIN_HBA_REG=99,     /* the argument is a pointer to a hba_register_t */
     55  1.15  mjacob     QIN_GETINFO,        /* the argument is a pointer to a info_t */
     56  1.15  mjacob     QIN_SETINFO,        /* the argument is a pointer to a info_t */
     57  1.15  mjacob     QIN_GETDLIST,       /* the argument is a pointer to a fc_dlist_t */
     58  1.15  mjacob     QIN_ENABLE,         /* the argument is a pointer to a enadis_t */
     59  1.15  mjacob     QIN_DISABLE,        /* the argument is a pointer to a enadis_t */
     60  1.15  mjacob     QIN_TMD_CONT,       /* the argument is a pointer to a tmd_cmd_t */
     61  1.15  mjacob     QIN_TMD_FIN,        /* the argument is a pointer to a tmd_cmd_t */
     62  1.15  mjacob     QIN_NOTIFY_ACK,     /* the argument is a pointer to a tmd_notify_t */
     63  1.15  mjacob     QIN_HBA_UNREG,      /* the argument is a pointer to a hba_register_t */
     64  1.15  mjacob } qact_e;
     65  1.15  mjacob 
     66  1.15  mjacob /*
     67  1.15  mjacob  * This structure is used to register to other software modules the
     68  1.15  mjacob  * binding of an HBA identifier, driver name and instance and the
     69  1.15  mjacob  * lun width capapbilities of this target driver. It's up to each
     70  1.15  mjacob  * platform to figure out how it wants to do this, but a typical
     71  1.15  mjacob  * sequence would be for the MD layer to find some external module's
     72  1.15  mjacob  * entry point and start by sending a QOUT_HBA_REG with info filled
     73  1.15  mjacob  * in, and the external module to call back with a QIN_HBA_REG that
     74  1.15  mjacob  * passes back the corresponding information.
     75  1.15  mjacob  */
     76  1.15  mjacob #define    QR_VERSION    16
     77  1.15  mjacob typedef struct {
     78  1.15  mjacob     /* NB: tags from here to r_version must never change */
     79  1.15  mjacob     void *                  r_identity;
     80  1.15  mjacob     void                    (*r_action)(qact_e, void *);
     81  1.15  mjacob     char                    r_name[8];
     82  1.15  mjacob     int                     r_inst;
     83  1.15  mjacob     int                     r_version;
     84  1.15  mjacob     uint32_t                r_locator;
     85  1.15  mjacob     uint32_t                r_nchannels;
     86  1.15  mjacob     enum { R_FC, R_SPI }    r_type;
     87  1.15  mjacob     void *                  r_private;
     88  1.15  mjacob } hba_register_t;
     89   1.1  mjacob 
     90   1.1  mjacob /*
     91  1.15  mjacob  * An information structure that is used to get or set per-channel transport layer parameters.
     92   1.1  mjacob  */
     93  1.15  mjacob typedef struct {
     94  1.15  mjacob     void *                  i_identity;
     95  1.15  mjacob     enum { I_FC, I_SPI }    i_type;
     96  1.15  mjacob     int                     i_channel;
     97  1.15  mjacob     int                     i_error;
     98  1.15  mjacob     union {
     99  1.15  mjacob         struct {
    100  1.15  mjacob             uint64_t    wwnn_nvram;
    101  1.15  mjacob             uint64_t    wwpn_nvram;
    102  1.15  mjacob             uint64_t    wwnn;
    103  1.15  mjacob             uint64_t    wwpn;
    104  1.15  mjacob         } fc;
    105  1.15  mjacob         struct {
    106  1.15  mjacob             int         iid;
    107  1.15  mjacob         } spi;
    108  1.15  mjacob     }                       i_id;
    109  1.15  mjacob } info_t;
    110   1.1  mjacob 
    111  1.15  mjacob /*
    112  1.15  mjacob  * An information structure to return a list of logged in WWPNs. FC specific.
    113  1.15  mjacob  */
    114   1.1  mjacob typedef struct {
    115  1.15  mjacob     void *                  d_identity;
    116  1.15  mjacob     int                     d_channel;
    117  1.15  mjacob     int                     d_error;
    118  1.15  mjacob     int                     d_count;
    119  1.15  mjacob     uint64_t *              d_wwpns;
    120  1.15  mjacob } fc_dlist_t;
    121  1.15  mjacob /*
    122  1.15  mjacob  * Notify structure
    123  1.15  mjacob  */
    124  1.15  mjacob typedef enum {
    125  1.15  mjacob     NT_ABORT_TASK=0x1000,
    126  1.15  mjacob     NT_ABORT_TASK_SET,
    127  1.15  mjacob     NT_CLEAR_ACA,
    128  1.15  mjacob     NT_CLEAR_TASK_SET,
    129  1.15  mjacob     NT_LUN_RESET,
    130  1.15  mjacob     NT_TARGET_RESET,
    131  1.15  mjacob     NT_BUS_RESET,
    132  1.15  mjacob     NT_LIP_RESET,
    133  1.15  mjacob     NT_LINK_UP,
    134  1.15  mjacob     NT_LINK_DOWN,
    135  1.15  mjacob     NT_LOGOUT,
    136  1.15  mjacob     NT_HBA_RESET
    137  1.15  mjacob } tmd_ncode_t;
    138  1.15  mjacob 
    139  1.15  mjacob typedef struct tmd_notify {
    140  1.15  mjacob     void *      nt_hba;         /* HBA tag */
    141  1.15  mjacob     uint64_t    nt_iid;         /* inititator id */
    142  1.15  mjacob     uint64_t    nt_tgt;         /* target id */
    143  1.15  mjacob     uint16_t    nt_lun;         /* logical unit */
    144  1.15  mjacob     uint16_t                : 15,
    145  1.15  mjacob                 nt_need_ack : 1;    /* this notify needs an ACK */
    146  1.15  mjacob     uint64_t    nt_tagval;      /* tag value */
    147  1.15  mjacob     uint32_t    nt_channel;     /* channel id */
    148  1.15  mjacob     tmd_ncode_t nt_ncode;       /* action */
    149  1.15  mjacob     void *      nt_lreserved;
    150  1.15  mjacob     void *      nt_hreserved;
    151  1.15  mjacob } tmd_notify_t;
    152  1.15  mjacob #define LUN_ANY     0xffff
    153  1.15  mjacob #define TGT_ANY     ((uint64_t) -1)
    154  1.15  mjacob #define INI_ANY     ((uint64_t) -1)
    155  1.15  mjacob #define TAG_ANY     ((uint64_t) 0)
    156  1.15  mjacob #define MATCH_TMD(tmd, iid, lun, tag)                   \
    157  1.15  mjacob     (                                                   \
    158  1.15  mjacob         (tmd) &&                                        \
    159  1.15  mjacob         (iid == INI_ANY || iid == tmd->cd_iid) &&       \
    160  1.15  mjacob         (lun == LUN_ANY || lun == tmd->cd_lun) &&       \
    161  1.15  mjacob         (tag == TAG_ANY || tag == tmd->cd_tagval)       \
    162  1.15  mjacob     )
    163   1.1  mjacob 
    164  1.15  mjacob /*
    165  1.15  mjacob  * A word about ENABLE/DISABLE: the argument is a pointer to a enadis_t
    166  1.15  mjacob  * with en_hba, en_iid, en_chan, en_tgt and en_lun filled out.
    167  1.15  mjacob  *
    168  1.15  mjacob  * If an error occurs in either enabling or disabling the described lun
    169  1.15  mjacob  * cd_error is set with an appropriate non-zero value.
    170  1.15  mjacob  */
    171   1.1  mjacob typedef struct {
    172  1.15  mjacob     void *          en_private;     /* for outer layer usage */
    173  1.15  mjacob     void *          en_hba;         /* HBA tag */
    174  1.15  mjacob     uint64_t        en_iid;         /* initiator ID */
    175  1.15  mjacob     uint64_t        en_tgt;         /* target id */
    176  1.15  mjacob     uint16_t        en_lun;         /* logical unit */
    177  1.15  mjacob     uint16_t        en_chan;        /* channel on card */
    178  1.15  mjacob     int             en_error;
    179  1.15  mjacob } enadis_t;
    180   1.1  mjacob 
    181   1.1  mjacob /*
    182   1.3      he  * Suggested Software Target Mode Command Handling structure.
    183   1.1  mjacob  *
    184   1.3      he  * A note about terminology:
    185   1.3      he  *
    186   1.3      he  *   MD stands for "Machine Dependent".
    187   1.3      he  *
    188   1.3      he  *    This driver is structured in three layers: Outer MD, core, and inner MD.
    189   1.3      he  *    The latter also is bus dependent (i.e., is cognizant of PCI bus issues
    190   1.3      he  *    as well as platform issues).
    191   1.3      he  *
    192   1.3      he  *
    193   1.3      he  *   "Outer Layer" means "Other Module"
    194   1.3      he  *
    195   1.3      he  *    Some additional module that actually implements SCSI target command
    196   1.3      he  *    policy is the recipient of incoming commands and the source of the
    197   1.3      he  *    disposition for them.
    198   1.3      he  *
    199   1.3      he  * The command structure below is one suggested possible MD command structure,
    200   1.3      he  * but since the handling of thbis is entirely in the MD layer, there is
    201   1.3      he  * no explicit or implicit requirement that it be used.
    202   1.1  mjacob  *
    203   1.1  mjacob  * The cd_private tag should be used by the MD layer to keep a free list
    204   1.1  mjacob  * of these structures. Code outside of this driver can then use this
    205   1.9  mjacob  * to identify it's own unit structures. That is, when not on the MD
    206   1.1  mjacob  * layer's freelist, the MD layer should shove into it the identifier
    207   1.1  mjacob  * that the outer layer has for it- passed in on an initial QIN_HBA_REG
    208   1.1  mjacob  * call (see below).
    209   1.1  mjacob  *
    210   1.1  mjacob  * The cd_hba tag is a tag that uniquely identifies the HBA this target
    211   1.1  mjacob  * mode command is coming from. The outer layer has to pass this back
    212   1.1  mjacob  * unchanged to avoid chaos.
    213   1.1  mjacob  *
    214  1.15  mjacob  * The cd_iid, cd_tgt, cd_lun and cd_port tags are used to identify the
    215   1.1  mjacob  * id of the initiator who sent us a command, the target claim to be, the
    216  1.15  mjacob  * lun on the target we claim to be, and the port instance (for multiple
    217  1.15  mjacob  * port host adapters) that this applies to (consider it an extra port
    218   1.1  mjacob  * parameter). The iid, tgt and lun values are deliberately chosen to be
    219   1.1  mjacob  * fat so that, for example, World Wide Names can be used instead of
    220  1.15  mjacob  * the units that the firmware uses (in the case where the MD
    221   1.1  mjacob  * layer maintains a port database, for example).
    222   1.1  mjacob  *
    223  1.15  mjacob  * The cd_tagtype field specifies what kind of command tag type, if
    224  1.15  mjacob  * any, has been sent with the command. Note that the Outer Layer
    225  1.15  mjacob  * still needs to pass the tag handle through unchanged even
    226  1.15  mjacob  * if the tag type is CD_UNTAGGED.
    227   1.1  mjacob  *
    228   1.1  mjacob  * The cd_cdb contains storage for the passed in command descriptor block.
    229  1.15  mjacob  * There is no need to define length as the callee should be able to
    230  1.15  mjacob  * figure this out.
    231   1.1  mjacob  *
    232   1.1  mjacob  * The tag cd_lflags are the flags set by the MD driver when it gets
    233   1.1  mjacob  * command incoming or when it needs to inform any outside entities
    234   1.1  mjacob  * that the last requested action failed.
    235   1.1  mjacob  *
    236   1.1  mjacob  * The tag cd_hflags should be set by any outside software to indicate
    237   1.1  mjacob  * the validity of sense and status fields (defined below) and to indicate
    238   1.1  mjacob  * the direction data is expected to move. It is an error to have both
    239   1.1  mjacob  * CDFH_DATA_IN and CDFH_DATA_OUT set.
    240   1.1  mjacob  *
    241   1.1  mjacob  * If the CDFH_STSVALID flag is set, the command should be completed (after
    242   1.1  mjacob  * sending any data and/or status). If CDFH_SNSVALID is set and the MD layer
    243   1.1  mjacob  * can also handle sending the associated sense data (either back with an
    244   1.1  mjacob  * FCP RESPONSE IU for Fibre Channel or otherwise automatically handling a
    245   1.1  mjacob  * REQUEST SENSE from the initator for this target/lun), the MD layer will
    246   1.1  mjacob  * set the CDFL_SENTSENSE flag on successful transmission of the sense data.
    247   1.1  mjacob  * It is an error for the CDFH_SNSVALID bit to be set and CDFH_STSVALID not
    248   1.1  mjacob  * to be set. It is an error for the CDFH_SNSVALID be set and the associated
    249   1.1  mjacob  * SCSI status (cd_scsi_status) not be set to CHECK CONDITON.
    250  1.15  mjacob  *
    251   1.1  mjacob  * The tag cd_data points to a data segment to either be filled or
    252   1.1  mjacob  * read from depending on the direction of data movement. The tag
    253   1.1  mjacob  * is undefined if no data direction is set. The MD layer and outer
    254  1.15  mjacob  * layers must agree on the meaning of cd_data and it is specifically
    255  1.15  mjacob  * not defined here.
    256   1.1  mjacob  *
    257   1.1  mjacob  * The tag cd_totlen is the total data amount expected to be moved
    258  1.15  mjacob  * over the life of the command. It may be set by the MD layer, possibly
    259   1.3      he  * from the datalen field of an FCP CMND IU unit. If it shows up in the outer
    260   1.3      he  * layers set to zero and the CDB indicates data should be moved, the outer
    261   1.3      he  * layer should set it to the amount expected to be moved.
    262   1.1  mjacob  *
    263   1.2  mjacob  * The tag cd_resid should be the total residual of data not transferred.
    264  1.15  mjacob  * The outer layers need to set this at the begining of command processing
    265   1.2  mjacob  * to equal cd_totlen. As data is successfully moved, this value is decreased.
    266   1.2  mjacob  * At the end of a command, any nonzero residual indicates the number of bytes
    267  1.15  mjacob  * requested by the command but not moved.
    268   1.1  mjacob  *
    269   1.1  mjacob  * The tag cd_xfrlen is the length of the currently active data transfer.
    270   1.1  mjacob  * This allows several interations between any outside software and the
    271   1.1  mjacob  * MD layer to move data.
    272   1.1  mjacob  *
    273   1.1  mjacob  * The reason that total length and total residual have to be tracked
    274  1.15  mjacob  * is to keep track of relative offset.
    275   1.1  mjacob  *
    276   1.1  mjacob  * The tags cd_sense and cd_scsi_status are pretty obvious.
    277   1.1  mjacob  *
    278   1.1  mjacob  * The tag cd_error is to communicate between the MD layer and outer software
    279   1.1  mjacob  * the current error conditions.
    280   1.1  mjacob  *
    281  1.10  mjacob  * The tag cd_lreserved, cd_hreserved are scratch areas for use for the MD
    282  1.10  mjacob  * and outer layers respectively.
    283  1.15  mjacob  *
    284   1.1  mjacob  */
    285   1.1  mjacob 
    286  1.15  mjacob #ifndef    TMD_CDBLEN
    287  1.15  mjacob #define    TMD_CDBLEN       16
    288  1.10  mjacob #endif
    289  1.15  mjacob #ifndef    TMD_SENSELEN
    290  1.15  mjacob #define    TMD_SENSELEN     18
    291   1.1  mjacob #endif
    292  1.15  mjacob #ifndef    QCDS
    293  1.15  mjacob #define    QCDS             (sizeof (void *))
    294   1.1  mjacob #endif
    295   1.1  mjacob 
    296   1.1  mjacob typedef struct tmd_cmd {
    297  1.15  mjacob     void *              cd_private; /* private data pointer */
    298  1.15  mjacob     void *              cd_hba;     /* HBA tag */
    299  1.15  mjacob     void *              cd_data;    /* 'pointer' to data */
    300  1.15  mjacob     uint64_t            cd_iid;     /* initiator ID */
    301  1.15  mjacob     uint64_t            cd_tgt;     /* target id */
    302  1.15  mjacob     uint8_t             cd_lun[8];  /* logical unit */
    303  1.15  mjacob     uint64_t            cd_tagval;  /* tag value */
    304  1.15  mjacob     uint32_t            cd_channel; /* channel index */
    305  1.15  mjacob     uint32_t            cd_lflags;  /* flags lower level sets */
    306  1.15  mjacob     uint32_t            cd_hflags;  /* flags higher level sets */
    307  1.15  mjacob     uint32_t            cd_totlen;  /* total data load */
    308  1.15  mjacob     uint32_t            cd_resid;   /* total data residual */
    309  1.15  mjacob     uint32_t            cd_xfrlen;  /* current data load */
    310  1.15  mjacob     int32_t             cd_error;   /* current error */
    311  1.15  mjacob     uint8_t             cd_tagtype; /* tag type */
    312  1.15  mjacob     uint8_t             cd_scsi_status;
    313  1.15  mjacob     uint8_t             cd_sense[TMD_SENSELEN];
    314  1.15  mjacob     uint8_t             cd_cdb[TMD_CDBLEN];
    315  1.15  mjacob     union {
    316  1.15  mjacob         void *          ptrs[QCDS / sizeof (void *)];
    317  1.15  mjacob         uint64_t        llongs[QCDS / sizeof (uint64_t)];
    318  1.15  mjacob         uint32_t        longs[QCDS / sizeof (uint32_t)];
    319  1.15  mjacob         uint16_t        shorts[QCDS / sizeof (uint16_t)];
    320  1.15  mjacob         uint8_t         bytes[QCDS];
    321  1.15  mjacob     } cd_lreserved[4], cd_hreserved[4];
    322   1.1  mjacob } tmd_cmd_t;
    323   1.1  mjacob 
    324  1.15  mjacob /* defined tags */
    325  1.15  mjacob #define CD_UNTAGGED     0
    326  1.15  mjacob #define CD_SIMPLE_TAG   1
    327  1.15  mjacob #define CD_ORDERED_TAG  2
    328  1.15  mjacob #define CD_HEAD_TAG     3
    329  1.15  mjacob #define CD_ACA_TAG      4
    330  1.15  mjacob 
    331  1.15  mjacob #ifndef    TMD_SIZE
    332  1.15  mjacob #define    TMD_SIZE     (sizeof (tmd_cmd_t))
    333  1.10  mjacob #endif
    334  1.10  mjacob 
    335  1.15  mjacob #define L0LUN_TO_FLATLUN(lptr)              ((((lptr)[0] & 0x3f) << 8) | ((lptr)[1]))
    336  1.15  mjacob #define FLATLUN_TO_L0LUN(lptr, lun)                 \
    337  1.15  mjacob     (lptr)[1] = lun & 0xff;                         \
    338  1.15  mjacob     if (sizeof (lun) == 1) {                        \
    339  1.15  mjacob         (lptr)[0] = 0;                              \
    340  1.15  mjacob     } else {                                        \
    341  1.15  mjacob         uint16_t nl = lun;                          \
    342  1.15  mjacob         if (nl == LUN_ANY) {                        \
    343  1.15  mjacob             (lptr)[0] = (nl >> 8) & 0xff;           \
    344  1.15  mjacob         } else if (nl < 256) {                      \
    345  1.15  mjacob             (lptr)[0] = 0;                          \
    346  1.15  mjacob         } else {                                    \
    347  1.15  mjacob             (lptr)[0] = 0x40 | ((nl >> 8) & 0x3f);  \
    348  1.15  mjacob         }                                           \
    349  1.15  mjacob     }                                               \
    350  1.15  mjacob     memset(&(lptr)[2], 0, 6)
    351  1.15  mjacob 
    352  1.10  mjacob /*
    353  1.10  mjacob  * Note that NODISC (obviously) doesn't apply to non-SPI transport.
    354  1.10  mjacob  *
    355  1.10  mjacob  * Note that knowing the data direction and lengh at the time of receipt of
    356  1.10  mjacob  * a command from the initiator is a feature only of Fibre Channel.
    357  1.10  mjacob  *
    358  1.10  mjacob  * The CDFL_BIDIR is in anticipation of the adoption of some newer
    359  1.10  mjacob  * features required by OSD.
    360  1.10  mjacob  *
    361  1.10  mjacob  * The principle selector for MD layer to know whether data is to
    362  1.10  mjacob  * be transferred in any QOUT_TMD_CONT call is cd_xfrlen- the
    363  1.10  mjacob  * flags CDFH_DATA_IN and CDFH_DATA_OUT define which direction.
    364  1.10  mjacob  */
    365  1.15  mjacob #define    CDFL_SNSVALID        0x01            /* sense data (from f/w) good */
    366  1.15  mjacob #define    CDFL_SENTSTATUS      0x02            /* last action sent status */
    367  1.15  mjacob #define    CDFL_DATA_IN         0x04            /* target (us) -> initiator (them) */
    368  1.15  mjacob #define    CDFL_DATA_OUT        0x08            /* initiator (them) -> target (us) */
    369  1.15  mjacob #define    CDFL_BIDIR           0x0C            /* bidirectional data */
    370  1.15  mjacob #define    CDFL_ERROR           0x10            /* last action ended in error */
    371  1.15  mjacob #define    CDFL_NODISC          0x20            /* disconnects disabled */
    372  1.15  mjacob #define    CDFL_SENTSENSE       0x40            /* last action sent sense data */
    373  1.15  mjacob #define    CDFL_BUSY            0x80            /* this command is not on a free list */
    374  1.15  mjacob #define    CDFL_PRIVATE         0xFF000000      /* private layer flags */
    375  1.15  mjacob 
    376  1.15  mjacob #define    CDFH_SNSVALID        0x01            /* sense data (from outer layer) good */
    377  1.15  mjacob #define    CDFH_STSVALID        0x02            /* status valid */
    378  1.15  mjacob #define    CDFH_DATA_IN         0x04            /* target (us) -> initiator (them) */
    379  1.15  mjacob #define    CDFH_DATA_OUT        0x08            /* initiator (them) -> target (us) */
    380  1.15  mjacob #define    CDFH_DATA_MASK       0x0C            /* mask to cover data direction */
    381  1.15  mjacob #define    CDFH_PRIVATE         0xFF000000      /* private layer flags */
    382   1.1  mjacob 
    383  1.10  mjacob 
    384   1.1  mjacob /*
    385   1.1  mjacob  * A word about the START/CONT/DONE/FIN dance:
    386   1.1  mjacob  *
    387  1.15  mjacob  *    When the HBA is enabled for receiving commands, one may show up
    388  1.15  mjacob  *    without notice. When that happens, the MD target mode driver
    389  1.15  mjacob  *    gets a tmd_cmd_t, fills it with the info that just arrived, and
    390  1.15  mjacob  *    calls the outer layer with a QOUT_TMD_START code and pointer to
    391  1.15  mjacob  *    the tmd_cmd_t.
    392  1.15  mjacob  *
    393  1.15  mjacob  *    The outer layer decodes the command, fetches data, prepares stuff,
    394  1.15  mjacob  *    whatever, and starts by passing back the pointer with a QIN_TMD_CONT
    395  1.15  mjacob  *    code which causes the MD target mode driver to generate CTIOs to
    396  1.15  mjacob  *    satisfy whatever action needs to be taken. When those CTIOs complete,
    397  1.15  mjacob  *    the MD target driver sends the pointer to the cmd_tmd_t back with
    398  1.15  mjacob  *    a QOUT_TMD_DONE code. This repeats for as long as necessary. These
    399  1.15  mjacob  *    may not be done in parallel- they are sequential operations.
    400  1.15  mjacob  *
    401  1.15  mjacob  *    The outer layer signals it wants to end the command by settings within
    402  1.15  mjacob  *    the tmd_cmd_t itself. When the final QIN_TMD_CONT is reported completed,
    403  1.15  mjacob  *    the outer layer frees the tmd_cmd_t by sending the pointer to it
    404  1.15  mjacob  *    back with a QIN_TMD_FIN code.
    405   1.1  mjacob  *
    406  1.15  mjacob  *    The graph looks like:
    407   1.1  mjacob  *
    408  1.15  mjacob  *    QOUT_TMD_START -> [ QIN_TMD_CONT -> QOUT_TMD_DONE ] * -> QIN_TMD_FIN.
    409   1.3      he  *
    410   1.3      he  */
    411   1.3      he 
    412   1.3      he /*
    413  1.10  mjacob  * Target handler functions.
    414  1.10  mjacob  *
    415  1.10  mjacob  * The MD target handler function (the outer layer calls this)
    416  1.10  mjacob  * should be be prototyped like:
    417  1.10  mjacob  *
    418  1.15  mjacob  *    void target_action(qact_e, void *arg)
    419  1.10  mjacob  *
    420  1.10  mjacob  * The outer layer target handler function (the MD layer calls this)
    421  1.10  mjacob  * should be be prototyped like:
    422  1.10  mjacob  *
    423  1.15  mjacob  *    void scsi_target_handler(tact_e, void *arg)
    424  1.15  mjacob  */
    425  1.15  mjacob #endif    /* _ISP_TPUBLIC_H */
    426  1.15  mjacob /*
    427  1.15  mjacob  * vim:ts=4:sw=4:expandtab
    428  1.10  mjacob  */
    429