All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvmet: return Invalid Field error on set features cmd fid 07h
@ 2020-02-28 12:52 amit.engel
  2020-02-28 20:33 ` Sagi Grimberg
  0 siblings, 1 reply; 7+ messages in thread
From: amit.engel @ 2020-02-28 12:52 UTC (permalink / raw)
  To: sagi, linux-nvme; +Cc: Amit Engel

From: Amit Engel <amit.engel@dell.com>

If the value specified in NCQR and NSQR fields (0's based) is 65,535
the controller should return an error of Invalid field in command

Signed-off-by: Amit Engel <Amit.Engel@dell.com>
---
 drivers/nvme/target/admin-cmd.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 19f949570625..94b0ac923e99 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -733,6 +733,9 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
 {
 	struct nvmet_subsys *subsys = req->sq->ctrl->subsys;
 	u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10);
+	u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11);
+	u16 ncqr = (cdw11 >> 16) & 0xffff;
+	u16 nsqr = cdw11 & 0xffff;
 	u16 status = 0;
 
 	if (!nvmet_check_data_len(req, 0))
@@ -740,6 +743,10 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
 
 	switch (cdw10 & 0xff) {
 	case NVME_FEAT_NUM_QUEUES:
+		if (ncqr == 0xffff || nsqr == 0xffff) {
+			status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
+			break;
+		}
 		nvmet_set_result(req,
 			(subsys->max_qid - 1) | ((subsys->max_qid - 1) << 16));
 		break;
-- 
2.16.5


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] nvmet: return Invalid Field error on set features cmd fid 07h
  2020-02-28 12:52 [PATCH] nvmet: return Invalid Field error on set features cmd fid 07h amit.engel
@ 2020-02-28 20:33 ` Sagi Grimberg
  2020-03-01  0:30   ` Chaitanya Kulkarni
  0 siblings, 1 reply; 7+ messages in thread
From: Sagi Grimberg @ 2020-02-28 20:33 UTC (permalink / raw)
  To: amit.engel, linux-nvme


> From: Amit Engel <amit.engel@dell.com>
> 
> If the value specified in NCQR and NSQR fields (0's based) is 65,535
> the controller should return an error of Invalid field in command
> 
> Signed-off-by: Amit Engel <Amit.Engel@dell.com>
> ---
>   drivers/nvme/target/admin-cmd.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
> index 19f949570625..94b0ac923e99 100644
> --- a/drivers/nvme/target/admin-cmd.c
> +++ b/drivers/nvme/target/admin-cmd.c
> @@ -733,6 +733,9 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
>   {
>   	struct nvmet_subsys *subsys = req->sq->ctrl->subsys;
>   	u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10);
> +	u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11);
> +	u16 ncqr = (cdw11 >> 16) & 0xffff;
> +	u16 nsqr = cdw11 & 0xffff;

I meant that here we only declare, assignment should go to where these
are used.

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] nvmet: return Invalid Field error on set features cmd fid 07h
  2020-02-28 20:33 ` Sagi Grimberg
@ 2020-03-01  0:30   ` Chaitanya Kulkarni
  2020-03-01  4:47     ` Engel, Amit
  0 siblings, 1 reply; 7+ messages in thread
From: Chaitanya Kulkarni @ 2020-03-01  0:30 UTC (permalink / raw)
  To: Sagi Grimberg, amit.engel, linux-nvme

Sent out a patch with following comments and appropriate history.

On 02/28/2020 12:33 PM, Sagi Grimberg wrote:
> I meant that here we only declare, assignment should go to where these
> are used.


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH] nvmet: return Invalid Field error on set features cmd fid 07h
  2020-03-01  0:30   ` Chaitanya Kulkarni
@ 2020-03-01  4:47     ` Engel, Amit
  0 siblings, 0 replies; 7+ messages in thread
From: Engel, Amit @ 2020-03-01  4:47 UTC (permalink / raw)
  To: Chaitanya Kulkarni, Sagi Grimberg, linux-nvme

Thank you

-----Original Message-----
From: Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com> 
Sent: Sunday, March 1, 2020 2:30 AM
To: Sagi Grimberg; Engel, Amit; linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvmet: return Invalid Field error on set features cmd fid 07h


[EXTERNAL EMAIL] 

Sent out a patch with following comments and appropriate history.

On 02/28/2020 12:33 PM, Sagi Grimberg wrote:
> I meant that here we only declare, assignment should go to where these 
> are used.


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH] nvmet: return Invalid Field error on set features cmd fid 07h
  2020-02-27 23:16 ` Sagi Grimberg
@ 2020-02-28 12:53   ` Engel, Amit
  0 siblings, 0 replies; 7+ messages in thread
From: Engel, Amit @ 2020-02-28 12:53 UTC (permalink / raw)
  To: Sagi Grimberg, linux-nvme

Sure, I just uploaded a fixed patch

Thanks
Amit Engel

-----Original Message-----
From: Sagi Grimberg <sagi@grimberg.me> 
Sent: Friday, February 28, 2020 1:16 AM
To: Engel, Amit; linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvmet: return Invalid Field error on set features cmd fid 07h


[EXTERNAL EMAIL] 


