Lines Matching +full:ctrl +full:- +full:ids

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (c) 2011-2014, Intel Corporation.
8 #include <linux/nvme-auth.h>
17 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_sysfs_reset() local
20 ret = nvme_reset_ctrl_sync(ctrl); in nvme_sysfs_reset()
31 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_sysfs_rescan() local
33 nvme_queue_scan(ctrl); in nvme_sysfs_rescan()
41 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_adm_passthru_err_log_enabled_show() local
44 ctrl->passthru_err_log_enabled ? "on\n" : "off\n"); in nvme_adm_passthru_err_log_enabled_show()
50 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_adm_passthru_err_log_enabled_store() local
56 return -EINVAL; in nvme_adm_passthru_err_log_enabled_store()
58 ctrl->passthru_err_log_enabled = passthru_err_log_enabled; in nvme_adm_passthru_err_log_enabled_store()
68 return disk->private_data; in dev_to_ns_head()
69 return nvme_get_ns_from_dev(dev)->head; in dev_to_ns_head()
77 return sysfs_emit(buf, head->passthru_err_log_enabled ? "on\n" : "off\n"); in nvme_io_passthru_err_log_enabled_show()
89 return -EINVAL; in nvme_io_passthru_err_log_enabled_store()
90 head->passthru_err_log_enabled = passthru_err_log_enabled; in nvme_io_passthru_err_log_enabled_store()
107 struct nvme_ns_ids *ids = &head->ids; in wwid_show() local
108 struct nvme_subsystem *subsys = head->subsys; in wwid_show()
109 int serial_len = sizeof(subsys->serial); in wwid_show()
110 int model_len = sizeof(subsys->model); in wwid_show()
112 if (!uuid_is_null(&ids->uuid)) in wwid_show()
113 return sysfs_emit(buf, "uuid.%pU\n", &ids->uuid); in wwid_show()
115 if (memchr_inv(ids->nguid, 0, sizeof(ids->nguid))) in wwid_show()
116 return sysfs_emit(buf, "eui.%16phN\n", ids->nguid); in wwid_show()
118 if (memchr_inv(ids->eui64, 0, sizeof(ids->eui64))) in wwid_show()
119 return sysfs_emit(buf, "eui.%8phN\n", ids->eui64); in wwid_show()
121 while (serial_len > 0 && (subsys->serial[serial_len - 1] == ' ' || in wwid_show()
122 subsys->serial[serial_len - 1] == '\0')) in wwid_show()
123 serial_len--; in wwid_show()
124 while (model_len > 0 && (subsys->model[model_len - 1] == ' ' || in wwid_show()
125 subsys->model[model_len - 1] == '\0')) in wwid_show()
126 model_len--; in wwid_show()
128 return sysfs_emit(buf, "nvme.%04x-%*phN-%*phN-%08x\n", subsys->vendor_id, in wwid_show()
129 serial_len, subsys->serial, model_len, subsys->model, in wwid_show()
130 head->ns_id); in wwid_show()
137 return sysfs_emit(buf, "%pU\n", dev_to_ns_head(dev)->ids.nguid); in nguid_show()
144 struct nvme_ns_ids *ids = &dev_to_ns_head(dev)->ids; in uuid_show() local
149 if (uuid_is_null(&ids->uuid)) { in uuid_show()
152 return sysfs_emit(buf, "%pU\n", ids->nguid); in uuid_show()
154 return sysfs_emit(buf, "%pU\n", &ids->uuid); in uuid_show()
161 return sysfs_emit(buf, "%8ph\n", dev_to_ns_head(dev)->ids.eui64); in eui_show()
168 return sysfs_emit(buf, "%d\n", dev_to_ns_head(dev)->ns_id); in nsid_show()
175 return sysfs_emit(buf, "%u\n", dev_to_ns_head(dev)->ids.csi); in csi_show()
182 return sysfs_emit(buf, "%u\n", dev_to_ns_head(dev)->ms); in metadata_bytes_show()
190 int srcu_idx, ret = -EWOULDBLOCK; in ns_head_update_nuse()
193 if (!__ratelimit(&head->rs_nuse)) in ns_head_update_nuse()
196 srcu_idx = srcu_read_lock(&head->srcu); in ns_head_update_nuse()
201 ret = nvme_identify_ns(ns->ctrl, head->ns_id, &id); in ns_head_update_nuse()
205 head->nuse = le64_to_cpu(id->nuse); in ns_head_update_nuse()
209 srcu_read_unlock(&head->srcu, srcu_idx); in ns_head_update_nuse()
219 if (!__ratelimit(&ns->head->rs_nuse)) in ns_update_nuse()
222 ret = nvme_identify_ns(ns->ctrl, ns->head->ns_id, &id); in ns_update_nuse()
226 ns->head->nuse = le64_to_cpu(id->nuse); in ns_update_nuse()
241 ret = ns_update_nuse(disk->private_data); in nuse_show()
245 return sysfs_emit(buf, "%llu\n", head->nuse); in nuse_show()
272 struct nvme_ns_ids *ids = &dev_to_ns_head(dev)->ids; in nvme_ns_attrs_are_visible() local
275 if (uuid_is_null(&ids->uuid) && in nvme_ns_attrs_are_visible()
276 !memchr_inv(ids->nguid, 0, sizeof(ids->nguid))) in nvme_ns_attrs_are_visible()
280 if (!memchr_inv(ids->nguid, 0, sizeof(ids->nguid))) in nvme_ns_attrs_are_visible()
284 if (!memchr_inv(ids->eui64, 0, sizeof(ids->eui64))) in nvme_ns_attrs_are_visible()
289 /* per-path attr */ in nvme_ns_attrs_are_visible()
292 if (!nvme_ctrl_use_ana(nvme_get_ns_from_dev(dev)->ctrl)) in nvme_ns_attrs_are_visible()
300 return a->mode; in nvme_ns_attrs_are_visible()
331 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); \
333 (int)sizeof(ctrl->subsys->field), ctrl->subsys->field); \
345 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); \
346 return sysfs_emit(buf, "%d\n", ctrl->field); \
360 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_sysfs_delete() local
362 if (!test_bit(NVME_CTRL_STARTED_ONCE, &ctrl->flags)) in nvme_sysfs_delete()
363 return -EBUSY; in nvme_sysfs_delete()
366 nvme_delete_ctrl_sync(ctrl); in nvme_sysfs_delete()
375 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_sysfs_show_transport() local
377 return sysfs_emit(buf, "%s\n", ctrl->ops->name); in nvme_sysfs_show_transport()
385 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_sysfs_show_state() local
386 unsigned state = (unsigned)nvme_ctrl_state(ctrl); in nvme_sysfs_show_state()
409 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_sysfs_show_subsysnqn() local
411 return sysfs_emit(buf, "%s\n", ctrl->subsys->subnqn); in nvme_sysfs_show_subsysnqn()
419 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_sysfs_show_hostnqn() local
421 return sysfs_emit(buf, "%s\n", ctrl->opts->host->nqn); in nvme_sysfs_show_hostnqn()
429 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_sysfs_show_hostid() local
431 return sysfs_emit(buf, "%pU\n", &ctrl->opts->host->id); in nvme_sysfs_show_hostid()
439 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_sysfs_show_address() local
441 return ctrl->ops->get_address(ctrl, buf, PAGE_SIZE); in nvme_sysfs_show_address()
448 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_ctrl_loss_tmo_show() local
449 struct nvmf_ctrl_options *opts = ctrl->opts; in nvme_ctrl_loss_tmo_show()
451 if (ctrl->opts->max_reconnects == -1) in nvme_ctrl_loss_tmo_show()
454 opts->max_reconnects * opts->reconnect_delay); in nvme_ctrl_loss_tmo_show()
460 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_ctrl_loss_tmo_store() local
461 struct nvmf_ctrl_options *opts = ctrl->opts; in nvme_ctrl_loss_tmo_store()
466 return -EINVAL; in nvme_ctrl_loss_tmo_store()
469 opts->max_reconnects = -1; in nvme_ctrl_loss_tmo_store()
471 opts->max_reconnects = DIV_ROUND_UP(ctrl_loss_tmo, in nvme_ctrl_loss_tmo_store()
472 opts->reconnect_delay); in nvme_ctrl_loss_tmo_store()
481 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_ctrl_reconnect_delay_show() local
483 if (ctrl->opts->reconnect_delay == -1) in nvme_ctrl_reconnect_delay_show()
485 return sysfs_emit(buf, "%d\n", ctrl->opts->reconnect_delay); in nvme_ctrl_reconnect_delay_show()
491 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_ctrl_reconnect_delay_store() local
499 ctrl->opts->reconnect_delay = v; in nvme_ctrl_reconnect_delay_store()
508 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_ctrl_fast_io_fail_tmo_show() local
510 if (ctrl->opts->fast_io_fail_tmo == -1) in nvme_ctrl_fast_io_fail_tmo_show()
512 return sysfs_emit(buf, "%d\n", ctrl->opts->fast_io_fail_tmo); in nvme_ctrl_fast_io_fail_tmo_show()
518 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_ctrl_fast_io_fail_tmo_store() local
519 struct nvmf_ctrl_options *opts = ctrl->opts; in nvme_ctrl_fast_io_fail_tmo_store()
524 return -EINVAL; in nvme_ctrl_fast_io_fail_tmo_store()
527 opts->fast_io_fail_tmo = -1; in nvme_ctrl_fast_io_fail_tmo_store()
529 opts->fast_io_fail_tmo = fast_io_fail_tmo; in nvme_ctrl_fast_io_fail_tmo_store()
543 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in cntrltype_show() local
545 if (ctrl->cntrltype > NVME_CTRL_ADMIN || !type[ctrl->cntrltype]) in cntrltype_show()
548 return sysfs_emit(buf, type[ctrl->cntrltype]); in cntrltype_show()
560 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in dctype_show() local
562 if (ctrl->dctype > NVME_DCTYPE_CDC || !type[ctrl->dctype]) in dctype_show()
565 return sysfs_emit(buf, type[ctrl->dctype]); in dctype_show()
573 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_ctrl_dhchap_secret_show() local
574 struct nvmf_ctrl_options *opts = ctrl->opts; in nvme_ctrl_dhchap_secret_show()
576 if (!opts->dhchap_secret) in nvme_ctrl_dhchap_secret_show()
578 return sysfs_emit(buf, "%s\n", opts->dhchap_secret); in nvme_ctrl_dhchap_secret_show()
584 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_ctrl_dhchap_secret_store() local
585 struct nvmf_ctrl_options *opts = ctrl->opts; in nvme_ctrl_dhchap_secret_store()
588 if (!ctrl->opts->dhchap_secret) in nvme_ctrl_dhchap_secret_store()
589 return -EINVAL; in nvme_ctrl_dhchap_secret_store()
591 return -EINVAL; in nvme_ctrl_dhchap_secret_store()
592 if (memcmp(buf, "DHHC-1:", 7)) in nvme_ctrl_dhchap_secret_store()
593 return -EINVAL; in nvme_ctrl_dhchap_secret_store()
597 return -ENOMEM; in nvme_ctrl_dhchap_secret_store()
599 nvme_auth_stop(ctrl); in nvme_ctrl_dhchap_secret_store()
600 if (strcmp(dhchap_secret, opts->dhchap_secret)) { in nvme_ctrl_dhchap_secret_store()
609 kfree(opts->dhchap_secret); in nvme_ctrl_dhchap_secret_store()
610 opts->dhchap_secret = dhchap_secret; in nvme_ctrl_dhchap_secret_store()
611 host_key = ctrl->host_key; in nvme_ctrl_dhchap_secret_store()
612 mutex_lock(&ctrl->dhchap_auth_mutex); in nvme_ctrl_dhchap_secret_store()
613 ctrl->host_key = key; in nvme_ctrl_dhchap_secret_store()
614 mutex_unlock(&ctrl->dhchap_auth_mutex); in nvme_ctrl_dhchap_secret_store()
618 /* Start re-authentication */ in nvme_ctrl_dhchap_secret_store()
619 dev_info(ctrl->device, "re-authenticating controller\n"); in nvme_ctrl_dhchap_secret_store()
620 queue_work(nvme_wq, &ctrl->dhchap_auth_work); in nvme_ctrl_dhchap_secret_store()
631 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_ctrl_dhchap_ctrl_secret_show() local
632 struct nvmf_ctrl_options *opts = ctrl->opts; in nvme_ctrl_dhchap_ctrl_secret_show()
634 if (!opts->dhchap_ctrl_secret) in nvme_ctrl_dhchap_ctrl_secret_show()
636 return sysfs_emit(buf, "%s\n", opts->dhchap_ctrl_secret); in nvme_ctrl_dhchap_ctrl_secret_show()
642 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_ctrl_dhchap_ctrl_secret_store() local
643 struct nvmf_ctrl_options *opts = ctrl->opts; in nvme_ctrl_dhchap_ctrl_secret_store()
646 if (!ctrl->opts->dhchap_ctrl_secret) in nvme_ctrl_dhchap_ctrl_secret_store()
647 return -EINVAL; in nvme_ctrl_dhchap_ctrl_secret_store()
649 return -EINVAL; in nvme_ctrl_dhchap_ctrl_secret_store()
650 if (memcmp(buf, "DHHC-1:", 7)) in nvme_ctrl_dhchap_ctrl_secret_store()
651 return -EINVAL; in nvme_ctrl_dhchap_ctrl_secret_store()
655 return -ENOMEM; in nvme_ctrl_dhchap_ctrl_secret_store()
657 nvme_auth_stop(ctrl); in nvme_ctrl_dhchap_ctrl_secret_store()
658 if (strcmp(dhchap_secret, opts->dhchap_ctrl_secret)) { in nvme_ctrl_dhchap_ctrl_secret_store()
667 kfree(opts->dhchap_ctrl_secret); in nvme_ctrl_dhchap_ctrl_secret_store()
668 opts->dhchap_ctrl_secret = dhchap_secret; in nvme_ctrl_dhchap_ctrl_secret_store()
669 ctrl_key = ctrl->ctrl_key; in nvme_ctrl_dhchap_ctrl_secret_store()
670 mutex_lock(&ctrl->dhchap_auth_mutex); in nvme_ctrl_dhchap_ctrl_secret_store()
671 ctrl->ctrl_key = key; in nvme_ctrl_dhchap_ctrl_secret_store()
672 mutex_unlock(&ctrl->dhchap_auth_mutex); in nvme_ctrl_dhchap_ctrl_secret_store()
676 /* Start re-authentication */ in nvme_ctrl_dhchap_ctrl_secret_store()
677 dev_info(ctrl->device, "re-authenticating controller\n"); in nvme_ctrl_dhchap_ctrl_secret_store()
678 queue_work(nvme_wq, &ctrl->dhchap_auth_work); in nvme_ctrl_dhchap_ctrl_secret_store()
722 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_dev_attrs_are_visible() local
724 if (a == &dev_attr_delete_controller.attr && !ctrl->ops->delete_ctrl) in nvme_dev_attrs_are_visible()
726 if (a == &dev_attr_address.attr && !ctrl->ops->get_address) in nvme_dev_attrs_are_visible()
728 if (a == &dev_attr_hostnqn.attr && !ctrl->opts) in nvme_dev_attrs_are_visible()
730 if (a == &dev_attr_hostid.attr && !ctrl->opts) in nvme_dev_attrs_are_visible()
732 if (a == &dev_attr_ctrl_loss_tmo.attr && !ctrl->opts) in nvme_dev_attrs_are_visible()
734 if (a == &dev_attr_reconnect_delay.attr && !ctrl->opts) in nvme_dev_attrs_are_visible()
736 if (a == &dev_attr_fast_io_fail_tmo.attr && !ctrl->opts) in nvme_dev_attrs_are_visible()
739 if (a == &dev_attr_dhchap_secret.attr && !ctrl->opts) in nvme_dev_attrs_are_visible()
741 if (a == &dev_attr_dhchap_ctrl_secret.attr && !ctrl->opts) in nvme_dev_attrs_are_visible()
745 return a->mode; in nvme_dev_attrs_are_visible()
758 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in tls_key_show() local
760 if (!ctrl->tls_pskid) in tls_key_show()
762 return sysfs_emit(buf, "%08x\n", ctrl->tls_pskid); in tls_key_show()
769 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in tls_configured_key_show() local
770 struct key *key = ctrl->opts->tls_key; in tls_configured_key_show()
779 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in tls_keyring_show() local
780 struct key *keyring = ctrl->opts->keyring; in tls_keyring_show()
782 return sysfs_emit(buf, "%s\n", keyring->description); in tls_keyring_show()
797 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_tls_attrs_are_visible() local
799 if (!ctrl->opts || strcmp(ctrl->opts->transport, "tcp")) in nvme_tls_attrs_are_visible()
803 !ctrl->opts->tls && !ctrl->opts->concat) in nvme_tls_attrs_are_visible()
806 (!ctrl->opts->tls_key || ctrl->opts->concat)) in nvme_tls_attrs_are_visible()
809 !ctrl->opts->keyring) in nvme_tls_attrs_are_visible()
812 return a->mode; in nvme_tls_attrs_are_visible()
840 return sysfs_emit(buf, "%s\n", subsys->subnqn); in nvme_subsys_show_nqn()
851 switch (subsys->subtype) { in nvme_subsys_show_type()
869 (int)sizeof(subsys->field), subsys->field); \