]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
scsi: lpfc: small sg cnt cleanup
authorJames Smart <jsmart2021@gmail.com>
Tue, 21 Nov 2017 00:00:43 +0000 (16:00 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 5 Dec 2017 01:32:55 +0000 (20:32 -0500)
The logic for sg_seg_cnt is a bit convoluted. This patch tries to clean
up a couple of areas, especially around the +2 and +1 logic.

This patch:

- Cleans up the lpfc_sg_seg_cnt attribute to specify a real minimum
  rather than making the minimum be whatever the default is.

- Removes the hardcoding of +2 (for the number of elements we use in a
  sgl for cmd iu and rsp iu) and +1 (an additional entry to compensate
  for nvme's reduction of io size based on a possible partial page)
  logic in sg list initialization. In the case where the +1 logic is
  referenced in host and target io checks, use the values set in the
  transport template as that value was properly set.

There can certainly be more done in this area and it will be addressed
in combined host/target driver effort.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/lpfc/lpfc.h
drivers/scsi/lpfc/lpfc_attr.c
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/lpfc/lpfc_nvme.c
drivers/scsi/lpfc/lpfc_nvmet.c

index 46a89bdff8e453a63b5ff0ba35b657ecefcdabae..dd2191c83052d32682db1a0f5fd1fc87efb5ec5b 100644 (file)
@@ -55,6 +55,7 @@ struct lpfc_sli2_slim;
 #define LPFC_MAX_SG_SLI4_SEG_CNT_DIF 128 /* sg element count per scsi cmnd */
 #define LPFC_MAX_SG_SEG_CNT_DIF 512    /* sg element count per scsi cmnd  */
 #define LPFC_MAX_SG_SEG_CNT    4096    /* sg element count per scsi cmnd */
+#define LPFC_MIN_SG_SEG_CNT    32      /* sg element count per scsi cmnd */
 #define LPFC_MAX_SGL_SEG_CNT   512     /* SGL element count per scsi cmnd */
 #define LPFC_MAX_BPL_SEG_CNT   4096    /* BPL element count per scsi cmnd */
 #define LPFC_MAX_NVME_SEG_CNT  256     /* max SGL element cnt per NVME cmnd */
index 5d83734f6c680b6de3f237011b0e94bc3298ae77..0eef5aa52fc0f29c4b884ede40175bf77b42e22e 100644 (file)
@@ -5140,7 +5140,7 @@ LPFC_ATTR(delay_discovery, 0, 0, 1,
  * this parameter will be limited to 128 if BlockGuard is enabled under SLI4
  * and will be limited to 512 if BlockGuard is enabled under SLI3.
  */
-LPFC_ATTR_R(sg_seg_cnt, LPFC_DEFAULT_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT,
+LPFC_ATTR_R(sg_seg_cnt, LPFC_MIN_SG_SEG_CNT, LPFC_DEFAULT_SG_SEG_CNT,
            LPFC_MAX_SG_SEG_CNT, "Max Scatter Gather Segment Count");
 
 /*
index a6ac72087f4cf62517bd0e29f033578b332b91f7..fa211550a32af7146908f3d5d5d0ca40b42f1192 100644 (file)
@@ -5806,6 +5806,7 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
        struct lpfc_mqe *mqe;
        int longs;
        int fof_vectors = 0;
+       int extra;
        uint64_t wwn;
 
        phba->sli4_hba.num_online_cpu = num_online_cpus();
@@ -5859,14 +5860,22 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
         * The WQ create will allocate the ring.
         */
 
+       /*
+        * 1 for cmd, 1 for rsp, NVME adds an extra one
+        * for boundary conditions in its max_sgl_segment template.
+        */
+       extra = 2;
+       if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)
+               extra++;
+
        /*
         * It doesn't matter what family our adapter is in, we are
         * limited to 2 Pages, 512 SGEs, for our SGL.
         * There are going to be 2 reserved SGEs: 1 FCP cmnd + 1 FCP rsp
         */
        max_buf_size = (2 * SLI4_PAGE_SIZE);
-       if (phba->cfg_sg_seg_cnt > LPFC_MAX_SGL_SEG_CNT - 2)
-               phba->cfg_sg_seg_cnt = LPFC_MAX_SGL_SEG_CNT - 2;
+       if (phba->cfg_sg_seg_cnt > LPFC_MAX_SGL_SEG_CNT - extra)
+               phba->cfg_sg_seg_cnt = LPFC_MAX_SGL_SEG_CNT - extra;
 
        /*
         * Since lpfc_sg_seg_cnt is module param, the sg_dma_buf_size
@@ -5899,14 +5908,14 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
                 */
                phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) +
                                sizeof(struct fcp_rsp) +
-                               ((phba->cfg_sg_seg_cnt + 2) *
+                               ((phba->cfg_sg_seg_cnt + extra) *
                                sizeof(struct sli4_sge));
 
                /* Total SGEs for scsi_sg_list */
-               phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + 2;
+               phba->cfg_total_seg_cnt = phba->cfg_sg_seg_cnt + extra;
 
                /*
-                * NOTE: if (phba->cfg_sg_seg_cnt + 2) <= 256 we only
+                * NOTE: if (phba->cfg_sg_seg_cnt + extra) <= 256 we only
                 * need to post 1 page for the SGL.
                 */
        }
index 1f02cf7e9d00081d875d8812c2453ed74a4bcbc1..c9945ed4b791f4faf5f12dffebd8abbf3f37044e 100644 (file)
@@ -62,6 +62,7 @@ lpfc_get_nvme_buf(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp);
 static void
 lpfc_release_nvme_buf(struct lpfc_hba *, struct lpfc_nvme_buf *);
 
+static struct nvme_fc_port_template lpfc_nvme_template;
 
 /**
  * lpfc_nvme_create_queue -
@@ -1174,7 +1175,7 @@ lpfc_nvme_prep_io_dma(struct lpfc_vport *vport,
 
                first_data_sgl = sgl;
                lpfc_ncmd->seg_cnt = nCmd->sg_cnt;
-               if (lpfc_ncmd->seg_cnt > phba->cfg_nvme_seg_cnt + 1) {
+               if (lpfc_ncmd->seg_cnt > lpfc_nvme_template.max_sgl_segments) {
                        lpfc_printf_log(phba, KERN_ERR, LOG_NVME_IOERR,
                                        "6058 Too many sg segments from "
                                        "NVME Transport.  Max %d, "
index 2b50aecc2722e9e329d56f478c8f86eea45d8f40..d80cd1def3b9aba71978bb6b1da37e71b77bece6 100644 (file)
@@ -2003,7 +2003,7 @@ lpfc_nvmet_prep_fcp_wqe(struct lpfc_hba *phba,
                return NULL;
        }
 
-       if (rsp->sg_cnt > phba->cfg_nvme_seg_cnt) {
+       if (rsp->sg_cnt > lpfc_tgttemplate.max_sgl_segments) {
                lpfc_printf_log(phba, KERN_ERR, LOG_NVME_IOERR,
                                "6109 NVMET prep FCP wqe: seg cnt err: "
                                "NPORT x%x oxid x%x ste %d cnt %d\n",