> From: Amit Engel <amit.engel@dell.com>
> 
> If the value specified in NCQR and NSQR fields (0's based) is 65,535 
> the controller should return an error of Invalid field in command
> 
> Signed-off-by: Amit Engel <Amit.Engel@dell.com>
> ---
>   drivers/nvme/target/admin-cmd.c | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/nvme/target/admin-cmd.c 
> b/drivers/nvme/target/admin-cmd.c index 19f949570625..f76b44768100 
> 100644
> --- a/drivers/nvme/target/admin-cmd.c
> +++ b/drivers/nvme/target/admin-cmd.c
> @@ -733,16 +733,25 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
>   {
>   	struct nvmet_subsys *subsys = req->sq->ctrl->subsys;
>   	u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10);
> +	u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11);
>   	u16 status = 0;
>   
>   	if (!nvmet_check_data_len(req, 0))
>   		return;
>   
>   	switch (cdw10 & 0xff) {
> -	case NVME_FEAT_NUM_QUEUES:
> +	case NVME_FEAT_NUM_QUEUES: {
> +		u16 ncqr = (cdw11 >> 16) & 0xffff;
> +		u16 nsqr = cdw11 & 0xffff;
> +
> +		if (ncqr == 0xffff || nsqr == 0xffff) {
> +			status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
> +			break;
> +		}
>   		nvmet_set_result(req,
>   			(subsys->max_qid - 1) | ((subsys->max_qid - 1) << 16));
>   		break;
> +	}

I'd avoid parenthesis in the switch-case statement, just declare them on top and assign them here.
_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] nvmet: return Invalid Field error on set features cmd fid 07h
  2020-02-27 14:16 amit.engel
@ 2020-02-27 23:16 ` Sagi Grimberg
  2020-02-28 12:53   ` Engel, Amit
  0 siblings, 1 reply; 7+ messages in thread
From: Sagi Grimberg @ 2020-02-27 23:16 UTC (permalink / raw)
  To: amit.engel, linux-nvme


> From: Amit Engel <amit.engel@dell.com>
> 
> If the value specified in NCQR and NSQR fields (0's based) is 65,535
> the controller should return an error of Invalid field in command
> 
> Signed-off-by: Amit Engel <Amit.Engel@dell.com>
> ---
>   drivers/nvme/target/admin-cmd.c | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
> index 19f949570625..f76b44768100 100644
> --- a/drivers/nvme/target/admin-cmd.c
> +++ b/drivers/nvme/target/admin-cmd.c
> @@ -733,16 +733,25 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
>   {
>   	struct nvmet_subsys *subsys = req->sq->ctrl->subsys;
>   	u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10);
> +	u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11);
>   	u16 status = 0;
>   
>   	if (!nvmet_check_data_len(req, 0))
>   		return;
>   
>   	switch (cdw10 & 0xff) {
> -	case NVME_FEAT_NUM_QUEUES:
> +	case NVME_FEAT_NUM_QUEUES: {
> +		u16 ncqr = (cdw11 >> 16) & 0xffff;
> +		u16 nsqr = cdw11 & 0xffff;
> +
> +		if (ncqr == 0xffff || nsqr == 0xffff) {
> +			status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
> +			break;
> +		}
>   		nvmet_set_result(req,
>   			(subsys->max_qid - 1) | ((subsys->max_qid - 1) << 16));
>   		break;
> +	}

I'd avoid parenthesis in the switch-case statement, just declare them on
top and assign them here.

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] nvmet: return Invalid Field error on set features cmd fid 07h
@ 2020-02-27 14:16 amit.engel
  2020-02-27 23:16 ` Sagi Grimberg
  0 siblings, 1 reply; 7+ messages in thread
From: amit.engel @ 2020-02-27 14:16 UTC (permalink / raw)
  To: sagi, linux-nvme; +Cc: Amit Engel

From: Amit Engel <amit.engel@dell.com>

If the value specified in NCQR and NSQR fields (0's based) is 65,535
the controller should return an error of Invalid field in command

Signed-off-by: Amit Engel <Amit.Engel@dell.com>
---
 drivers/nvme/target/admin-cmd.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 19f949570625..f76b44768100 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -733,16 +733,25 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
 {
 	struct nvmet_subsys *subsys = req->sq->ctrl->subsys;
 	u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10);
+	u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11);
 	u16 status = 0;
 
 	if (!nvmet_check_data_len(req, 0))
 		return;
 
 	switch (cdw10 & 0xff) {
-	case NVME_FEAT_NUM_QUEUES:
+	case NVME_FEAT_NUM_QUEUES: {
+		u16 ncqr = (cdw11 >> 16) & 0xffff;
+		u16 nsqr = cdw11 & 0xffff;
+
+		if (ncqr == 0xffff || nsqr == 0xffff) {
+			status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
+			break;
+		}
 		nvmet_set_result(req,
 			(subsys->max_qid - 1) | ((subsys->max_qid - 1) << 16));
 		break;
+	}
 	case NVME_FEAT_KATO:
 		status = nvmet_set_feat_kato(req);
 		break;
-- 
2.16.5


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-03-01  4:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-28 12:52 [PATCH] nvmet: return Invalid Field error on set features cmd fid 07h amit.engel
2020-02-28 20:33 ` Sagi Grimberg
2020-03-01  0:30   ` Chaitanya Kulkarni
2020-03-01  4:47     ` Engel, Amit
  -- strict thread matches above, loose matches on Subject: below --
2020-02-27 14:16 amit.engel
2020-02-27 23:16 ` Sagi Grimberg
2020-02-28 12:53   ` Engel, Amit

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.