Skip to contentSkip to conversation

lnvm: minor clean-ups

PATCH New Minwoo Im 1 participant 6 messages Jul 21, 2019 NVMe

lore
Share & tools
lore

Minwoo Im

author
#0 lore raw

cover lnvm: minor clean-ups

Hi,

This series is nothing but a clean-up patch series. I hope it's not a just code churns, but a good start to do something for lnvm.

The first one removed a redundant whitespace in the command description. The second one removed unnecessary print for the sizeof(dev) which will always be zero in case user does not give any argument for the device. The third patch removed temp variable instead casting the pinter directly. The last one just sync-up the kernel UAPI header file to the latest.

Please review.

Thanks,

Minwoo Im (4):
lnvm: remove redundant whitespace in lnvm_init()
lnvm: do not print 0 when the arg is not given
lnvm: cast identity structure to (void *) directly
lnvm: sync-up uapi lightnvm.h header from kernel

 linux/lightnvm.h         | 52 +++++++++++++++++++++++++++++++++++++++-
 nvme-lightnvm.c          |  5 ++--
 plugins/lnvm/lnvm-nvme.c |  8 +++----
 3 files changed, 57 insertions(+), 8 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/4 lnvm: remove redundant whitespace in lnvm_init()

The description for lnvm-init subcommand has a redundant whitespace.

Cc Keith Busch <kbusch at kernel.org>
Cc Matias Bjorling <mb at lightnvm.io>
Signed-off-by Minwoo Im <minwoo.im.dev at gmail.com>
---
 plugins/lnvm/lnvm-nvme.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
plugins/lnvm/lnvm-nvme.c +1 -1
index 754931a..37b6733 100644
@@ -17,7 +17,7 @@
 static int lnvm_init(int argc, char **argv, struct command *cmd, struct plugin *plugin)
 {
 	const char *desc = "Initialize LightNVM device. A LightNVM/Open-Channel SSD"\
-			   " must have a media manager associated before it can "\
+			   " must have a media manager associated before it can"\
 			   " be exposed to the user. The default is to initialize"
 			   " the general media manager on top of the device.\n\n"
 			   "Example:"
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH 2/4 lnvm: do not print 0 when the arg is not given

If an argument is not given by the user, it just needs to show the situation, not a prominent 0 which indicates the size of the argument variable.

Cc Keith Busch <kbusch at kernel.org>
Cc Matias Bjorling <mb at lightnvm.io>
Signed-off-by Minwoo Im <minwoo.im.dev at gmail.com>
---
 plugins/lnvm/lnvm-nvme.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
plugins/lnvm/lnvm-nvme.c +3 -3
index 37b6733..aacd469 100644
@@ -48,7 +48,7 @@ static int lnvm_init(int argc, char **argv, struct command *cmd, struct plugin *
 		return ret;
 
 	if (!strlen(cfg.devname)) {
-		fprintf(stderr, "device name missing %d\n", (int)strlen(cfg.devname));
+		fprintf(stderr, "device name missing\n");
 		return -EINVAL;
 	}
 
@@ -179,7 +179,7 @@ static int lnvm_create_tgt(int argc, char **argv, struct command *cmd, struct pl
 		return ret;
 
 	if (!strlen(cfg.devname)) {
-		fprintf(stderr, "device name missing %d\n", (int)strlen(cfg.devname));
+		fprintf(stderr, "device name missing\n");
 		return -EINVAL;
 	}
 	if (!strlen(cfg.tgtname)) {
@@ -265,7 +265,7 @@ static int lnvm_factory_init(int argc, char **argv, struct command *cmd, struct
 		return ret;
 
 	if (!strlen(cfg.devname)) {
-		fprintf(stderr, "device name missing %d\n", (int)strlen(cfg.devname));
+		fprintf(stderr, "device name missing\n");
 		return -EINVAL;
 	}
 
Signature · 1 line
2.17.1
author
#3 lore raw

PATCH 3/4 lnvm: cast identity structure to (void *) directly

If we use "tmp" or something like this, we can expect that it just stores the previous pointer and do something else with the previous pointer. But, in this function, it just to cast it out.

Cc Keith Busch <kbusch at kernel.org>
Cc Matias Bjorling <mb at lightnvm.io>
Signed-off-by Minwoo Im <minwoo.im.dev at gmail.com>
---
 nvme-lightnvm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
nvme-lightnvm.c +2 -3
index 0b99786..62bdc40 100644
@@ -422,13 +422,12 @@ static void show_lnvm_id20_ns(struct nvme_nvm_id20 *id, unsigned int flags)
 
 static void show_lnvm_id_ns(struct nvme_nvm_id *id, unsigned int flags)
 {
-	void *tmp = id;
 	switch (id->ver_id) {
 		case 1:
-			show_lnvm_id12_ns(tmp, flags);
+			show_lnvm_id12_ns((void *) id, flags);
 		break;
 		case 2:
-			show_lnvm_id20_ns(tmp, flags);
+			show_lnvm_id20_ns((void *) id, flags);
 		break;
 		default:
 			fprintf(stderr, "Version %d not supported.\n",
Signature · 1 line
2.17.1
author
#4 lore raw

PATCH 4/4 lnvm: sync-up uapi lightnvm.h header from kernel

This patch just syncs-up UAPI header from the kernel. No functional changes included.

Cc Keith Busch <kbusch at kernel.org>
Cc Matias Bjorling <mb at lightnvm.io>
Signed-off-by Minwoo Im <minwoo.im.dev at gmail.com>
---
 linux/lightnvm.h | 52 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)
linux/lightnvm.h +51 -1
index f678ffb..c937160 100644
@@ -77,7 +77,7 @@ struct nvm_ioctl_create_simple {
 struct nvm_ioctl_create_extended {
 	__u16 lun_begin;
 	__u16 lun_end;
-	__u16 over_prov;
+	__u16 op;
 	__u16 rsv;
 };
 
@@ -135,6 +135,44 @@ struct nvm_ioctl_dev_factory {
 	__u32 flags;
 };
 
+struct nvm_user_vio {
+	__u8 opcode;
+	__u8 flags;
+	__u16 control;
+	__u16 nppas;
+	__u16 rsvd;
+	__u64 metadata;
+	__u64 addr;
+	__u64 ppa_list;
+	__u32 metadata_len;
+	__u32 data_len;
+	__u64 status;
+	__u32 result;
+	__u32 rsvd3[3];
+};
+
+struct nvm_passthru_vio {
+	__u8 opcode;
+	__u8 flags;
+	__u8 rsvd[2];
+	__u32 nsid;
+	__u32 cdw2;
+	__u32 cdw3;
+	__u64 metadata;
+	__u64 addr;
+	__u32 metadata_len;
+	__u32 data_len;
+	__u64 ppa_list;
+	__u16 nppas;
+	__u16 control;
+	__u32 cdw13;
+	__u32 cdw14;
+	__u32 cdw15;
+	__u64 status;
+	__u32 result;
+	__u32 timeout_ms;
+};
+
 /* The ioctl type, 'L', 0x20 - 0x2F documented in ioctl-number.txt */
 enum {
 	/* top level cmds */
@@ -150,6 +188,11 @@ enum {
 
 	/* Factory reset device */
 	NVM_DEV_FACTORY_CMD,
+
+	/* Vector user I/O */
+	NVM_DEV_VIO_ADMIN_CMD = 0x41,
+	NVM_DEV_VIO_CMD = 0x42,
+	NVM_DEV_VIO_USER_CMD = 0x43,
 };
 
 #define NVM_IOCTL 'L' /* 0x4c */
@@ -167,6 +210,13 @@ enum {
 #define NVM_DEV_FACTORY		_IOW(NVM_IOCTL, NVM_DEV_FACTORY_CMD, \
 						struct nvm_ioctl_dev_factory)
 
+#define NVME_NVM_IOCTL_IO_VIO		_IOWR(NVM_IOCTL, NVM_DEV_VIO_USER_CMD, \
+						struct nvm_passthru_vio)
+#define NVME_NVM_IOCTL_ADMIN_VIO	_IOWR(NVM_IOCTL, NVM_DEV_VIO_ADMIN_CMD,\
+						struct nvm_passthru_vio)
+#define NVME_NVM_IOCTL_SUBMIT_VIO	_IOWR(NVM_IOCTL, NVM_DEV_VIO_CMD,\
+						struct nvm_user_vio)
+
 #define NVM_VERSION_MAJOR	1
 #define NVM_VERSION_MINOR	0
 #define NVM_VERSION_PATCHLEVEL	0
Signature · 1 line
2.17.1