Skip to contentSkip to conversation

nvmet: use macro definition for setting nmic value

PATCH Applied Max Gurtovoy 5 participants 12 messages Sep 23, 2021 – Oct 12, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 nvmet: use macro definition for setting nmic value

This makes the code more readable.

---
 drivers/nvme/target/admin-cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/admin-cmd.c +1 -1
index aa6d84d8848e..4ee9fe134697 100644
@@ -536,7 +536,7 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req)
 	 * Our namespace might always be shared.  Not just with other
 	 * controllers, but also with any other user of the block device.
 	 */
-	id->nmic = (1 << 0);
+	id->nmic = NVME_NS_NMIC_SHARED;
 	id->anagrpid = cpu_to_le32(req->ns->anagrpid);
 
 	memcpy(&id->nguid, &req->ns->nguid, sizeof(id->nguid));
Signature · 7 lines
2.18.1


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
#1 lore raw

PATCH 2/2 nvmet: use macro definitions for setting cmic value

This makes the code more readable.

---
 drivers/nvme/target/admin-cmd.c | 3 ++-
 include/linux/nvme.h            | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/target/admin-cmd.c +2 -1
index 4ee9fe134697..92d81dc5906b 100644
@@ -380,7 +380,8 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
 	 */
 
 	/* we support multiple ports, multiples hosts and ANA: */
-	id->cmic = (1 << 0) | (1 << 1) | (1 << 3);
+	id->cmic = NVME_CTRL_CMIC_MULTI_PORT | NVME_CTRL_CMIC_MULTI_CTRL |
+		NVME_CTRL_CMIC_ANA;
 
 	/* Limit MDTS according to transport capability */
 	if (ctrl->ops->get_mdts)
