* [PATCH] RDMA/srpt: Report the SCSI residual to the initiator
@ 2019-10-29 23:02 Bart Van Assche
2019-11-04 11:10 ` Honggang LI
0 siblings, 1 reply; 8+ messages in thread
From: Bart Van Assche @ 2019-10-29 23:02 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Leon Romanovsky, Doug Ledford, linux-rdma, Bart Van Assche,
Honggang LI, Laurence Oberman
The code added by this patch is similar to the code that already exists
in ibmvscsis_determine_resid(). This patch has been tested by running
the following command:
strace -f sg_raw -r 1k /dev/sdb 12 00 00 00 60 00 -o inquiry.bin |&
grep resid=
Cc: Honggang LI <honli@redhat.com>
Cc: Laurence Oberman <loberman@redhat.com>
Fixes: a42d985bd5b2 ("ib_srpt: Initial SRP Target merge for v3.3-rc1")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/infiniband/ulp/srpt/ib_srpt.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index a278e76b9e02..c9972b686c27 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -1362,9 +1362,11 @@ static int srpt_build_cmd_rsp(struct srpt_rdma_ch *ch,
struct srpt_send_ioctx *ioctx, u64 tag,
int status)
{
+ struct se_cmd *cmd = &ioctx->cmd;
struct srp_rsp *srp_rsp;
const u8 *sense_data;
int sense_data_len, max_sense_len;
+ int resid = cmd->residual_count;
/*
* The lowest bit of all SAM-3 status codes is zero (see also
@@ -1386,6 +1388,28 @@ static int srpt_build_cmd_rsp(struct srpt_rdma_ch *ch,
srp_rsp->tag = tag;
srp_rsp->status = status;
+ if (cmd->se_cmd_flags & SCF_UNDERFLOW_BIT) {
+ if (cmd->data_direction == DMA_TO_DEVICE) {
+ /* residual data from an underflow write */
+ srp_rsp->flags = SRP_RSP_FLAG_DOUNDER;
+ srp_rsp->data_out_res_cnt = cpu_to_be32(resid);
+ } else if (cmd->data_direction == DMA_FROM_DEVICE) {
+ /* residual data from an underflow read */
+ srp_rsp->flags = SRP_RSP_FLAG_DIUNDER;
+ srp_rsp->data_in_res_cnt = cpu_to_be32(resid);
+ }
+ } else if (cmd->se_cmd_flags & SCF_OVERFLOW_BIT) {
+ if (cmd->data_direction == DMA_TO_DEVICE) {
+ /* residual data from an overflow write */
+ srp_rsp->flags = SRP_RSP_FLAG_DOOVER;
+ srp_rsp->data_out_res_cnt = cpu_to_be32(resid);
+ } else if (cmd->data_direction == DMA_FROM_DEVICE) {
+ /* residual data from an overflow read */
+ srp_rsp->flags = SRP_RSP_FLAG_DIOVER;
+ srp_rsp->data_in_res_cnt = cpu_to_be32(resid);
+ }
+ }
+
if (sense_data_len) {
BUILD_BUG_ON(MIN_MAX_RSP_SIZE <= sizeof(*srp_rsp));
max_sense_len = ch->max_ti_iu_len - sizeof(*srp_rsp);
--
2.24.0.rc0.303.g954a862665-goog
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] RDMA/srpt: Report the SCSI residual to the initiator
2019-10-29 23:02 [PATCH] RDMA/srpt: Report the SCSI residual to the initiator Bart Van Assche
@ 2019-11-04 11:10 ` Honggang LI
2019-11-04 16:01 ` Bart Van Assche
0 siblings, 1 reply; 8+ messages in thread
From: Honggang LI @ 2019-11-04 11:10 UTC (permalink / raw)
To: Bart Van Assche
Cc: Jason Gunthorpe, Leon Romanovsky, Doug Ledford, linux-rdma,
Laurence Oberman
On Tue, Oct 29, 2019 at 04:02:57PM -0700, Bart Van Assche wrote:
> The code added by this patch is similar to the code that already exists
> in ibmvscsis_determine_resid(). This patch has been tested by running
> the following command:
>
> strace -f sg_raw -r 1k /dev/sdb 12 00 00 00 60 00 -o inquiry.bin |&
> grep resid=
>
> Cc: Honggang LI <honli@redhat.com>
> Cc: Laurence Oberman <loberman@redhat.com>
> Fixes: a42d985bd5b2 ("ib_srpt: Initial SRP Target merge for v3.3-rc1")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> drivers/infiniband/ulp/srpt/ib_srpt.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
> index a278e76b9e02..c9972b686c27 100644
> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
> @@ -1362,9 +1362,11 @@ static int srpt_build_cmd_rsp(struct srpt_rdma_ch *ch,
> struct srpt_send_ioctx *ioctx, u64 tag,
> int status)
> {
> + struct se_cmd *cmd = &ioctx->cmd;
> struct srp_rsp *srp_rsp;
> const u8 *sense_data;
> int sense_data_len, max_sense_len;
> + int resid = cmd->residual_count;
^^^
Should be u32?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] RDMA/srpt: Report the SCSI residual to the initiator
2019-11-04 11:10 ` Honggang LI
@ 2019-11-04 16:01 ` Bart Van Assche
0 siblings, 0 replies; 8+ messages in thread
From: Bart Van Assche @ 2019-11-04 16:01 UTC (permalink / raw)
To: Honggang LI
Cc: Jason Gunthorpe, Leon Romanovsky, Doug Ledford, linux-rdma,
Laurence Oberman
On 11/4/19 3:10 AM, Honggang LI wrote:
> On Tue, Oct 29, 2019 at 04:02:57PM -0700, Bart Van Assche wrote:
>> The code added by this patch is similar to the code that already exists
>> in ibmvscsis_determine_resid(). This patch has been tested by running
>> the following command:
>>
>> strace -f sg_raw -r 1k /dev/sdb 12 00 00 00 60 00 -o inquiry.bin |&
>> grep resid=
>>
>> Cc: Honggang LI <honli@redhat.com>
>> Cc: Laurence Oberman <loberman@redhat.com>
>> Fixes: a42d985bd5b2 ("ib_srpt: Initial SRP Target merge for v3.3-rc1")
>> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
>> ---
>> drivers/infiniband/ulp/srpt/ib_srpt.c | 24 ++++++++++++++++++++++++
>> 1 file changed, 24 insertions(+)
>>
>> diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
>> index a278e76b9e02..c9972b686c27 100644
>> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
>> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
>> @@ -1362,9 +1362,11 @@ static int srpt_build_cmd_rsp(struct srpt_rdma_ch *ch,
>> struct srpt_send_ioctx *ioctx, u64 tag,
>> int status)
>> {
>> + struct se_cmd *cmd = &ioctx->cmd;
>> struct srp_rsp *srp_rsp;
>> const u8 *sense_data;
>> int sense_data_len, max_sense_len;
>> + int resid = cmd->residual_count;
> ^^^
> Should be u32?
Since se_cmd.residual_count has been declared as u32 it's probably
better to declare this variable as u32 too. I will make that change and
post a v2.
Thanks,
Bart.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] RDMA/srpt: Report the SCSI residual to the initiator
@ 2019-11-05 21:46 Bart Van Assche
2019-11-05 21:47 ` Bart Van Assche
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Bart Van Assche @ 2019-11-05 21:46 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Leon Romanovsky, Doug Ledford, linux-rdma, Bart Van Assche,
Honggang LI, Laurence Oberman
The code added by this patch is similar to the code that already exists
in ibmvscsis_determine_resid(). This patch has been tested by running
the following command:
strace sg_raw -r 1k /dev/sdb 12 00 00 00 60 00 -o inquiry.bin |&
grep resid=
Cc: Honggang LI <honli@redhat.com>
Cc: Laurence Oberman <loberman@redhat.com>
Fixes: a42d985bd5b2 ("ib_srpt: Initial SRP Target merge for v3.3-rc1")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/infiniband/ulp/srpt/ib_srpt.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 653de1583cf9..23c782e3d49a 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -1362,9 +1362,11 @@ static int srpt_build_cmd_rsp(struct srpt_rdma_ch *ch,
struct srpt_send_ioctx *ioctx, u64 tag,
int status)
{
+ struct se_cmd *cmd = &ioctx->cmd;
struct srp_rsp *srp_rsp;
const u8 *sense_data;
int sense_data_len, max_sense_len;
+ u32 resid = cmd->residual_count;
/*
* The lowest bit of all SAM-3 status codes is zero (see also
@@ -1386,6 +1388,28 @@ static int srpt_build_cmd_rsp(struct srpt_rdma_ch *ch,
srp_rsp->tag = tag;
srp_rsp->status = status;
+ if (cmd->se_cmd_flags & SCF_UNDERFLOW_BIT) {
+ if (cmd->data_direction == DMA_TO_DEVICE) {
+ /* residual data from an underflow write */
+ srp_rsp->flags = SRP_RSP_FLAG_DOUNDER;
+ srp_rsp->data_out_res_cnt = cpu_to_be32(resid);
+ } else if (cmd->data_direction == DMA_FROM_DEVICE) {
+ /* residual data from an underflow read */
+ srp_rsp->flags = SRP_RSP_FLAG_DIUNDER;
+ srp_rsp->data_in_res_cnt = cpu_to_be32(resid);
+ }
+ } else if (cmd->se_cmd_flags & SCF_OVERFLOW_BIT) {
+ if (cmd->data_direction == DMA_TO_DEVICE) {
+ /* residual data from an overflow write */
+ srp_rsp->flags = SRP_RSP_FLAG_DOOVER;
+ srp_rsp->data_out_res_cnt = cpu_to_be32(resid);
+ } else if (cmd->data_direction == DMA_FROM_DEVICE) {
+ /* residual data from an overflow read */
+ srp_rsp->flags = SRP_RSP_FLAG_DIOVER;
+ srp_rsp->data_in_res_cnt = cpu_to_be32(resid);
+ }
+ }
+
if (sense_data_len) {
BUILD_BUG_ON(MIN_MAX_RSP_SIZE <= sizeof(*srp_rsp));
max_sense_len = ch->max_ti_iu_len - sizeof(*srp_rsp);
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] RDMA/srpt: Report the SCSI residual to the initiator
2019-11-05 21:46 Bart Van Assche
@ 2019-11-05 21:47 ` Bart Van Assche
2019-11-06 3:13 ` Honggang LI
2019-11-14 14:10 ` Jason Gunthorpe
2 siblings, 0 replies; 8+ messages in thread
From: Bart Van Assche @ 2019-11-05 21:47 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Leon Romanovsky, Doug Ledford, linux-rdma, Honggang LI, Laurence Oberman
On 11/5/19 1:46 PM, Bart Van Assche wrote:
> The code added by this patch is similar to the code that already exists
> in ibmvscsis_determine_resid(). This patch has been tested by running
> the following command: [ ... ]
(replying to my own e-mail)
This is version 2 of this patch. The only change compared to the
previous version is that the datatype of 'resid' has been changed from
'int' into 'u32'.
Bart.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] RDMA/srpt: Report the SCSI residual to the initiator
2019-11-05 21:46 Bart Van Assche
2019-11-05 21:47 ` Bart Van Assche
@ 2019-11-06 3:13 ` Honggang LI
2019-11-14 3:53 ` Bart Van Assche
2019-11-14 14:10 ` Jason Gunthorpe
2 siblings, 1 reply; 8+ messages in thread
From: Honggang LI @ 2019-11-06 3:13 UTC (permalink / raw)
To: Bart Van Assche
Cc: Jason Gunthorpe, Leon Romanovsky, Doug Ledford, linux-rdma,
Laurence Oberman
On Tue, Nov 05, 2019 at 01:46:32PM -0800, Bart Van Assche wrote:
> The code added by this patch is similar to the code that already exists
> in ibmvscsis_determine_resid(). This patch has been tested by running
> the following command:
>
> strace sg_raw -r 1k /dev/sdb 12 00 00 00 60 00 -o inquiry.bin |&
> grep resid=
>
> Cc: Honggang LI <honli@redhat.com>
> Cc: Laurence Oberman <loberman@redhat.com>
> Fixes: a42d985bd5b2 ("ib_srpt: Initial SRP Target merge for v3.3-rc1")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> drivers/infiniband/ulp/srpt/ib_srpt.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
> index 653de1583cf9..23c782e3d49a 100644
> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
> @@ -1362,9 +1362,11 @@ static int srpt_build_cmd_rsp(struct srpt_rdma_ch *ch,
> struct srpt_send_ioctx *ioctx, u64 tag,
> int status)
> {
> + struct se_cmd *cmd = &ioctx->cmd;
> struct srp_rsp *srp_rsp;
> const u8 *sense_data;
> int sense_data_len, max_sense_len;
> + u32 resid = cmd->residual_count;
>
> /*
> * The lowest bit of all SAM-3 status codes is zero (see also
> @@ -1386,6 +1388,28 @@ static int srpt_build_cmd_rsp(struct srpt_rdma_ch *ch,
> srp_rsp->tag = tag;
> srp_rsp->status = status;
>
> + if (cmd->se_cmd_flags & SCF_UNDERFLOW_BIT) {
> + if (cmd->data_direction == DMA_TO_DEVICE) {
> + /* residual data from an underflow write */
> + srp_rsp->flags = SRP_RSP_FLAG_DOUNDER;
> + srp_rsp->data_out_res_cnt = cpu_to_be32(resid);
> + } else if (cmd->data_direction == DMA_FROM_DEVICE) {
> + /* residual data from an underflow read */
> + srp_rsp->flags = SRP_RSP_FLAG_DIUNDER;
> + srp_rsp->data_in_res_cnt = cpu_to_be32(resid);
> + }
> + } else if (cmd->se_cmd_flags & SCF_OVERFLOW_BIT) {
> + if (cmd->data_direction == DMA_TO_DEVICE) {
> + /* residual data from an overflow write */
> + srp_rsp->flags = SRP_RSP_FLAG_DOOVER;
> + srp_rsp->data_out_res_cnt = cpu_to_be32(resid);
> + } else if (cmd->data_direction == DMA_FROM_DEVICE) {
> + /* residual data from an overflow read */
> + srp_rsp->flags = SRP_RSP_FLAG_DIOVER;
> + srp_rsp->data_in_res_cnt = cpu_to_be32(resid);
> + }
> + }
> +
> if (sense_data_len) {
> BUILD_BUG_ON(MIN_MAX_RSP_SIZE <= sizeof(*srp_rsp));
> max_sense_len = ch->max_ti_iu_len - sizeof(*srp_rsp);
Acked-by: Honggang Li <honli@redhat.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] RDMA/srpt: Report the SCSI residual to the initiator
2019-11-06 3:13 ` Honggang LI
@ 2019-11-14 3:53 ` Bart Van Assche
0 siblings, 0 replies; 8+ messages in thread
From: Bart Van Assche @ 2019-11-14 3:53 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Honggang LI, Leon Romanovsky, Doug Ledford, linux-rdma, Laurence Oberman
On 2019-11-05 19:13, Honggang LI wrote:
> On Tue, Nov 05, 2019 at 01:46:32PM -0800, Bart Van Assche wrote:
>> The code added by this patch is similar to the code that already exists
>> in ibmvscsis_determine_resid(). This patch has been tested by running
>> the following command:
> [ ... ]
> Acked-by: Honggang Li <honli@redhat.com>
Hi Jason,
Please let me know if you want me to repost this patch.
Thanks,
Bart.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] RDMA/srpt: Report the SCSI residual to the initiator
2019-11-05 21:46 Bart Van Assche
2019-11-05 21:47 ` Bart Van Assche
2019-11-06 3:13 ` Honggang LI
@ 2019-11-14 14:10 ` Jason Gunthorpe
2 siblings, 0 replies; 8+ messages in thread
From: Jason Gunthorpe @ 2019-11-14 14:10 UTC (permalink / raw)
To: Bart Van Assche
Cc: Leon Romanovsky, Doug Ledford, linux-rdma, Honggang LI, Laurence Oberman
On Tue, Nov 05, 2019 at 01:46:32PM -0800, Bart Van Assche wrote:
> The code added by this patch is similar to the code that already exists
> in ibmvscsis_determine_resid(). This patch has been tested by running
> the following command:
>
> strace sg_raw -r 1k /dev/sdb 12 00 00 00 60 00 -o inquiry.bin |&
> grep resid=
>
> Cc: Honggang LI <honli@redhat.com>
> Cc: Laurence Oberman <loberman@redhat.com>
> Fixes: a42d985bd5b2 ("ib_srpt: Initial SRP Target merge for v3.3-rc1")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> Acked-by: Honggang Li <honli@redhat.com>
> ---
> drivers/infiniband/ulp/srpt/ib_srpt.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
Applied to for-next, thanks
Jason
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-11-14 14:10 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-29 23:02 [PATCH] RDMA/srpt: Report the SCSI residual to the initiator Bart Van Assche
2019-11-04 11:10 ` Honggang LI
2019-11-04 16:01 ` Bart Van Assche
2019-11-05 21:46 Bart Van Assche
2019-11-05 21:47 ` Bart Van Assche
2019-11-06 3:13 ` Honggang LI
2019-11-14 3:53 ` Bart Van Assche
2019-11-14 14:10 ` Jason Gunthorpe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.