Lines Matching +full:ctrl +full:- +full:len

1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright (c) 2015-2016 HGST, a Western Digital Company.
15 #include <linux/nvme-keyring.h>
33 kref_init(&host->ref); in nvmf_host_alloc()
34 uuid_copy(&host->id, id); in nvmf_host_alloc()
35 strscpy(host->nqn, hostnqn, NVMF_NQN_SIZE); in nvmf_host_alloc()
53 bool same_hostnqn = !strcmp(host->nqn, hostnqn); in nvmf_host_add()
54 bool same_hostid = uuid_equal(&host->id, id); in nvmf_host_add()
57 kref_get(&host->ref); in nvmf_host_add()
63 host = ERR_PTR(-EINVAL); in nvmf_host_add()
69 host = ERR_PTR(-EINVAL); in nvmf_host_add()
76 host = ERR_PTR(-ENOMEM); in nvmf_host_add()
80 list_add_tail(&host->list, &nvmf_hosts); in nvmf_host_add()
94 "nqn.2014-08.org.nvmexpress:uuid:%pUb", &id); in nvmf_host_default()
101 list_add_tail(&host->list, &nvmf_hosts); in nvmf_host_default()
112 list_del(&host->list); in nvmf_host_destroy()
121 kref_put(&host->ref, nvmf_host_destroy); in nvmf_host_put()
125 * nvmf_get_address() - Get address/port
126 * @ctrl: Host NVMe controller instance which we got the address
130 int nvmf_get_address(struct nvme_ctrl *ctrl, char *buf, int size) in nvmf_get_address() argument
132 int len = 0; in nvmf_get_address() local
134 if (ctrl->opts->mask & NVMF_OPT_TRADDR) in nvmf_get_address()
135 len += scnprintf(buf, size, "traddr=%s", ctrl->opts->traddr); in nvmf_get_address()
136 if (ctrl->opts->mask & NVMF_OPT_TRSVCID) in nvmf_get_address()
137 len += scnprintf(buf + len, size - len, "%strsvcid=%s", in nvmf_get_address()
138 (len) ? "," : "", ctrl->opts->trsvcid); in nvmf_get_address()
139 if (ctrl->opts->mask & NVMF_OPT_HOST_TRADDR) in nvmf_get_address()
140 len += scnprintf(buf + len, size - len, "%shost_traddr=%s", in nvmf_get_address()
141 (len) ? "," : "", ctrl->opts->host_traddr); in nvmf_get_address()
142 if (ctrl->opts->mask & NVMF_OPT_HOST_IFACE) in nvmf_get_address()
143 len += scnprintf(buf + len, size - len, "%shost_iface=%s", in nvmf_get_address()
144 (len) ? "," : "", ctrl->opts->host_iface); in nvmf_get_address()
145 len += scnprintf(buf + len, size - len, "\n"); in nvmf_get_address()
147 return len; in nvmf_get_address()
152 * nvmf_reg_read32() - NVMe Fabrics "Property Get" API function.
153 * @ctrl: Host NVMe controller instance maintaining the admin
161 * Used by the host system to retrieve a 32-bit capsule property value
172 int nvmf_reg_read32(struct nvme_ctrl *ctrl, u32 off, u32 *val) in nvmf_reg_read32() argument
182 ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, NULL, 0, in nvmf_reg_read32()
188 dev_err(ctrl->device, in nvmf_reg_read32()
197 * nvmf_reg_read64() - NVMe Fabrics "Property Get" API function.
198 * @ctrl: Host NVMe controller instance maintaining the admin
206 * Used by the host system to retrieve a 64-bit capsule property value
217 int nvmf_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val) in nvmf_reg_read64() argument
228 ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, NULL, 0, in nvmf_reg_read64()
234 dev_err(ctrl->device, in nvmf_reg_read64()
242 * nvmf_reg_write32() - NVMe Fabrics "Property Write" API function.
243 * @ctrl: Host NVMe controller instance maintaining the admin
251 * Used by the NVMe host system to write a 32-bit capsule property value
262 int nvmf_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val) in nvmf_reg_write32() argument
273 ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, NULL, NULL, 0, in nvmf_reg_write32()
276 dev_err(ctrl->device, in nvmf_reg_write32()
284 * nvmf_log_connect_error() - Error-parsing-diagnostic print out function for
286 * @ctrl: The specific /dev/nvmeX device that had the error.
287 * @errval: Error code to be decoded in a more human-friendly
294 static void nvmf_log_connect_error(struct nvme_ctrl *ctrl, in nvmf_log_connect_error() argument
301 dev_err(ctrl->device, in nvmf_log_connect_error()
313 dev_err(ctrl->device, in nvmf_log_connect_error()
315 inv_data, data->cntlid); in nvmf_log_connect_error()
318 dev_err(ctrl->device, in nvmf_log_connect_error()
320 inv_data, data->hostnqn); in nvmf_log_connect_error()
323 dev_err(ctrl->device, in nvmf_log_connect_error()
325 inv_data, data->subsysnqn); in nvmf_log_connect_error()
328 dev_err(ctrl->device, in nvmf_log_connect_error()
338 dev_err(ctrl->device, in nvmf_log_connect_error()
340 inv_sqe, cmd->connect.qid); in nvmf_log_connect_error()
343 dev_err(ctrl->device, in nvmf_log_connect_error()
350 dev_err(ctrl->device, in nvmf_log_connect_error()
352 data->subsysnqn, data->hostnqn); in nvmf_log_connect_error()
355 dev_err(ctrl->device, in nvmf_log_connect_error()
359 dev_err(ctrl->device, in nvmf_log_connect_error()
361 cmd->connect.recfmt); in nvmf_log_connect_error()
364 dev_err(ctrl->device, in nvmf_log_connect_error()
368 dev_err(ctrl->device, in nvmf_log_connect_error()
372 dev_err(ctrl->device, in nvmf_log_connect_error()
379 static struct nvmf_connect_data *nvmf_connect_data_prep(struct nvme_ctrl *ctrl, in nvmf_connect_data_prep() argument
388 uuid_copy(&data->hostid, &ctrl->opts->host->id); in nvmf_connect_data_prep()
389 data->cntlid = cpu_to_le16(cntlid); in nvmf_connect_data_prep()
390 strscpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE); in nvmf_connect_data_prep()
391 strscpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE); in nvmf_connect_data_prep()
396 static void nvmf_connect_cmd_prep(struct nvme_ctrl *ctrl, u16 qid, in nvmf_connect_cmd_prep() argument
399 cmd->connect.opcode = nvme_fabrics_command; in nvmf_connect_cmd_prep()
400 cmd->connect.fctype = nvme_fabrics_type_connect; in nvmf_connect_cmd_prep()
401 cmd->connect.qid = cpu_to_le16(qid); in nvmf_connect_cmd_prep()
404 cmd->connect.sqsize = cpu_to_le16(ctrl->sqsize); in nvmf_connect_cmd_prep()
406 cmd->connect.sqsize = cpu_to_le16(NVME_AQ_DEPTH - 1); in nvmf_connect_cmd_prep()
409 * set keep-alive timeout in seconds granularity (ms * 1000) in nvmf_connect_cmd_prep()
411 cmd->connect.kato = cpu_to_le32(ctrl->kato * 1000); in nvmf_connect_cmd_prep()
414 if (ctrl->opts->disable_sqflow) in nvmf_connect_cmd_prep()
415 cmd->connect.cattr |= NVME_CONNECT_DISABLE_SQFLOW; in nvmf_connect_cmd_prep()
419 * nvmf_connect_admin_queue() - NVMe Fabrics Admin Queue "Connect"
421 * @ctrl: Host nvme controller instance used to request
428 * fabrics-protocol connection of the NVMe Admin queue between the
438 int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl) in nvmf_connect_admin_queue() argument
446 nvmf_connect_cmd_prep(ctrl, 0, &cmd); in nvmf_connect_admin_queue()
448 data = nvmf_connect_data_prep(ctrl, 0xffff); in nvmf_connect_admin_queue()
450 return -ENOMEM; in nvmf_connect_admin_queue()
452 ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, in nvmf_connect_admin_queue()
458 nvmf_log_connect_error(ctrl, ret, le32_to_cpu(res.u32), in nvmf_connect_admin_queue()
464 ctrl->cntlid = result & 0xFFFF; in nvmf_connect_admin_queue()
468 dev_warn(ctrl->device, in nvmf_connect_admin_queue()
474 ret = nvme_auth_negotiate(ctrl, 0); in nvmf_connect_admin_queue()
476 dev_warn(ctrl->device, in nvmf_connect_admin_queue()
481 ret = nvme_auth_wait(ctrl, 0); in nvmf_connect_admin_queue()
483 dev_warn(ctrl->device, in nvmf_connect_admin_queue()
486 dev_info(ctrl->device, in nvmf_connect_admin_queue()
496 * nvmf_connect_io_queue() - NVMe Fabrics I/O Queue "Connect"
498 * @ctrl: Host nvme controller instance used to establish an
505 * This function issues a fabrics-protocol connection
515 int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid) in nvmf_connect_io_queue() argument
523 nvmf_connect_cmd_prep(ctrl, qid, &cmd); in nvmf_connect_io_queue()
525 data = nvmf_connect_data_prep(ctrl, ctrl->cntlid); in nvmf_connect_io_queue()
527 return -ENOMEM; in nvmf_connect_io_queue()
529 ret = __nvme_submit_sync_cmd(ctrl->connect_q, &cmd, &res, in nvmf_connect_io_queue()
535 nvmf_log_connect_error(ctrl, ret, le32_to_cpu(res.u32), in nvmf_connect_io_queue()
543 dev_warn(ctrl->device, in nvmf_connect_io_queue()
549 ret = nvme_auth_negotiate(ctrl, qid); in nvmf_connect_io_queue()
551 dev_warn(ctrl->device, in nvmf_connect_io_queue()
555 ret = nvme_auth_wait(ctrl, qid); in nvmf_connect_io_queue()
557 dev_warn(ctrl->device, in nvmf_connect_io_queue()
567 bool nvmf_should_reconnect(struct nvme_ctrl *ctrl) in nvmf_should_reconnect() argument
569 if (ctrl->opts->max_reconnects == -1 || in nvmf_should_reconnect()
570 ctrl->nr_reconnects < ctrl->opts->max_reconnects) in nvmf_should_reconnect()
578 * nvmf_register_transport() - NVMe Fabrics Library registration function.
588 if (!ops->create_ctrl) in nvmf_register_transport()
589 return -EINVAL; in nvmf_register_transport()
592 list_add_tail(&ops->entry, &nvmf_transports); in nvmf_register_transport()
600 * nvmf_unregister_transport() - NVMe Fabrics Library unregistration function.
611 list_del(&ops->entry); in nvmf_unregister_transport()
624 if (strcmp(ops->name, opts->transport) == 0) in nvmf_lookup_transport()
637 return ERR_PTR(-EINVAL); in nvmf_parse_key()
698 opts->queue_size = NVMF_DEF_QUEUE_SIZE; in nvmf_parse_options()
699 opts->nr_io_queues = num_online_cpus(); in nvmf_parse_options()
700 opts->reconnect_delay = NVMF_DEF_RECONNECT_DELAY; in nvmf_parse_options()
701 opts->kato = 0; in nvmf_parse_options()
702 opts->duplicate_connect = false; in nvmf_parse_options()
703 opts->fast_io_fail_tmo = NVMF_DEF_FAIL_FAST_TMO; in nvmf_parse_options()
704 opts->hdr_digest = false; in nvmf_parse_options()
705 opts->data_digest = false; in nvmf_parse_options()
706 opts->tos = -1; /* < 0 == use transport default */ in nvmf_parse_options()
707 opts->tls = false; in nvmf_parse_options()
708 opts->tls_key = NULL; in nvmf_parse_options()
709 opts->keyring = NULL; in nvmf_parse_options()
713 return -ENOMEM; in nvmf_parse_options()
716 uuid_copy(&hostid, &nvmf_default_host->id); in nvmf_parse_options()
717 strscpy(hostnqn, nvmf_default_host->nqn, NVMF_NQN_SIZE); in nvmf_parse_options()
724 opts->mask |= token; in nvmf_parse_options()
729 ret = -ENOMEM; in nvmf_parse_options()
732 kfree(opts->transport); in nvmf_parse_options()
733 opts->transport = p; in nvmf_parse_options()
738 ret = -ENOMEM; in nvmf_parse_options()
741 kfree(opts->subsysnqn); in nvmf_parse_options()
742 opts->subsysnqn = p; in nvmf_parse_options()
743 nqnlen = strlen(opts->subsysnqn); in nvmf_parse_options()
746 opts->subsysnqn, NVMF_NQN_SIZE); in nvmf_parse_options()
747 ret = -EINVAL; in nvmf_parse_options()
750 opts->discovery_nqn = in nvmf_parse_options()
751 !(strcmp(opts->subsysnqn, in nvmf_parse_options()
757 ret = -ENOMEM; in nvmf_parse_options()
760 kfree(opts->traddr); in nvmf_parse_options()
761 opts->traddr = p; in nvmf_parse_options()
766 ret = -ENOMEM; in nvmf_parse_options()
769 kfree(opts->trsvcid); in nvmf_parse_options()
770 opts->trsvcid = p; in nvmf_parse_options()
774 ret = -EINVAL; in nvmf_parse_options()
780 ret = -EINVAL; in nvmf_parse_options()
783 opts->queue_size = token; in nvmf_parse_options()
787 ret = -EINVAL; in nvmf_parse_options()
792 ret = -EINVAL; in nvmf_parse_options()
795 if (opts->discovery_nqn) { in nvmf_parse_options()
800 opts->nr_io_queues = min_t(unsigned int, in nvmf_parse_options()
805 ret = -EINVAL; in nvmf_parse_options()
811 ret = -EINVAL; in nvmf_parse_options()
813 } else if (token == 0 && !opts->discovery_nqn) { in nvmf_parse_options()
817 opts->kato = token; in nvmf_parse_options()
821 ret = -EINVAL; in nvmf_parse_options()
831 ret = -EINVAL; in nvmf_parse_options()
839 token = -1; in nvmf_parse_options()
841 opts->fast_io_fail_tmo = token; in nvmf_parse_options()
844 if (opts->host) { in nvmf_parse_options()
845 pr_err("hostnqn already user-assigned: %s\n", in nvmf_parse_options()
846 opts->host->nqn); in nvmf_parse_options()
847 ret = -EADDRINUSE; in nvmf_parse_options()
852 ret = -ENOMEM; in nvmf_parse_options()
860 ret = -EINVAL; in nvmf_parse_options()
868 ret = -EINVAL; in nvmf_parse_options()
873 ret = -EINVAL; in nvmf_parse_options()
876 opts->reconnect_delay = token; in nvmf_parse_options()
881 ret = -ENOMEM; in nvmf_parse_options()
884 kfree(opts->host_traddr); in nvmf_parse_options()
885 opts->host_traddr = p; in nvmf_parse_options()
890 ret = -ENOMEM; in nvmf_parse_options()
893 kfree(opts->host_iface); in nvmf_parse_options()
894 opts->host_iface = p; in nvmf_parse_options()
899 ret = -ENOMEM; in nvmf_parse_options()
905 ret = -EINVAL; in nvmf_parse_options()
912 opts->duplicate_connect = true; in nvmf_parse_options()
915 opts->disable_sqflow = true; in nvmf_parse_options()
918 opts->hdr_digest = true; in nvmf_parse_options()
921 opts->data_digest = true; in nvmf_parse_options()
925 ret = -EINVAL; in nvmf_parse_options()
930 ret = -EINVAL; in nvmf_parse_options()
933 opts->nr_write_queues = token; in nvmf_parse_options()
937 ret = -EINVAL; in nvmf_parse_options()
942 ret = -EINVAL; in nvmf_parse_options()
945 opts->nr_poll_queues = token; in nvmf_parse_options()
949 ret = -EINVAL; in nvmf_parse_options()
954 ret = -EINVAL; in nvmf_parse_options()
961 opts->tos = token; in nvmf_parse_options()
965 ret = -EINVAL; in nvmf_parse_options()
973 key_put(opts->keyring); in nvmf_parse_options()
974 opts->keyring = key; in nvmf_parse_options()
978 ret = -EINVAL; in nvmf_parse_options()
986 key_put(opts->tls_key); in nvmf_parse_options()
987 opts->tls_key = key; in nvmf_parse_options()
990 opts->discovery_nqn = true; in nvmf_parse_options()
995 ret = -ENOMEM; in nvmf_parse_options()
998 if (strlen(p) < 11 || strncmp(p, "DHHC-1:", 7)) { in nvmf_parse_options()
999 pr_err("Invalid DH-CHAP secret %s\n", p); in nvmf_parse_options()
1000 ret = -EINVAL; in nvmf_parse_options()
1003 kfree(opts->dhchap_secret); in nvmf_parse_options()
1004 opts->dhchap_secret = p; in nvmf_parse_options()
1009 ret = -ENOMEM; in nvmf_parse_options()
1012 if (strlen(p) < 11 || strncmp(p, "DHHC-1:", 7)) { in nvmf_parse_options()
1013 pr_err("Invalid DH-CHAP secret %s\n", p); in nvmf_parse_options()
1014 ret = -EINVAL; in nvmf_parse_options()
1017 kfree(opts->dhchap_ctrl_secret); in nvmf_parse_options()
1018 opts->dhchap_ctrl_secret = p; in nvmf_parse_options()
1023 ret = -EINVAL; in nvmf_parse_options()
1026 opts->tls = true; in nvmf_parse_options()
1029 pr_warn("unknown parameter or missing value '%s' in ctrl creation request\n", in nvmf_parse_options()
1031 ret = -EINVAL; in nvmf_parse_options()
1036 if (opts->discovery_nqn) { in nvmf_parse_options()
1037 opts->nr_io_queues = 0; in nvmf_parse_options()
1038 opts->nr_write_queues = 0; in nvmf_parse_options()
1039 opts->nr_poll_queues = 0; in nvmf_parse_options()
1040 opts->duplicate_connect = true; in nvmf_parse_options()
1042 if (!opts->kato) in nvmf_parse_options()
1043 opts->kato = NVME_DEFAULT_KATO; in nvmf_parse_options()
1046 opts->max_reconnects = -1; in nvmf_parse_options()
1048 opts->max_reconnects = DIV_ROUND_UP(ctrl_loss_tmo, in nvmf_parse_options()
1049 opts->reconnect_delay); in nvmf_parse_options()
1050 if (ctrl_loss_tmo < opts->fast_io_fail_tmo) in nvmf_parse_options()
1052 opts->fast_io_fail_tmo, ctrl_loss_tmo); in nvmf_parse_options()
1055 opts->host = nvmf_host_add(hostnqn, &hostid); in nvmf_parse_options()
1056 if (IS_ERR(opts->host)) { in nvmf_parse_options()
1057 ret = PTR_ERR(opts->host); in nvmf_parse_options()
1058 opts->host = NULL; in nvmf_parse_options()
1070 if (opts->nr_write_queues && opts->nr_io_queues < nr_io_queues) { in nvmf_set_io_queues()
1076 io_queues[HCTX_TYPE_READ] = opts->nr_io_queues; in nvmf_set_io_queues()
1077 nr_io_queues -= io_queues[HCTX_TYPE_READ]; in nvmf_set_io_queues()
1079 min(opts->nr_write_queues, nr_io_queues); in nvmf_set_io_queues()
1080 nr_io_queues -= io_queues[HCTX_TYPE_DEFAULT]; in nvmf_set_io_queues()
1088 min(opts->nr_io_queues, nr_io_queues); in nvmf_set_io_queues()
1089 nr_io_queues -= io_queues[HCTX_TYPE_DEFAULT]; in nvmf_set_io_queues()
1092 if (opts->nr_poll_queues && nr_io_queues) { in nvmf_set_io_queues()
1095 min(opts->nr_poll_queues, nr_io_queues); in nvmf_set_io_queues()
1100 void nvmf_map_queues(struct blk_mq_tag_set *set, struct nvme_ctrl *ctrl, in nvmf_map_queues() argument
1103 struct nvmf_ctrl_options *opts = ctrl->opts; in nvmf_map_queues()
1105 if (opts->nr_write_queues && io_queues[HCTX_TYPE_READ]) { in nvmf_map_queues()
1107 set->map[HCTX_TYPE_DEFAULT].nr_queues = in nvmf_map_queues()
1109 set->map[HCTX_TYPE_DEFAULT].queue_offset = 0; in nvmf_map_queues()
1110 set->map[HCTX_TYPE_READ].nr_queues = in nvmf_map_queues()
1112 set->map[HCTX_TYPE_READ].queue_offset = in nvmf_map_queues()
1116 set->map[HCTX_TYPE_DEFAULT].nr_queues = in nvmf_map_queues()
1118 set->map[HCTX_TYPE_DEFAULT].queue_offset = 0; in nvmf_map_queues()
1119 set->map[HCTX_TYPE_READ].nr_queues = in nvmf_map_queues()
1121 set->map[HCTX_TYPE_READ].queue_offset = 0; in nvmf_map_queues()
1124 blk_mq_map_queues(&set->map[HCTX_TYPE_DEFAULT]); in nvmf_map_queues()
1125 blk_mq_map_queues(&set->map[HCTX_TYPE_READ]); in nvmf_map_queues()
1126 if (opts->nr_poll_queues && io_queues[HCTX_TYPE_POLL]) { in nvmf_map_queues()
1128 set->map[HCTX_TYPE_POLL].nr_queues = io_queues[HCTX_TYPE_POLL]; in nvmf_map_queues()
1129 set->map[HCTX_TYPE_POLL].queue_offset = in nvmf_map_queues()
1132 blk_mq_map_queues(&set->map[HCTX_TYPE_POLL]); in nvmf_map_queues()
1135 dev_info(ctrl->device, in nvmf_map_queues()
1146 if ((opts->mask & required_opts) != required_opts) { in nvmf_check_required_opts()
1151 !(opt_tokens[i].token & opts->mask)) { in nvmf_check_required_opts()
1157 return -EINVAL; in nvmf_check_required_opts()
1163 bool nvmf_ip_options_match(struct nvme_ctrl *ctrl, in nvmf_ip_options_match() argument
1166 if (!nvmf_ctlr_matches_baseopts(ctrl, opts) || in nvmf_ip_options_match()
1167 strcmp(opts->traddr, ctrl->opts->traddr) || in nvmf_ip_options_match()
1168 strcmp(opts->trsvcid, ctrl->opts->trsvcid)) in nvmf_ip_options_match()
1178 * - local address or host interface is specified and address in nvmf_ip_options_match()
1180 * - local address or host interface is not specified but in nvmf_ip_options_match()
1184 if ((opts->mask & NVMF_OPT_HOST_TRADDR) && in nvmf_ip_options_match()
1185 (ctrl->opts->mask & NVMF_OPT_HOST_TRADDR)) { in nvmf_ip_options_match()
1186 if (strcmp(opts->host_traddr, ctrl->opts->host_traddr)) in nvmf_ip_options_match()
1188 } else if ((opts->mask & NVMF_OPT_HOST_TRADDR) || in nvmf_ip_options_match()
1189 (ctrl->opts->mask & NVMF_OPT_HOST_TRADDR)) { in nvmf_ip_options_match()
1193 if ((opts->mask & NVMF_OPT_HOST_IFACE) && in nvmf_ip_options_match()
1194 (ctrl->opts->mask & NVMF_OPT_HOST_IFACE)) { in nvmf_ip_options_match()
1195 if (strcmp(opts->host_iface, ctrl->opts->host_iface)) in nvmf_ip_options_match()
1197 } else if ((opts->mask & NVMF_OPT_HOST_IFACE) || in nvmf_ip_options_match()
1198 (ctrl->opts->mask & NVMF_OPT_HOST_IFACE)) { in nvmf_ip_options_match()
1209 if (opts->mask & ~allowed_opts) { in nvmf_check_allowed_opts()
1213 if ((opt_tokens[i].token & opts->mask) && in nvmf_check_allowed_opts()
1220 return -EINVAL; in nvmf_check_allowed_opts()
1228 nvmf_host_put(opts->host); in nvmf_free_options()
1229 key_put(opts->keyring); in nvmf_free_options()
1230 key_put(opts->tls_key); in nvmf_free_options()
1231 kfree(opts->transport); in nvmf_free_options()
1232 kfree(opts->traddr); in nvmf_free_options()
1233 kfree(opts->trsvcid); in nvmf_free_options()
1234 kfree(opts->subsysnqn); in nvmf_free_options()
1235 kfree(opts->host_traddr); in nvmf_free_options()
1236 kfree(opts->host_iface); in nvmf_free_options()
1237 kfree(opts->dhchap_secret); in nvmf_free_options()
1238 kfree(opts->dhchap_ctrl_secret); in nvmf_free_options()
1256 struct nvme_ctrl *ctrl; in nvmf_create_ctrl() local
1261 return ERR_PTR(-ENOMEM); in nvmf_create_ctrl()
1268 request_module("nvme-%s", opts->transport); in nvmf_create_ctrl()
1278 opts->mask &= ~NVMF_REQUIRED_OPTS; in nvmf_create_ctrl()
1284 opts->transport); in nvmf_create_ctrl()
1285 ret = -EINVAL; in nvmf_create_ctrl()
1289 if (!try_module_get(ops->module)) { in nvmf_create_ctrl()
1290 ret = -EBUSY; in nvmf_create_ctrl()
1295 ret = nvmf_check_required_opts(opts, ops->required_opts); in nvmf_create_ctrl()
1299 ops->allowed_opts | ops->required_opts); in nvmf_create_ctrl()
1303 ctrl = ops->create_ctrl(dev, opts); in nvmf_create_ctrl()
1304 if (IS_ERR(ctrl)) { in nvmf_create_ctrl()
1305 ret = PTR_ERR(ctrl); in nvmf_create_ctrl()
1309 module_put(ops->module); in nvmf_create_ctrl()
1310 return ctrl; in nvmf_create_ctrl()
1313 module_put(ops->module); in nvmf_create_ctrl()
1329 struct seq_file *seq_file = file->private_data; in nvmf_dev_write()
1330 struct nvme_ctrl *ctrl; in nvmf_dev_write() local
1335 return -ENOMEM; in nvmf_dev_write()
1342 if (seq_file->private) { in nvmf_dev_write()
1343 ret = -EINVAL; in nvmf_dev_write()
1347 ctrl = nvmf_create_ctrl(nvmf_device, buf); in nvmf_dev_write()
1348 if (IS_ERR(ctrl)) { in nvmf_dev_write()
1349 ret = PTR_ERR(ctrl); in nvmf_dev_write()
1353 seq_file->private = ctrl; in nvmf_dev_write()
1368 * signal an invalid/non-existing controller in __nvmf_concat_opt_tokens()
1370 seq_puts(seq_file, "instance=-1,cntlid=-1"); in __nvmf_concat_opt_tokens()
1373 if (tok->token == NVMF_OPT_ERR) in __nvmf_concat_opt_tokens()
1376 seq_puts(seq_file, tok->pattern); in __nvmf_concat_opt_tokens()
1383 struct nvme_ctrl *ctrl; in nvmf_dev_show() local
1386 ctrl = seq_file->private; in nvmf_dev_show()
1387 if (!ctrl) { in nvmf_dev_show()
1393 ctrl->instance, ctrl->cntlid); in nvmf_dev_show()
1403 * The miscdevice code initializes file->private_data, but doesn't in nvmf_dev_open()
1406 file->private_data = NULL; in nvmf_dev_open()
1412 struct seq_file *seq_file = file->private_data; in nvmf_dev_release()
1413 struct nvme_ctrl *ctrl = seq_file->private; in nvmf_dev_release() local
1415 if (ctrl) in nvmf_dev_release()
1416 nvme_put_ctrl(ctrl); in nvmf_dev_release()
1430 .name = "nvme-fabrics",
1440 return -ENOMEM; in nvmf_init()
1442 nvmf_class = class_create("nvme-fabrics"); in nvmf_init()
1444 pr_err("couldn't register class nvme-fabrics\n"); in nvmf_init()
1452 pr_err("couldn't create nvme-fabrics device!\n"); in nvmf_init()