diff --git a/nvme.c b/nvme.c index 6cb2710..38299be 100644 --- a/nvme.c +++ b/nvme.c @@ -74,6 +74,13 @@ struct stat nvme_stat; const char *devicename; +#define CMD_NOT_YET_SUPPORTED() \ +{ \ + fprintf(stderr, \ + "Error: this command is not yet supported in the current version of switchtec-nvme utility.\n");\ + return -1; \ +} + static const char nvme_version_string[] = NVME_VERSION; static struct plugin builtin = { @@ -339,6 +346,8 @@ static int get_smart_log(int argc, char **argv, struct command *cmd, struct plug OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -390,6 +399,8 @@ static int get_ana_log(int argc, char **argv, struct command *cmd, OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -465,6 +476,8 @@ static int get_telemetry_log(int argc, char **argv, struct command *cmd, struct OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -584,6 +597,8 @@ static int get_endurance_log(int argc, char **argv, struct command *cmd, struct OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -632,6 +647,8 @@ static int get_effects_log(int argc, char **argv, struct command *cmd, struct pl OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -687,6 +704,8 @@ static int get_error_log(int argc, char **argv, struct command *cmd, struct plug OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -759,6 +778,8 @@ static int get_fw_log(int argc, char **argv, struct command *cmd, struct plugin OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -807,6 +828,8 @@ static int get_changed_ns_list_log(int argc, char **argv, struct command *cmd, s OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -882,6 +905,8 @@ static int get_log(int argc, char **argv, struct command *cmd, struct plugin *pl OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -960,6 +985,8 @@ static int sanitize_log(int argc, char **argv, struct command *command, struct p OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -1374,6 +1401,8 @@ static int list_subsys(int argc, char **argv, struct command *cmd, OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = argconfig_parse(argc, argv, desc, opts); if (err < 0) goto ret; @@ -1711,6 +1740,8 @@ static int id_ns_granularity(int argc, char **argv, struct command *cmd, struct OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -1768,6 +1799,8 @@ static int id_nvmset(int argc, char **argv, struct command *cmd, struct plugin * OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -1819,6 +1852,8 @@ static int id_uuid(int argc, char **argv, struct command *cmd, struct plugin *pl OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) return fd; @@ -2035,6 +2070,8 @@ static int device_self_test(int argc, char **argv, struct command *cmd, struct p OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -2086,6 +2123,8 @@ static int self_test_log(int argc, char **argv, struct command *cmd, struct plug OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -2160,6 +2199,8 @@ static int get_feature(int argc, char **argv, struct command *cmd, struct plugin OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -2453,6 +2494,8 @@ static int subsystem_reset(int argc, char **argv, struct command *cmd, struct pl OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -2480,6 +2523,8 @@ static int reset(int argc, char **argv, struct command *cmd, struct plugin *plug OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -2502,6 +2547,8 @@ static int ns_rescan(int argc, char **argv, struct command *cmd, struct plugin * OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -2555,6 +2602,8 @@ static int sanitize(int argc, char **argv, struct command *cmd, struct plugin *p OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + ret = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -2634,6 +2683,8 @@ static int show_registers(int argc, char **argv, struct command *cmd, struct plu OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -2692,6 +2743,8 @@ static int get_property(int argc, char **argv, struct command *cmd, struct plugi OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -2741,6 +2794,8 @@ static int set_property(int argc, char **argv, struct command *cmd, struct plugi OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -3037,6 +3092,8 @@ static int set_feature(int argc, char **argv, struct command *cmd, struct plugin OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -3149,6 +3206,8 @@ static int sec_send(int argc, char **argv, struct command *cmd, struct plugin *p OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -3257,6 +3316,8 @@ static int dir_send(int argc, char **argv, struct command *cmd, struct plugin *p OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -3556,6 +3617,8 @@ static int dsm(int argc, char **argv, struct command *cmd, struct plugin *plugin OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -3624,6 +3687,8 @@ static int flush(int argc, char **argv, struct command *cmd, struct plugin *plug OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -3692,6 +3757,8 @@ static int resv_acquire(int argc, char **argv, struct command *cmd, struct plugi OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -3764,6 +3831,8 @@ static int resv_register(int argc, char **argv, struct command *cmd, struct plug OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -3844,6 +3913,8 @@ static int resv_release(int argc, char **argv, struct command *cmd, struct plugi OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -3916,6 +3987,8 @@ static int resv_report(int argc, char **argv, struct command *cmd, struct plugin OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -4223,6 +4296,9 @@ static int compare(int argc, char **argv, struct command *cmd, struct plugin *pl const char *desc = "Compare specified logical blocks on "\ "device with specified data buffer; return failure if buffer "\ "and block(s) are dissimilar"; + + CMD_NOT_YET_SUPPORTED(); + return submit_io(nvme_cmd_compare, "compare", desc, argc, argv); } @@ -4230,6 +4306,9 @@ static int read_cmd(int argc, char **argv, struct command *cmd, struct plugin *p { const char *desc = "Copy specified logical blocks on the given "\ "device to specified data buffer (default buffer is stdout)."; + + CMD_NOT_YET_SUPPORTED(); + return submit_io(nvme_cmd_read, "read", desc, argc, argv); } @@ -4238,6 +4317,9 @@ static int write_cmd(int argc, char **argv, struct command *cmd, struct plugin * const char *desc = "Copy from provided data buffer (default "\ "buffer is stdin) to specified logical blocks on the given "\ "device."; + + CMD_NOT_YET_SUPPORTED(); + return submit_io(nvme_cmd_write, "write", desc, argc, argv); } @@ -4293,6 +4375,8 @@ static int verify_cmd(int argc, char **argv, struct command *cmd, struct plugin OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto err; @@ -4378,6 +4462,8 @@ static int sec_recv(int argc, char **argv, struct command *cmd, struct plugin *p OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -4459,6 +4545,8 @@ static int get_lba_status(int argc, char **argv, struct command *cmd, OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto err; @@ -4546,6 +4634,8 @@ static int dir_receive(int argc, char **argv, struct command *cmd, struct plugin OPT_END() }; + CMD_NOT_YET_SUPPORTED(); + err = fd = parse_and_open(argc, argv, desc, opts); if (fd < 0) goto ret; @@ -4849,7 +4939,7 @@ static int gen_hostnqn_cmd(int argc, char **argv, struct command *command, struc { uuid_t uuid; char uuid_str[37]; /* e.g. 1b4e28ba-2fa1-11d2-883f-0016d3cca427 + \0 */ - + CMD_NOT_YET_SUPPORTED(); uuid_generate_random(uuid); uuid_unparse_lower(uuid, uuid_str); printf("nqn.2014-08.org.nvmexpress:uuid:%s\n", uuid_str); @@ -4858,6 +4948,7 @@ static int gen_hostnqn_cmd(int argc, char **argv, struct command *command, struc #else static int gen_hostnqn_cmd(int argc, char **argv, struct command *command, struct plugin *plugin) { + CMD_NOT_YET_SUPPORTED(); fprintf(stderr, "\"%s\" not supported. Install lib uuid and rebuild.\n", command->name); return -ENOTSUP; @@ -4868,6 +4959,8 @@ static int show_hostnqn_cmd(int argc, char **argv, struct command *command, stru { char *hostnqn; + CMD_NOT_YET_SUPPORTED(); + hostnqn = hostnqn_read(); if (hostnqn) { fputs(hostnqn, stdout); @@ -4882,30 +4975,39 @@ static int show_hostnqn_cmd(int argc, char **argv, struct command *command, stru static int discover_cmd(int argc, char **argv, struct command *command, struct plugin *plugin) { const char *desc = "Send Get Log Page request to Discovery Controller."; + + CMD_NOT_YET_SUPPORTED(); + return fabrics_discover(desc, argc, argv, false); } static int connect_all_cmd(int argc, char **argv, struct command *command, struct plugin *plugin) { const char *desc = "Discover NVMeoF subsystems and connect to them"; + + CMD_NOT_YET_SUPPORTED(); + return fabrics_discover(desc, argc, argv, true); } static int connect_cmd(int argc, char **argv, struct command *command, struct plugin *plugin) { const char *desc = "Connect to NVMeoF subsystem"; + CMD_NOT_YET_SUPPORTED(); return fabrics_connect(desc, argc, argv); } static int disconnect_cmd(int argc, char **argv, struct command *command, struct plugin *plugin) { const char *desc = "Disconnect from NVMeoF subsystem"; + CMD_NOT_YET_SUPPORTED(); return fabrics_disconnect(desc, argc, argv); } static int disconnect_all_cmd(int argc, char **argv, struct command *command, struct plugin *plugin) { const char *desc = "Disconnect from all connected NVMeoF subsystems"; + CMD_NOT_YET_SUPPORTED(); return fabrics_disconnect_all(desc, argc, argv); } diff --git a/plugins/microchip/switchtec-nvme.c b/plugins/microchip/switchtec-nvme.c index 7448ee6..bd1b49c 100644 --- a/plugins/microchip/switchtec-nvme.c +++ b/plugins/microchip/switchtec-nvme.c @@ -563,7 +563,8 @@ static int pax_check_ep_pdfid(struct switchtec_dev *dev, uint16_t pdfid) return NOT_FOUND; } -static int pax_check_pdfid_type(struct switchtec_dev *dev, uint16_t pdfid) +static int pax_check_pdfid_type(struct switchtec_dev *dev, uint16_t pdfid, + int *pax_id) { int i; int ret = NOT_FOUND; @@ -599,8 +600,10 @@ static int pax_check_pdfid_type(struct switchtec_dev *dev, uint16_t pdfid) continue; ret = pax_check_ep_pdfid(dev, pdfid); - if (ret != NOT_FOUND) + if (ret != NOT_FOUND) { + *pax_id = i; break; + } } } @@ -650,6 +653,7 @@ static int switchtec_vf_reset(int argc, char **argv, struct command *command, char device_str[64]; char pdfid_str[64]; struct switchtec_dev *dev; + int pax_id = SWITCHTEC_PAX_ID_LOCAL; const char *desc = "Perform a Function Level Reset (FLR) on a Virtual Function"; const char *force = "The \"I know what I'm doing\" flag, skip confirmation before sending command"; struct config { @@ -705,7 +709,7 @@ static int switchtec_vf_reset(int argc, char **argv, struct command *command, return -ENODEV; } - ret = pax_check_pdfid_type(dev, pdfid); + ret = pax_check_pdfid_type(dev, pdfid, &pax_id); if (ret == IS_PF) { fprintf(stderr, "vf-reset error: the given device %s is a Physical Function\n", @@ -718,7 +722,7 @@ static int switchtec_vf_reset(int argc, char **argv, struct command *command, goto close; } - ret = switchtec_set_pax_id(dev, SWITCHTEC_PAX_ID_LOCAL); + ret = switchtec_set_pax_id(dev, pax_id); if (ret) { switchtec_perror("vf-reset"); goto close;