Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F168536507
D14261.id39033.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
11 KB
Referenced Files
None
Subscribers
None
D14261.id39033.diff
View Options
Index: mpr/mpr.c
===================================================================
--- mpr/mpr.c
+++ mpr/mpr.c
@@ -382,7 +382,7 @@
static void
mpr_resize_queues(struct mpr_softc *sc)
{
- int reqcr, prireqcr;
+ u_int reqcr, prireqcr, maxio, sges_per_frame;
/*
* Size the queues. Since the reply queues always need one free
@@ -401,7 +401,54 @@
sc->num_replies = MIN(sc->max_replyframes + sc->max_evtframes,
sc->facts->MaxReplyDescriptorPostQueueDepth) - 1;
+ /* Store the request frame size in bytes rather than as 32bit words */
+ sc->reqframesz = sc->facts->IOCRequestFrameSize * 4;
+
/*
+ * Gen3 and beyond uses the IOCMaxChainSegmentSize from IOC Facts to
+ * get the size of a Chain Frame. Previous versions use the size as a
+ * Request Frame for the Chain Frame size. If IOCMaxChainSegmentSize
+ * is 0, use the default value. The IOCMaxChainSegmentSize is the
+ * number of 16-byte elelements that can fit in a Chain Frame, which is
+ * the size of an IEEE Simple SGE.
+ */
+ if (sc->facts->MsgVersion >= MPI2_VERSION_02_05) {
+ sc->chain_seg_size =
+ htole16(sc->facts->IOCMaxChainSegmentSize);
+ if (sc->chain_seg_size == 0) {
+ sc->chain_frame_size = MPR_DEFAULT_CHAIN_SEG_SIZE *
+ MPR_MAX_CHAIN_ELEMENT_SIZE;
+ } else {
+ sc->chain_frame_size = sc->chain_seg_size *
+ MPR_MAX_CHAIN_ELEMENT_SIZE;
+ }
+ } else {
+ sc->chain_frame_size = sc->reqframesz;
+ }
+
+ /*
+ * 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.
+ */
+ sges_per_frame = sc->chain_frame_size/sizeof(MPI2_IEEE_SGE_SIMPLE64)-1;
+ maxio = (sges_per_frame * sc->facts->MaxChainDepth + 1) * PAGE_SIZE;
+ if (sc->max_io_pages > 0)
+ maxio = min(maxio, sc->max_io_pages * PAGE_SIZE);
+ else
+ maxio = min(maxio, MAXPHYS);
+ sc->maxio = maxio;
+
+ sc->num_chains = (maxio / PAGE_SIZE + sges_per_frame - 2) /
+ sges_per_frame * reqcr;
+ if (sc->max_chains > 0 && sc->max_chains < sc->num_chains)
+ sc->num_chains = sc->max_chains;
+
+ /*
* Figure out the number of MSIx-based queues. If the firmware or
* user has done something crazy and not allowed enough credit for
* the queues to be useful then don't enable multi-queue.
@@ -1355,9 +1402,6 @@
struct mpr_chain *chain;
int i, rsize, nsegs;
- /* Store the request frame size in bytes rather than as 32bit words */
- sc->reqframesz = sc->facts->IOCRequestFrameSize * 4;
-
rsize = sc->reqframesz * sc->num_reqs;
if (bus_dma_tag_create( sc->mpr_parent_dmat, /* parent */
16, 0, /* algnmnt, boundary */
@@ -1382,28 +1426,7 @@
bus_dmamap_load(sc->req_dmat, sc->req_map, sc->req_frames, rsize,
mpr_memaddr_cb, &sc->req_busaddr, 0);
- /*
- * Gen3 and beyond uses the IOCMaxChainSegmentSize from IOC Facts to
- * get the size of a Chain Frame. Previous versions use the size as a
- * Request Frame for the Chain Frame size. If IOCMaxChainSegmentSize
- * is 0, use the default value. The IOCMaxChainSegmentSize is the
- * number of 16-byte elelements that can fit in a Chain Frame, which is
- * the size of an IEEE Simple SGE.
- */
- if (sc->facts->MsgVersion >= MPI2_VERSION_02_05) {
- sc->chain_seg_size =
- htole16(sc->facts->IOCMaxChainSegmentSize);
- if (sc->chain_seg_size == 0) {
- sc->chain_frame_size = MPR_DEFAULT_CHAIN_SEG_SIZE *
- MPR_MAX_CHAIN_ELEMENT_SIZE;
- } else {
- sc->chain_frame_size = sc->chain_seg_size *
- MPR_MAX_CHAIN_ELEMENT_SIZE;
- }
- } else {
- sc->chain_frame_size = sc->reqframesz;
- }
- rsize = sc->chain_frame_size * sc->max_chains;
+ rsize = sc->chain_frame_size * sc->num_chains;
if (bus_dma_tag_create( sc->mpr_parent_dmat, /* parent */
16, 0, /* algnmnt, boundary */
BUS_SPACE_MAXADDR, /* lowaddr */
@@ -1451,13 +1474,13 @@
bus_dmamap_load(sc->sense_dmat, sc->sense_map, sc->sense_frames, rsize,
mpr_memaddr_cb, &sc->sense_busaddr, 0);
- sc->chains = malloc(sizeof(struct mpr_chain) * sc->max_chains, M_MPR,
+ sc->chains = malloc(sizeof(struct mpr_chain) * sc->num_chains, M_MPR,
M_WAITOK | M_ZERO);
if (!sc->chains) {
mpr_dprint(sc, MPR_ERROR, "Cannot allocate chain memory\n");
return (ENOMEM);
}
- for (i = 0; i < sc->max_chains; i++) {
+ for (i = 0; i < sc->num_chains; i++) {
chain = &sc->chains[i];
chain->chain = (MPI2_SGE_IO_UNION *)(sc->chain_frames +
i * sc->chain_frame_size);
Index: mpr/mpr_sas.c
===================================================================
--- mpr/mpr_sas.c
+++ mpr/mpr_sas.c
@@ -1009,7 +1009,6 @@
{
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;
@@ -1043,24 +1042,7 @@
cpi->transport_version = 0;
cpi->protocol = PROTO_SCSI;
cpi->protocol_version = SCSI_REV_SPC;
-
- /*
- * 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.
- */
- 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;
- sc->maxio = cpi->maxio;
+ cpi->maxio = sc->maxio;
mprsas_set_ccbstatus(ccb, CAM_REQ_CMP);
break;
}
Index: mpr/mprvar.h
===================================================================
--- mpr/mprvar.h
+++ mpr/mprvar.h
@@ -41,7 +41,7 @@
#define MPR_PRI_REQ_FRAMES 128
#define MPR_EVT_REPLY_FRAMES 32
#define MPR_REPLY_FRAMES MPR_REQ_FRAMES
-#define MPR_CHAIN_FRAMES 2048
+#define MPR_CHAIN_FRAMES (-1)
#define MPR_MAXIO_PAGES (-1)
#define MPR_SENSE_LEN SSD_FULL_SIZE
#define MPR_MSI_MAX 1
@@ -361,6 +361,7 @@
int num_reqs;
int num_prireqs;
int num_replies;
+ int num_chains;
int fqdepth; /* Free queue */
int pqdepth; /* Post queue */
Index: mps/mps.c
===================================================================
--- mps/mps.c
+++ mps/mps.c
@@ -379,8 +379,8 @@
static void
mps_resize_queues(struct mps_softc *sc)
{
- int reqcr, prireqcr;
-
+ u_int reqcr, prireqcr, maxio, sges_per_frame;
+
/*
* Size the queues. Since the reply queues always need one free
* entry, we'll deduct one reply message here. The LSI documents
@@ -398,7 +398,32 @@
sc->num_replies = MIN(sc->max_replyframes + sc->max_evtframes,
sc->facts->MaxReplyDescriptorPostQueueDepth) - 1;
+ /* Store the request frame size in bytes rather than as 32bit words */
+ sc->reqframesz = sc->facts->IOCRequestFrameSize * 4;
+
/*
+ * 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.
+ */
+ sges_per_frame = sc->reqframesz / sizeof(MPI2_SGE_SIMPLE64) - 1;
+ maxio = (sges_per_frame * sc->facts->MaxChainDepth + 1) * PAGE_SIZE;
+ if (sc->max_io_pages > 0)
+ maxio = min(maxio, sc->max_io_pages * PAGE_SIZE);
+ else
+ maxio = min(maxio, MAXPHYS);
+ sc->maxio = maxio;
+
+ sc->num_chains = (maxio / PAGE_SIZE + sges_per_frame - 2) /
+ sges_per_frame * reqcr;
+ if (sc->max_chains > 0 && sc->max_chains < sc->num_chains)
+ sc->num_chains = sc->max_chains;
+
+ /*
* Figure out the number of MSIx-based queues. If the firmware or
* user has done something crazy and not allowed enough credit for
* the queues to be useful then don't enable multi-queue.
@@ -1334,9 +1359,6 @@
struct mps_chain *chain;
int i, rsize, nsegs;
- /* Store the request frame size in bytes rather than as 32bit words */
- sc->reqframesz = sc->facts->IOCRequestFrameSize * 4;
-
rsize = sc->reqframesz * sc->num_reqs;
if (bus_dma_tag_create( sc->mps_parent_dmat, /* parent */
16, 0, /* algnmnt, boundary */
@@ -1361,7 +1383,7 @@
bus_dmamap_load(sc->req_dmat, sc->req_map, sc->req_frames, rsize,
mps_memaddr_cb, &sc->req_busaddr, 0);
- rsize = sc->reqframesz * sc->max_chains;
+ rsize = sc->reqframesz * sc->num_chains;
if (bus_dma_tag_create( sc->mps_parent_dmat, /* parent */
16, 0, /* algnmnt, boundary */
BUS_SPACE_MAXADDR_32BIT,/* lowaddr */
@@ -1409,13 +1431,13 @@
bus_dmamap_load(sc->sense_dmat, sc->sense_map, sc->sense_frames, rsize,
mps_memaddr_cb, &sc->sense_busaddr, 0);
- sc->chains = malloc(sizeof(struct mps_chain) * sc->max_chains, M_MPT2,
+ sc->chains = malloc(sizeof(struct mps_chain) * sc->num_chains, M_MPT2,
M_WAITOK | M_ZERO);
if(!sc->chains) {
mps_dprint(sc, MPS_ERROR, "Cannot allocate chains memory\n");
return (ENOMEM);
}
- for (i = 0; i < sc->max_chains; i++) {
+ for (i = 0; i < sc->num_chains; i++) {
chain = &sc->chains[i];
chain->chain = (MPI2_SGE_IO_UNION *)(sc->chain_frames +
i * sc->reqframesz);
Index: mps/mps_sas.c
===================================================================
--- mps/mps_sas.c
+++ mps/mps_sas.c
@@ -958,7 +958,6 @@
{
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;
@@ -987,23 +986,7 @@
cpi->transport_version = 0;
cpi->protocol = PROTO_SCSI;
cpi->protocol_version = SCSI_REV_SPC;
-
- /*
- * 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.
- */
- sges_per_frame = ((sc->reqframesz) /
- 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;
+ cpi->maxio = sc->maxio;
mpssas_set_ccbstatus(ccb, CAM_REQ_CMP);
break;
}
Index: mps/mpsvar.h
===================================================================
--- mps/mpsvar.h
+++ mps/mpsvar.h
@@ -43,7 +43,7 @@
#define MPS_PRI_REQ_FRAMES 128
#define MPS_EVT_REPLY_FRAMES 32
#define MPS_REPLY_FRAMES MPS_REQ_FRAMES
-#define MPS_CHAIN_FRAMES 2048
+#define MPS_CHAIN_FRAMES (-1)
#define MPS_MAXIO_PAGES (-1)
#define MPS_SENSE_LEN SSD_FULL_SIZE
#define MPS_MSI_MAX 1
@@ -315,6 +315,7 @@
int chain_free;
int max_chains;
int max_io_pages;
+ u_int maxio;
int chain_free_lowwater;
u_int enable_ssu;
int spinup_wait_time;
@@ -349,6 +350,7 @@
int num_reqs;
int num_prireqs;
int num_replies;
+ int num_chains;
int fqdepth; /* Free queue */
int pqdepth; /* Post queue */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Aug 29, 9:56 PM (2 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37543616
Default Alt Text
D14261.id39033.diff (11 KB)
Attached To
Mode
D14261: Allocate sufficient number of chain frames in mps(4) and mpr(4).
Attached
Detach File
Event Timeline
Log In to Comment