summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorslm <slm@FreeBSD.org>2016-07-19 16:46:27 +0000
committerslm <slm@FreeBSD.org>2016-07-19 16:46:27 +0000
commitccb13f18cfd4b4fcbcd68c01609f4082564e190a (patch)
tree23ed71da144a5fa969fe22f44cb0727a5d24ec2d /sys
parent3760c494321b25497428e91014ec0883ec849117 (diff)
downloadFreeBSD-src-ccb13f18cfd4b4fcbcd68c01609f4082564e190a.zip
FreeBSD-src-ccb13f18cfd4b4fcbcd68c01609f4082564e190a.tar.gz
MFC r302673
Use real values to calculate Max I/O size instead of guessing. Reviewed by: ken, scottl Approved by: re(gjb), ken, scottl, ambrisko (mentors) Differential Revision: https://reviews.freebsd.org/D7043
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/mpr/mpr.c11
-rw-r--r--sys/dev/mpr/mpr_sas.c22
-rw-r--r--sys/dev/mpr/mprvar.h4
-rw-r--r--sys/dev/mps/mps.c11
-rw-r--r--sys/dev/mps/mps_sas.c21
-rw-r--r--sys/dev/mps/mpsvar.h4
6 files changed, 62 insertions, 11 deletions
diff --git a/sys/dev/mpr/mpr.c b/sys/dev/mpr/mpr.c
index 5ae9f4c..9e84290 100644
--- a/sys/dev/mpr/mpr.c
+++ b/sys/dev/mpr/mpr.c
@@ -1373,6 +1373,7 @@ mpr_get_tunables(struct mpr_softc *sc)
sc->disable_msix = 0;
sc->disable_msi = 0;
sc->max_chains = MPR_CHAIN_FRAMES;
+ sc->max_io_pages = MPR_MAXIO_PAGES;
sc->enable_ssu = MPR_SSU_ENABLE_SSD_DISABLE_HDD;
sc->spinup_wait_time = DEFAULT_SPINUP_WAIT;
@@ -1383,6 +1384,7 @@ mpr_get_tunables(struct mpr_softc *sc)
TUNABLE_INT_FETCH("hw.mpr.disable_msix", &sc->disable_msix);
TUNABLE_INT_FETCH("hw.mpr.disable_msi", &sc->disable_msi);
TUNABLE_INT_FETCH("hw.mpr.max_chains", &sc->max_chains);
+ TUNABLE_INT_FETCH("hw.mpr.max_io_pages", &sc->max_io_pages);
TUNABLE_INT_FETCH("hw.mpr.enable_ssu", &sc->enable_ssu);
TUNABLE_INT_FETCH("hw.mpr.spinup_wait_time", &sc->spinup_wait_time);
@@ -1403,6 +1405,10 @@ mpr_get_tunables(struct mpr_softc *sc)
device_get_unit(sc->mpr_dev));
TUNABLE_INT_FETCH(tmpstr, &sc->max_chains);
+ snprintf(tmpstr, sizeof(tmpstr), "dev.mpr.%d.max_io_pages",
+ device_get_unit(sc->mpr_dev));
+ TUNABLE_INT_FETCH(tmpstr, &sc->max_io_pages);
+
bzero(sc->exclude_ids, sizeof(sc->exclude_ids));
snprintf(tmpstr, sizeof(tmpstr), "dev.mpr.%d.exclude_ids",
device_get_unit(sc->mpr_dev));
@@ -1488,6 +1494,11 @@ mpr_setup_sysctl(struct mpr_softc *sc)
&sc->max_chains, 0,"maximum chain frames that will be allocated");
SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
+ OID_AUTO, "max_io_pages", CTLFLAG_RD,
+ &sc->max_io_pages, 0,"maximum pages to allow per I/O (if <1 use "
+ "IOCFacts)");
+
+ SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
OID_AUTO, "enable_ssu", CTLFLAG_RW, &sc->enable_ssu, 0,
"enable SSU to SATA SSD/HDD at shutdown");
diff --git a/sys/dev/mpr/mpr_sas.c b/sys/dev/mpr/mpr_sas.c
index 45c0bbd..d44e502 100644
--- a/sys/dev/mpr/mpr_sas.c
+++ b/sys/dev/mpr/mpr_sas.c
@@ -971,6 +971,8 @@ mprsas_action(struct cam_sim *sim, union ccb *ccb)
case XPT_PATH_INQ:
{
struct ccb_pathinq *cpi = &ccb->cpi;
+ struct mpr_softc *sc = sassc->sc;
+ uint8_t sges_per_frame;
cpi->version_num = 1;
cpi->hba_inquiry = PI_SDTR_ABLE|PI_TAG_ABLE|PI_WIDE_16;
@@ -999,13 +1001,23 @@ mprsas_action(struct cam_sim *sim, union ccb *ccb)
cpi->transport_version = 0;
cpi->protocol = PROTO_SCSI;
cpi->protocol_version = SCSI_REV_SPC;
-#if __FreeBSD_version >= 800001
+
/*
- * XXXSLM-probably need to base this number on max SGL's and
- * page size.
+ * Max IO Size is Page Size * the following:
+ * ((SGEs per frame - 1 for chain element) *
+ * Max Chain Depth) + 1 for no chain needed in last frame
+ *
+ * If user suggests a Max IO size to use, use the smaller of the
+ * user's value and the calculated value as long as the user's
+ * value is larger than 0. The user's value is in pages.
*/
- cpi->maxio = 256 * 1024;
-#endif
+ sges_per_frame = (sc->chain_frame_size /
+ sizeof(MPI2_IEEE_SGE_SIMPLE64)) - 1;
+ cpi->maxio = (sges_per_frame * sc->facts->MaxChainDepth) + 1;
+ cpi->maxio *= PAGE_SIZE;
+ if ((sc->max_io_pages > 0) && (sc->max_io_pages * PAGE_SIZE <
+ cpi->maxio))
+ cpi->maxio = sc->max_io_pages * PAGE_SIZE;
mprsas_set_ccbstatus(ccb, CAM_REQ_CMP);
break;
}
diff --git a/sys/dev/mpr/mprvar.h b/sys/dev/mpr/mprvar.h
index dd4b40f..b3a61f4 100644
--- a/sys/dev/mpr/mprvar.h
+++ b/sys/dev/mpr/mprvar.h
@@ -33,7 +33,7 @@
#ifndef _MPRVAR_H
#define _MPRVAR_H
-#define MPR_DRIVER_VERSION "13.00.00.00-fbsd"
+#define MPR_DRIVER_VERSION "13.01.00.00-fbsd"
#define MPR_DB_MAX_WAIT 2500
@@ -41,6 +41,7 @@
#define MPR_EVT_REPLY_FRAMES 32
#define MPR_REPLY_FRAMES MPR_REQ_FRAMES
#define MPR_CHAIN_FRAMES 2048
+#define MPR_MAXIO_PAGES (-1)
#define MPR_SENSE_LEN SSD_FULL_SIZE
#define MPR_MSI_COUNT 1
#define MPR_SGE64_SIZE 12
@@ -264,6 +265,7 @@ struct mpr_softc {
int io_cmds_highwater;
int chain_free;
int max_chains;
+ int max_io_pages;
int chain_free_lowwater;
uint32_t chain_frame_size;
uint16_t chain_seg_size;
diff --git a/sys/dev/mps/mps.c b/sys/dev/mps/mps.c
index 3f75989..7f9cf0b 100644
--- a/sys/dev/mps/mps.c
+++ b/sys/dev/mps/mps.c
@@ -1350,6 +1350,7 @@ mps_get_tunables(struct mps_softc *sc)
sc->disable_msix = 0;
sc->disable_msi = 0;
sc->max_chains = MPS_CHAIN_FRAMES;
+ sc->max_io_pages = MPS_MAXIO_PAGES;
sc->enable_ssu = MPS_SSU_ENABLE_SSD_DISABLE_HDD;
sc->spinup_wait_time = DEFAULT_SPINUP_WAIT;
@@ -1360,6 +1361,7 @@ mps_get_tunables(struct mps_softc *sc)
TUNABLE_INT_FETCH("hw.mps.disable_msix", &sc->disable_msix);
TUNABLE_INT_FETCH("hw.mps.disable_msi", &sc->disable_msi);
TUNABLE_INT_FETCH("hw.mps.max_chains", &sc->max_chains);
+ TUNABLE_INT_FETCH("hw.mps.max_io_pages", &sc->max_io_pages);
TUNABLE_INT_FETCH("hw.mps.enable_ssu", &sc->enable_ssu);
TUNABLE_INT_FETCH("hw.mps.spinup_wait_time", &sc->spinup_wait_time);
@@ -1380,6 +1382,10 @@ mps_get_tunables(struct mps_softc *sc)
device_get_unit(sc->mps_dev));
TUNABLE_INT_FETCH(tmpstr, &sc->max_chains);
+ snprintf(tmpstr, sizeof(tmpstr), "dev.mps.%d.max_io_pages",
+ device_get_unit(sc->mps_dev));
+ TUNABLE_INT_FETCH(tmpstr, &sc->max_io_pages);
+
bzero(sc->exclude_ids, sizeof(sc->exclude_ids));
snprintf(tmpstr, sizeof(tmpstr), "dev.mps.%d.exclude_ids",
device_get_unit(sc->mps_dev));
@@ -1465,6 +1471,11 @@ mps_setup_sysctl(struct mps_softc *sc)
&sc->max_chains, 0,"maximum chain frames that will be allocated");
SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
+ OID_AUTO, "max_io_pages", CTLFLAG_RD,
+ &sc->max_io_pages, 0,"maximum pages to allow per I/O (if <1 use "
+ "IOCFacts)");
+
+ SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
OID_AUTO, "enable_ssu", CTLFLAG_RW, &sc->enable_ssu, 0,
"enable SSU to SATA SSD/HDD at shutdown");
diff --git a/sys/dev/mps/mps_sas.c b/sys/dev/mps/mps_sas.c
index 6a34c38..2f23612 100644
--- a/sys/dev/mps/mps_sas.c
+++ b/sys/dev/mps/mps_sas.c
@@ -928,6 +928,8 @@ mpssas_action(struct cam_sim *sim, union ccb *ccb)
case XPT_PATH_INQ:
{
struct ccb_pathinq *cpi = &ccb->cpi;
+ struct mps_softc *sc = sassc->sc;
+ uint8_t sges_per_frame;
cpi->version_num = 1;
cpi->hba_inquiry = PI_SDTR_ABLE|PI_TAG_ABLE|PI_WIDE_16;
@@ -951,12 +953,23 @@ mpssas_action(struct cam_sim *sim, union ccb *ccb)
cpi->transport_version = 0;
cpi->protocol = PROTO_SCSI;
cpi->protocol_version = SCSI_REV_SPC;
-#if __FreeBSD_version >= 800001
+
/*
- * XXX KDM where does this number come from?
+ * Max IO Size is Page Size * the following:
+ * ((SGEs per frame - 1 for chain element) *
+ * Max Chain Depth) + 1 for no chain needed in last frame
+ *
+ * If user suggests a Max IO size to use, use the smaller of the
+ * user's value and the calculated value as long as the user's
+ * value is larger than 0. The user's value is in pages.
*/
- cpi->maxio = 256 * 1024;
-#endif
+ sges_per_frame = ((sc->facts->IOCRequestFrameSize * 4) /
+ sizeof(MPI2_SGE_SIMPLE64)) - 1;
+ cpi->maxio = (sges_per_frame * sc->facts->MaxChainDepth) + 1;
+ cpi->maxio *= PAGE_SIZE;
+ if ((sc->max_io_pages > 0) && (sc->max_io_pages * PAGE_SIZE <
+ cpi->maxio))
+ cpi->maxio = sc->max_io_pages * PAGE_SIZE;
mpssas_set_ccbstatus(ccb, CAM_REQ_CMP);
break;
}
diff --git a/sys/dev/mps/mpsvar.h b/sys/dev/mps/mpsvar.h
index 74c5e55..f3a8929 100644
--- a/sys/dev/mps/mpsvar.h
+++ b/sys/dev/mps/mpsvar.h
@@ -33,7 +33,7 @@
#ifndef _MPSVAR_H
#define _MPSVAR_H
-#define MPS_DRIVER_VERSION "21.00.00.00-fbsd"
+#define MPS_DRIVER_VERSION "21.01.00.00-fbsd"
#define MPS_DB_MAX_WAIT 2500
@@ -41,6 +41,7 @@
#define MPS_EVT_REPLY_FRAMES 32
#define MPS_REPLY_FRAMES MPS_REQ_FRAMES
#define MPS_CHAIN_FRAMES 2048
+#define MPS_MAXIO_PAGES (-1)
#define MPS_SENSE_LEN SSD_FULL_SIZE
#define MPS_MSI_COUNT 1
#define MPS_SGE64_SIZE 12
@@ -280,6 +281,7 @@ struct mps_softc {
int io_cmds_highwater;
int chain_free;
int max_chains;
+ int max_io_pages;
int chain_free_lowwater;
u_int enable_ssu;
int spinup_wait_time;
OpenPOWER on IntegriCloud