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()
283 int nvmf_subsystem_reset(struct nvme_ctrl *ctrl) in nvmf_subsystem_reset() argument
287 if (!nvme_wait_reset(ctrl)) in nvmf_subsystem_reset()
288 return -EBUSY; in nvmf_subsystem_reset()
290 ret = ctrl->ops->reg_write32(ctrl, NVME_REG_NSSR, NVME_SUBSYS_RESET); in nvmf_subsystem_reset()
294 return nvme_try_sched_reset(ctrl); in nvmf_subsystem_reset()
299 * nvmf_log_connect_error() - Error-parsing-diagnostic print out function for
301 * @ctrl: The specific /dev/nvmeX device that had the error.
302 * @errval: Error code to be decoded in a more human-friendly
309 static void nvmf_log_connect_error(struct nvme_ctrl *ctrl, in nvmf_log_connect_error() argument
316 dev_err(ctrl->device, in nvmf_log_connect_error()
328 dev_err(ctrl->device, in nvmf_log_connect_error()
330 inv_data, data->cntlid); in nvmf_log_connect_error()
333 dev_err(ctrl->device, in nvmf_log_connect_error()
335 inv_data, data->hostnqn); in nvmf_log_connect_error()
338 dev_err(ctrl->device, in nvmf_log_connect_error()
340 inv_data, data->subsysnqn); in nvmf_log_connect_error()
343 dev_err(ctrl->device, in nvmf_log_connect_error()
353 dev_err(ctrl->device, in nvmf_log_connect_error()
355 inv_sqe, cmd->connect.qid); in nvmf_log_connect_error()
358 dev_err(ctrl->device, in nvmf_log_connect_error()
365 dev_err(ctrl->device, in nvmf_log_connect_error()
367 data->subsysnqn, data->hostnqn); in nvmf_log_connect_error()
370 dev_err(ctrl->device, in nvmf_log_connect_error()
374 dev_err(ctrl->device, in nvmf_log_connect_error()
376 cmd->connect.recfmt); in nvmf_log_connect_error()
379 dev_err(ctrl->device, in nvmf_log_connect_error()
383 dev_err(ctrl->device, in nvmf_log_connect_error()
387 dev_err(ctrl->device, in nvmf_log_connect_error()
394 static struct nvmf_connect_data *nvmf_connect_data_prep(struct nvme_ctrl *ctrl, in nvmf_connect_data_prep() argument
403 uuid_copy(&data->hostid, &ctrl->opts->host->id); in nvmf_connect_data_prep()
404 data->cntlid = cpu_to_le16(cntlid); in nvmf_connect_data_prep()
405 strscpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE); in nvmf_connect_data_prep()
406 strscpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE); in nvmf_connect_data_prep()
411 static void nvmf_connect_cmd_prep(struct nvme_ctrl *ctrl, u16 qid, in nvmf_connect_cmd_prep() argument
414 cmd->connect.opcode = nvme_fabrics_command; in nvmf_connect_cmd_prep()
415 cmd->connect.fctype = nvme_fabrics_type_connect; in nvmf_connect_cmd_prep()
416 cmd->connect.qid = cpu_to_le16(qid); in nvmf_connect_cmd_prep()
419 cmd->connect.sqsize = cpu_to_le16(ctrl->sqsize); in nvmf_connect_cmd_prep()
421 cmd->connect.sqsize = cpu_to_le16(NVME_AQ_DEPTH - 1); in nvmf_connect_cmd_prep()
424 * set keep-alive timeout in seconds granularity (ms * 1000) in nvmf_connect_cmd_prep()
426 cmd->connect.kato = cpu_to_le32(ctrl->kato * 1000); in nvmf_connect_cmd_prep()
429 if (ctrl->opts->disable_sqflow) in nvmf_connect_cmd_prep()
430 cmd->connect.cattr |= NVME_CONNECT_DISABLE_SQFLOW; in nvmf_connect_cmd_prep()
434 * nvmf_connect_admin_queue() - NVMe Fabrics Admin Queue "Connect"
436 * @ctrl: Host nvme controller instance used to request
443 * fabrics-protocol connection of the NVMe Admin queue between the
447 int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl) in nvmf_connect_admin_queue() argument
455 nvmf_connect_cmd_prep(ctrl, 0, &cmd); in nvmf_connect_admin_queue()
457 data = nvmf_connect_data_prep(ctrl, 0xffff); in nvmf_connect_admin_queue()
459 return -ENOMEM; in nvmf_connect_admin_queue()
461 ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, in nvmf_connect_admin_queue()
467 nvmf_log_connect_error(ctrl, ret, le32_to_cpu(res.u32), in nvmf_connect_admin_queue()
473 ctrl->cntlid = result & 0xFFFF; in nvmf_connect_admin_queue()
477 dev_warn(ctrl->device, in nvmf_connect_admin_queue()
479 ret = -EOPNOTSUPP; in nvmf_connect_admin_queue()
483 ret = nvme_auth_negotiate(ctrl, 0); in nvmf_connect_admin_queue()
485 dev_warn(ctrl->device, in nvmf_connect_admin_queue()
489 ret = nvme_auth_wait(ctrl, 0); in nvmf_connect_admin_queue()
491 dev_warn(ctrl->device, in nvmf_connect_admin_queue()
495 dev_info(ctrl->device, in nvmf_connect_admin_queue()
505 * nvmf_connect_io_queue() - NVMe Fabrics I/O Queue "Connect"
507 * @ctrl: Host nvme controller instance used to establish an
514 * This function issues a fabrics-protocol connection
524 int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid) in nvmf_connect_io_queue() argument
532 nvmf_connect_cmd_prep(ctrl, qid, &cmd); in nvmf_connect_io_queue()
534 data = nvmf_connect_data_prep(ctrl, ctrl->cntlid); in nvmf_connect_io_queue()
536 return -ENOMEM; in nvmf_connect_io_queue()
538 ret = __nvme_submit_sync_cmd(ctrl->connect_q, &cmd, &res, in nvmf_connect_io_queue()
544 nvmf_log_connect_error(ctrl, ret, le32_to_cpu(res.u32), in nvmf_connect_io_queue()
552 dev_warn(ctrl->device, in nvmf_connect_io_queue()
554 ret = -EOPNOTSUPP; in nvmf_connect_io_queue()
558 ret = nvme_auth_negotiate(ctrl, qid); in nvmf_connect_io_queue()
560 dev_warn(ctrl->device, in nvmf_connect_io_queue()
564 ret = nvme_auth_wait(ctrl, qid); in nvmf_connect_io_queue()
566 dev_warn(ctrl->device, in nvmf_connect_io_queue()
583 * - the DNR bit is set and the specification states no further connect
586 * - when the authentication attempt fails, because the key was invalid.
589 bool nvmf_should_reconnect(struct nvme_ctrl *ctrl, int status) in nvmf_should_reconnect() argument
594 if (status == -EKEYREJECTED) in nvmf_should_reconnect()
597 if (ctrl->opts->max_reconnects == -1 || in nvmf_should_reconnect()
598 ctrl->nr_reconnects < ctrl->opts->max_reconnects) in nvmf_should_reconnect()
606 * nvmf_register_transport() - NVMe Fabrics Library registration function.
616 if (!ops->create_ctrl) in nvmf_register_transport()
617 return -EINVAL; in nvmf_register_transport()
620 list_add_tail(&ops->entry, &nvmf_transports); in nvmf_register_transport()
628 * nvmf_unregister_transport() - NVMe Fabrics Library unregistration function.
639 list_del(&ops->entry); in nvmf_unregister_transport()
652 if (strcmp(ops->name, opts->transport) == 0) in nvmf_lookup_transport()
665 return ERR_PTR(-EINVAL); in nvmf_parse_key()
726 opts->queue_size = NVMF_DEF_QUEUE_SIZE; in nvmf_parse_options()
727 opts->nr_io_queues = num_online_cpus(); in nvmf_parse_options()
728 opts->reconnect_delay = NVMF_DEF_RECONNECT_DELAY; in nvmf_parse_options()
729 opts->kato = 0; in nvmf_parse_options()
730 opts->duplicate_connect = false; in nvmf_parse_options()
731 opts->fast_io_fail_tmo = NVMF_DEF_FAIL_FAST_TMO; in nvmf_parse_options()
732 opts->hdr_digest = false; in nvmf_parse_options()
733 opts->data_digest = false; in nvmf_parse_options()
734 opts->tos = -1; /* < 0 == use transport default */ in nvmf_parse_options()
735 opts->tls = false; in nvmf_parse_options()
736 opts->tls_key = NULL; in nvmf_parse_options()
737 opts->keyring = NULL; in nvmf_parse_options()
741 return -ENOMEM; in nvmf_parse_options()
744 uuid_copy(&hostid, &nvmf_default_host->id); in nvmf_parse_options()
745 strscpy(hostnqn, nvmf_default_host->nqn, NVMF_NQN_SIZE); in nvmf_parse_options()
752 opts->mask |= token; in nvmf_parse_options()
757 ret = -ENOMEM; in nvmf_parse_options()
760 kfree(opts->transport); in nvmf_parse_options()
761 opts->transport = p; in nvmf_parse_options()
766 ret = -ENOMEM; in nvmf_parse_options()
769 kfree(opts->subsysnqn); in nvmf_parse_options()
770 opts->subsysnqn = p; in nvmf_parse_options()
771 nqnlen = strlen(opts->subsysnqn); in nvmf_parse_options()
774 opts->subsysnqn, NVMF_NQN_SIZE); in nvmf_parse_options()
775 ret = -EINVAL; in nvmf_parse_options()
778 opts->discovery_nqn = in nvmf_parse_options()
779 !(strcmp(opts->subsysnqn, in nvmf_parse_options()
785 ret = -ENOMEM; in nvmf_parse_options()
788 kfree(opts->traddr); in nvmf_parse_options()
789 opts->traddr = p; in nvmf_parse_options()
794 ret = -ENOMEM; in nvmf_parse_options()
797 kfree(opts->trsvcid); in nvmf_parse_options()
798 opts->trsvcid = p; in nvmf_parse_options()
802 ret = -EINVAL; in nvmf_parse_options()
808 ret = -EINVAL; in nvmf_parse_options()
811 opts->queue_size = token; in nvmf_parse_options()
815 ret = -EINVAL; in nvmf_parse_options()
820 ret = -EINVAL; in nvmf_parse_options()
823 if (opts->discovery_nqn) { in nvmf_parse_options()
828 opts->nr_io_queues = min_t(unsigned int, in nvmf_parse_options()
833 ret = -EINVAL; in nvmf_parse_options()
839 ret = -EINVAL; in nvmf_parse_options()
841 } else if (token == 0 && !opts->discovery_nqn) { in nvmf_parse_options()
845 opts->kato = token; in nvmf_parse_options()
849 ret = -EINVAL; in nvmf_parse_options()
859 ret = -EINVAL; in nvmf_parse_options()
867 token = -1; in nvmf_parse_options()
869 opts->fast_io_fail_tmo = token; in nvmf_parse_options()
872 if (opts->host) { in nvmf_parse_options()
873 pr_err("hostnqn already user-assigned: %s\n", in nvmf_parse_options()
874 opts->host->nqn); in nvmf_parse_options()
875 ret = -EADDRINUSE; in nvmf_parse_options()
880 ret = -ENOMEM; in nvmf_parse_options()
888 ret = -EINVAL; in nvmf_parse_options()
896 ret = -EINVAL; in nvmf_parse_options()
901 ret = -EINVAL; in nvmf_parse_options()
904 opts->reconnect_delay = token; in nvmf_parse_options()
909 ret = -ENOMEM; in nvmf_parse_options()
912 kfree(opts->host_traddr); in nvmf_parse_options()
913 opts->host_traddr = p; in nvmf_parse_options()
918 ret = -ENOMEM; in nvmf_parse_options()
921 kfree(opts->host_iface); in nvmf_parse_options()
922 opts->host_iface = p; in nvmf_parse_options()
927 ret = -ENOMEM; in nvmf_parse_options()
933 ret = -EINVAL; in nvmf_parse_options()
940 opts->duplicate_connect = true; in nvmf_parse_options()
943 opts->disable_sqflow = true; in nvmf_parse_options()
946 opts->hdr_digest = true; in nvmf_parse_options()
949 opts->data_digest = true; in nvmf_parse_options()
953 ret = -EINVAL; in nvmf_parse_options()
958 ret = -EINVAL; in nvmf_parse_options()
961 opts->nr_write_queues = token; in nvmf_parse_options()
965 ret = -EINVAL; in nvmf_parse_options()
970 ret = -EINVAL; in nvmf_parse_options()
973 opts->nr_poll_queues = token; in nvmf_parse_options()
977 ret = -EINVAL; in nvmf_parse_options()
982 ret = -EINVAL; in nvmf_parse_options()
989 opts->tos = token; in nvmf_parse_options()
993 ret = -EINVAL; in nvmf_parse_options()
1001 key_put(opts->keyring); in nvmf_parse_options()
1002 opts->keyring = key; in nvmf_parse_options()
1006 ret = -EINVAL; in nvmf_parse_options()
1014 key_put(opts->tls_key); in nvmf_parse_options()
1015 opts->tls_key = key; in nvmf_parse_options()
1018 opts->discovery_nqn = true; in nvmf_parse_options()
1023 ret = -ENOMEM; in nvmf_parse_options()
1026 if (strlen(p) < 11 || strncmp(p, "DHHC-1:", 7)) { in nvmf_parse_options()
1027 pr_err("Invalid DH-CHAP secret %s\n", p); in nvmf_parse_options()
1028 ret = -EINVAL; in nvmf_parse_options()
1031 kfree(opts->dhchap_secret); in nvmf_parse_options()
1032 opts->dhchap_secret = p; in nvmf_parse_options()
1037 ret = -ENOMEM; in nvmf_parse_options()
1040 if (strlen(p) < 11 || strncmp(p, "DHHC-1:", 7)) { in nvmf_parse_options()
1041 pr_err("Invalid DH-CHAP secret %s\n", p); in nvmf_parse_options()
1042 ret = -EINVAL; in nvmf_parse_options()
1045 kfree(opts->dhchap_ctrl_secret); in nvmf_parse_options()
1046 opts->dhchap_ctrl_secret = p; in nvmf_parse_options()
1051 ret = -EINVAL; in nvmf_parse_options()
1054 opts->tls = true; in nvmf_parse_options()
1057 pr_warn("unknown parameter or missing value '%s' in ctrl creation request\n", in nvmf_parse_options()
1059 ret = -EINVAL; in nvmf_parse_options()
1064 if (opts->discovery_nqn) { in nvmf_parse_options()
1065 opts->nr_io_queues = 0; in nvmf_parse_options()
1066 opts->nr_write_queues = 0; in nvmf_parse_options()
1067 opts->nr_poll_queues = 0; in nvmf_parse_options()
1068 opts->duplicate_connect = true; in nvmf_parse_options()
1070 if (!opts->kato) in nvmf_parse_options()
1071 opts->kato = NVME_DEFAULT_KATO; in nvmf_parse_options()
1074 opts->max_reconnects = -1; in nvmf_parse_options()
1076 opts->max_reconnects = DIV_ROUND_UP(ctrl_loss_tmo, in nvmf_parse_options()
1077 opts->reconnect_delay); in nvmf_parse_options()
1078 if (ctrl_loss_tmo < opts->fast_io_fail_tmo) in nvmf_parse_options()
1080 opts->fast_io_fail_tmo, ctrl_loss_tmo); in nvmf_parse_options()
1083 opts->host = nvmf_host_add(hostnqn, &hostid); in nvmf_parse_options()
1084 if (IS_ERR(opts->host)) { in nvmf_parse_options()
1085 ret = PTR_ERR(opts->host); in nvmf_parse_options()
1086 opts->host = NULL; in nvmf_parse_options()
1098 if (opts->nr_write_queues && opts->nr_io_queues < nr_io_queues) { in nvmf_set_io_queues()
1104 io_queues[HCTX_TYPE_READ] = opts->nr_io_queues; in nvmf_set_io_queues()
1105 nr_io_queues -= io_queues[HCTX_TYPE_READ]; in nvmf_set_io_queues()
1107 min(opts->nr_write_queues, nr_io_queues); in nvmf_set_io_queues()
1108 nr_io_queues -= io_queues[HCTX_TYPE_DEFAULT]; in nvmf_set_io_queues()
1116 min(opts->nr_io_queues, nr_io_queues); in nvmf_set_io_queues()
1117 nr_io_queues -= io_queues[HCTX_TYPE_DEFAULT]; in nvmf_set_io_queues()
1120 if (opts->nr_poll_queues && nr_io_queues) { in nvmf_set_io_queues()
1123 min(opts->nr_poll_queues, nr_io_queues); in nvmf_set_io_queues()
1128 void nvmf_map_queues(struct blk_mq_tag_set *set, struct nvme_ctrl *ctrl, in nvmf_map_queues() argument
1131 struct nvmf_ctrl_options *opts = ctrl->opts; in nvmf_map_queues()
1133 if (opts->nr_write_queues && io_queues[HCTX_TYPE_READ]) { in nvmf_map_queues()
1135 set->map[HCTX_TYPE_DEFAULT].nr_queues = in nvmf_map_queues()
1137 set->map[HCTX_TYPE_DEFAULT].queue_offset = 0; in nvmf_map_queues()
1138 set->map[HCTX_TYPE_READ].nr_queues = in nvmf_map_queues()
1140 set->map[HCTX_TYPE_READ].queue_offset = in nvmf_map_queues()
1144 set->map[HCTX_TYPE_DEFAULT].nr_queues = in nvmf_map_queues()
1146 set->map[HCTX_TYPE_DEFAULT].queue_offset = 0; in nvmf_map_queues()
1147 set->map[HCTX_TYPE_READ].nr_queues = in nvmf_map_queues()
1149 set->map[HCTX_TYPE_READ].queue_offset = 0; in nvmf_map_queues()
1152 blk_mq_map_queues(&set->map[HCTX_TYPE_DEFAULT]); in nvmf_map_queues()
1153 blk_mq_map_queues(&set->map[HCTX_TYPE_READ]); in nvmf_map_queues()
1154 if (opts->nr_poll_queues && io_queues[HCTX_TYPE_POLL]) { in nvmf_map_queues()
1156 set->map[HCTX_TYPE_POLL].nr_queues = io_queues[HCTX_TYPE_POLL]; in nvmf_map_queues()
1157 set->map[HCTX_TYPE_POLL].queue_offset = in nvmf_map_queues()
1160 blk_mq_map_queues(&set->map[HCTX_TYPE_POLL]); in nvmf_map_queues()
1163 dev_info(ctrl->device, in nvmf_map_queues()
1174 if ((opts->mask & required_opts) != required_opts) { in nvmf_check_required_opts()
1179 !(opt_tokens[i].token & opts->mask)) { in nvmf_check_required_opts()
1185 return -EINVAL; in nvmf_check_required_opts()
1191 bool nvmf_ip_options_match(struct nvme_ctrl *ctrl, in nvmf_ip_options_match() argument
1194 if (!nvmf_ctlr_matches_baseopts(ctrl, opts) || in nvmf_ip_options_match()
1195 strcmp(opts->traddr, ctrl->opts->traddr) || in nvmf_ip_options_match()
1196 strcmp(opts->trsvcid, ctrl->opts->trsvcid)) in nvmf_ip_options_match()
1206 * - local address or host interface is specified and address in nvmf_ip_options_match()
1208 * - local address or host interface is not specified but in nvmf_ip_options_match()
1212 if ((opts->mask & NVMF_OPT_HOST_TRADDR) && in nvmf_ip_options_match()
1213 (ctrl->opts->mask & NVMF_OPT_HOST_TRADDR)) { in nvmf_ip_options_match()
1214 if (strcmp(opts->host_traddr, ctrl->opts->host_traddr)) in nvmf_ip_options_match()
1216 } else if ((opts->mask & NVMF_OPT_HOST_TRADDR) || in nvmf_ip_options_match()
1217 (ctrl->opts->mask & NVMF_OPT_HOST_TRADDR)) { in nvmf_ip_options_match()
1221 if ((opts->mask & NVMF_OPT_HOST_IFACE) && in nvmf_ip_options_match()
1222 (ctrl->opts->mask & NVMF_OPT_HOST_IFACE)) { in nvmf_ip_options_match()
1223 if (strcmp(opts->host_iface, ctrl->opts->host_iface)) in nvmf_ip_options_match()
1225 } else if ((opts->mask & NVMF_OPT_HOST_IFACE) || in nvmf_ip_options_match()
1226 (ctrl->opts->mask & NVMF_OPT_HOST_IFACE)) { in nvmf_ip_options_match()
1237 if (opts->mask & ~allowed_opts) { in nvmf_check_allowed_opts()
1241 if ((opt_tokens[i].token & opts->mask) && in nvmf_check_allowed_opts()
1248 return -EINVAL; in nvmf_check_allowed_opts()
1256 nvmf_host_put(opts->host); in nvmf_free_options()
1257 key_put(opts->keyring); in nvmf_free_options()
1258 key_put(opts->tls_key); in nvmf_free_options()
1259 kfree(opts->transport); in nvmf_free_options()
1260 kfree(opts->traddr); in nvmf_free_options()
1261 kfree(opts->trsvcid); in nvmf_free_options()
1262 kfree(opts->subsysnqn); in nvmf_free_options()
1263 kfree(opts->host_traddr); in nvmf_free_options()
1264 kfree(opts->host_iface); in nvmf_free_options()
1265 kfree(opts->dhchap_secret); in nvmf_free_options()
1266 kfree(opts->dhchap_ctrl_secret); in nvmf_free_options()
1284 struct nvme_ctrl *ctrl; in nvmf_create_ctrl() local
1289 return ERR_PTR(-ENOMEM); in nvmf_create_ctrl()
1296 request_module("nvme-%s", opts->transport); in nvmf_create_ctrl()
1306 opts->mask &= ~NVMF_REQUIRED_OPTS; in nvmf_create_ctrl()
1312 opts->transport); in nvmf_create_ctrl()
1313 ret = -EINVAL; in nvmf_create_ctrl()
1317 if (!try_module_get(ops->module)) { in nvmf_create_ctrl()
1318 ret = -EBUSY; in nvmf_create_ctrl()
1323 ret = nvmf_check_required_opts(opts, ops->required_opts); in nvmf_create_ctrl()
1327 ops->allowed_opts | ops->required_opts); in nvmf_create_ctrl()
1331 ctrl = ops->create_ctrl(dev, opts); in nvmf_create_ctrl()
1332 if (IS_ERR(ctrl)) { in nvmf_create_ctrl()
1333 ret = PTR_ERR(ctrl); in nvmf_create_ctrl()
1337 module_put(ops->module); in nvmf_create_ctrl()
1338 return ctrl; in nvmf_create_ctrl()
1341 module_put(ops->module); in nvmf_create_ctrl()
1351 .name = "nvme-fabrics",
1360 struct seq_file *seq_file = file->private_data; in nvmf_dev_write()
1361 struct nvme_ctrl *ctrl; in nvmf_dev_write() local
1366 return -ENOMEM; in nvmf_dev_write()
1373 if (seq_file->private) { in nvmf_dev_write()
1374 ret = -EINVAL; in nvmf_dev_write()
1378 ctrl = nvmf_create_ctrl(nvmf_device, buf); in nvmf_dev_write()
1379 if (IS_ERR(ctrl)) { in nvmf_dev_write()
1380 ret = PTR_ERR(ctrl); in nvmf_dev_write()
1384 seq_file->private = ctrl; in nvmf_dev_write()
1399 * signal an invalid/non-existing controller in __nvmf_concat_opt_tokens()
1401 seq_puts(seq_file, "instance=-1,cntlid=-1"); in __nvmf_concat_opt_tokens()
1404 if (tok->token == NVMF_OPT_ERR) in __nvmf_concat_opt_tokens()
1407 seq_puts(seq_file, tok->pattern); in __nvmf_concat_opt_tokens()
1414 struct nvme_ctrl *ctrl; in nvmf_dev_show() local
1417 ctrl = seq_file->private; in nvmf_dev_show()
1418 if (!ctrl) { in nvmf_dev_show()
1424 ctrl->instance, ctrl->cntlid); in nvmf_dev_show()
1434 * The miscdevice code initializes file->private_data, but doesn't in nvmf_dev_open()
1437 file->private_data = NULL; in nvmf_dev_open()
1443 struct seq_file *seq_file = file->private_data; in nvmf_dev_release()
1444 struct nvme_ctrl *ctrl = seq_file->private; in nvmf_dev_release() local
1446 if (ctrl) in nvmf_dev_release()
1447 nvme_put_ctrl(ctrl); in nvmf_dev_release()
1461 .name = "nvme-fabrics",
1471 return -ENOMEM; in nvmf_init()
1475 pr_err("couldn't register class nvme-fabrics\n"); in nvmf_init()
1482 pr_err("couldn't create nvme-fabrics device!\n"); in nvmf_init()