include/linux/nvme.h +1 -0
index b7c4c4130b65..36662641fd7b 100644
@@ -312,6 +312,7 @@ struct nvme_id_ctrl {
 };
 
 enum {
+	NVME_CTRL_CMIC_MULTI_PORT		= 1 << 0,
 	NVME_CTRL_CMIC_MULTI_CTRL		= 1 << 1,
 	NVME_CTRL_CMIC_ANA			= 1 << 3,
 	NVME_CTRL_ONCS_COMPARE			= 1 << 0,
Signature · 7 lines
2.18.1


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
#2 lore raw

Re: [PATCH 2/2] nvmet: use macro definitions for setting cmic value

Quoted 13 lines · Max Gurtovoy

This makes the code more readable.

---
  drivers/nvme/target/admin-cmd.c | 3 ++-
  include/linux/nvme.h            | 1 +
  2 files changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/target/admin-cmd.c +0 -0
index 4ee9fe134697..92d81dc5906b 100644

drivers/nvme/target/admin-cmd.c static void nvmet_execute_identify_ctrl(struct nvmet_req *req) · line 386

Quoted 8 lines
drivers/nvme/target/admin-cmd.c +2 -1
@@ -380,7 +380,8 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
  	 */
 
  	/* we support multiple ports, multiples hosts and ANA: */
-	id->cmic = (1 << 0) | (1 << 1) | (1 << 3);
+	id->cmic = NVME_CTRL_CMIC_MULTI_PORT | NVME_CTRL_CMIC_MULTI_CTRL |
+		NVME_CTRL_CMIC_ANA;
 
 

So we actually had this discussion before to keep it open coded.

If I remember Keith had already sent out patch for this one...

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

maintainer
#3 lore raw

Re: [PATCH 2/2] nvmet: use macro definitions for setting cmic value

Quoted 25 lines · Chaitanya Kulkarni
Quoted 13 lines · Max Gurtovoy

This makes the code more readable.

---
  drivers/nvme/target/admin-cmd.c | 3 ++-
  include/linux/nvme.h            | 1 +
  2 files changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/target/admin-cmd.c +0 -0
index 4ee9fe134697..92d81dc5906b 100644

drivers/nvme/target/admin-cmd.c static void nvmet_execute_identify_ctrl(struct nvmet_req *req) · line 386

Quoted 8 lines
drivers/nvme/target/admin-cmd.c +2 -1
@@ -380,7 +380,8 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
  	 */
 
  	/* we support multiple ports, multiples hosts and ANA: */
-	id->cmic = (1 << 0) | (1 << 1) | (1 << 3);
+	id->cmic = NVME_CTRL_CMIC_MULTI_PORT | NVME_CTRL_CMIC_MULTI_CTRL |
+		NVME_CTRL_CMIC_ANA;
 
 

So we actually had this discussion before to keep it open coded.

Quoted 1 line

If I remember Keith had already sent out patch for this one...

The similiar patch I'd sent went in as 92decf118f1da. I argued symbolic names helps browsing the code since we can tag/cscope them, so I think this is a fine change.

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

#4 lore raw

Re: [PATCH 2/2] nvmet: use macro definitions for setting cmic value

Quoted 10 lines
Quoted 5 lines

So we actually had this discussion before to keep it open coded.

If I remember Keith had already sent out patch for this one...

The similiar patch I'd sent went in as 92decf118f1da. I argued symbolic names helps browsing the code since we can tag/cscope them, so I think this is a fine change.

thanks for the clarification, I think I've missed the final decision..

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

#5 lore raw

Re: [PATCH 2/2] nvmet: use macro definitions for setting cmic value

In reply to Chaitanya Kulkarni
Quoted 24 lines · Chaitanya Kulkarni
Quoted 13 lines · Max Gurtovoy

This makes the code more readable.

---
   drivers/nvme/target/admin-cmd.c | 3 ++-
   include/linux/nvme.h            | 1 +
   2 files changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/target/admin-cmd.c +0 -0
index 4ee9fe134697..92d81dc5906b 100644

drivers/nvme/target/admin-cmd.c static void nvmet_execute_identify_ctrl(struct nvmet_req *req) · line 386

Quoted 8 lines
drivers/nvme/target/admin-cmd.c +2 -1
@@ -380,7 +380,8 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
   	 */
 
   	/* we support multiple ports, multiples hosts and ANA: */
-	id->cmic = (1 << 0) | (1 << 1) | (1 << 3);
+	id->cmic = NVME_CTRL_CMIC_MULTI_PORT | NVME_CTRL_CMIC_MULTI_CTRL |
+		NVME_CTRL_CMIC_ANA;
 
 

So we actually had this discussion before to keep it open coded.

Quoted 1 line

If I remember Keith had already sent out patch for this one...

I don't understand why our code should include constants and not macros.

And if so, let's do it for all macros we have for the spec. We need one policy.

Quoted 2 lines

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

Reviewed-by
#6 lore raw

Re: [PATCH 2/2] nvmet: use macro definitions for setting cmic value

Quoted 23 lines
Quoted 23 lines
Quoted 14 lines

This makes the code more readable.

---
   drivers/nvme/target/admin-cmd.c | 3 ++-
   include/linux/nvme.h            | 1 +

   2 files changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/target/admin-cmd.c +0 -0
index 4ee9fe134697..92d81dc5906b 100644

drivers/nvme/target/admin-cmd.c static void nvmet_execute_identify_ctrl(struct · line 385

Quoted 7 lines
drivers/nvme/target/admin-cmd.c +2 -1
@@ -380,7 +380,8 @@ static void nvmet_execute_identify_ctrl(struct 
 nvmet_req *req)
         */
        /* we support multiple ports, multiples hosts and ANA: */
-    id->cmic = (1 << 0) | (1 << 1) | (1 << 3);
+    id->cmic = NVME_CTRL_CMIC_MULTI_PORT | NVME_CTRL_CMIC_MULTI_CTRL |
+        NVME_CTRL_CMIC_ANA;
 

So we actually had this discussion before to keep it open coded.

Quoted 7 lines
Quoted 1 line

If I remember Keith had already sent out patch for this one...

I don't understand why our code should include constants and not macros.

And if so, let's do it for all macros we have for the spec. We need one policy.

Agree, looks good.

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme