- Pull in some updates from FreeBSD - mainly clarifications. Thanks to

Mike Smith <msmith@freebsd.org> for pointing these out.
- Ensure that we get AENs: reserve one CCB/command block for parameter
  retrieval, and chain AEN retrievals that are the result of an interrupt.
This commit is contained in:
ad 2000-11-08 19:23:50 +00:00
parent 142ab5b1ec
commit 891c4efd74
3 changed files with 290 additions and 99 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: twe.c,v 1.2 2000/10/20 15:14:25 ad Exp $ */
/* $NetBSD: twe.c,v 1.3 2000/11/08 19:23:50 ad Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -98,12 +98,14 @@
#define TWE_OUTL(sc, port, val) \
bus_space_write_4((sc)->sc_iot, (sc)->sc_ioh, port, val)
#define PCI_CBIO 0x10
#if TWE_MAX_QUEUECNT > TWE_MAX_CMDS
#error TWE_MAX_QUEUECNT > TWE_MAX_CMDS
#if TWE_MAX_QUEUECNT == TWE_MAX_CMDS
#define TWE_REAL_MAX_QUEUECNT TWE_MAX_CMDS
#else
#define TWE_REAL_MAX_QUEUECNT TWE_MAX_CMDS + 1
#endif
#define PCI_CBIO 0x10
static void twe_aen_handler(struct twe_ccb *, int);
static void twe_attach(struct device *, struct device *, void *);
static int twe_init_connection(struct twe_softc *);
@ -123,15 +125,22 @@ struct cfattach twe_ca = {
};
struct {
const u_int aen;
const u_int aen; /* High byte non-zero if w/unit */
const char *desc;
} static const twe_aen_names[] = {
{ 0x0000, "queue empty" },
{ 0x0001, "soft reset" },
{ 0x0002, "degraded mirror" },
{ 0x0102, "degraded mirror" },
{ 0x0003, "controller error" },
{ 0x0004, "rebuild fail" },
{ 0x0005, "rebuild done" },
{ 0x0104, "rebuild fail" },
{ 0x0105, "rebuild done" },
{ 0x0106, "incompatible unit" },
{ 0x0107, "init done" },
{ 0x0108, "unclean shutdown" },
{ 0x0109, "aport timeout" },
{ 0x010a, "drive error" },
{ 0x010b, "rebuild started" },
{ 0x0015, "table undefined" },
{ 0x00ff, "aen queue full" },
};
@ -177,7 +186,7 @@ twe_attach(struct device *parent, struct device *self, void *aux)
SIMPLEQ_INIT(&sc->sc_ccb_queue);
SLIST_INIT(&sc->sc_ccb_freelist);
printf(": 3ware Escalade RAID controller\n");
printf(": 3ware Escalade\n");
if (pci_mapreg_map(pa, PCI_CBIO, PCI_MAPREG_TYPE_IO, 0,
&sc->sc_iot, &sc->sc_ioh, NULL, NULL)) {
@ -211,7 +220,7 @@ twe_attach(struct device *parent, struct device *self, void *aux)
/*
* Allocate and initialise the command blocks and CCBs.
*/
size = sizeof(struct twe_cmd) * TWE_MAX_QUEUECNT;
size = sizeof(struct twe_cmd) * TWE_REAL_MAX_QUEUECNT;
if ((rv = bus_dmamem_alloc(sc->sc_dmat, size, NBPG, 0, &seg, 1,
&rseg, BUS_DMA_NOWAIT)) != 0) {
@ -245,7 +254,7 @@ twe_attach(struct device *parent, struct device *self, void *aux)
sc->sc_cmds_paddr = sc->sc_dmamap->dm_segs[0].ds_addr;
memset(sc->sc_cmds, 0, size);
ccb = malloc(sizeof(*ccb) * TWE_MAX_QUEUECNT, M_DEVBUF, M_WAITOK);
ccb = malloc(sizeof(*ccb) * TWE_REAL_MAX_QUEUECNT, M_DEVBUF, M_WAITOK);
if (ccb == NULL) {
printf("%s: unable to allocate CCBs\n", sc->sc_dv.dv_xname);
return;
@ -254,7 +263,7 @@ twe_attach(struct device *parent, struct device *self, void *aux)
sc->sc_ccbs = ccb;
tc = (struct twe_cmd *)sc->sc_cmds;
for (i = 0; i < TWE_MAX_QUEUECNT; i++, tc++, ccb++) {
for (i = 0; i < TWE_REAL_MAX_QUEUECNT; i++, tc++, ccb++) {
ccb->ccb_cmd = tc;
ccb->ccb_cmdid = i;
ccb->ccb_flags = 0;
@ -263,11 +272,18 @@ twe_attach(struct device *parent, struct device *self, void *aux)
&ccb->ccb_dmamap_xfer);
if (rv != 0)
break;
SLIST_INSERT_HEAD(&sc->sc_ccb_freelist, ccb, ccb_chain.slist);
/* Save one CCB for parameter retrieval. */
if (i != 0)
SLIST_INSERT_HEAD(&sc->sc_ccb_freelist, ccb,
ccb_chain.slist);
}
if (i != TWE_MAX_QUEUECNT)
printf("%s: %d/%d CCBs usable\n", sc->sc_dv.dv_xname, i,
TWE_MAX_QUEUECNT);
if ((sc->sc_nccbs = i) <= TWE_MIN_QUEUECNT) {
printf("%s: too few CCBs available\n", sc->sc_dv.dv_xname);
return;
}
if (sc->sc_nccbs != TWE_REAL_MAX_QUEUECNT)
printf("%s: %d/%d CCBs usable\n", sc->sc_dv.dv_xname,
sc->sc_nccbs, TWE_REAL_MAX_QUEUECNT);
/* Wait for the controller to become ready. */
if (twe_status_wait(sc, TWE_STS_MICROCONTROLLER_READY, 6)) {
@ -283,23 +299,25 @@ twe_attach(struct device *parent, struct device *self, void *aux)
return;
}
/* Find attached drives. XXX Magic numbers. */
if ((dtp = twe_param_get(sc, 3, 3, TWE_MAX_UNITS, NULL)) == NULL) {
/* Find attached units. */
dtp = twe_param_get(sc, TWE_PARAM_UNITSUMMARY,
TWE_PARAM_UNITSUMMARY_Status, TWE_MAX_UNITS, NULL);
if (dtp == NULL) {
printf("%s: can't detect attached units\n",
sc->sc_dv.dv_xname);
return;
}
/* For each detected unit, collect size and store in an array. */
for (i = 0; i < TWE_MAX_UNITS; i++) {
for (i = 0, sc->sc_nunits = 0; i < TWE_MAX_UNITS; i++) {
/* Unit present? */
if (dtp->tp_data[i] == 0) {
if ((dtp->tp_data[i] & TWE_PARAM_UNITSTATUS_Online) == 0) {
sc->sc_dsize[i] = 0;
continue;
}
ctp = twe_param_get(sc, TWE_UNIT_INFORMATION_TABLE_BASE + i,
4, 4, NULL);
ctp = twe_param_get(sc, TWE_PARAM_UNITINFO + i,
TWE_PARAM_UNITINFO_Capacity, 4, NULL);
if (ctp == NULL) {
printf("%s: error fetching capacity for unit %d\n",
sc->sc_dv.dv_xname, i);
@ -308,6 +326,7 @@ twe_attach(struct device *parent, struct device *self, void *aux)
sc->sc_dsize[i] = le32toh(*(u_int32_t *)ctp->tp_data);
free(ctp, M_DEVBUF);
sc->sc_nunits++;
}
free(dtp, M_DEVBUF);
@ -355,10 +374,11 @@ twe_reset(struct twe_softc *sc)
/* Pull AENs out of the controller; look for a soft reset AEN. */
for (got = 0;;) {
/* XXX Magic numbers. */
if ((tp = twe_param_get(sc, 0x401, 2, 2, NULL)) == NULL)
tp = twe_param_get(sc, TWE_PARAM_AEN, TWE_PARAM_AEN_UnitCode,
2, NULL);
if (tp == NULL)
return (-1);
aen = le16toh(*(u_int16_t *)tp->tp_data);
aen = TWE_AEN_CODE(le16toh(*(u_int16_t *)tp->tp_data));
free(tp, M_DEVBUF);
if (aen == TWE_AEN_QUEUE_EMPTY)
break;
@ -456,8 +476,8 @@ twe_intr(void *arg)
* state change has occured.
*/
if ((status & TWE_STS_ATTN_INTR) != 0) {
/* XXX Magic numbers. */
twe_param_get(sc, 0x401, 2, 2, twe_aen_handler);
twe_param_get(sc, TWE_PARAM_AEN, TWE_PARAM_AEN_UnitCode, 2,
twe_aen_handler);
TWE_OUTL(sc, TWE_REG_CTL, TWE_CTL_CLEAR_ATTN_INTR);
caught = 1;
}
@ -494,40 +514,56 @@ twe_aen_handler(struct twe_ccb *ccb, int error)
struct twe_param *tp;
const char *str;
u_int aen;
int i;
int i, hu;
sc = (struct twe_softc *)ccb->ccb_tx.tx_dv;
tp = ccb->ccb_tx.tx_context;
twe_ccb_unmap(sc, ccb);
if (error)
if (error) {
printf("%s: error retrieving AEN\n", sc->sc_dv.dv_xname);
else {
aen = TWE_AEN_QUEUE_EMPTY;
} else
aen = le16toh(*(u_int16_t *)tp->tp_data);
str = "<unknown>";
i = 0;
while (i < sizeof(twe_aen_names) / sizeof(twe_aen_names[0])) {
if (twe_aen_names[i].aen == aen) {
str = twe_aen_names[i].desc;
break;
}
i++;
}
printf("%s: AEN 0x%04x (%s) recieved\n", sc->sc_dv.dv_xname,
aen, str);
}
free(tp, M_DEVBUF);
twe_ccb_free(sc, ccb);
if (TWE_AEN_CODE(aen) != TWE_AEN_QUEUE_EMPTY) {
str = "<unknown>";
i = 0;
hu = 0;
while (i < sizeof(twe_aen_names) / sizeof(twe_aen_names[0])) {
if (TWE_AEN_CODE(twe_aen_names[i].aen) ==
TWE_AEN_CODE(aen)) {
str = twe_aen_names[i].desc;
hu = (TWE_AEN_UNIT(twe_aen_names[i].aen) != 0);
break;
}
i++;
}
printf("%s: AEN 0x%04x (%s) received", sc->sc_dv.dv_xname,
TWE_AEN_CODE(aen), str);
if (hu != 0)
printf(" for unit %d", TWE_AEN_UNIT(aen));
printf("\n");
/*
* Chain another retrieval in case interrupts have been
* coalesced.
*/
twe_param_get(sc, TWE_PARAM_AEN, TWE_PARAM_AEN_UnitCode, 2,
twe_aen_handler);
}
}
/*
* Execute a TWE_OP_GET_PARAM command. If a callback function is provided,
* it will be called with generated context when the command has completed.
* If no callback is provided, the command will be executed synchronously
* and the data returned.
* and a pointer to a buffer containing the data returned.
*
* The caller or callback is responsible for freeing the data.
* The caller or callback is responsible for freeing the buffer.
*/
static void *
twe_param_get(struct twe_softc *sc, int table_id, int param_id, size_t size,
@ -538,16 +574,13 @@ twe_param_get(struct twe_softc *sc, int table_id, int param_id, size_t size,
struct twe_param *tp;
int rv, s;
if (twe_ccb_alloc(sc, &ccb, 1) != 0) {
/* XXX */
if (twe_ccb_alloc(sc, &ccb, TWE_CCB_PARAM | TWE_CCB_DATA_IN |
TWE_CCB_DATA_OUT) != 0)
return (NULL);
}
tp = malloc(TWE_SECTOR_SIZE, M_DEVBUF, M_NOWAIT);
ccb->ccb_data = tp;
ccb->ccb_datasize = TWE_SECTOR_SIZE;
ccb->ccb_flags = TWE_CCB_DATA_IN | TWE_CCB_DATA_OUT;
ccb->ccb_tx.tx_handler = func;
ccb->ccb_tx.tx_context = tp;
ccb->ccb_tx.tx_dv = &sc->sc_dv;
@ -601,7 +634,7 @@ twe_init_connection(struct twe_softc *sc)
struct twe_cmd *tc;
int rv;
if ((rv = twe_ccb_alloc(sc, &ccb, 1)) != 0)
if ((rv = twe_ccb_alloc(sc, &ccb, 0)) != 0)
return (rv);
/* Build the command. */
@ -609,7 +642,7 @@ twe_init_connection(struct twe_softc *sc)
tc->tc_size = 3;
tc->tc_opcode = TWE_OP_INIT_CONNECTION;
tc->tc_unit = 0;
tc->tc_count = htole16(TWE_INIT_MESSAGE_CREDITS);
tc->tc_count = htole16(TWE_MAX_CMDS);
tc->tc_args.init_connection.response_queue_pointer = 0;
/* Submit the command for immediate execution. */
@ -642,7 +675,7 @@ twe_poll(struct twe_softc *sc)
found = 1;
cmdid = TWE_INL(sc, TWE_REG_RESP_QUEUE);
cmdid = (cmdid & TWE_RESP_MASK) >> TWE_RESP_SHIFT;
if (cmdid >= TWE_MAX_QUEUECNT) {
if (cmdid >= TWE_REAL_MAX_QUEUECNT) {
printf("%s: bad completion\n", sc->sc_dv.dv_xname);
continue;
}
@ -717,54 +750,56 @@ twe_status_check(struct twe_softc *sc, u_int status)
* Allocate and initialise a CCB.
*/
int
twe_ccb_alloc(struct twe_softc *sc, struct twe_ccb **ccbp, int nowait)
twe_ccb_alloc(struct twe_softc *sc, struct twe_ccb **ccbp, int flags)
{
struct twe_cmd *tc;
struct twe_ccb *ccb;
int s;
s = splbio();
/* Allocate a CCB and command block. */
if (SLIST_FIRST(&sc->sc_ccb_freelist) == NULL) {
if (nowait) {
if ((flags & TWE_CCB_PARAM) != 0)
ccb = sc->sc_ccbs;
else {
s = splbio();
/* Allocate a CCB and command block. */
if (SLIST_FIRST(&sc->sc_ccb_freelist) == NULL) {
splx(s);
return (EAGAIN);
}
sc->sc_ccb_waitcnt++;
tsleep(&sc->sc_ccb_waitcnt, PRIBIO, "twepaqc", 0);
ccb = SLIST_FIRST(&sc->sc_ccb_freelist);
SLIST_REMOVE_HEAD(&sc->sc_ccb_freelist, ccb_chain.slist);
splx(s);
}
ccb = SLIST_FIRST(&sc->sc_ccb_freelist);
SLIST_REMOVE_HEAD(&sc->sc_ccb_freelist, ccb_chain.slist);
#ifdef DIAGNOSTIC
if ((ccb->ccb_flags & TWE_CCB_ALLOCED) != 0)
panic("twe_ccb_alloc: CCB already allocated");
flags |= TWE_CCB_ALLOCED;
#endif
/* Initialise some fields and return. */
ccb->ccb_tx.tx_handler = NULL;
ccb->ccb_flags = flags;
tc = ccb->ccb_cmd;
tc->tc_status = 0;
tc->tc_flags = 0;
tc->tc_cmdid = ccb->ccb_cmdid;
splx(s);
*ccbp = ccb;
return (0);
}
/*
* Free a CCB. Wake one process that's waiting for a free CCB, if any.
* Free a CCB.
*/
void
twe_ccb_free(struct twe_softc *sc, struct twe_ccb *ccb)
{
int s;
ccb->ccb_flags = 0;
s = splbio();
SLIST_INSERT_HEAD(&sc->sc_ccb_freelist, ccb, ccb_chain.slist);
if (sc->sc_ccb_waitcnt != 0) {
sc->sc_ccb_waitcnt--;
wakeup_one(&sc->sc_ccb_waitcnt);
}
if ((ccb->ccb_flags & TWE_CCB_PARAM) == 0)
SLIST_INSERT_HEAD(&sc->sc_ccb_freelist, ccb, ccb_chain.slist);
ccb->ccb_flags = 0;
splx(s);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: twereg.h,v 1.2 2000/10/26 14:43:50 ad Exp $ */
/* $NetBSD: twereg.h,v 1.3 2000/11/08 19:23:50 ad Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -109,25 +109,27 @@
#define TWE_STS_UNEXPECTED_BITS 0x00f80000
/* Command packet opcodes. */
#define TWE_OP_NOP 0x00
#define TWE_OP_INIT_CONNECTION 0x01
#define TWE_OP_READ 0x02
#define TWE_OP_WRITE 0x03
#define TWE_OP_VERIFY 0x04
#define TWE_OP_GET_PARAM 0x12
#define TWE_OP_SET_PARAM 0x13
#define TWE_OP_SECTOR_INFO 0x1a
#define TWE_OP_AEN_LISTEN 0x1c
/* Asynchronous event notification (AEN) codes. */
#define TWE_AEN_QUEUE_EMPTY 0x0000
#define TWE_AEN_SOFT_RESET 0x0001
#define TWE_AEN_DEGRADED_MIRROR 0x0002
#define TWE_AEN_CONTROLLER_ERROR 0x0003
#define TWE_AEN_REBUILD_FAIL 0x0004
#define TWE_AEN_REBUILD_DONE 0x0005
#define TWE_AEN_TABLE_UNDEFINED 0x0015
#define TWE_AEN_QUEUE_FULL 0x00ff
#define TWE_OP_NOP 0x00
#define TWE_OP_INIT_CONNECTION 0x01
#define TWE_OP_READ 0x02
#define TWE_OP_WRITE 0x03
#define TWE_OP_READVERIFY 0x04
#define TWE_OP_VERIFY 0x05
#define TWE_OP_ZEROUNIT 0x08
#define TWE_OP_REPLACEUNIT 0x09
#define TWE_OP_HOTSWAP 0x0a
#define TWE_OP_SETATAFEATURE 0x0c
#define TWE_OP_FLUSH 0x0e
#define TWE_OP_ABORT 0x0f
#define TWE_OP_CHECKSTATUS 0x10
#define TWE_OP_GET_PARAM 0x12
#define TWE_OP_SET_PARAM 0x13
#define TWE_OP_CREATEUNIT 0x14
#define TWE_OP_DELETEUNIT 0x15
#define TWE_OP_REBUILDUNIT 0x17
#define TWE_OP_SECTOR_INFO 0x1a
#define TWE_OP_AEN_LISTEN 0x1c
#define TWE_OP_CMD_PACKET 0x1d
/* Response queue entries. Masking and shifting yields request ID. */
#define TWE_RESP_MASK 0x00000ff0
@ -136,18 +138,16 @@
/* Miscellenous constants. */
#define TWE_ALIGNMENT 512
#define TWE_MAX_UNITS 16
#define TWE_INIT_MESSAGE_CREDITS 0x100
#define TWE_INIT_CMD_PACKET_SIZE 0x3
#define TWE_SG_SIZE 62
#define TWE_MAX_CMDS 255
#define TWE_Q_START 0
#define TWE_UNIT_INFORMATION_TABLE_BASE 0x300
#define TWE_IOCTL 0x80
#define TWE_MAX_AEN_TRIES 100
#define TWE_SECTOR_SIZE 512
/* Maximum transfer size. XXX This is an arbitrarily chosen value. */
#define TWE_MAX_XFER 1048576
#define TWE_MAX_XFER (TWE_SG_SIZE * NBPG)
/* Scatter/gather block. */
struct twe_sgb {
@ -190,4 +190,150 @@ struct twe_param {
u_int8_t tp_data[1];
} __attribute__ ((packed));
/*
* From 3ware's documentation:
*
* All parameters maintained by the controller are grouped into related
* tables. Tables are are accessed indirectly via get and set parameter
* commands. To access a specific parameter in a table, the table ID and
* parameter index are used to uniquely identify a parameter. Table
* 0xffff is the directory table and provides a list of the table IDs and
* sizes of all other tables. Index zero in each table specifies the
* entire table, and index one specifies the size of the table. An entire
* table can be read or set by using index zero.
*/
#define TWE_PARAM_PARAM_ALL 0
#define TWE_PARAM_PARAM_SIZE 1
#define TWE_PARAM_DIRECTORY 0xffff /* size is 4 * number of tables */
#define TWE_PARAM_DIRECTORY_TABLES 2 /* 16 bits * number of tables */
#define TWE_PARAM_DIRECTORY_SIZES 3 /* 16 bits * number of tables */
#define TWE_PARAM_DRIVESUMMARY 0x0002
#define TWE_PARAM_DRIVESUMMARY_Num 2 /* number of physical drives [2] */
#define TWE_PARAM_DRIVESUMMARY_Status 3 /* array giving drive status per aport */
#define TWE_PARAM_DRIVESTATUS_Missing 0x00
#define TWE_PARAM_DRIVESTATUS_NotSupp 0xfe
#define TWE_PARAM_DRIVESTATUS_Present 0xff
#define TWE_PARAM_UNITSUMMARY 0x0003
#define TWE_PARAM_UNITSUMMARY_Num 2 /* number of logical units [2] */
#define TWE_PARAM_UNITSUMMARY_Status 3 /* array giving unit status [16] */
#define TWE_PARAM_UNITSTATUS_Online (1<<0)
#define TWE_PARAM_UNITSTATUS_Complete (1<<1)
#define TWE_PARAM_UNITSTATUS_MASK 0xfc
#define TWE_PARAM_UNITSTATUS_Normal 0xfc
#define TWE_PARAM_UNITSTATUS_Initialising 0xf4 /* cannot be incomplete */
#define TWE_PARAM_UNITSTATUS_Degraded 0xec
#define TWE_PARAM_UNITSTATUS_Rebuilding 0xdc /* cannot be incomplete */
#define TWE_PARAM_UNITSTATUS_Verifying 0xcc /* cannot be incomplete */
#define TWE_PARAM_UNITSTATUS_Corrupt 0xbc /* cannot be complete */
#define TWE_PARAM_UNITSTATUS_Missing 0x00 /* cannot be complete or online */
#define TWE_PARAM_DRIVEINFO 0x0200 /* add drive number 0x00-0x0f XXX docco confused 0x0100 vs 0x0200 */
#define TWE_PARAM_DRIVEINFO_Size 2 /* size in blocks [4] */
#define TWE_PARAM_DRIVEINFO_Model 3 /* drive model string [40] */
#define TWE_PARAM_DRIVEINFO_Serial 4 /* drive serial number [20] */
#define TWE_PARAM_DRIVEINFO_PhysCylNum 5 /* physical geometry [2] */
#define TWE_PARAM_DRIVEINFO_PhysHeadNum 6 /* [2] */
#define TWE_PARAM_DRIVEINFO_PhysSectorNym 7 /* [2] */
#define TWE_PARAM_DRIVEINFO_LogCylNum 8 /* logical geometry [2] */
#define TWE_PARAM_DRIVEINFO_LogHeadNum 9 /* [2] */
#define TWE_PARAM_DRIVEINFO_LogSectorNum 10 /* [2] */
#define TWE_PARAM_DRIVEINFO_UnitNum 11 /* unit number this drive is associated with or 0xff [1] */
#define TWE_PARAM_DRIVEINFO_DriveFlags 12 /* N/A [1] */
#define TWE_PARAM_APORTTIMEOUT 0x02c0 /* add (aport_number * 3) to parameter index */
#define TWE_PARAM_APORTTIMEOUT_READ 2 /* read timeouts last 24hrs [2] */
#define TWE_PARAM_APORTTIMEOUT_WRITE 3 /* write timeouts last 24hrs [2] */
#define TWE_PARAM_APORTTIMEOUT_DEGRADE 4 /* degrade threshold [2] */
#define TWE_PARAM_UNITINFO 0x0300 /* add unit number 0x00-0x0f */
#define TWE_PARAM_UNITINFO_Number 2 /* unit number [1] */
#define TWE_PARAM_UNITINFO_Status 3 /* unit status [1] */
#define TWE_PARAM_UNITINFO_Capacity 4 /* unit capacity in blocks [4] */
#define TWE_PARAM_UNITINFO_DescriptorSize 5 /* unit descriptor size + 3 bytes [2] */
#define TWE_PARAM_UNITINFO_Descriptor 6 /* unit descriptor, TWE_UnitDescriptor or TWE_Array_Descriptor */
#define TWE_PARAM_UNITINFO_Flags 7 /* unit flags [1] */
#define TWE_PARAM_UNITFLAGS_WCE (1<<0)
#define TWE_PARAM_AEN 0x0401
#define TWE_PARAM_AEN_UnitCode 2 /* (unit number << 8) | AEN code [2] */
#define TWE_AEN_QUEUE_EMPTY 0x00
#define TWE_AEN_SOFT_RESET 0x01
#define TWE_AEN_DEGRADED_MIRROR 0x02 /* reports unit */
#define TWE_AEN_CONTROLLER_ERROR 0x03
#define TWE_AEN_REBUILD_FAIL 0x04 /* reports unit */
#define TWE_AEN_REBUILD_DONE 0x05 /* reports unit */
#define TWE_AEN_INCOMP_UNIT 0x06 /* reports unit */
#define TWE_AEN_INIT_DONE 0x07 /* reports unit */
#define TWE_AEN_UNCLEAN_SHUTDOWN 0x08 /* reports unit */
#define TWE_AEN_APORT_TIMEOUT 0x09 /* reports unit, rate limited to 1 per 2^16 errors */
#define TWE_AEN_DRIVE_ERROR 0x0a /* reports unit */
#define TWE_AEN_REBUILD_STARTED 0x0b /* reports unit */
#define TWE_AEN_QUEUE_FULL 0xff
#define TWE_AEN_TABLE_UNDEFINED 0x15
#define TWE_AEN_CODE(x) ((x) & 0xff)
#define TWE_AEN_UNIT(x) ((x) >> 8)
#define TWE_PARAM_VERSION 0x0402
#define TWE_PARAM_VERSION_Mon 2 /* monitor version [16] */
#define TWE_PARAM_VERSION_FW 3 /* firmware version [16] */
#define TWE_PARAM_VERSION_BIOS 4 /* BIOSs version [16] */
#define TWE_PARAM_VERSION_PCB 5 /* PCB version [8] */
#define TWE_PARAM_VERSION_ATA 6 /* A-chip version [8] */
#define TWE_PARAM_VERSION_PCI 7 /* P-chip version [8] */
#define TWE_PARAM_VERSION_CtrlModel 8 /* N/A */
#define TWE_PARAM_VERSION_CtrlSerial 9 /* N/A */
#define TWE_PARAM_VERSION_SBufSize 10 /* N/A */
#define TWE_PARAM_VERSION_CompCode 11 /* compatibility code [4] */
#define TWE_PARAM_CONTROLLER 0x0403
#define TWE_PARAM_CONTROLLER_DCBSectors 2 /* # sectors reserved for DCB per drive [2] */
#define TWE_PARAM_CONTROLLER_PortCount 3 /* number of drive ports [1] */
#define TWE_PARAM_FEATURES 0x404
#define TWE_PARAM_FEATURES_DriverShutdown 2 /* set to 1 if driver supports shutdown notification [1] */
struct twe_unit_descriptor {
u_int8_t num_subunits; /* must be zero */
u_int8_t configuration;
#define TWE_UD_CONFIG_CBOD 0x0c /* JBOD with DCB, used for mirrors */
#define TWE_UD_CONFIG_SPARE 0x0d /* same as CBOD, but firmware will use as spare */
#define TWE_UD_CONFIG_SUBUNIT 0x0e /* drive is a subunit in an array */
#define TWE_UD_CONFIG_JBOD 0x0f /* plain drive */
u_int8_t phys_drv_num; /* may be 0xff if port can't be determined at runtime */
u_int8_t log_drv_num; /* must be zero for configuration == 0x0f */
u_int32_t start_lba;
u_int32_t block_count; /* actual drive size if configuration == 0x0f, otherwise less DCB size */
} __attribute__ ((packed));
struct twe_mirror_descriptor {
u_int8_t flag; /* must be 0xff */
u_int8_t res1;
u_int8_t mirunit_status[4]; /* bitmap of functional subunits in each mirror */
u_int8_t res2[6];
} __attribute__ ((packed));
struct twe_array_descriptor {
u_int8_t num_subunits; /* number of subunits, or number of mirror units in RAID10 */
u_int8_t configuration;
#define TWE_AD_CONFIG_RAID0 0x00
#define TWE_AD_CONFIG_RAID1 0x01
#define TWE_AD_CONFIG_TwinStor 0x02
#define TWE_AD_CONFIG_RAID5 0x05
#define TWE_AD_CONFIG_RAID10 0x06
u_int8_t stripe_size;
#define TWE_AD_STRIPE_4k 0x03
#define TWE_AD_STRIPE_8k 0x04
#define TWE_AD_STRIPE_16k 0x05
#define TWE_AD_STRIPE_32k 0x06
#define TWE_AD_STRIPE_64k 0x07
u_int8_t log_drv_status; /* bitmap of functional subunits, or mirror units in RAID10 */
u_int32_t start_lba;
u_int32_t block_count; /* actual drive size if configuration == 0x0f, otherwise less DCB size */
struct twe_unit_descriptor subunit[1];
} __attribute__ ((packed));
#endif /* !_PCI_TWEREG_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: twevar.h,v 1.2 2000/10/20 15:14:25 ad Exp $ */
/* $NetBSD: twevar.h,v 1.3 2000/11/08 19:23:50 ad Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -70,9 +70,16 @@
#include "locators.h"
#define TWE_MIN_QUEUECNT 9 /* One per unit + one for AENs */
#ifndef TWE_MAX_QUEUECNT
#define TWE_MAX_QUEUECNT 128 /* Maximum per-adapter queue count */
#elif TWE_MAX_QUEUECNT > TWE_MAX_CMDS
#error TWE_MAX_QUEUECNT > TWE_MAX_CMDS
#elif TWE_MAX_QUEUECNT < TWE_MIN_QUEUECNT
#error TWE_MAX_QUEUECNT < TWE_MIN_QUEUECNT
#endif
#ifndef TWE_MAX_PU_QUEUECNT
#define TWE_MAX_PU_QUEUECNT 32 /* Maximum per-unit queue count */
#endif
@ -93,10 +100,11 @@ struct twe_softc {
void *sc_ih;
caddr_t sc_cmds;
bus_addr_t sc_cmds_paddr;
int sc_nccbs;
struct twe_ccb *sc_ccbs;
SIMPLEQ_HEAD(, twe_ccb) sc_ccb_queue;
SLIST_HEAD(, twe_ccb) sc_ccb_freelist;
int sc_ccb_waitcnt;
int sc_nunits;
u_int sc_dsize[TWE_MAX_UNITS];
};
@ -126,6 +134,8 @@ struct twe_ccb {
#define TWE_CCB_DATA_OUT 0x02 /* Map describes outbound xfer */
#define TWE_CCB_COMPLETE 0x04 /* Command completed */
#define TWE_CCB_ACTIVE 0x08 /* Command active */
#define TWE_CCB_PARAM 0x10 /* For parameter retrieval */
#define TWE_CCB_ALLOCED 0x20 /* CCB allocated */
struct twe_attach_args {
int twea_unit;