[nvmecli: PATCH 1/1] nvme: add NVIDIA plugin for NVMe SNAP controllers
Max Gurtovoy
mgurtovoy at nvidia.com
Thu Apr 1 09:38:49 BST 2021
SNAP technology is supported on NVIDIA Mellanox BlueField DPU family
and combines a unique hardware-accelerated virtualization of NVMe
devices with the advanced networking and programmability capabilities of
the BlueField SmartNIC.
Add initial vendor specific parsing for id-ctrl command of NVMe SNAP
controllers.
For more info: https://www.mellanox.com/products/software/nvme-snap
Signed-off-by: Max Gurtovoy <mgurtovoy at nvidia.com>
---
Makefile | 3 +-
plugins/nvidia/nvidia-nvme.c | 59 ++++++++++++++++++++++++++++++++++++
plugins/nvidia/nvidia-nvme.h | 17 +++++++++++
3 files changed, 78 insertions(+), 1 deletion(-)
create mode 100644 plugins/nvidia/nvidia-nvme.c
create mode 100644 plugins/nvidia/nvidia-nvme.h
diff --git a/Makefile b/Makefile
index 3ea17b5..5fcb3dc 100644
--- a/Makefile
+++ b/Makefile
@@ -81,7 +81,8 @@ PLUGIN_OBJS := \
plugins/dera/dera-nvme.o \
plugins/scaleflux/sfx-nvme.o \
plugins/transcend/transcend-nvme.o \
- plugins/zns/zns.o
+ plugins/zns/zns.o \
+ plugins/nvidia/nvidia-nvme.o
nvme: nvme.c nvme.h $(OBJS) $(PLUGIN_OBJS) $(UTIL_OBJS) NVME-VERSION-FILE
$(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) $(INC) $< -o $(NVME) $(OBJS) $(PLUGIN_OBJS) $(UTIL_OBJS) $(LDFLAGS)
diff --git a/plugins/nvidia/nvidia-nvme.c b/plugins/nvidia/nvidia-nvme.c
new file mode 100644
index 0000000..9942901
--- /dev/null
+++ b/plugins/nvidia/nvidia-nvme.c
@@ -0,0 +1,59 @@
+#include <fcntl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <inttypes.h>
+
+#include "linux/nvme_ioctl.h"
+
+#include "common.h"
+#include "nvme.h"
+#include "nvme-print.h"
+#include "nvme-ioctl.h"
+#include "json.h"
+#include "plugin.h"
+
+#include "argconfig.h"
+#include "suffix.h"
+
+#define CREATE_CMD
+#include "nvidia-nvme.h"
+
+struct nvme_vu_id_ctrl_field {
+ __u16 json_rpc_2_0_mjr;
+ __u16 json_rpc_2_0_mnr;
+ __u16 json_rpc_2_0_ter;
+ __u8 reserved0[1018];
+};
+
+static void json_nvidia_id_ctrl(struct nvme_vu_id_ctrl_field *id,
+ char *json_rpc_2_0_ver, struct json_object *root)
+{
+ json_object_add_value_string(root, "json_rpc_2_0_ver",
+ json_rpc_2_0_ver);
+}
+
+static void nvidia_id_ctrl(__u8 *vs, struct json_object *root)
+{
+ struct nvme_vu_id_ctrl_field *id = (struct nvme_vu_id_ctrl_field *)vs;
+ char json_rpc_2_0_ver[16] = { 0 };
+
+ snprintf(json_rpc_2_0_ver, sizeof(json_rpc_2_0_ver), "0x%04x%04x%04x",
+ le16_to_cpu(id->json_rpc_2_0_mjr),
+ le16_to_cpu(id->json_rpc_2_0_mnr),
+ le16_to_cpu(id->json_rpc_2_0_ter));
+
+ if (root) {
+ json_nvidia_id_ctrl(id, json_rpc_2_0_ver, root);
+ return;
+ }
+
+ printf("json_rpc_2_0_ver : %s\n", json_rpc_2_0_ver);
+}
+
+static int id_ctrl(int argc, char **argv, struct command *cmd,
+ struct plugin *plugin)
+{
+ return __id_ctrl(argc, argv, cmd, plugin, nvidia_id_ctrl);
+}
diff --git a/plugins/nvidia/nvidia-nvme.h b/plugins/nvidia/nvidia-nvme.h
new file mode 100644
index 0000000..bf562b9
--- /dev/null
+++ b/plugins/nvidia/nvidia-nvme.h
@@ -0,0 +1,17 @@
+#undef CMD_INC_FILE
+#define CMD_INC_FILE plugins/nvidia/nvidia-nvme
+
+#if !defined(NVIDIA_NVME) || defined(CMD_HEADER_MULTI_READ)
+#define NVIDIA_NVME
+
+#include "cmd.h"
+
+PLUGIN(NAME("nvidia", "NVIDIA vendor specific extensions"),
+ COMMAND_LIST(
+ ENTRY("id-ctrl", "Send NVMe Identify Controller", id_ctrl)
+ )
+);
+
+#endif
+
+#include "define_cmd.h"
--
2.18.2
More information about the Linux-nvme
mailing list