Re: [mpt3sas driver 07/10] mpt3sas: Add support for configurable Chain Frame Size

2016-02-08 Thread Tomas Henzl
On 5.2.2016 08:56, Sreekanth Reddy wrote:
> On Thu, Feb 4, 2016 at 8:35 PM, Tomas Henzl  wrote:
>> On 28.1.2016 07:37, Suganath prabu Subaramani wrote:
>>> From: Suganath prabu Subramani 
>>>
>>> Added support for configurable Chain Frame Size. Calculate the
>>> Chain Message Frame size from the IOCMaxChainSegementSize (iocfacts).
>>> Applicable only for mpt3sas/SAS3.0 HBA's.
>>>
>>> Signed-off-by: Suganath prabu Subramani 
>>> 
>>> Signed-off-by: Chaitra P B 
>> Is this done in order to prepare for some future patch, or how  does it work?
>> I noticed only changes in allocation of (probably larger) fields, but
>> how is it actually used ?
> Tomas,
>
> In this patch set we have added new Intruder and Cutlass (high ports)
> PCI devices which are based on MPI26 version.
> In this MPI26 version, Request Frame size is doubled when compared to
> older MPI version, but their is
> no change in the Chain buffer size from MPI26 to older versions. In
> older version Request frame size and
> chain buffer size were same, so in the drivers previously we used to
> use Request Frame size reference for
> Chain buffer size. But we can't use that reference now. So now we are
> determining the chain buffer size from
> IOCFact's IOCMaxChainSegementSize field instead of using the Request
> frame size reference.
>
> ~Sreekanth

Thanks,

Reviewed-by: Tomas Henzl 

Tomas

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [mpt3sas driver 07/10] mpt3sas: Add support for configurable Chain Frame Size

2016-02-04 Thread Sreekanth Reddy
On Thu, Feb 4, 2016 at 8:35 PM, Tomas Henzl  wrote:
> On 28.1.2016 07:37, Suganath prabu Subaramani wrote:
>> From: Suganath prabu Subramani 
>>
>> Added support for configurable Chain Frame Size. Calculate the
>> Chain Message Frame size from the IOCMaxChainSegementSize (iocfacts).
>> Applicable only for mpt3sas/SAS3.0 HBA's.
>>
>> Signed-off-by: Suganath prabu Subramani 
>> 
>> Signed-off-by: Chaitra P B 
>
> Is this done in order to prepare for some future patch, or how  does it work?
> I noticed only changes in allocation of (probably larger) fields, but
> how is it actually used ?

Tomas,

In this patch set we have added new Intruder and Cutlass (high ports)
PCI devices which are based on MPI26 version.
In this MPI26 version, Request Frame size is doubled when compared to
older MPI version, but their is
no change in the Chain buffer size from MPI26 to older versions. In
older version Request frame size and
chain buffer size were same, so in the drivers previously we used to
use Request Frame size reference for
Chain buffer size. But we can't use that reference now. So now we are
determining the chain buffer size from
IOCFact's IOCMaxChainSegementSize field instead of using the Request
frame size reference.

~Sreekanth


