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 !ctrl->opts->concat) { in nvmf_connect_admin_queue()
478 dev_warn(ctrl->device, in nvmf_connect_admin_queue()
480 ret = -EOPNOTSUPP; in nvmf_connect_admin_queue()
484 ret = nvme_auth_negotiate(ctrl, 0); in nvmf_connect_admin_queue()
486 dev_warn(ctrl->device, in nvmf_connect_admin_queue()
490 ret = nvme_auth_wait(ctrl, 0); in nvmf_connect_admin_queue()
492 dev_warn(ctrl->device, in nvmf_connect_admin_queue()
496 dev_info(ctrl->device, in nvmf_connect_admin_queue()
506 * nvmf_connect_io_queue() - NVMe Fabrics I/O Queue "Connect"
508 * @ctrl: Host nvme controller instance used to establish an
515 * This function issues a fabrics-protocol connection
525 int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid) in nvmf_connect_io_queue() argument
533 nvmf_connect_cmd_prep(ctrl, qid, &cmd); in nvmf_connect_io_queue()
535 data = nvmf_connect_data_prep(ctrl, ctrl->cntlid); in nvmf_connect_io_queue()
537 return -ENOMEM; in nvmf_connect_io_queue()
539 ret = __nvme_submit_sync_cmd(ctrl->connect_q, &cmd, &res, in nvmf_connect_io_queue()
545 nvmf_log_connect_error(ctrl, ret, le32_to_cpu(res.u32), in nvmf_connect_io_queue()
553 dev_warn(ctrl->device, in nvmf_connect_io_queue()
555 ret = -EOPNOTSUPP; in nvmf_connect_io_queue()
559 ret = nvme_auth_negotiate(ctrl, qid); in nvmf_connect_io_queue()
561 dev_warn(ctrl->device, in nvmf_connect_io_queue()
565 ret = nvme_auth_wait(ctrl, qid); in nvmf_connect_io_queue()
567 dev_warn(ctrl->device, in nvmf_connect_io_queue()
584 * - the DNR bit is set and the specification states no further connect
587 * - when the authentication attempt fails, because the key was invalid.
590 bool nvmf_should_reconnect(struct nvme_ctrl *ctrl, int status) in nvmf_should_reconnect() argument
595 if (status == -EKEYREJECTED) in nvmf_should_reconnect()
598 if (ctrl->opts->max_reconnects == -1 || in nvmf_should_reconnect()
599 ctrl->nr_reconnects < ctrl->opts->max_reconnects) in nvmf_should_reconnect()
607 * nvmf_register_transport() - NVMe Fabrics Library registration function.
617 if (!ops->create_ctrl) in nvmf_register_transport()
618 return -EINVAL; in nvmf_register_transport()
621 list_add_tail(&ops->entry, &nvmf_transports); in nvmf_register_transport()
629 * nvmf_unregister_transport() - NVMe Fabrics Library unregistration function.
640 list_del(&ops->entry); in nvmf_unregister_transport()
653 if (strcmp(ops->name, opts->transport) == 0) in nvmf_lookup_transport()
666 return ERR_PTR(-EINVAL); in nvmf_parse_key()
728 opts->queue_size = NVMF_DEF_QUEUE_SIZE; in nvmf_parse_options()
729 opts->nr_io_queues = num_online_cpus(); in nvmf_parse_options()
730 opts->reconnect_delay = NVMF_DEF_RECONNECT_DELAY; in nvmf_parse_options()
731 opts->kato = 0; in nvmf_parse_options()
732 opts->duplicate_connect = false; in nvmf_parse_options()
733 opts->fast_io_fail_tmo = NVMF_DEF_FAIL_FAST_TMO; in nvmf_parse_options()
734 opts->hdr_digest = false; in nvmf_parse_options()
735 opts->data_digest = false; in nvmf_parse_options()
736 opts->tos = -1; /* < 0 == use transport default */ in nvmf_parse_options()
737 opts->tls = false; in nvmf_parse_options()
738 opts->tls_key = NULL; in nvmf_parse_options()
739 opts->keyring = NULL; in nvmf_parse_options()
740 opts->concat = false; in nvmf_parse_options()
744 return -ENOMEM; in nvmf_parse_options()
747 uuid_copy(&hostid, &nvmf_default_host->id); in nvmf_parse_options()
748 strscpy(hostnqn, nvmf_default_host->nqn, NVMF_NQN_SIZE); in nvmf_parse_options()
755 opts->mask |= token; in nvmf_parse_options()
760 ret = -ENOMEM; in nvmf_parse_options()
763 kfree(opts->transport); in nvmf_parse_options()
764 opts->transport = p; in nvmf_parse_options()
769 ret = -ENOMEM; in nvmf_parse_options()
772 kfree(opts->subsysnqn); in nvmf_parse_options()
773 opts->subsysnqn = p; in nvmf_parse_options()
774 nqnlen = strlen(opts->subsysnqn); in nvmf_parse_options()
777 opts->subsysnqn, NVMF_NQN_SIZE); in nvmf_parse_options()
778 ret = -EINVAL; in nvmf_parse_options()
781 opts->discovery_nqn = in nvmf_parse_options()
782 !(strcmp(opts->subsysnqn, in nvmf_parse_options()
788 ret = -ENOMEM; in nvmf_parse_options()
791 kfree(opts->traddr); in nvmf_parse_options()
792 opts->traddr = p; in nvmf_parse_options()
797 ret = -ENOMEM; in nvmf_parse_options()
800 kfree(opts->trsvcid); in nvmf_parse_options()
801 opts->trsvcid = p; in nvmf_parse_options()
805 ret = -EINVAL; in nvmf_parse_options()
811 ret = -EINVAL; in nvmf_parse_options()
814 opts->queue_size = token; in nvmf_parse_options()
818 ret = -EINVAL; in nvmf_parse_options()
823 ret = -EINVAL; in nvmf_parse_options()
826 if (opts->discovery_nqn) { in nvmf_parse_options()
831 opts->nr_io_queues = min_t(unsigned int, in nvmf_parse_options()
836 ret = -EINVAL; in nvmf_parse_options()
842 ret = -EINVAL; in nvmf_parse_options()
844 } else if (token == 0 && !opts->discovery_nqn) { in nvmf_parse_options()
848 opts->kato = token; in nvmf_parse_options()
852 ret = -EINVAL; in nvmf_parse_options()
862 ret = -EINVAL; in nvmf_parse_options()
870 token = -1; in nvmf_parse_options()
872 opts->fast_io_fail_tmo = token; in nvmf_parse_options()
875 if (opts->host) { in nvmf_parse_options()
876 pr_err("hostnqn already user-assigned: %s\n", in nvmf_parse_options()
877 opts->host->nqn); in nvmf_parse_options()
878 ret = -EADDRINUSE; in nvmf_parse_options()
883 ret = -ENOMEM; in nvmf_parse_options()
891 ret = -EINVAL; in nvmf_parse_options()
899 ret = -EINVAL; in nvmf_parse_options()
904 ret = -EINVAL; in nvmf_parse_options()
907 opts->reconnect_delay = token; in nvmf_parse_options()
912 ret = -ENOMEM; in nvmf_parse_options()
915 kfree(opts->host_traddr); in nvmf_parse_options()
916 opts->host_traddr = p; in nvmf_parse_options()
921 ret = -ENOMEM; in nvmf_parse_options()
924 kfree(opts->host_iface); in nvmf_parse_options()
925 opts->host_iface = p; in nvmf_parse_options()
930 ret = -ENOMEM; in nvmf_parse_options()
936 ret = -EINVAL; in nvmf_parse_options()
943 opts->duplicate_connect = true; in nvmf_parse_options()
946 opts->disable_sqflow = true; in nvmf_parse_options()
949 opts->hdr_digest = true; in nvmf_parse_options()
952 opts->data_digest = true; in nvmf_parse_options()
956 ret = -EINVAL; in nvmf_parse_options()
961 ret = -EINVAL; in nvmf_parse_options()
964 opts->nr_write_queues = token; in nvmf_parse_options()
968 ret = -EINVAL; in nvmf_parse_options()
973 ret = -EINVAL; in nvmf_parse_options()
976 opts->nr_poll_queues = token; in nvmf_parse_options()
980 ret = -EINVAL; in nvmf_parse_options()
985 ret = -EINVAL; in nvmf_parse_options()
992 opts->tos = token; in nvmf_parse_options()
996 ret = -EINVAL; in nvmf_parse_options()
1004 key_put(opts->keyring); in nvmf_parse_options()
1005 opts->keyring = key; in nvmf_parse_options()
1009 ret = -EINVAL; in nvmf_parse_options()
1017 key_put(opts->tls_key); in nvmf_parse_options()
1018 opts->tls_key = key; in nvmf_parse_options()
1021 opts->discovery_nqn = true; in nvmf_parse_options()
1026 ret = -ENOMEM; in nvmf_parse_options()
1029 if (strlen(p) < 11 || strncmp(p, "DHHC-1:", 7)) { in nvmf_parse_options()
1030 pr_err("Invalid DH-CHAP secret %s\n", p); in nvmf_parse_options()
1031 ret = -EINVAL; in nvmf_parse_options()
1034 kfree(opts->dhchap_secret); in nvmf_parse_options()
1035 opts->dhchap_secret = p; in nvmf_parse_options()
1040 ret = -ENOMEM; in nvmf_parse_options()
1043 if (strlen(p) < 11 || strncmp(p, "DHHC-1:", 7)) { in nvmf_parse_options()
1044 pr_err("Invalid DH-CHAP secret %s\n", p); in nvmf_parse_options()
1045 ret = -EINVAL; in nvmf_parse_options()
1048 kfree(opts->dhchap_ctrl_secret); in nvmf_parse_options()
1049 opts->dhchap_ctrl_secret = p; in nvmf_parse_options()
1054 ret = -EINVAL; in nvmf_parse_options()
1057 opts->tls = true; in nvmf_parse_options()
1062 ret = -EINVAL; in nvmf_parse_options()
1065 opts->concat = true; in nvmf_parse_options()
1068 pr_warn("unknown parameter or missing value '%s' in ctrl creation request\n", in nvmf_parse_options()
1070 ret = -EINVAL; in nvmf_parse_options()
1075 if (opts->discovery_nqn) { in nvmf_parse_options()
1076 opts->nr_io_queues = 0; in nvmf_parse_options()
1077 opts->nr_write_queues = 0; in nvmf_parse_options()
1078 opts->nr_poll_queues = 0; in nvmf_parse_options()
1079 opts->duplicate_connect = true; in nvmf_parse_options()
1081 if (!opts->kato) in nvmf_parse_options()
1082 opts->kato = NVME_DEFAULT_KATO; in nvmf_parse_options()
1085 opts->max_reconnects = -1; in nvmf_parse_options()
1087 opts->max_reconnects = DIV_ROUND_UP(ctrl_loss_tmo, in nvmf_parse_options()
1088 opts->reconnect_delay); in nvmf_parse_options()
1089 if (ctrl_loss_tmo < opts->fast_io_fail_tmo) in nvmf_parse_options()
1091 opts->fast_io_fail_tmo, ctrl_loss_tmo); in nvmf_parse_options()
1093 if (opts->concat) { in nvmf_parse_options()
1094 if (opts->tls) { in nvmf_parse_options()
1096 ret = -EINVAL; in nvmf_parse_options()
1099 if (opts->tls_key) { in nvmf_parse_options()
1101 ret = -EINVAL; in nvmf_parse_options()
1104 if (!opts->dhchap_secret) { in nvmf_parse_options()
1105 pr_err("Need to enable DH-CHAP for secure concatenation\n"); in nvmf_parse_options()
1106 ret = -EINVAL; in nvmf_parse_options()
1111 opts->host = nvmf_host_add(hostnqn, &hostid); in nvmf_parse_options()
1112 if (IS_ERR(opts->host)) { in nvmf_parse_options()
1113 ret = PTR_ERR(opts->host); in nvmf_parse_options()
1114 opts->host = NULL; in nvmf_parse_options()
1126 if (opts->nr_write_queues && opts->nr_io_queues < nr_io_queues) { in nvmf_set_io_queues()
1132 io_queues[HCTX_TYPE_READ] = opts->nr_io_queues; in nvmf_set_io_queues()
1133 nr_io_queues -= io_queues[HCTX_TYPE_READ]; in nvmf_set_io_queues()
1135 min(opts->nr_write_queues, nr_io_queues); in nvmf_set_io_queues()
1136 nr_io_queues -= io_queues[HCTX_TYPE_DEFAULT]; in nvmf_set_io_queues()
1144 min(opts->nr_io_queues, nr_io_queues); in nvmf_set_io_queues()
1145 nr_io_queues -= io_queues[HCTX_TYPE_DEFAULT]; in nvmf_set_io_queues()
1148 if (opts->nr_poll_queues && nr_io_queues) { in nvmf_set_io_queues()
1151 min(opts->nr_poll_queues, nr_io_queues); in nvmf_set_io_queues()
1156 void nvmf_map_queues(struct blk_mq_tag_set *set, struct nvme_ctrl *ctrl, in nvmf_map_queues() argument
1159 struct nvmf_ctrl_options *opts = ctrl->opts; in nvmf_map_queues()
1161 if (opts->nr_write_queues && io_queues[HCTX_TYPE_READ]) { in nvmf_map_queues()
1163 set->map[HCTX_TYPE_DEFAULT].nr_queues = in nvmf_map_queues()
1165 set->map[HCTX_TYPE_DEFAULT].queue_offset = 0; in nvmf_map_queues()
1166 set->map[HCTX_TYPE_READ].nr_queues = in nvmf_map_queues()
1168 set->map[HCTX_TYPE_READ].queue_offset = in nvmf_map_queues()
1172 set->map[HCTX_TYPE_DEFAULT].nr_queues = in nvmf_map_queues()
1174 set->map[HCTX_TYPE_DEFAULT].queue_offset = 0; in nvmf_map_queues()
1175 set->map[HCTX_TYPE_READ].nr_queues = in nvmf_map_queues()
1177 set->map[HCTX_TYPE_READ].queue_offset = 0; in nvmf_map_queues()
1180 blk_mq_map_queues(&set->map[HCTX_TYPE_DEFAULT]); in nvmf_map_queues()
1181 blk_mq_map_queues(&set->map[HCTX_TYPE_READ]); in nvmf_map_queues()
1182 if (opts->nr_poll_queues && io_queues[HCTX_TYPE_POLL]) { in nvmf_map_queues()
1184 set->map[HCTX_TYPE_POLL].nr_queues = io_queues[HCTX_TYPE_POLL]; in nvmf_map_queues()
1185 set->map[HCTX_TYPE_POLL].queue_offset = in nvmf_map_queues()
1188 blk_mq_map_queues(&set->map[HCTX_TYPE_POLL]); in nvmf_map_queues()
1191 dev_info(ctrl->device, in nvmf_map_queues()
1202 if ((opts->mask & required_opts) != required_opts) { in nvmf_check_required_opts()
1207 !(opt_tokens[i].token & opts->mask)) { in nvmf_check_required_opts()
1213 return -EINVAL; in nvmf_check_required_opts()
1219 bool nvmf_ip_options_match(struct nvme_ctrl *ctrl, in nvmf_ip_options_match() argument
1222 if (!nvmf_ctlr_matches_baseopts(ctrl, opts) || in nvmf_ip_options_match()
1223 strcmp(opts->traddr, ctrl->opts->traddr) || in nvmf_ip_options_match()
1224 strcmp(opts->trsvcid, ctrl->opts->trsvcid)) in nvmf_ip_options_match()
1234 * - local address or host interface is specified and address in nvmf_ip_options_match()
1236 * - local address or host interface is not specified but in nvmf_ip_options_match()
1240 if ((opts->mask & NVMF_OPT_HOST_TRADDR) && in nvmf_ip_options_match()
1241 (ctrl->opts->mask & NVMF_OPT_HOST_TRADDR)) { in nvmf_ip_options_match()
1242 if (strcmp(opts->host_traddr, ctrl->opts->host_traddr)) in nvmf_ip_options_match()
1244 } else if ((opts->mask & NVMF_OPT_HOST_TRADDR) || in nvmf_ip_options_match()
1245 (ctrl->opts->mask & NVMF_OPT_HOST_TRADDR)) { in nvmf_ip_options_match()
1249 if ((opts->mask & NVMF_OPT_HOST_IFACE) && in nvmf_ip_options_match()
1250 (ctrl->opts->mask & NVMF_OPT_HOST_IFACE)) { in nvmf_ip_options_match()
1251 if (strcmp(opts->host_iface, ctrl->opts->host_iface)) in nvmf_ip_options_match()
1253 } else if ((opts->mask & NVMF_OPT_HOST_IFACE) || in nvmf_ip_options_match()
1254 (ctrl->opts->mask & NVMF_OPT_HOST_IFACE)) { in nvmf_ip_options_match()
1265 if (opts->mask & ~allowed_opts) { in nvmf_check_allowed_opts()
1269 if ((opt_tokens[i].token & opts->mask) && in nvmf_check_allowed_opts()
1276 return -EINVAL; in nvmf_check_allowed_opts()
1284 nvmf_host_put(opts->host); in nvmf_free_options()
1285 key_put(opts->keyring); in nvmf_free_options()
1286 key_put(opts->tls_key); in nvmf_free_options()
1287 kfree(opts->transport); in nvmf_free_options()
1288 kfree(opts->traddr); in nvmf_free_options()
1289 kfree(opts->trsvcid); in nvmf_free_options()
1290 kfree(opts->subsysnqn); in nvmf_free_options()
1291 kfree(opts->host_traddr); in nvmf_free_options()
1292 kfree(opts->host_iface); in nvmf_free_options()
1293 kfree(opts->dhchap_secret); in nvmf_free_options()
1294 kfree(opts->dhchap_ctrl_secret); in nvmf_free_options()
1312 struct nvme_ctrl *ctrl; in nvmf_create_ctrl() local
1317 return ERR_PTR(-ENOMEM); in nvmf_create_ctrl()
1324 request_module("nvme-%s", opts->transport); in nvmf_create_ctrl()
1334 opts->mask &= ~NVMF_REQUIRED_OPTS; in nvmf_create_ctrl()
1340 opts->transport); in nvmf_create_ctrl()
1341 ret = -EINVAL; in nvmf_create_ctrl()
1345 if (!try_module_get(ops->module)) { in nvmf_create_ctrl()
1346 ret = -EBUSY; in nvmf_create_ctrl()
1351 ret = nvmf_check_required_opts(opts, ops->required_opts); in nvmf_create_ctrl()
1355 ops->allowed_opts | ops->required_opts); in nvmf_create_ctrl()
1359 ctrl = ops->create_ctrl(dev, opts); in nvmf_create_ctrl()
1360 if (IS_ERR(ctrl)) { in nvmf_create_ctrl()
1361 ret = PTR_ERR(ctrl); in nvmf_create_ctrl()
1365 module_put(ops->module); in nvmf_create_ctrl()
1366 return ctrl; in nvmf_create_ctrl()
1369 module_put(ops->module); in nvmf_create_ctrl()
1379 .name = "nvme-fabrics",
1388 struct seq_file *seq_file = file->private_data; in nvmf_dev_write()
1389 struct nvme_ctrl *ctrl; in nvmf_dev_write() local
1394 return -ENOMEM; in nvmf_dev_write()
1401 if (seq_file->private) { in nvmf_dev_write()
1402 ret = -EINVAL; in nvmf_dev_write()
1406 ctrl = nvmf_create_ctrl(nvmf_device, buf); in nvmf_dev_write()
1407 if (IS_ERR(ctrl)) { in nvmf_dev_write()
1408 ret = PTR_ERR(ctrl); in nvmf_dev_write()
1412 seq_file->private = ctrl; in nvmf_dev_write()
1427 * signal an invalid/non-existing controller in __nvmf_concat_opt_tokens()
1429 seq_puts(seq_file, "instance=-1,cntlid=-1"); in __nvmf_concat_opt_tokens()
1432 if (tok->token == NVMF_OPT_ERR) in __nvmf_concat_opt_tokens()
1435 seq_puts(seq_file, tok->pattern); in __nvmf_concat_opt_tokens()
1442 struct nvme_ctrl *ctrl; in nvmf_dev_show() local
1445 ctrl = seq_file->private; in nvmf_dev_show()
1446 if (!ctrl) { in nvmf_dev_show()
1452 ctrl->instance, ctrl->cntlid); in nvmf_dev_show()
1462 * The miscdevice code initializes file->private_data, but doesn't in nvmf_dev_open()
1465 file->private_data = NULL; in nvmf_dev_open()
1471 struct seq_file *seq_file = file->private_data; in nvmf_dev_release()
1472 struct nvme_ctrl *ctrl = seq_file->private; in nvmf_dev_release() local
1474 if (ctrl) in nvmf_dev_release()
1475 nvme_put_ctrl(ctrl); in nvmf_dev_release()
1489 .name = "nvme-fabrics",
1499 return -ENOMEM; in nvmf_init()
1503 pr_err("couldn't register class nvme-fabrics\n"); in nvmf_init()
1510 pr_err("couldn't create nvme-fabrics device!\n"); in nvmf_init()