[BACK]Return to twereg.h CVS log [TXT][DIR] Up to [local] / sys / dev / ic

Annotation of sys/dev/ic/twereg.h, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: twereg.h,v 1.8 2007/04/10 17:47:55 miod Exp $ */
                      2:
                      3: /*
                      4:  * Copyright (c) 2000 Michael Shalayeff
                      5:  * All rights reserved.
                      6:  *
                      7:  * Redistribution and use in source and binary forms, with or without
                      8:  * modification, are permitted provided that the following conditions
                      9:  * are met:
                     10:  * 1. Redistributions of source code must retain the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer.
                     12:  * 2. Redistributions in binary form must reproduce the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer in the
                     14:  *    documentation and/or other materials provided with the distribution.
                     15:  *
                     16:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     17:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     18:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     19:  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
                     20:  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
                     21:  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
                     22:  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     23:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
                     24:  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
                     25:  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
                     26:  * THE POSSIBILITY OF SUCH DAMAGE.
                     27:  */
                     28: /*
                     29:  * most of the meaning for registers were taken from
                     30:  * freebsd driver, which in turn got 'em from linux.
                     31:  * it seems those got 'em from windows driver, in turn.
                     32:  */
                     33:
                     34:
                     35: /* general parameters */
                     36: #define        TWE_MAX_UNITS           16
                     37: #define        TWE_MAXOFFSETS          62
                     38: #define        TWE_MAXCMDS             255
                     39: #define        TWE_SECTOR_SIZE         512
                     40: #define        TWE_ALIGN               512
                     41: #define        TWE_MAXFER              (TWE_MAXOFFSETS * PAGE_SIZE)
                     42:
                     43: /* registers */
                     44: #define        TWE_CONTROL             0x00
                     45: #define                TWE_CTRL_CHOSTI 0x00080000      /* clear host int */
                     46: #define                TWE_CTRL_CATTNI 0x00040000      /* clear attention int */
                     47: #define                TWE_CTRL_MCMDI  0x00020000      /* mask cmd int */
                     48: #define                TWE_CTRL_MRDYI  0x00010000      /* mask ready int */
                     49: #define                TWE_CTRL_ECMDI  0x00008000      /* enable cmd int */
                     50: #define                TWE_CTRL_ERDYI  0x00004000      /* enable ready int */
                     51: #define                TWE_CTRL_CERR   0x00000200      /* clear error status */
                     52: #define                TWE_CTRL_SRST   0x00000100      /* soft reset */
                     53: #define                TWE_CTRL_EINT   0x00000080      /* enable ints */
                     54: #define                TWE_CTRL_MINT   0x00000040      /* mask ints */
                     55: #define                TWE_CTRL_HOSTI  0x00000020      /* generate host int */
                     56: #define        TWE_STATUS              0x04
                     57: #define                TWE_STAT_MAJV   0xf0000000
                     58: #define                TWE_MAJV(st)    (((st) >> 28) & 0xf)
                     59: #define                TWE_STAT_MINV   0x0f000000
                     60: #define                TWE_MINV(st)    (((st) >> 24) & 0xf)
                     61: #define                TWE_STAT_PCIPAR 0x00800000
                     62: #define                TWE_STAT_QUEUEE 0x00400000
                     63: #define                TWE_STAT_CPUERR 0x00200000
                     64: #define                TWE_STAT_PCIABR 0x00100000
                     65: #define                TWE_STAT_HOSTI  0x00080000
                     66: #define                TWE_STAT_ATTNI  0x00040000
                     67: #define                TWE_STAT_CMDI   0x00020000
                     68: #define                TWE_STAT_RDYI   0x00010000
                     69: #define                TWE_STAT_CQF    0x00008000      /* cmd queue full */
                     70: #define                TWE_STAT_RQE    0x00004000      /* ready queue empty */
                     71: #define                TWE_STAT_CPURDY 0x00002000      /* cpu ready */
                     72: #define                TWE_STAT_CQR    0x00001000      /* cmd queue ready */
                     73: #define                TWE_STAT_FLAGS  0x00fff000      /* mask out other stuff */
                     74: #define                TWE_STAT_BITS   "\020\015cqr\016cpurdy\017rqe\20cqf"    \
                     75:     "\021rdyi\022cmdi\023attni\024hosti\025pciabr\026cpuerr\027queuee\030pcipar"
                     76:
                     77: #define        TWE_COMMANDQUEUE        0x08
                     78:        /*
                     79:         * the segs offset is encoded into upper 3 bits of the opcode.
                     80:         * i bet other bits mean something too
                     81:         * upper 8 bits is the command size in 32bit words.
                     82:         */
                     83: #define                TWE_CMD_NOP     0x0200
                     84: #define                TWE_CMD_INIT    0x0301
                     85: #define                TWE_CMD_READ    0x0362
                     86: #define                TWE_CMD_WRITE   0x0363
                     87: #define                TWE_CMD_RDVRFY  0x0364
                     88: #define                TWE_CMD_VERIFY  0x0365
                     89: #define                TWE_CMD_ZRFUNIT 0x0208
                     90: #define                TWE_CMD_RPLUNIT 0x0209
                     91: #define                TWE_CMD_HOTSWAP 0x020a
                     92: #define                TWE_CMD_SETATA  0x020c
                     93: #define                TWE_CMD_FLUSH   0x020e
                     94: #define                TWE_CMD_ABORT   0x020f
                     95: #define                TWE_CMD_QSTAT   0x0210
                     96: #define                TWE_CMD_GPARAM  0x0252
                     97: #define                TWE_CMD_SPARAM  0x0253
                     98: #define                TWE_CMD_NEWUNIT 0x0214
                     99: #define                TWE_CMD_DELUNIT 0x0215
                    100: #define                TWE_CMD_RBLUNIT 0x0217  /* rebuild */
                    101: #define                TWE_CMD_SECINF  0x021a
                    102: #define                TWE_CMD_AEN     0x021c
                    103: #define                TWE_CMD_CMDPK   0x021d
                    104: #define        TWE_READYQUEUE          0x0c
                    105: #define                TWE_READYID(u)  (((u) >> 4) & 0xff)
                    106:
                    107: /*
                    108:  * From 3ware's documentation:
                    109:  *
                    110:  *   All parameters maintained by the controller are grouped into related
                    111:  *   tables.  Tables are are accessed indirectly via get and set parameter
                    112:  *   commands.  To access a specific parameter in a table, the table ID and
                    113:  *   parameter index are used to uniquely identify a parameter.  Table
                    114:  *   0xffff is the directory table and provides a list of the table IDs and
                    115:  *   sizes of all other tables.  Index zero in each table specifies the
                    116:  *   entire table, and index one specifies the size of the table.  An entire
                    117:  *   table can be read or set by using index zero.
                    118:  */
                    119:
                    120: /* get/set param table ids */
                    121: #define        TWE_PARAM_ALL   0x000   /* everything */
                    122: #define        TWE_PARAM_DSUM  0x002   /* drive summary */
                    123: #define        TWE_PARAM_UC    0x003   /* unit config */
                    124: #define        TWE_PARAM_DC    0x200   /* + 15 -- drive config (doc says 0x100) */
                    125: #define        TWE_PARAM_UI    0x300   /* + 16 -- unit information */
                    126: #define        TWE_PARAM_AEN   0x401
                    127: #define        TWE_PARAM_VER   0x402   /* version info */
                    128: #define        TWE_PARAM_CTRL  0x403   /* controller info */
                    129: #define        TWE_PARAM_FTRS  0x404   /* features */
                    130: #define        TWE_PARAM_DIR   0xffff  /* param table directory */
                    131:
                    132: #define        TWE_AEN_QEMPTY  0x0000
                    133: #define        TWE_AEN_SRST    0x0001  /* soft reset */
                    134: #define        TWE_AEN_DMIRROR 0x0002  /* degraded mirror */
                    135: #define        TWE_AEN_CERROR  0x0003  /* controller error */
                    136: #define        TWE_AEN_RBFAIL  0x0004  /* rebuild failed */
                    137: #define        TWE_AEN_RBDONE  0x0005  /* rebuild done */
                    138: #define        TWE_AEN_ILLUN   0x0006  /* incompatible unit */
                    139: #define        TWE_AEN_INDONE  0x0007  /* init done */
                    140: #define        TWE_AEN_DSHUT   0x0008  /* unclean shutdown */
                    141: #define        TWE_AEN_APORT   0x0009  /* aport timeout */
                    142: #define        TWE_AEN_DRVERR  0x000a  /* drive error */
                    143: #define        TWE_AEN_RBSTART 0x000b  /* rebuild start */
                    144: #define        TWE_AEN_ISTART  0x000c  /* init started */
                    145: #define        TWE_AEN_TUN     0x0015  /* table undefined */
                    146: /*     TWE_AEN_        0x0000   * dunno what this is (yet) */
                    147: #define        TWE_AEN_QFULL   0x00ff
                    148:
                    149: #pragma pack(1)
                    150:
                    151: /* struct definitions */
                    152: struct twe_param {
                    153:        u_int16_t       table_id;
                    154:        u_int8_t        param_id;
                    155:        u_int8_t        param_size;
                    156:        u_int8_t        data[1];
                    157: };
                    158:
                    159: struct twe_segs {
                    160:        u_int32_t twes_addr;
                    161:        u_int32_t twes_len;
                    162: };
                    163:
                    164: struct twe_cmd {
                    165:        u_int16_t       cmd_op;
                    166:        u_int8_t        cmd_index;
                    167:        u_int8_t        cmd_unit_host;
                    168: #define        TWE_UNITHOST(u, h)      (((u) & 0xf) | ((h) << 4))
                    169:        u_int8_t        cmd_status;
                    170:        u_int8_t        cmd_flags;
                    171: #define        TWE_FLAGS_CACHEDISABLE          0x01
                    172:        union {
                    173:                struct {
                    174:                        u_int16_t       count;
                    175:                        u_int32_t       lba;
                    176:                        struct twe_segs segs[TWE_MAXOFFSETS];
                    177:                        u_int32_t       pad;
                    178:                } _cmd_io;
                    179: #define        cmd_io          _._cmd_io
                    180:                struct {
                    181:                        u_int16_t       count;
                    182:                        struct twe_segs segs[TWE_MAXOFFSETS];
                    183:                } _cmd_param;
                    184: #define        cmd_param       _._cmd_param
                    185:                struct {
                    186:                        u_int16_t       msgcr;
                    187:                        u_int32_t       rdy_q_ptr;
                    188:                } _cmd_init;
                    189: #define        cmd_init        _._cmd_init
                    190:                struct {
                    191:                        u_int8_t        action;
                    192: #define        TWE_HSWAP_REMOVE        0
                    193: #define        TWE_HSWAP_ADDCBOD       1
                    194: #define        TWE_HSWAP_ADDSPARE      2
                    195:                        u_int8_t        port;
                    196:                } _cmd_aport;
                    197: #define        cmd_hswap       _._cmd_hswap
                    198:                struct {
                    199:                        u_int8_t        feature;
                    200: #define        TWE_ATA_WCE     0x02
                    201: #define        TWE_ATA_NWCE    0x82
                    202:                        u_int8_t        mode;
                    203:                        u_int16_t       units;
                    204:                        u_int16_t       persist;
                    205:                } _cmd_ata;
                    206: #define        cmd_ata         _._cmd_ata
                    207:                u_int16_t       cmd_status;
                    208:                struct {
                    209:                        u_int8_t        action;
                    210: #define        TWE_REBUILD_NOP         0
                    211: #define        TWE_REBUILD_STOP        2
                    212: #define        TWE_REBUILD_START       4
                    213: #define        TWE_REBUILD_STARTU      5
                    214: #define        TWE_REBUILD_CS          0x80
                    215:                        u_int8_t        subunit;        /* raid10 lu rebuild */
                    216:                } _cmd_rebuild;
                    217: #define        cmd_rebuild     _._cmd_rebuild
                    218:        } _;
                    219: };     /* 512 bytes */
                    220:
                    221: #pragma pack()

CVSweb