From owner-svn-src-projects@FreeBSD.ORG Wed Aug 24 14:53:49 2011 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E3576106566B; Wed, 24 Aug 2011 14:53:49 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D33948FC0C; Wed, 24 Aug 2011 14:53:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7OErnAN059319; Wed, 24 Aug 2011 14:53:49 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7OErneC059317; Wed, 24 Aug 2011 14:53:49 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201108241453.p7OErneC059317@svn.freebsd.org> From: Alexander Motin Date: Wed, 24 Aug 2011 14:53:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225147 - projects/zfsd/head/sys/cam/scsi X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Aug 2011 14:53:50 -0000 Author: mav Date: Wed Aug 24 14:53:49 2011 New Revision: 225147 URL: http://svn.freebsd.org/changeset/base/225147 Log: Try to read global flags on startup. Fix SAFT_BAIL() macro usage. Modified: projects/zfsd/head/sys/cam/scsi/scsi_enc_safte.c Modified: projects/zfsd/head/sys/cam/scsi/scsi_enc_safte.c ============================================================================== --- projects/zfsd/head/sys/cam/scsi/scsi_enc_safte.c Wed Aug 24 14:12:35 2011 (r225146) +++ projects/zfsd/head/sys/cam/scsi/scsi_enc_safte.c Wed Aug 24 14:53:49 2011 (r225147) @@ -70,6 +70,7 @@ static int perf_slotop(enc_softc_t *, ui #define SAFTE_RD_RDCFG 0x00 /* read enclosure configuration */ #define SAFTE_RD_RDESTS 0x01 /* read enclosure status */ #define SAFTE_RD_RDDSTS 0x04 /* read drive slot status */ +#define SAFTE_RD_RDGFLG 0x05 /* read global flags */ /* * WRITE BUFFER ('set' commands) IDs- placed in offset 0 of databuf @@ -86,6 +87,7 @@ static int perf_slotop(enc_softc_t *, ui typedef enum { SAFTE_UPDATE_NONE, SAFTE_UPDATE_READCONFIG, + SAFTE_UPDATE_READGFLAGS, SAFTE_UPDATE_READENCSTATUS, SAFTE_UPDATE_READSLOTSTATUS, SAFTE_NUM_UPDATE_STATES @@ -93,6 +95,7 @@ typedef enum { static fsm_fill_handler_t safte_fill_read_buf_io; static fsm_done_handler_t safte_process_config; +static fsm_done_handler_t safte_process_gflags; static fsm_done_handler_t safte_process_status; static fsm_done_handler_t safte_process_slotstatus; @@ -109,6 +112,15 @@ static struct enc_fsm_state enc_fsm_stat enc_error }, { + "SAFTE_UPDATE_READGFLAGS", + SAFTE_RD_RDGFLG, + 16, + 60 * 1000, + safte_fill_read_buf_io, + safte_process_gflags, + enc_error + }, + { "SAFTE_UPDATE_READENCSTATUS", SAFTE_RD_RDESTS, SCSZ, @@ -167,10 +179,9 @@ struct scfg { #define SAFT_PRIVATE sizeof (struct scfg) static char *safte_2little = "Too Little Data Returned (%d) at line %d\n"; -#define SAFT_BAIL(r, x, k) \ +#define SAFT_BAIL(r, x) \ if ((r) >= (x)) { \ ENC_LOG(enc, safte_2little, x, __LINE__);\ - ENC_FREE((k)); \ return (EIO); \ } @@ -266,6 +277,7 @@ safte_process_config(enc_softc_t *enc, s for (i = 0; i < cfg->Nslots; i++) enc->enc_cache.elm_map[r++].enctype = ELMTYP_DEVICE; + enc_update_request(enc, SAFTE_UPDATE_READGFLAGS); enc_update_request(enc, SAFTE_UPDATE_READENCSTATUS); enc_update_request(enc, SAFTE_UPDATE_READSLOTSTATUS); @@ -273,6 +285,24 @@ safte_process_config(enc_softc_t *enc, s } static int +safte_process_gflags(enc_softc_t *enc, struct enc_fsm_state *state, + union ccb *ccb, uint8_t **bufp, int xfer_len) +{ + struct scfg *cfg; + uint8_t *buf = *bufp; + + cfg = enc->enc_private; + if (cfg == NULL) + return (ENXIO); + + SAFT_BAIL(3, xfer_len); + cfg->flag1 = buf[1]; + cfg->flag2 = buf[2]; + + return (0); +} + +static int safte_process_status(enc_softc_t *enc, struct enc_fsm_state *state, union ccb *ccb, uint8_t **bufp, int xfer_len) { @@ -289,7 +319,7 @@ safte_process_status(enc_softc_t *enc, s oid = r = 0; for (nitems = i = 0; i < cfg->Nfans; i++) { - SAFT_BAIL(r, xfer_len, buf); + SAFT_BAIL(r, xfer_len); /* * 0 = Fan Operational * 1 = Fan is malfunctioning @@ -366,7 +396,7 @@ safte_process_status(enc_softc_t *enc, s for (i = 0; i < cfg->Npwr; i++) { - SAFT_BAIL(r, xfer_len, buf); + SAFT_BAIL(r, xfer_len); cache->elm_map[oid].encstat[0] = SES_OBJSTAT_UNKNOWN; cache->elm_map[oid].encstat[1] = 0; /* resvd */ cache->elm_map[oid].encstat[2] = 0; /* resvd */ @@ -427,7 +457,7 @@ safte_process_status(enc_softc_t *enc, s * We always have doorlock status, no matter what, * but we only save the status if we have one. */ - SAFT_BAIL(r, xfer_len, buf); + SAFT_BAIL(r, xfer_len); if (cfg->DoorLock) { /* * 0 = Door Locked @@ -465,7 +495,7 @@ safte_process_status(enc_softc_t *enc, s * We always have speaker status, no matter what, * but we only save the status if we have one. */ - SAFT_BAIL(r, xfer_len, buf); + SAFT_BAIL(r, xfer_len); if (cfg->Nspkrs) { cache->elm_map[oid].encstat[1] = 0; cache->elm_map[oid].encstat[2] = 0; @@ -500,13 +530,13 @@ safte_process_status(enc_softc_t *enc, s * binary temperature sensor. */ - SAFT_BAIL(r + cfg->Ntherm, xfer_len, buf); + SAFT_BAIL(r + cfg->Ntherm, xfer_len); tempflags = buf[r + cfg->Ntherm]; - SAFT_BAIL(r + cfg->Ntherm + 1, xfer_len, buf); + SAFT_BAIL(r + cfg->Ntherm + 1, xfer_len); tempflags |= (tempflags << 8) | buf[r + cfg->Ntherm + 1]; for (i = 0; i < cfg->Ntherm; i++) { - SAFT_BAIL(r, xfer_len, buf); + SAFT_BAIL(r, xfer_len); /* * Status is a range from -10 to 245 deg Celsius, * which we need to normalize to -20 to -245 according @@ -606,7 +636,7 @@ safte_process_slotstatus(enc_softc_t *en oid = cfg->slotoff; for (r = i = 0; i < cfg->Nslots; i++, r += 4) { - SAFT_BAIL(r+3, xfer_len, buf); + SAFT_BAIL(r+3, xfer_len); cache->elm_map[oid].encstat[0] = SES_OBJSTAT_UNSUPPORTED; cache->elm_map[oid].encstat[1] = (uint8_t) i; cache->elm_map[oid].encstat[2] = 0;