Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Aug 2011 12:09:40 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r225175 - projects/zfsd/head/sys/cam/scsi
Message-ID:  <201108251209.p7PC9e3w002929@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Thu Aug 25 12:09:40 2011
New Revision: 225175
URL: http://svn.freebsd.org/changeset/base/225175

Log:
  Make emulate_array_devices global to not bother with locking and kenv.
  This also makes it writable sysctl.

Modified:
  projects/zfsd/head/sys/cam/scsi/scsi_enc.c
  projects/zfsd/head/sys/cam/scsi/scsi_enc_safte.c

Modified: projects/zfsd/head/sys/cam/scsi/scsi_enc.c
==============================================================================
--- projects/zfsd/head/sys/cam/scsi/scsi_enc.c	Thu Aug 25 11:39:32 2011	(r225174)
+++ projects/zfsd/head/sys/cam/scsi/scsi_enc.c	Thu Aug 25 12:09:40 2011	(r225175)
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/queue.h>
 #include <sys/sx.h>
 #include <sys/systm.h>
+#include <sys/sysctl.h>
 #include <sys/types.h>
 
 #include <machine/stdarg.h>
@@ -76,6 +77,9 @@ static  periph_start_t  enc_start;
 static void enc_async(void *, uint32_t, struct cam_path *, void *);
 static enctyp enc_type(struct ccb_getdev *);
 
+SYSCTL_NODE(_kern_cam, OID_AUTO, enc, CTLFLAG_RD, 0,
+            "CAM Enclosure Services driver");
+
 static struct periph_driver encdriver = {
 	enc_init, "enc",
 	TAILQ_HEAD_INITIALIZER(encdriver.units), /* generation */ 0

Modified: projects/zfsd/head/sys/cam/scsi/scsi_enc_safte.c
==============================================================================
--- projects/zfsd/head/sys/cam/scsi/scsi_enc_safte.c	Thu Aug 25 11:39:32 2011	(r225174)
+++ projects/zfsd/head/sys/cam/scsi/scsi_enc_safte.c	Thu Aug 25 12:09:40 2011	(r225175)
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD: head/sys/cam/scsi/sc
 #include <sys/queue.h>
 #include <sys/sx.h>
 #include <sys/systm.h>
+#include <sys/sysctl.h>
 #include <sys/types.h>
 
 #include <cam/cam.h>
@@ -162,7 +163,6 @@ enum {
 };
 
 struct scfg {
-	int	emulate_array_devices;
 	/*
 	 * Cached Configuration
 	 */
@@ -214,6 +214,12 @@ static char *safte_2little = "Too Little
 		return (EIO); \
 	}
 
+int emulate_array_devices = 1;
+SYSCTL_DECL(_kern_cam_enc);
+SYSCTL_INT(_kern_cam_enc, OID_AUTO, emulate_array_devices, CTLFLAG_RW,
+           &emulate_array_devices, 0, "Emulate Array Devices for SAF-TE");
+TUNABLE_INT("kern.cam.enc.emulate_array_devices", &emulate_array_devices);
+
 static int
 safte_fill_read_buf_io(enc_softc_t *enc, struct enc_fsm_state *state,
 		       union ccb *ccb, uint8_t *buf)
@@ -302,7 +308,7 @@ safte_process_config(enc_softc_t *enc, s
 	cfg->slotoff = (uint8_t) r;
 	for (i = 0; i < cfg->Nslots; i++)
 		enc->enc_cache.elm_map[r++].enctype =
-		    cfg->emulate_array_devices ? ELMTYP_ARRAY_DEV :
+		    emulate_array_devices ? ELMTYP_ARRAY_DEV :
 		     ELMTYP_DEVICE;
 
 	enc_update_request(enc, SAFTE_UPDATE_READGFLAGS);
@@ -488,7 +494,7 @@ safte_process_status(enc_softc_t *enc, s
 	 */
 	for (i = 0; i < cfg->Nslots; i++) {
 		SAFT_BAIL(r, xfer_len);
-		if (!cfg->emulate_array_devices)
+		if (cache->elm_map[cfg->slotoff + i].enctype == ELMTYP_DEVICE)
 			cache->elm_map[cfg->slotoff + i].encstat[1] = buf[r];
 		r++;
 	}
@@ -660,7 +666,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);
-		if (cfg->emulate_array_devices)
+		if (cache->elm_map[oid].enctype == ELMTYP_ARRAY_DEV)
 			cache->elm_map[oid].encstat[1] = 0;
 		cache->elm_map[oid].encstat[2] &= SESCTL_RQSID;
 		cache->elm_map[oid].encstat[3] = 0;
@@ -687,7 +693,7 @@ safte_process_slotstatus(enc_softc_t *en
 			cache->elm_map[oid].encstat[3] |= SESCTL_RQSFLT;
 		if (buf[r+0] & 0x40)
 			cache->elm_map[oid].encstat[0] |= SESCTL_PRDFAIL;
-		if (cfg->emulate_array_devices) {
+		if (cache->elm_map[oid].enctype == ELMTYP_ARRAY_DEV) {
 			if (buf[r+0] & 0x04)
 				cache->elm_map[oid].encstat[1] |= 0x02;
 			if (buf[r+0] & 0x08)
@@ -763,7 +769,7 @@ safte_fill_control_request(enc_softc_t *
 					ep->priv |= 0x02;
 				if ((ep->priv & 0x46) == 0)
 					ep->priv |= 0x01;	/* no errors */
-				if (cfg->emulate_array_devices) {
+				if (ep->enctype == ELMTYP_ARRAY_DEV) {
 					if (req->elm_stat[1] & 0x01)
 						ep->priv |= 0x200;
 					if (req->elm_stat[1] & 0x02)
@@ -1103,7 +1109,6 @@ int
 safte_softc_init(enc_softc_t *enc, int doinit)
 {
 	struct scfg *cfg;
-	char buf[32];
 
 	if (doinit == 0) {
 		safte_softc_cleanup(enc->periph);
@@ -1124,10 +1129,6 @@ safte_softc_init(enc_softc_t *enc, int d
 	enc->enc_cache.enc_status = 0;
 
 	TAILQ_INIT(&cfg->requests);
-	cfg->emulate_array_devices = 1;
-	snprintf(buf, sizeof(buf), "kern.cam.enc.%d.emulate_array_devices",
-	    enc->periph->unit_number);
-	TUNABLE_INT_FETCH(buf, &cfg->emulate_array_devices);
 	return (0);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201108251209.p7PC9e3w002929>