>
> --tm
>
>> ---
>>  drivers/scsi/mpt3sas/mpt3sas_base.c | 27 ++-
>>  drivers/scsi/mpt3sas/mpt3sas_base.h |  8 +++-
>>  2 files changed, 29 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
>> b/drivers/scsi/mpt3sas/mpt3sas_base.c
>> index a1a3b39..0f623fb 100644
>> --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
>> +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
>> @@ -3248,6 +3248,19 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER 
>> *ioc,  int sleep_flag)
>>   /* reply frame size */
>>   ioc->reply_sz = facts->ReplyFrameSize * 4;
>>
>> + /* chain segment size */
>> + if (ioc->hba_mpi_version_belonged != MPI2_VERSION) {
>> + if (facts->IOCMaxChainSegmentSize)
>> + ioc->chain_segment_sz =
>> + facts->IOCMaxChainSegmentSize *
>> + MAX_CHAIN_ELEMT_SZ;
>> + else
>> + /* set to 128 bytes size if IOCMaxChainSegmentSize is zero */
>> + ioc->chain_segment_sz = DEFAULT_NUM_FWCHAIN_ELEMTS *
>> + MAX_CHAIN_ELEMT_SZ;
>> + } else
>> + ioc->chain_segment_sz = ioc->request_sz;
>> +
>>   /* calculate the max scatter element size */
>>   sge_size = max_t(u16, ioc->sge_size, ioc->sge_size_ieee);
>>
>> @@ -3259,7 +3272,7 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER 
>> *ioc,  int sleep_flag)
>>   ioc->max_sges_in_main_message = max_sge_elements/sge_size;
>>
>>   /* now do the same for a chain buffer */
>> - max_sge_elements = ioc->request_sz - sge_size;
>> + max_sge_elements = ioc->chain_segment_sz - sge_size;
>>   ioc->max_sges_in_chain_message = max_sge_elements/sge_size;
>>
>>   /*
>> @@ -3451,7 +3464,7 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER 
>> *ioc,  int sleep_flag)
>>   goto out;
>>   }
>>   ioc->chain_dma_pool = pci_pool_create("chain pool", ioc->pdev,
>> - ioc->request_sz, 16, 0);
>> + ioc->chain_segment_sz, 16, 0);
>>   if (!ioc->chain_dma_pool) {
>>   pr_err(MPT3SAS_FMT "chain_dma_pool: pci_pool_create failed\n",
>>   ioc->name);
>> @@ -3465,13 +3478,13 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER 
>> *ioc,  int sleep_flag)
>>   ioc->chain_depth = i;
>>   goto chain_done;
>>   }
>> - total_sz += ioc->request_sz;
>> + total_sz += ioc->chain_segment_sz;
>>   }
>>   chain_done:
>>   dinitprintk(ioc, pr_info(MPT3SAS_FMT
>>   "chain pool depth(%d), frame_size(%d), pool_size(%d kB)\n",
>> - ioc->name, ioc->chain_depth, ioc->request_sz,
>> - ((ioc->chain_depth *  ioc->request_sz))/1024));
>> + ioc->name, ioc->chain_depth, ioc->chain_segment_sz,
>> + ((ioc->chain_depth *  ioc->chain_segment_sz))/1024));
>>
>>   /* initialize hi-priority queue smid's */
>>   ioc->hpr_lookup = kcalloc(ioc->hi_priority_depth,
>> @@ -4332,6 +4345,10 @@ _base_get_ioc_facts(struct MPT3SAS_ADAPTER *ioc, int 
>> sleep_flag)
>>   facts->FWVersion.Word = le32_to_cpu(mpi_reply.FWVersion.Word);
>>   facts->IOCRequestFrameSize =
>>   le16_to_cpu(mpi_reply.IOCRequestFrameSize);
>> + if (ioc->hba_mpi_version_belonged != MPI2_VERSION) {
>> + facts->IOCMaxChainSegmentSize =
>> + le16_to_cpu(mpi_reply.IOCMaxChainSegmentSize);
>> + }
>>   facts->MaxInitiators = le16_to_cpu(mpi_reply.MaxInitiators);
>>   facts->MaxTargets = le16_to_cpu(mpi_reply.MaxTargets);
>>   ioc->shost->max_id = -1;
>> diff --git a/

Re: [mpt3sas driver 07/10] mpt3sas: Add support for configurable Chain Frame Size

2016-02-04 Thread Tomas Henzl
On 28.1.2016 07:37, Suganath prabu Subaramani wrote:
> From: Suganath prabu Subramani 
>
> Added support for configurable Chain Frame Size. Calculate the
> Chain Message Frame size from the IOCMaxChainSegementSize (iocfacts).
> Applicable only for mpt3sas/SAS3.0 HBA's.
>
> Signed-off-by: Suganath prabu Subramani 
> 
> Signed-off-by: Chaitra P B 

Is this done in order to prepare for some future patch, or how  does it work?
I noticed only changes in allocation of (probably larger) fields, but
how is it actually used ?

--tm

> ---
>  drivers/scsi/mpt3sas/mpt3sas_base.c | 27 ++-
>  drivers/scsi/mpt3sas/mpt3sas_base.h |  8 +++-
>  2 files changed, 29 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
> b/drivers/scsi/mpt3sas/mpt3sas_base.c
> index a1a3b39..0f623fb 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
> @@ -3248,6 +3248,19 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER 
> *ioc,  int sleep_flag)
>   /* reply frame size */
>   ioc->reply_sz = facts->ReplyFrameSize * 4;
>  
> + /* chain segment size */
> + if (ioc->hba_mpi_version_belonged != MPI2_VERSION) {
> + if (facts->IOCMaxChainSegmentSize)
> + ioc->chain_segment_sz =
> + facts->IOCMaxChainSegmentSize *
> + MAX_CHAIN_ELEMT_SZ;
> + else
> + /* set to 128 bytes size if IOCMaxChainSegmentSize is zero */
> + ioc->chain_segment_sz = DEFAULT_NUM_FWCHAIN_ELEMTS *
> + MAX_CHAIN_ELEMT_SZ;
> + } else
> + ioc->chain_segment_sz = ioc->request_sz;
> +
>   /* calculate the max scatter element size */
>   sge_size = max_t(u16, ioc->sge_size, ioc->sge_size_ieee);
>  
> @@ -3259,7 +3272,7 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER 
> *ioc,  int sleep_flag)
>   ioc->max_sges_in_main_message = max_sge_elements/sge_size;
>  
>   /* now do the same for a chain buffer */
> - max_sge_elements = ioc->request_sz - sge_size;
> + max_sge_elements = ioc->chain_segment_sz - sge_size;
>   ioc->max_sges_in_chain_message = max_sge_elements/sge_size;
>  
>   /*
> @@ -3451,7 +3464,7 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER 
> *ioc,  int sleep_flag)
>   goto out;
>   }
>   ioc->chain_dma_pool = pci_pool_create("chain pool", ioc->pdev,
> - ioc->request_sz, 16, 0);
> + ioc->chain_segment_sz, 16, 0);
>   if (!ioc->chain_dma_pool) {
>   pr_err(MPT3SAS_FMT "chain_dma_pool: pci_pool_create failed\n",
>   ioc->name);
> @@ -3465,13 +3478,13 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER 
> *ioc,  int sleep_flag)
>   ioc->chain_depth = i;
>   goto chain_done;
>   }
> - total_sz += ioc->request_sz;
> + total_sz += ioc->chain_segment_sz;
>   }
>   chain_done:
>   dinitprintk(ioc, pr_info(MPT3SAS_FMT
>   "chain pool depth(%d), frame_size(%d), pool_size(%d kB)\n",
> - ioc->name, ioc->chain_depth, ioc->request_sz,
> - ((ioc->chain_depth *  ioc->request_sz))/1024));
> + ioc->name, ioc->chain_depth, ioc->chain_segment_sz,
> + ((ioc->chain_depth *  ioc->chain_segment_sz))/1024));
>  
>   /* initialize hi-priority queue smid's */
>   ioc->hpr_lookup = kcalloc(ioc->hi_priority_depth,
> @@ -4332,6 +4345,10 @@ _base_get_ioc_facts(struct MPT3SAS_ADAPTER *ioc, int 
> sleep_flag)
>   facts->FWVersion.Word = le32_to_cpu(mpi_reply.FWVersion.Word);
>   facts->IOCRequestFrameSize =
>   le16_to_cpu(mpi_reply.IOCRequestFrameSize);
> + if (ioc->hba_mpi_version_belonged != MPI2_VERSION) {
> + facts->IOCMaxChainSegmentSize =
> + le16_to_cpu(mpi_reply.IOCMaxChainSegmentSize);
> + }
>   facts->MaxInitiators = le16_to_cpu(mpi_reply.MaxInitiators);
>   facts->MaxTargets = le16_to_cpu(mpi_reply.MaxTargets);
>   ioc->shost->max_id = -1;
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
> b/drivers/scsi/mpt3sas/mpt3sas_base.h
> index 4b52a07..d1fee34 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_base.h
> +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
> @@ -129,6 +129,9 @@
>  
>  #define MPT3SAS_INVALID_DEVICE_HANDLE0x
>  
> +#define MAX_CHAIN_ELEMT_SZ   16
> +#define DEFAULT_NUM_FWCHAIN_ELEMTS   8
> +
>  /*
>   * reset phases
>   */
> @@ -759,7 +762,7 @@ struct mpt3sas_facts {
>   u32 IOCCapabilities;
>   union mpi3_version_unionFWVersion;
>   u16 IOCRequestFrameSize;
> - u16 Reserved3;
> + u16 IOCMaxChainSegmentSize;
>   u16 MaxInitiators;
>   u16 MaxTargets;
>  

[mpt3sas driver 07/10] mpt3sas: Add support for configurable Chain Frame Size

2016-01-27 Thread Suganath prabu Subaramani
From: Suganath prabu Subramani 

Added support for configurable Chain Frame Size. Calculate the
Chain Message Frame size from the IOCMaxChainSegementSize (iocfacts).
Applicable only for mpt3sas/SAS3.0 HBA's.

Signed-off-by: Suganath prabu Subramani 
Signed-off-by: Chaitra P B 
---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 27 ++-
 drivers/scsi/mpt3sas/mpt3sas_base.h |  8 +++-
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c 
b/drivers/scsi/mpt3sas/mpt3sas_base.c
index a1a3b39..0f623fb 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -3248,6 +3248,19 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER *ioc, 
 int sleep_flag)
/* reply frame size */
ioc->reply_sz = facts->ReplyFrameSize * 4;
 
+   /* chain segment size */
+   if (ioc->hba_mpi_version_belonged != MPI2_VERSION) {
+   if (facts->IOCMaxChainSegmentSize)
+   ioc->chain_segment_sz =
+   facts->IOCMaxChainSegmentSize *
+   MAX_CHAIN_ELEMT_SZ;
+   else
+   /* set to 128 bytes size if IOCMaxChainSegmentSize is zero */
+   ioc->chain_segment_sz = DEFAULT_NUM_FWCHAIN_ELEMTS *
+   MAX_CHAIN_ELEMT_SZ;
+   } else
+   ioc->chain_segment_sz = ioc->request_sz;
+
/* calculate the max scatter element size */
sge_size = max_t(u16, ioc->sge_size, ioc->sge_size_ieee);
 
@@ -3259,7 +3272,7 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER *ioc,  
int sleep_flag)
ioc->max_sges_in_main_message = max_sge_elements/sge_size;
 
