Home | History | Annotate | Line # | Download | only in ic
isp_tpublic.h revision 1.13.4.2
      1  1.13.4.2    yamt /* $NetBSD: isp_tpublic.h,v 1.13.4.2 2008/03/17 09:14:42 yamt Exp $ */
      2  1.13.4.2    yamt /*-
      3  1.13.4.2    yamt  *  Copyright (c) 1997-2008 by Matthew Jacob
      4  1.13.4.2    yamt  *  All rights reserved.
      5  1.13.4.1    yamt  *
      6  1.13.4.2    yamt  *  Redistribution and use in source and binary forms, with or without
      7  1.13.4.2    yamt  *  modification, are permitted provided that the following conditions
      8  1.13.4.2    yamt  *  are met:
      9  1.13.4.1    yamt  *
     10  1.13.4.2    yamt  *  1. Redistributions of source code must retain the above copyright
     11  1.13.4.2    yamt  *     notice, this list of conditions and the following disclaimer.
     12  1.13.4.2    yamt  *  2. Redistributions in binary form must reproduce the above copyright
     13  1.13.4.2    yamt  *     notice, this list of conditions and the following disclaimer in the
     14  1.13.4.2    yamt  *     documentation and/or other materials provided with the distribution.
     15  1.13.4.2    yamt  *
     16  1.13.4.2    yamt  *  THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     17  1.13.4.2    yamt  *  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18  1.13.4.2    yamt  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19  1.13.4.2    yamt  *  ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
     20  1.13.4.2    yamt  *  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21  1.13.4.2    yamt  *  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22  1.13.4.2    yamt  *  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  1.13.4.2    yamt  *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24  1.13.4.2    yamt  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  1.13.4.2    yamt  *  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  1.13.4.2    yamt  *  SUCH DAMAGE.
     27       1.1  mjacob  */
     28  1.13.4.1    yamt /*
     29  1.13.4.1    yamt  * Host Adapter Public Target Interface Structures && Routines
     30  1.13.4.1    yamt  */
     31  1.13.4.2    yamt /*
     32  1.13.4.2    yamt  * A note about terminology:
     33  1.13.4.2    yamt  *
     34  1.13.4.2    yamt  *  "Inner Layer" means this driver (isp and the isp_tpublic API).
     35  1.13.4.2    yamt  *
     36  1.13.4.2    yamt  *    This module includes the both generic and platform specific pieces.
     37  1.13.4.2    yamt  *
     38  1.13.4.2    yamt  *  "Outer Layer" means another (external) module.
     39  1.13.4.2    yamt  *
     40  1.13.4.2    yamt  *    This is an additional module that actually implements SCSI target command
     41  1.13.4.2    yamt  *    decode and is the recipient of incoming commands and the source of the
     42  1.13.4.2    yamt  *    disposition for them.
     43  1.13.4.2    yamt  */
     44  1.13.4.1    yamt 
     45  1.13.4.1    yamt #ifndef    _ISP_TPUBLIC_H
     46  1.13.4.1    yamt #define    _ISP_TPUBLIC_H    1
     47       1.1  mjacob 
     48       1.1  mjacob /*
     49  1.13.4.2    yamt  * Action codes set by the Inner Layer for the outer layer to figure out what to do with.
     50       1.1  mjacob  */
     51  1.13.4.1    yamt typedef enum {
     52  1.13.4.1    yamt     QOUT_HBA_REG=0,     /* the argument is a pointer to a hba_register_t */
     53  1.13.4.1    yamt     QOUT_ENABLE,        /* the argument is a pointer to a enadis_t */
     54  1.13.4.1    yamt     QOUT_DISABLE,       /* the argument is a pointer to a enadis_t */
     55  1.13.4.1    yamt     QOUT_TMD_START,     /* the argument is a pointer to a tmd_cmd_t */
     56  1.13.4.2    yamt     QOUT_TMD_DONE,      /* the argument is a pointer to a tmd_xact_t */
     57  1.13.4.1    yamt     QOUT_NOTIFY,        /* the argument is a pointer to a tmd_notify_t */
     58  1.13.4.1    yamt     QOUT_HBA_UNREG      /* the argument is a pointer to a hba_register_t */
     59  1.13.4.1    yamt } tact_e;
     60       1.1  mjacob 
     61  1.13.4.1    yamt /*
     62  1.13.4.2    yamt  * Action codes set by the outer layer for the
     63  1.13.4.2    yamt  * inner layer to figure out what to do with.
     64  1.13.4.1    yamt  */
     65  1.13.4.1    yamt typedef enum {
     66  1.13.4.1    yamt     QIN_HBA_REG=99,     /* the argument is a pointer to a hba_register_t */
     67  1.13.4.1    yamt     QIN_GETINFO,        /* the argument is a pointer to a info_t */
     68  1.13.4.1    yamt     QIN_SETINFO,        /* the argument is a pointer to a info_t */
     69  1.13.4.1    yamt     QIN_GETDLIST,       /* the argument is a pointer to a fc_dlist_t */
     70  1.13.4.1    yamt     QIN_ENABLE,         /* the argument is a pointer to a enadis_t */
     71  1.13.4.1    yamt     QIN_DISABLE,        /* the argument is a pointer to a enadis_t */
     72  1.13.4.2    yamt     QIN_TMD_CONT,       /* the argument is a pointer to a tmd_xact_t */
     73  1.13.4.1    yamt     QIN_TMD_FIN,        /* the argument is a pointer to a tmd_cmd_t */
     74  1.13.4.1    yamt     QIN_NOTIFY_ACK,     /* the argument is a pointer to a tmd_notify_t */
     75  1.13.4.1    yamt     QIN_HBA_UNREG,      /* the argument is a pointer to a hba_register_t */
     76  1.13.4.1    yamt } qact_e;
     77  1.13.4.1    yamt 
     78  1.13.4.1    yamt /*
     79  1.13.4.2    yamt  * This structure is used to register to the outer layer the
     80  1.13.4.1    yamt  * binding of an HBA identifier, driver name and instance and the
     81  1.13.4.2    yamt  * lun width capapbilities of this inner layer. It's up to each
     82  1.13.4.2    yamt  * platform to figure out how it wants to actually implement this.
     83  1.13.4.2    yamt  * A typical sequence would be for the MD layer to find some external
     84  1.13.4.2    yamt  * module's entry point and start by sending a QOUT_HBA_REG with info
     85  1.13.4.2    yamt  * filled in, and the external module to call back with a QIN_HBA_REG
     86  1.13.4.2    yamt  * that passes back the corresponding information.
     87  1.13.4.2    yamt  *
     88  1.13.4.2    yamt  * The r_version tag defines the version of this API.
     89  1.13.4.1    yamt  */
     90  1.13.4.2    yamt #define    QR_VERSION    19
     91  1.13.4.1    yamt typedef struct {
     92  1.13.4.2    yamt     /* NB: structure tags from here to r_version must never change */
     93  1.13.4.1    yamt     void *                  r_identity;
     94  1.13.4.1    yamt     void                    (*r_action)(qact_e, void *);
     95  1.13.4.1    yamt     char                    r_name[8];
     96  1.13.4.1    yamt     int                     r_inst;
     97  1.13.4.1    yamt     int                     r_version;
     98  1.13.4.1    yamt     uint32_t                r_locator;
     99  1.13.4.1    yamt     uint32_t                r_nchannels;
    100  1.13.4.1    yamt     enum { R_FC, R_SPI }    r_type;
    101  1.13.4.1    yamt     void *                  r_private;
    102  1.13.4.1    yamt } hba_register_t;
    103  1.13.4.1    yamt 
    104  1.13.4.1    yamt /*
    105  1.13.4.1    yamt  * An information structure that is used to get or set per-channel transport layer parameters.
    106  1.13.4.1    yamt  */
    107  1.13.4.1    yamt typedef struct {
    108  1.13.4.1    yamt     void *                  i_identity;
    109  1.13.4.1    yamt     enum { I_FC, I_SPI }    i_type;
    110  1.13.4.1    yamt     int                     i_channel;
    111  1.13.4.1    yamt     int                     i_error;
    112  1.13.4.1    yamt     union {
    113  1.13.4.1    yamt         struct {
    114  1.13.4.1    yamt             uint64_t    wwnn_nvram;
    115  1.13.4.1    yamt             uint64_t    wwpn_nvram;
    116  1.13.4.1    yamt             uint64_t    wwnn;
    117  1.13.4.1    yamt             uint64_t    wwpn;
    118  1.13.4.1    yamt         } fc;
    119  1.13.4.1    yamt         struct {
    120  1.13.4.1    yamt             int         iid;
    121  1.13.4.1    yamt         } spi;
    122  1.13.4.1    yamt     }                       i_id;
    123  1.13.4.1    yamt } info_t;
    124  1.13.4.1    yamt 
    125  1.13.4.1    yamt /*
    126  1.13.4.1    yamt  * An information structure to return a list of logged in WWPNs. FC specific.
    127  1.13.4.1    yamt  */
    128       1.1  mjacob typedef struct {
    129  1.13.4.1    yamt     void *                  d_identity;
    130  1.13.4.1    yamt     int                     d_channel;
    131  1.13.4.1    yamt     int                     d_error;
    132  1.13.4.1    yamt     int                     d_count;
    133  1.13.4.1    yamt     uint64_t *              d_wwpns;
    134  1.13.4.1    yamt } fc_dlist_t;
    135  1.13.4.2    yamt 
    136  1.13.4.1    yamt /*
    137  1.13.4.2    yamt  * Notify structure- these are for asynchronous events that need to be sent
    138  1.13.4.2    yamt  * as notifications to the outer layer. It should be pretty self-explanatory.
    139  1.13.4.1    yamt  */
    140  1.13.4.1    yamt typedef enum {
    141  1.13.4.2    yamt     NT_UNKNOWN=0x999,
    142  1.13.4.1    yamt     NT_ABORT_TASK=0x1000,
    143  1.13.4.1    yamt     NT_ABORT_TASK_SET,
    144  1.13.4.1    yamt     NT_CLEAR_ACA,
    145  1.13.4.1    yamt     NT_CLEAR_TASK_SET,
    146  1.13.4.1    yamt     NT_LUN_RESET,
    147  1.13.4.1    yamt     NT_TARGET_RESET,
    148  1.13.4.1    yamt     NT_BUS_RESET,
    149  1.13.4.1    yamt     NT_LIP_RESET,
    150  1.13.4.1    yamt     NT_LINK_UP,
    151  1.13.4.1    yamt     NT_LINK_DOWN,
    152  1.13.4.1    yamt     NT_LOGOUT,
    153  1.13.4.1    yamt     NT_HBA_RESET
    154  1.13.4.1    yamt } tmd_ncode_t;
    155  1.13.4.1    yamt 
    156  1.13.4.1    yamt typedef struct tmd_notify {
    157  1.13.4.1    yamt     void *      nt_hba;         /* HBA tag */
    158  1.13.4.1    yamt     uint64_t    nt_iid;         /* inititator id */
    159  1.13.4.1    yamt     uint64_t    nt_tgt;         /* target id */
    160  1.13.4.1    yamt     uint16_t    nt_lun;         /* logical unit */
    161  1.13.4.1    yamt     uint16_t                : 15,
    162  1.13.4.1    yamt                 nt_need_ack : 1;    /* this notify needs an ACK */
    163  1.13.4.1    yamt     uint64_t    nt_tagval;      /* tag value */
    164  1.13.4.1    yamt     uint32_t    nt_channel;     /* channel id */
    165  1.13.4.1    yamt     tmd_ncode_t nt_ncode;       /* action */
    166  1.13.4.1    yamt     void *      nt_lreserved;
    167  1.13.4.1    yamt     void *      nt_hreserved;
    168  1.13.4.1    yamt } tmd_notify_t;
    169  1.13.4.1    yamt #define LUN_ANY     0xffff
    170  1.13.4.1    yamt #define TGT_ANY     ((uint64_t) -1)
    171  1.13.4.2    yamt #ifdef  INI_ANY
    172  1.13.4.1    yamt #define INI_ANY     ((uint64_t) -1)
    173  1.13.4.2    yamt #endif
    174  1.13.4.2    yamt #ifndef INI_NONE
    175  1.13.4.2    yamt #define INI_NONE    ((uint64_t) 0)
    176  1.13.4.2    yamt #endif
    177  1.13.4.1    yamt #define TAG_ANY     ((uint64_t) 0)
    178  1.13.4.1    yamt #define MATCH_TMD(tmd, iid, lun, tag)                   \
    179  1.13.4.1    yamt     (                                                   \
    180  1.13.4.1    yamt         (tmd) &&                                        \
    181  1.13.4.1    yamt         (iid == INI_ANY || iid == tmd->cd_iid) &&       \
    182  1.13.4.1    yamt         (lun == LUN_ANY || lun == tmd->cd_lun) &&       \
    183  1.13.4.1    yamt         (tag == TAG_ANY || tag == tmd->cd_tagval)       \
    184  1.13.4.1    yamt     )
    185       1.1  mjacob 
    186  1.13.4.1    yamt /*
    187  1.13.4.2    yamt  * Lun ENABLE/DISABLE
    188  1.13.4.2    yamt  *
    189  1.13.4.1    yamt  * A word about ENABLE/DISABLE: the argument is a pointer to a enadis_t
    190  1.13.4.2    yamt  * with en_hba, en_chan and en_lun filled out. We used to have an iid
    191  1.13.4.2    yamt  * and target pair, but this just gets silly so we made initiator id
    192  1.13.4.2    yamt  * and target id something you set, once, elsewhere.
    193  1.13.4.1    yamt  *
    194  1.13.4.1    yamt  * If an error occurs in either enabling or disabling the described lun
    195  1.13.4.2    yamt  * en_error is set with an appropriate non-zero value.
    196  1.13.4.1    yamt  */
    197       1.1  mjacob typedef struct {
    198  1.13.4.1    yamt     void *          en_private;     /* for outer layer usage */
    199  1.13.4.1    yamt     void *          en_hba;         /* HBA tag */
    200  1.13.4.1    yamt     uint16_t        en_lun;         /* logical unit */
    201  1.13.4.1    yamt     uint16_t        en_chan;        /* channel on card */
    202  1.13.4.1    yamt     int             en_error;
    203  1.13.4.1    yamt } enadis_t;
    204       1.1  mjacob 
    205  1.13.4.2    yamt 
    206  1.13.4.2    yamt 
    207       1.1  mjacob /*
    208  1.13.4.2    yamt  * Data Transaction
    209       1.3      he  *
    210  1.13.4.2    yamt  * A tmd_xact_t is a structure used to describe a transaction within
    211  1.13.4.2    yamt  * an overall command. It used to be part of the overall command,
    212  1.13.4.2    yamt  * but it became desirable to allow for multiple simultaneous
    213  1.13.4.2    yamt  * transfers for a command to happen. Generally these structures
    214  1.13.4.2    yamt  * define data to be moved (along with the relative offset within
    215  1.13.4.2    yamt  * the overall command) with the last structure containing status
    216  1.13.4.2    yamt  * and sense (if needed) as well.
    217  1.13.4.2    yamt  *
    218  1.13.4.2    yamt  * The td_cmd tag points back to the owning command.
    219  1.13.4.2    yamt  *
    220  1.13.4.2    yamt  * The td_data tag points to the (platform specific) data descriptor.
    221  1.13.4.2    yamt  *
    222  1.13.4.2    yamt  * The td_lprivate is for use by the Inner Layer for private usage.
    223  1.13.4.2    yamt  *
    224  1.13.4.2    yamt  * The td_xfrlen says whether this transaction is moving data- if nonzero.
    225  1.13.4.2    yamt  *
    226  1.13.4.2    yamt  * The td_offset states what the relative offset within the comamnd the
    227  1.13.4.2    yamt  * data transfer will start at. It is undefined if td_xfrlen is zero.
    228  1.13.4.2    yamt  *
    229  1.13.4.2    yamt  * The td_error flag will note any errors that occurred during an attempt
    230  1.13.4.2    yamt  * to start this transaction. The inner layer is responsible for setting
    231  1.13.4.2    yamt  * this.
    232  1.13.4.2    yamt  *
    233  1.13.4.2    yamt  * The td_hflags tag is set by the outer layer to indicate how the inner
    234  1.13.4.2    yamt  * layer is supposed to treat this transaction.
    235  1.13.4.2    yamt  *
    236  1.13.4.2    yamt  * The td_lflags tag is set by the inner layer to indicate whether this
    237  1.13.4.2    yamt  * transaction sent status and/or sense. Note that (much as it hurts),
    238  1.13.4.2    yamt  * this API allows the inner layer to *fail* to send sense even if asked
    239  1.13.4.2    yamt  * to- that is, AUTOSENSE is not a requirement of this API and the outer
    240  1.13.4.2    yamt  * layer has to be prepared for this (unlikely) eventuality.
    241  1.13.4.2    yamt  */
    242  1.13.4.2    yamt 
    243  1.13.4.2    yamt typedef struct tmd_cmd tmd_cmd_t;
    244  1.13.4.2    yamt typedef struct tmd_xact {
    245  1.13.4.2    yamt     tmd_cmd_t *         td_cmd;                 /* cross-ref to tmd_cmd_t */
    246  1.13.4.2    yamt     void *              td_data;                /* data descriptor */
    247  1.13.4.2    yamt     void *              td_lprivate;            /* private for lower layer */
    248  1.13.4.2    yamt     uint32_t            td_xfrlen;              /* size of this data load */
    249  1.13.4.2    yamt     uint32_t            td_offset;              /* offset for this data load */
    250  1.13.4.2    yamt     int                 td_error;               /* error with this transfer */
    251  1.13.4.2    yamt     uint8_t             td_hflags;              /* flags set by caller */
    252  1.13.4.2    yamt     uint8_t             td_lflags;              /* flags set by callee */
    253  1.13.4.2    yamt } tmd_xact_t;
    254  1.13.4.2    yamt 
    255  1.13.4.2    yamt #define TDFH_STSVALID   0x01    /* status is valid - include it */
    256  1.13.4.2    yamt #define TDFH_SNSVALID   0x02    /* sense data (from outer layer) good - include it */
    257  1.13.4.2    yamt #define TDFH_DATA_IN    0x04    /* target (us) -> initiator (them) */
    258  1.13.4.2    yamt #define TDFH_DATA_OUT   0x08    /* initiator (them) -> target (us) */
    259  1.13.4.2    yamt #define TDFH_DATA_MASK  0x0C    /* mask to cover data direction */
    260  1.13.4.2    yamt #define TDFH_PRIVATE    0xF0    /* private outer layer usage */
    261  1.13.4.2    yamt 
    262  1.13.4.2    yamt #define TDFL_SENTSTATUS 0x01    /* this transaction sent status */
    263  1.13.4.2    yamt #define TDFL_SENTSENSE  0x02    /* this transaction sent sense data */
    264  1.13.4.2    yamt #define TDFL_ERROR      0x04    /* this transaction had an error */
    265  1.13.4.2    yamt #define TDFL_PRIVATE    0xF0    /* private inner layer usage */
    266  1.13.4.2    yamt 
    267  1.13.4.2    yamt /*
    268  1.13.4.2    yamt  * The command structure below the SCSI Command structure that is
    269  1.13.4.2    yamt  * is the whole point of this API. After a LUN is (or LUNS are)
    270  1.13.4.2    yamt  * enabled, initiators who send commands addressed to the port,
    271  1.13.4.2    yamt  * channel and lun that have been enabled cause an interrupt which
    272  1.13.4.2    yamt  * causes the chip to receive the command and present it to the
    273  1.13.4.2    yamt  * inner layer. The inner layer allocates one of this command
    274  1.13.4.2    yamt  * structures and copies relevant information to it and sends it
    275  1.13.4.2    yamt  * to the outer layer with the action QOUT_TMD_START.
    276  1.13.4.2    yamt  *
    277  1.13.4.2    yamt  * The outer layer is then responsible for command decode and is responsible
    278  1.13.4.2    yamt  * for sending any transactions back (via a QIN_TMD_CONT) to the inner layer
    279  1.13.4.2    yamt  * that (optionally) moves data and then sends closing status.
    280  1.13.4.2    yamt  *
    281  1.13.4.2    yamt  * The outer layer, when informed of the status of the final transaction
    282  1.13.4.2    yamt  * then releases this structure by sending it back to the inner layer
    283  1.13.4.2    yamt  * with the action QOUT_TMD_FIN.
    284       1.3      he  *
    285  1.13.4.2    yamt  * The structure tag meanings are as described below.
    286       1.1  mjacob  *
    287       1.1  mjacob  * The cd_hba tag is a tag that uniquely identifies the HBA this target
    288       1.1  mjacob  * mode command is coming from. The outer layer has to pass this back
    289  1.13.4.2    yamt  * unchanged to avoid chaos. It is identical to the r_identity tag used
    290  1.13.4.2    yamt  * by the inner layer to register with the outer layer.
    291  1.13.4.2    yamt  *
    292  1.13.4.2    yamt  * The cd_iid, cd_channel, cd_tgt and cd_lun tags are used to identify the
    293  1.13.4.2    yamt  * the initiator who sent us a command, the channel on the this particular
    294  1.13.4.2    yamt  * hardware port we arrived on (for multiple channel devices), the target we
    295  1.13.4.2    yamt  * claim to be, and the lun on that target.
    296  1.13.4.2    yamt  *
    297  1.13.4.2    yamt  * The cd_tagval field is a tag that uniquely describes this tag. It may
    298  1.13.4.2    yamt  * or may not have any correspondence to an underying hardware tag. The
    299  1.13.4.2    yamt  * outer layer must pass this back unchanged or chaos will result.
    300  1.13.4.2    yamt  *
    301  1.13.4.2    yamt  * The tag cd_totlen is the total data amount expected to be moved
    302  1.13.4.2    yamt  * for this command. This will be set to non-zero for transports
    303  1.13.4.2    yamt  * that know this value from the transport level (e.g., Fibre Channel).
    304  1.13.4.2    yamt  * If it shows up in the outer layers set to zero, the total data length
    305  1.13.4.2    yamt  * must be inferred from the CDB.
    306  1.13.4.2    yamt  *
    307  1.13.4.2    yamt  * The tag cd_moved is the total amount of data moved so far. It is the
    308  1.13.4.2    yamt  * responsibilty of the inner layer to set this for every transaction and
    309  1.13.4.2    yamt  * to keep track of it so that transport level residuals may be correctly
    310  1.13.4.2    yamt  * set.
    311       1.1  mjacob  *
    312  1.13.4.2    yamt  * The cd_cdb contains storage for the passed in SCSI command.
    313       1.1  mjacob  *
    314  1.13.4.1    yamt  * The cd_tagtype field specifies what kind of command tag type, if
    315  1.13.4.2    yamt  * any, has been sent with this command.
    316       1.1  mjacob  *
    317  1.13.4.2    yamt  * The tag cd_flags has some junk flags set but mostly has flags reserved for outer layer use.
    318       1.1  mjacob  *
    319  1.13.4.2    yamt  * The tags cd_sense and cd_scsi_status are self-explanatory.
    320       1.1  mjacob  *
    321  1.13.4.2    yamt  * The cd_xact tag is the first or only transaction structure related to this command.
    322       1.1  mjacob  *
    323  1.13.4.2    yamt  * The tag cd_lreserved, cd_hreserved are scratch areas for use for the outer and inner layers respectively.
    324  1.13.4.1    yamt  *
    325       1.1  mjacob  */
    326       1.1  mjacob 
    327  1.13.4.2    yamt #ifndef TMD_CDBLEN
    328  1.13.4.2    yamt #define TMD_CDBLEN       16
    329  1.13.4.2    yamt #endif
    330  1.13.4.2    yamt #ifndef TMD_SENSELEN
    331  1.13.4.2    yamt #define TMD_SENSELEN     18
    332      1.10  mjacob #endif
    333  1.13.4.2    yamt #ifndef QCDS
    334  1.13.4.2    yamt #define QCDS             (sizeof (uint64_t))
    335       1.1  mjacob #endif
    336  1.13.4.2    yamt #ifndef TMD_PRIV_LO
    337  1.13.4.2    yamt #define TMD_PRIV_LO 4
    338  1.13.4.2    yamt #endif
    339  1.13.4.2    yamt #ifndef TMD_PRIV_HI
    340  1.13.4.2    yamt #define TMD_PRIV_HI 4
    341       1.1  mjacob #endif
    342       1.1  mjacob 
    343  1.13.4.2    yamt struct tmd_cmd {
    344  1.13.4.1    yamt     void *              cd_hba;     /* HBA tag */
    345  1.13.4.1    yamt     uint64_t            cd_iid;     /* initiator ID */
    346  1.13.4.1    yamt     uint64_t            cd_tgt;     /* target id */
    347  1.13.4.1    yamt     uint64_t            cd_tagval;  /* tag value */
    348  1.13.4.2    yamt     uint8_t             cd_lun[8];  /* logical unit */
    349  1.13.4.1    yamt     uint32_t            cd_totlen;  /* total data load */
    350  1.13.4.2    yamt     uint32_t            cd_moved;   /* total data moved so far */
    351  1.13.4.2    yamt     uint16_t            cd_channel; /* channel index */
    352  1.13.4.2    yamt     uint16_t            cd_flags;   /* flags */
    353  1.13.4.2    yamt     uint16_t            cd_req_cnt; /* how many tmd_xact_t's are active */
    354  1.13.4.2    yamt     uint8_t             cd_cdb[TMD_CDBLEN];
    355  1.13.4.1    yamt     uint8_t             cd_tagtype; /* tag type */
    356  1.13.4.1    yamt     uint8_t             cd_scsi_status;
    357  1.13.4.1    yamt     uint8_t             cd_sense[TMD_SENSELEN];
    358  1.13.4.2    yamt     tmd_xact_t          cd_xact;    /* first or only transaction */
    359  1.13.4.1    yamt     union {
    360  1.13.4.2    yamt         void *          ptrs[QCDS / sizeof (void *)];       /* (assume) one pointer */
    361  1.13.4.2    yamt         uint64_t        llongs[QCDS / sizeof (uint64_t)];   /* one long long */
    362  1.13.4.2    yamt         uint32_t        longs[QCDS / sizeof (uint32_t)];    /* two longs */
    363  1.13.4.2    yamt         uint16_t        shorts[QCDS / sizeof (uint16_t)];   /* four shorts */
    364  1.13.4.2    yamt         uint8_t         bytes[QCDS];                        /* eight bytes */
    365  1.13.4.2    yamt     } cd_lreserved[TMD_PRIV_LO], cd_hreserved[TMD_PRIV_HI];
    366  1.13.4.2    yamt };
    367  1.13.4.2    yamt 
    368  1.13.4.2    yamt #define CDF_NODISC      0x0001  /* disconnects disabled */
    369  1.13.4.2    yamt #define CDF_DATA_IN     0x0002  /* target (us) -> initiator (them) */
    370  1.13.4.2    yamt #define CDF_DATA_OUT    0x0004  /* initiator (them) -> target (us) */
    371  1.13.4.2    yamt #define CDF_BIDIR       0x0006  /* bidirectional data */
    372  1.13.4.2    yamt #define CDF_SNSVALID    0x0008  /* sense is set on incoming command */
    373  1.13.4.2    yamt #define CDF_PRIVATE     0xff00  /* available for private use in outer layer */
    374       1.1  mjacob 
    375  1.13.4.1    yamt /* defined tags */
    376  1.13.4.1    yamt #define CD_UNTAGGED     0
    377  1.13.4.1    yamt #define CD_SIMPLE_TAG   1
    378  1.13.4.1    yamt #define CD_ORDERED_TAG  2
    379  1.13.4.1    yamt #define CD_HEAD_TAG     3
    380  1.13.4.1    yamt #define CD_ACA_TAG      4
    381  1.13.4.1    yamt 
    382  1.13.4.1    yamt #ifndef    TMD_SIZE
    383  1.13.4.1    yamt #define    TMD_SIZE     (sizeof (tmd_cmd_t))
    384      1.10  mjacob #endif
    385      1.10  mjacob 
    386  1.13.4.1    yamt #define L0LUN_TO_FLATLUN(lptr)              ((((lptr)[0] & 0x3f) << 8) | ((lptr)[1]))
    387  1.13.4.1    yamt #define FLATLUN_TO_L0LUN(lptr, lun)                 \
    388  1.13.4.1    yamt     (lptr)[1] = lun & 0xff;                         \
    389  1.13.4.1    yamt     if (sizeof (lun) == 1) {                        \
    390  1.13.4.1    yamt         (lptr)[0] = 0;                              \
    391  1.13.4.1    yamt     } else {                                        \
    392  1.13.4.1    yamt         uint16_t nl = lun;                          \
    393  1.13.4.1    yamt         if (nl == LUN_ANY) {                        \
    394  1.13.4.1    yamt             (lptr)[0] = (nl >> 8) & 0xff;           \
    395  1.13.4.1    yamt         } else if (nl < 256) {                      \
    396  1.13.4.1    yamt             (lptr)[0] = 0;                          \
    397  1.13.4.1    yamt         } else {                                    \
    398  1.13.4.1    yamt             (lptr)[0] = 0x40 | ((nl >> 8) & 0x3f);  \
    399  1.13.4.1    yamt         }                                           \
    400  1.13.4.1    yamt     }                                               \
    401  1.13.4.1    yamt     memset(&(lptr)[2], 0, 6)
    402  1.13.4.1    yamt 
    403      1.10  mjacob /*
    404  1.13.4.2    yamt  * Inner Layer Handler Function.
    405      1.10  mjacob  *
    406  1.13.4.2    yamt  * The inner layer target handler function (the outer layer calls this)
    407  1.13.4.2    yamt  * should be be prototyped like so:
    408      1.10  mjacob  *
    409  1.13.4.1    yamt  *    void target_action(qact_e, void *arg)
    410      1.10  mjacob  *
    411  1.13.4.2    yamt  * The outer layer target handler function (the inner layer calls this)
    412      1.10  mjacob  * should be be prototyped like:
    413      1.10  mjacob  *
    414  1.13.4.1    yamt  *    void scsi_target_handler(tact_e, void *arg)
    415  1.13.4.1    yamt  */
    416  1.13.4.1    yamt #endif    /* _ISP_TPUBLIC_H */
    417  1.13.4.1    yamt /*
    418  1.13.4.1    yamt  * vim:ts=4:sw=4:expandtab
    419      1.10  mjacob  */
    420