printf("\tHost Memory Buffer Size (HSIZE): %u\n", hmb->hsize);
}
-void nvme_directive_show_fields(__u8 dtype, __u8 doper, unsigned int result, unsigned char *buf)
+static void nvme_directive_show_fields(__u8 dtype, __u8 doper, unsigned int result, unsigned char *buf)
{
__u8 *field = buf;
int count, i;
+
switch (dtype) {
case NVME_DIR_IDENTIFY:
switch (doper) {
return;
}
+void nvme_directive_show(__u8 type, __u8 oper, __u16 spec, __u32 nsid, __u32 result,
+ void *buf, __u32 len, enum nvme_print_flags flags)
+{
+ if (flags & BINARY) {
+ if (buf)
+ return d_raw(buf, len);
+ return;
+ }
+
+ printf("dir-receive: type:%#x operation:%#x spec:%#x nsid:%#x result:%#x\n",
+ type, oper, spec, nsid, result);
+ if (flags & VERBOSE)
+ nvme_directive_show_fields(type, oper, result, buf);
+ else if (buf)
+ d(buf, len, 16, 1);
+}
+
static const char *nvme_plm_window(__u32 plm)
{
switch (plm & 0x7) {
enum nvme_print_flags flags);
void nvme_feature_show_fields(__u32 fid, unsigned int result, unsigned char *buf);
-void nvme_directive_show_fields(__u8 dtype, __u8 doper, unsigned int result, unsigned char *buf);
+void nvme_directive_show(__u8 type, __u8 oper, __u16 spec, __u32 nsid, __u32 result,
+ void *buf, __u32 len, enum nvme_print_flags flags);
void nvme_show_select_result(__u32 result);
const char *nvme_status_to_string(__u32 status);
const char *doper = "directive operation";
const char *nsr = "namespace stream requested";
const char *human_readable = "show directive in readable format";
+
+ enum nvme_print_flags flags = NORMAL;
int err, fd;
__u32 result;
__u32 dw12 = 0;
if (fd < 0)
goto ret;
+ if (cfg.human_readable)
+ flags |= VERBOSE;
+ if (cfg.raw_binary)
+ flags = BINARY;
+
switch (cfg.dtype) {
case NVME_DIR_IDENTIFY:
switch (cfg.doper) {
err = nvme_dir_recv(fd, cfg.namespace_id, cfg.dspec, cfg.dtype, cfg.doper,
cfg.data_len, dw12, buf, &result);
- if (err < 0) {
- perror("dir-receive");
- goto free;
- }
-
- if (!err) {
- printf("dir-receive: type %#x, operation %#x, spec %#x, nsid %#x, result %#x \n",
- cfg.dtype, cfg.doper, cfg.dspec, cfg.namespace_id, result);
- if (cfg.human_readable)
- nvme_directive_show_fields(cfg.dtype, cfg.doper, result, buf);
- else {
- if (buf) {
- if (!cfg.raw_binary)
- d(buf, cfg.data_len, 16, 1);
- else
- d_raw(buf, cfg.data_len);
- }
- }
- }
+ if (!err)
+ nvme_directive_show(cfg.dtype, cfg.doper, cfg.dspec,
+ cfg.namespace_id, result, buf, cfg.data_len,
+ flags);
else if (err > 0)
nvme_show_status(err);
-free:
+ else if (err < 0)
+ perror("dir-receive");
+
if (cfg.data_len)
free(buf);
close_fd:
} else if (data && cfg.read)
d_raw((unsigned char *)data, cfg.data_len);
}
-
free_data:
if (cfg.data_len)
nvme_free(data, huge);
free_metadata:
if (cfg.metadata_len)
free(metadata);
-
close_wfd:
if (strlen(cfg.input_file))
close(wfd);
void register_extension(struct plugin *plugin)
{
plugin->parent = &nvme;
-
nvme.extensions->tail->next = plugin;
nvme.extensions->tail = plugin;
}