Lines Matching +full:ctrl +full:- +full:len
1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright (c) 2015-2016 HGST, a Western Digital Company.
32 kref_init(&host->ref); in nvmf_host_alloc()
33 uuid_copy(&host->id, id); in nvmf_host_alloc()
34 strscpy(host->nqn, hostnqn, NVMF_NQN_SIZE); in nvmf_host_alloc()
52 bool same_hostnqn = !strcmp(host->nqn, hostnqn); in nvmf_host_add()
53 bool same_hostid = uuid_equal(&host->id, id); in nvmf_host_add()
56 kref_get(&host->ref); in nvmf_host_add()
62 host = ERR_PTR(-EINVAL); in nvmf_host_add()
68 host = ERR_PTR(-EINVAL); in nvmf_host_add()
75 host = ERR_PTR(-ENOMEM); in nvmf_host_add()
79 list_add_tail(&host->list, &nvmf_hosts); in nvmf_host_add()
93 "nqn.2014-08.org.nvmexpress:uuid:%pUb", &id); in nvmf_host_default()
100 list_add_tail(&host->list, &nvmf_hosts); in nvmf_host_default()
111 list_del(&host->list); in nvmf_host_destroy()
120 kref_put(&host->ref, nvmf_host_destroy); in nvmf_host_put()
124 * nvmf_get_address() - Get address/port
125 * @ctrl: Host NVMe controller instance which we got the address
129 int nvmf_get_address(struct nvme_ctrl *ctrl, char *buf, int size) in nvmf_get_address() argument
131 int len = 0; in nvmf_get_address() local
133 if (ctrl->opts->mask & NVMF_OPT_TRADDR) in nvmf_get_address()
134 len += scnprintf(buf, size, "traddr=%s", ctrl->opts->traddr); in nvmf_get_address()
135 if (ctrl->opts->mask & NVMF_OPT_TRSVCID) in nvmf_get_address()
136 len += scnprintf(buf + len, size - len, "%strsvcid=%s", in nvmf_get_address()
137 (len) ? "," : "", ctrl->opts->trsvcid); in nvmf_get_address()
138 if (ctrl->opts->mask & NVMF_OPT_HOST_TRADDR) in nvmf_get_address()
139 len += scnprintf(buf + len, size - len, "%shost_traddr=%s", in nvmf_get_address()
140 (len) ? "," : "", ctrl->opts->host_traddr); in nvmf_get_address()
141 if (ctrl->opts->mask & NVMF_OPT_HOST_IFACE) in nvmf_get_address()
142 len += scnprintf(buf + len, size - len, "%shost_iface=%s", in nvmf_get_address()
143 (len) ? "," : "", ctrl->opts->host_iface); in nvmf_get_address()
144 len += scnprintf(buf + len, size - len, "\n"); in nvmf_get_address()
146 return len; in nvmf_get_address()
151 * nvmf_reg_read32() - NVMe Fabrics "Property Get" API function.
152 * @ctrl: Host NVMe controller instance maintaining the admin
160 * Used by the host system to retrieve a 32-bit capsule property value
171 int nvmf_reg_read32(struct nvme_ctrl *ctrl, u32 off, u32 *val) in nvmf_reg_read32() argument
181 ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, NULL, 0, in nvmf_reg_read32()
187 dev_err(ctrl->device, in nvmf_reg_read32()
196 * nvmf_reg_read64() - NVMe Fabrics "Property Get" API function.
197 * @ctrl: Host NVMe controller instance maintaining the admin
205 * Used by the host system to retrieve a 64-bit capsule property value
216 int nvmf_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val) in nvmf_reg_read64() argument
227 ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, NULL, 0, in nvmf_reg_read64()
233 dev_err(ctrl->device, in nvmf_reg_read64()
241 * nvmf_reg_write32() - NVMe Fabrics "Property Write" API function.
242 * @ctrl: Host NVMe controller instance maintaining the admin
250 * Used by the NVMe host system to write a 32-bit capsule property value
261 int nvmf_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val) in nvmf_reg_write32() argument
272 ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, NULL, NULL, 0, in nvmf_reg_write32()
275 dev_err(ctrl->device, in nvmf_reg_write32()
283 * nvmf_log_connect_error() - Error-parsing-diagnostic print out function for
285 * @ctrl: The specific /dev/nvmeX device that had the error.
286 * @errval: Error code to be decoded in a more human-friendly
293 static void nvmf_log_connect_error(struct nvme_ctrl *ctrl, in nvmf_log_connect_error() argument
300 dev_err(ctrl->device, in nvmf_log_connect_error()
312 dev_err(ctrl->device, in nvmf_log_connect_error()
314 inv_data, data->cntlid); in nvmf_log_connect_error()
317 dev_err(ctrl->device, in nvmf_log_connect_error()
319 inv_data, data->hostnqn); in nvmf_log_connect_error()
322 dev_err(ctrl->device, in nvmf_log_connect_error()
324 inv_data, data->subsysnqn); in nvmf_log_connect_error()
327 dev_err(ctrl->device, in nvmf_log_connect_error()
337 dev_err(ctrl->device, in nvmf_log_connect_error()
339 inv_sqe, cmd->connect.qid); in nvmf_log_connect_error()
342 dev_err(ctrl->device, in nvmf_log_connect_error()
349 dev_err(ctrl->device, in nvmf_log_connect_error()
351 data->subsysnqn, data->hostnqn); in nvmf_log_connect_error()
354 dev_err(ctrl->device, in nvmf_log_connect_error()
358 dev_err(ctrl->device, in nvmf_log_connect_error()
360 cmd->connect.recfmt); in nvmf_log_connect_error()
363 dev_err(ctrl->device, in nvmf_log_connect_error()
367 dev_err(ctrl->device, in nvmf_log_connect_error()
371 dev_err(ctrl->device, in nvmf_log_connect_error()
378 static struct nvmf_connect_data *nvmf_connect_data_prep(struct nvme_ctrl *ctrl, in nvmf_connect_data_prep() argument
387 uuid_copy(&data->hostid, &ctrl->opts->host->id); in nvmf_connect_data_prep()
388 data->cntlid = cpu_to_le16(cntlid); in nvmf_connect_data_prep()
389 strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE); in nvmf_connect_data_prep()
390 strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE); in nvmf_connect_data_prep()
395 static void nvmf_connect_cmd_prep(struct nvme_ctrl *ctrl, u16 qid, in nvmf_connect_cmd_prep() argument
398 cmd->connect.opcode = nvme_fabrics_command; in nvmf_connect_cmd_prep()
399 cmd->connect.fctype = nvme_fabrics_type_connect; in nvmf_connect_cmd_prep()
400 cmd->connect.qid = cpu_to_le16(qid); in nvmf_connect_cmd_prep()
403 cmd->connect.sqsize = cpu_to_le16(ctrl->sqsize); in nvmf_connect_cmd_prep()
405 cmd->connect.sqsize = cpu_to_le16(NVME_AQ_DEPTH - 1); in nvmf_connect_cmd_prep()
408 * set keep-alive timeout in seconds granularity (ms * 1000) in nvmf_connect_cmd_prep()
410 cmd->connect.kato = cpu_to_le32(ctrl->kato * 1000); in nvmf_connect_cmd_prep()
413 if (ctrl->opts->disable_sqflow) in nvmf_connect_cmd_prep()
414 cmd->connect.cattr |= NVME_CONNECT_DISABLE_SQFLOW; in nvmf_connect_cmd_prep()
418 * nvmf_connect_admin_queue() - NVMe Fabrics Admin Queue "Connect"
420 * @ctrl: Host nvme controller instance used to request
427 * fabrics-protocol connection of the NVMe Admin queue between the
437 int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl) in nvmf_connect_admin_queue() argument
445 nvmf_connect_cmd_prep(ctrl, 0, &cmd); in nvmf_connect_admin_queue()
447 data = nvmf_connect_data_prep(ctrl, 0xffff); in nvmf_connect_admin_queue()
449 return -ENOMEM; in nvmf_connect_admin_queue()
451 ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, in nvmf_connect_admin_queue()
455 nvmf_log_connect_error(ctrl, ret, le32_to_cpu(res.u32), in nvmf_connect_admin_queue()
461 ctrl->cntlid = result & 0xFFFF; in nvmf_connect_admin_queue()
465 dev_warn(ctrl->device, in nvmf_connect_admin_queue()
471 ret = nvme_auth_negotiate(ctrl, 0); in nvmf_connect_admin_queue()
473 dev_warn(ctrl->device, in nvmf_connect_admin_queue()
478 ret = nvme_auth_wait(ctrl, 0); in nvmf_connect_admin_queue()
480 dev_warn(ctrl->device, in nvmf_connect_admin_queue()
483 dev_info(ctrl->device, in nvmf_connect_admin_queue()
493 * nvmf_connect_io_queue() - NVMe Fabrics I/O Queue "Connect"
495 * @ctrl: Host nvme controller instance used to establish an
502 * This function issues a fabrics-protocol connection
512 int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid) in nvmf_connect_io_queue() argument
520 nvmf_connect_cmd_prep(ctrl, qid, &cmd); in nvmf_connect_io_queue()
522 data = nvmf_connect_data_prep(ctrl, ctrl->cntlid); in nvmf_connect_io_queue()
524 return -ENOMEM; in nvmf_connect_io_queue()
526 ret = __nvme_submit_sync_cmd(ctrl->connect_q, &cmd, &res, in nvmf_connect_io_queue()
530 nvmf_log_connect_error(ctrl, ret, le32_to_cpu(res.u32), in nvmf_connect_io_queue()
537 dev_warn(ctrl->device, in nvmf_connect_io_queue()
543 ret = nvme_auth_negotiate(ctrl, qid); in nvmf_connect_io_queue()
545 dev_warn(ctrl->device, in nvmf_connect_io_queue()
549 ret = nvme_auth_wait(ctrl, qid); in nvmf_connect_io_queue()
551 dev_warn(ctrl->device, in nvmf_connect_io_queue()
561 bool nvmf_should_reconnect(struct nvme_ctrl *ctrl) in nvmf_should_reconnect() argument
563 if (ctrl->opts->max_reconnects == -1 || in nvmf_should_reconnect()
564 ctrl->nr_reconnects < ctrl->opts->max_reconnects) in nvmf_should_reconnect()
572 * nvmf_register_transport() - NVMe Fabrics Library registration function.
582 if (!ops->create_ctrl) in nvmf_register_transport()
583 return -EINVAL; in nvmf_register_transport()
586 list_add_tail(&ops->entry, &nvmf_transports); in nvmf_register_transport()
594 * nvmf_unregister_transport() - NVMe Fabrics Library unregistration function.
605 list_del(&ops->entry); in nvmf_unregister_transport()
618 if (strcmp(ops->name, opts->transport) == 0) in nvmf_lookup_transport()
667 opts->queue_size = NVMF_DEF_QUEUE_SIZE; in nvmf_parse_options()
668 opts->nr_io_queues = num_online_cpus(); in nvmf_parse_options()
669 opts->reconnect_delay = NVMF_DEF_RECONNECT_DELAY; in nvmf_parse_options()
670 opts->kato = 0; in nvmf_parse_options()
671 opts->duplicate_connect = false; in nvmf_parse_options()
672 opts->fast_io_fail_tmo = NVMF_DEF_FAIL_FAST_TMO; in nvmf_parse_options()
673 opts->hdr_digest = false; in nvmf_parse_options()
674 opts->data_digest = false; in nvmf_parse_options()
675 opts->tos = -1; /* < 0 == use transport default */ in nvmf_parse_options()
679 return -ENOMEM; in nvmf_parse_options()
682 uuid_copy(&hostid, &nvmf_default_host->id); in nvmf_parse_options()
683 strscpy(hostnqn, nvmf_default_host->nqn, NVMF_NQN_SIZE); in nvmf_parse_options()
690 opts->mask |= token; in nvmf_parse_options()
695 ret = -ENOMEM; in nvmf_parse_options()
698 kfree(opts->transport); in nvmf_parse_options()
699 opts->transport = p; in nvmf_parse_options()
704 ret = -ENOMEM; in nvmf_parse_options()
707 kfree(opts->subsysnqn); in nvmf_parse_options()
708 opts->subsysnqn = p; in nvmf_parse_options()
709 nqnlen = strlen(opts->subsysnqn); in nvmf_parse_options()
712 opts->subsysnqn, NVMF_NQN_SIZE); in nvmf_parse_options()
713 ret = -EINVAL; in nvmf_parse_options()
716 opts->discovery_nqn = in nvmf_parse_options()
717 !(strcmp(opts->subsysnqn, in nvmf_parse_options()
723 ret = -ENOMEM; in nvmf_parse_options()
726 kfree(opts->traddr); in nvmf_parse_options()
727 opts->traddr = p; in nvmf_parse_options()
732 ret = -ENOMEM; in nvmf_parse_options()
735 kfree(opts->trsvcid); in nvmf_parse_options()
736 opts->trsvcid = p; in nvmf_parse_options()
740 ret = -EINVAL; in nvmf_parse_options()
746 ret = -EINVAL; in nvmf_parse_options()
749 opts->queue_size = token; in nvmf_parse_options()
753 ret = -EINVAL; in nvmf_parse_options()
758 ret = -EINVAL; in nvmf_parse_options()
761 if (opts->discovery_nqn) { in nvmf_parse_options()
766 opts->nr_io_queues = min_t(unsigned int, in nvmf_parse_options()
771 ret = -EINVAL; in nvmf_parse_options()
777 ret = -EINVAL; in nvmf_parse_options()
779 } else if (token == 0 && !opts->discovery_nqn) { in nvmf_parse_options()
783 opts->kato = token; in nvmf_parse_options()
787 ret = -EINVAL; in nvmf_parse_options()
797 ret = -EINVAL; in nvmf_parse_options()
805 token = -1; in nvmf_parse_options()
807 opts->fast_io_fail_tmo = token; in nvmf_parse_options()
810 if (opts->host) { in nvmf_parse_options()
811 pr_err("hostnqn already user-assigned: %s\n", in nvmf_parse_options()
812 opts->host->nqn); in nvmf_parse_options()
813 ret = -EADDRINUSE; in nvmf_parse_options()
818 ret = -ENOMEM; in nvmf_parse_options()
826 ret = -EINVAL; in nvmf_parse_options()
834 ret = -EINVAL; in nvmf_parse_options()
839 ret = -EINVAL; in nvmf_parse_options()
842 opts->reconnect_delay = token; in nvmf_parse_options()
847 ret = -ENOMEM; in nvmf_parse_options()
850 kfree(opts->host_traddr); in nvmf_parse_options()
851 opts->host_traddr = p; in nvmf_parse_options()
856 ret = -ENOMEM; in nvmf_parse_options()
859 kfree(opts->host_iface); in nvmf_parse_options()
860 opts->host_iface = p; in nvmf_parse_options()
865 ret = -ENOMEM; in nvmf_parse_options()
871 ret = -EINVAL; in nvmf_parse_options()
878 opts->duplicate_connect = true; in nvmf_parse_options()
881 opts->disable_sqflow = true; in nvmf_parse_options()
884 opts->hdr_digest = true; in nvmf_parse_options()
887 opts->data_digest = true; in nvmf_parse_options()
891 ret = -EINVAL; in nvmf_parse_options()
896 ret = -EINVAL; in nvmf_parse_options()
899 opts->nr_write_queues = token; in nvmf_parse_options()
903 ret = -EINVAL; in nvmf_parse_options()
908 ret = -EINVAL; in nvmf_parse_options()
911 opts->nr_poll_queues = token; in nvmf_parse_options()
915 ret = -EINVAL; in nvmf_parse_options()
920 ret = -EINVAL; in nvmf_parse_options()
927 opts->tos = token; in nvmf_parse_options()
930 opts->discovery_nqn = true; in nvmf_parse_options()
935 ret = -ENOMEM; in nvmf_parse_options()
938 if (strlen(p) < 11 || strncmp(p, "DHHC-1:", 7)) { in nvmf_parse_options()
939 pr_err("Invalid DH-CHAP secret %s\n", p); in nvmf_parse_options()
940 ret = -EINVAL; in nvmf_parse_options()
943 kfree(opts->dhchap_secret); in nvmf_parse_options()
944 opts->dhchap_secret = p; in nvmf_parse_options()
949 ret = -ENOMEM; in nvmf_parse_options()
952 if (strlen(p) < 11 || strncmp(p, "DHHC-1:", 7)) { in nvmf_parse_options()
953 pr_err("Invalid DH-CHAP secret %s\n", p); in nvmf_parse_options()
954 ret = -EINVAL; in nvmf_parse_options()
957 kfree(opts->dhchap_ctrl_secret); in nvmf_parse_options()
958 opts->dhchap_ctrl_secret = p; in nvmf_parse_options()
961 pr_warn("unknown parameter or missing value '%s' in ctrl creation request\n", in nvmf_parse_options()
963 ret = -EINVAL; in nvmf_parse_options()
968 if (opts->discovery_nqn) { in nvmf_parse_options()
969 opts->nr_io_queues = 0; in nvmf_parse_options()
970 opts->nr_write_queues = 0; in nvmf_parse_options()
971 opts->nr_poll_queues = 0; in nvmf_parse_options()
972 opts->duplicate_connect = true; in nvmf_parse_options()
974 if (!opts->kato) in nvmf_parse_options()
975 opts->kato = NVME_DEFAULT_KATO; in nvmf_parse_options()
978 opts->max_reconnects = -1; in nvmf_parse_options()
980 opts->max_reconnects = DIV_ROUND_UP(ctrl_loss_tmo, in nvmf_parse_options()
981 opts->reconnect_delay); in nvmf_parse_options()
982 if (ctrl_loss_tmo < opts->fast_io_fail_tmo) in nvmf_parse_options()
984 opts->fast_io_fail_tmo, ctrl_loss_tmo); in nvmf_parse_options()
987 opts->host = nvmf_host_add(hostnqn, &hostid); in nvmf_parse_options()
988 if (IS_ERR(opts->host)) { in nvmf_parse_options()
989 ret = PTR_ERR(opts->host); in nvmf_parse_options()
990 opts->host = NULL; in nvmf_parse_options()
1002 if (opts->nr_write_queues && opts->nr_io_queues < nr_io_queues) { in nvmf_set_io_queues()
1008 io_queues[HCTX_TYPE_READ] = opts->nr_io_queues; in nvmf_set_io_queues()
1009 nr_io_queues -= io_queues[HCTX_TYPE_READ]; in nvmf_set_io_queues()
1011 min(opts->nr_write_queues, nr_io_queues); in nvmf_set_io_queues()
1012 nr_io_queues -= io_queues[HCTX_TYPE_DEFAULT]; in nvmf_set_io_queues()
1020 min(opts->nr_io_queues, nr_io_queues); in nvmf_set_io_queues()
1021 nr_io_queues -= io_queues[HCTX_TYPE_DEFAULT]; in nvmf_set_io_queues()
1024 if (opts->nr_poll_queues && nr_io_queues) { in nvmf_set_io_queues()
1027 min(opts->nr_poll_queues, nr_io_queues); in nvmf_set_io_queues()
1032 void nvmf_map_queues(struct blk_mq_tag_set *set, struct nvme_ctrl *ctrl, in nvmf_map_queues() argument
1035 struct nvmf_ctrl_options *opts = ctrl->opts; in nvmf_map_queues()
1037 if (opts->nr_write_queues && io_queues[HCTX_TYPE_READ]) { in nvmf_map_queues()
1039 set->map[HCTX_TYPE_DEFAULT].nr_queues = in nvmf_map_queues()
1041 set->map[HCTX_TYPE_DEFAULT].queue_offset = 0; in nvmf_map_queues()
1042 set->map[HCTX_TYPE_READ].nr_queues = in nvmf_map_queues()
1044 set->map[HCTX_TYPE_READ].queue_offset = in nvmf_map_queues()
1048 set->map[HCTX_TYPE_DEFAULT].nr_queues = in nvmf_map_queues()
1050 set->map[HCTX_TYPE_DEFAULT].queue_offset = 0; in nvmf_map_queues()
1051 set->map[HCTX_TYPE_READ].nr_queues = in nvmf_map_queues()
1053 set->map[HCTX_TYPE_READ].queue_offset = 0; in nvmf_map_queues()
1056 blk_mq_map_queues(&set->map[HCTX_TYPE_DEFAULT]); in nvmf_map_queues()
1057 blk_mq_map_queues(&set->map[HCTX_TYPE_READ]); in nvmf_map_queues()
1058 if (opts->nr_poll_queues && io_queues[HCTX_TYPE_POLL]) { in nvmf_map_queues()
1060 set->map[HCTX_TYPE_POLL].nr_queues = io_queues[HCTX_TYPE_POLL]; in nvmf_map_queues()
1061 set->map[HCTX_TYPE_POLL].queue_offset = in nvmf_map_queues()
1064 blk_mq_map_queues(&set->map[HCTX_TYPE_POLL]); in nvmf_map_queues()
1067 dev_info(ctrl->device, in nvmf_map_queues()
1078 if ((opts->mask & required_opts) != required_opts) { in nvmf_check_required_opts()
1083 !(opt_tokens[i].token & opts->mask)) { in nvmf_check_required_opts()
1089 return -EINVAL; in nvmf_check_required_opts()
1095 bool nvmf_ip_options_match(struct nvme_ctrl *ctrl, in nvmf_ip_options_match() argument
1098 if (!nvmf_ctlr_matches_baseopts(ctrl, opts) || in nvmf_ip_options_match()
1099 strcmp(opts->traddr, ctrl->opts->traddr) || in nvmf_ip_options_match()
1100 strcmp(opts->trsvcid, ctrl->opts->trsvcid)) in nvmf_ip_options_match()
1110 * - local address or host interface is specified and address in nvmf_ip_options_match()
1112 * - local address or host interface is not specified but in nvmf_ip_options_match()
1116 if ((opts->mask & NVMF_OPT_HOST_TRADDR) && in nvmf_ip_options_match()
1117 (ctrl->opts->mask & NVMF_OPT_HOST_TRADDR)) { in nvmf_ip_options_match()
1118 if (strcmp(opts->host_traddr, ctrl->opts->host_traddr)) in nvmf_ip_options_match()
1120 } else if ((opts->mask & NVMF_OPT_HOST_TRADDR) || in nvmf_ip_options_match()
1121 (ctrl->opts->mask & NVMF_OPT_HOST_TRADDR)) { in nvmf_ip_options_match()
1125 if ((opts->mask & NVMF_OPT_HOST_IFACE) && in nvmf_ip_options_match()
1126 (ctrl->opts->mask & NVMF_OPT_HOST_IFACE)) { in nvmf_ip_options_match()
1127 if (strcmp(opts->host_iface, ctrl->opts->host_iface)) in nvmf_ip_options_match()
1129 } else if ((opts->mask & NVMF_OPT_HOST_IFACE) || in nvmf_ip_options_match()
1130 (ctrl->opts->mask & NVMF_OPT_HOST_IFACE)) { in nvmf_ip_options_match()
1141 if (opts->mask & ~allowed_opts) { in nvmf_check_allowed_opts()
1145 if ((opt_tokens[i].token & opts->mask) && in nvmf_check_allowed_opts()
1152 return -EINVAL; in nvmf_check_allowed_opts()
1160 nvmf_host_put(opts->host); in nvmf_free_options()
1161 kfree(opts->transport); in nvmf_free_options()
1162 kfree(opts->traddr); in nvmf_free_options()
1163 kfree(opts->trsvcid); in nvmf_free_options()
1164 kfree(opts->subsysnqn); in nvmf_free_options()
1165 kfree(opts->host_traddr); in nvmf_free_options()
1166 kfree(opts->host_iface); in nvmf_free_options()
1167 kfree(opts->dhchap_secret); in nvmf_free_options()
1168 kfree(opts->dhchap_ctrl_secret); in nvmf_free_options()
1186 struct nvme_ctrl *ctrl; in nvmf_create_ctrl() local
1191 return ERR_PTR(-ENOMEM); in nvmf_create_ctrl()
1198 request_module("nvme-%s", opts->transport); in nvmf_create_ctrl()
1208 opts->mask &= ~NVMF_REQUIRED_OPTS; in nvmf_create_ctrl()
1214 opts->transport); in nvmf_create_ctrl()
1215 ret = -EINVAL; in nvmf_create_ctrl()
1219 if (!try_module_get(ops->module)) { in nvmf_create_ctrl()
1220 ret = -EBUSY; in nvmf_create_ctrl()
1225 ret = nvmf_check_required_opts(opts, ops->required_opts); in nvmf_create_ctrl()
1229 ops->allowed_opts | ops->required_opts); in nvmf_create_ctrl()
1233 ctrl = ops->create_ctrl(dev, opts); in nvmf_create_ctrl()
1234 if (IS_ERR(ctrl)) { in nvmf_create_ctrl()
1235 ret = PTR_ERR(ctrl); in nvmf_create_ctrl()
1239 module_put(ops->module); in nvmf_create_ctrl()
1240 return ctrl; in nvmf_create_ctrl()
1243 module_put(ops->module); in nvmf_create_ctrl()
1259 struct seq_file *seq_file = file->private_data; in nvmf_dev_write()
1260 struct nvme_ctrl *ctrl; in nvmf_dev_write() local
1265 return -ENOMEM; in nvmf_dev_write()
1272 if (seq_file->private) { in nvmf_dev_write()
1273 ret = -EINVAL; in nvmf_dev_write()
1277 ctrl = nvmf_create_ctrl(nvmf_device, buf); in nvmf_dev_write()
1278 if (IS_ERR(ctrl)) { in nvmf_dev_write()
1279 ret = PTR_ERR(ctrl); in nvmf_dev_write()
1283 seq_file->private = ctrl; in nvmf_dev_write()
1298 * signal an invalid/non-existing controller in __nvmf_concat_opt_tokens()
1300 seq_puts(seq_file, "instance=-1,cntlid=-1"); in __nvmf_concat_opt_tokens()
1303 if (tok->token == NVMF_OPT_ERR) in __nvmf_concat_opt_tokens()
1306 seq_puts(seq_file, tok->pattern); in __nvmf_concat_opt_tokens()
1313 struct nvme_ctrl *ctrl; in nvmf_dev_show() local
1316 ctrl = seq_file->private; in nvmf_dev_show()
1317 if (!ctrl) { in nvmf_dev_show()
1323 ctrl->instance, ctrl->cntlid); in nvmf_dev_show()
1333 * The miscdevice code initializes file->private_data, but doesn't in nvmf_dev_open()
1336 file->private_data = NULL; in nvmf_dev_open()
1342 struct seq_file *seq_file = file->private_data; in nvmf_dev_release()
1343 struct nvme_ctrl *ctrl = seq_file->private; in nvmf_dev_release() local
1345 if (ctrl) in nvmf_dev_release()
1346 nvme_put_ctrl(ctrl); in nvmf_dev_release()
1360 .name = "nvme-fabrics",
1370 return -ENOMEM; in nvmf_init()
1372 nvmf_class = class_create("nvme-fabrics"); in nvmf_init()
1374 pr_err("couldn't register class nvme-fabrics\n"); in nvmf_init()
1382 pr_err("couldn't create nvme-fabrics device!\n"); in nvmf_init()