/* now do the same for a chain buffer */
-   max_sge_elements = ioc->request_sz - sge_size;
+   max_sge_elements = ioc->chain_segment_sz - sge_size;
ioc->max_sges_in_chain_message = max_sge_elements/sge_size;
 
/*
@@ -3451,7 +3464,7 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER *ioc,  
int sleep_flag)
goto out;
}
ioc->chain_dma_pool = pci_pool_create("chain pool", ioc->pdev,
-   ioc->request_sz, 16, 0);
+   ioc->chain_segment_sz, 16, 0);
if (!ioc->chain_dma_pool) {
pr_err(MPT3SAS_FMT "chain_dma_pool: pci_pool_create failed\n",
ioc->name);
@@ -3465,13 +3478,13 @@ _base_allocate_memory_pools(struct MPT3SAS_ADAPTER 
*ioc,  int sleep_flag)
ioc->chain_depth = i;
goto chain_done;
}
-   total_sz += ioc->request_sz;
+   total_sz += ioc->chain_segment_sz;
}
  chain_done:
dinitprintk(ioc, pr_info(MPT3SAS_FMT
"chain pool depth(%d), frame_size(%d), pool_size(%d kB)\n",
-   ioc->name, ioc->chain_depth, ioc->request_sz,
-   ((ioc->chain_depth *  ioc->request_sz))/1024));
+   ioc->name, ioc->chain_depth, ioc->chain_segment_sz,
+   ((ioc->chain_depth *  ioc->chain_segment_sz))/1024));
 
/* initialize hi-priority queue smid's */
ioc->hpr_lookup = kcalloc(ioc->hi_priority_depth,
@@ -4332,6 +4345,10 @@ _base_get_ioc_facts(struct MPT3SAS_ADAPTER *ioc, int 
sleep_flag)
facts->FWVersion.Word = le32_to_cpu(mpi_reply.FWVersion.Word);
facts->IOCRequestFrameSize =
le16_to_cpu(mpi_reply.IOCRequestFrameSize);
+   if (ioc->hba_mpi_version_belonged != MPI2_VERSION) {
+   facts->IOCMaxChainSegmentSize =
+   le16_to_cpu(mpi_reply.IOCMaxChainSegmentSize);
+   }
facts->MaxInitiators = le16_to_cpu(mpi_reply.MaxInitiators);
facts->MaxTargets = le16_to_cpu(mpi_reply.MaxTargets);
ioc->shost->max_id = -1;
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
b/drivers/scsi/mpt3sas/mpt3sas_base.h
index 4b52a07..d1fee34 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -129,6 +129,9 @@
 
 #define MPT3SAS_INVALID_DEVICE_HANDLE  0x
 
+#define MAX_CHAIN_ELEMT_SZ 16
+#define DEFAULT_NUM_FWCHAIN_ELEMTS 8
+
 /*
  * reset phases
  */
@@ -759,7 +762,7 @@ struct mpt3sas_facts {
u32 IOCCapabilities;
union mpi3_version_unionFWVersion;
u16 IOCRequestFrameSize;
-   u16 Reserved3;
+   u16 IOCMaxChainSegmentSize;
u16 MaxInitiators;
u16 MaxTargets;
u16 MaxSasExpanders;
@@ -906,6 +909,8 @@ typedef void (*MPT3SAS_FLUSH_RUNNING_CMDS)(struct 
MPT3SAS_ADAPTER *ioc);
  * @max_sges_in_chain_message: number sg elements per chain
  * @chains_needed_per_io: max chains per io
  * @chain_depth: total chains allocated
+ * @chain_segment_sz: gives the max number of
+ *