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()
270 struct nvme_ns_ids *ids = &dev_to_ns_head(dev)->ids; in nvme_ns_attrs_are_visible() local
273 if (uuid_is_null(&ids->uuid) && in nvme_ns_attrs_are_visible()
274 !memchr_inv(ids->nguid, 0, sizeof(ids->nguid))) in nvme_ns_attrs_are_visible()
278 if (!memchr_inv(ids->nguid, 0, sizeof(ids->nguid))) in nvme_ns_attrs_are_visible()
282 if (!memchr_inv(ids->eui64, 0, sizeof(ids->eui64))) in nvme_ns_attrs_are_visible()
287 /* per-path attr */ in nvme_ns_attrs_are_visible()
290 if (!nvme_ctrl_use_ana(nvme_get_ns_from_dev(dev)->ctrl)) in nvme_ns_attrs_are_visible()
294 return a->mode; in nvme_ns_attrs_are_visible()
311 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); \
313 (int)sizeof(ctrl->subsys->field), ctrl->subsys->field); \
325 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); \
326 return sysfs_emit(buf, "%d\n", ctrl->field); \
340 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_sysfs_delete() local
342 if (!test_bit(NVME_CTRL_STARTED_ONCE, &ctrl->flags)) in nvme_sysfs_delete()
343 return -EBUSY; in nvme_sysfs_delete()
346 nvme_delete_ctrl_sync(ctrl); in nvme_sysfs_delete()
355 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_sysfs_show_transport() local
357 return sysfs_emit(buf, "%s\n", ctrl->ops->name); in nvme_sysfs_show_transport()
365 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_sysfs_show_state() local
366 unsigned state = (unsigned)nvme_ctrl_state(ctrl); in nvme_sysfs_show_state()
389 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_sysfs_show_subsysnqn() local
391 return sysfs_emit(buf, "%s\n", ctrl->subsys->subnqn); in nvme_sysfs_show_subsysnqn()
399 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_sysfs_show_hostnqn() local
401 return sysfs_emit(buf, "%s\n", ctrl->opts->host->nqn); in nvme_sysfs_show_hostnqn()
409 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_sysfs_show_hostid() local
411 return sysfs_emit(buf, "%pU\n", &ctrl->opts->host->id); in nvme_sysfs_show_hostid()
419 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_sysfs_show_address() local
421 return ctrl->ops->get_address(ctrl, buf, PAGE_SIZE); in nvme_sysfs_show_address()
428 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_ctrl_loss_tmo_show() local
429 struct nvmf_ctrl_options *opts = ctrl->opts; in nvme_ctrl_loss_tmo_show()
431 if (ctrl->opts->max_reconnects == -1) in nvme_ctrl_loss_tmo_show()
434 opts->max_reconnects * opts->reconnect_delay); in nvme_ctrl_loss_tmo_show()
440 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_ctrl_loss_tmo_store() local
441 struct nvmf_ctrl_options *opts = ctrl->opts; in nvme_ctrl_loss_tmo_store()
446 return -EINVAL; in nvme_ctrl_loss_tmo_store()
449 opts->max_reconnects = -1; in nvme_ctrl_loss_tmo_store()
451 opts->max_reconnects = DIV_ROUND_UP(ctrl_loss_tmo, in nvme_ctrl_loss_tmo_store()
452 opts->reconnect_delay); in nvme_ctrl_loss_tmo_store()
461 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_ctrl_reconnect_delay_show() local
463 if (ctrl->opts->reconnect_delay == -1) in nvme_ctrl_reconnect_delay_show()
465 return sysfs_emit(buf, "%d\n", ctrl->opts->reconnect_delay); in nvme_ctrl_reconnect_delay_show()
471 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_ctrl_reconnect_delay_store() local
479 ctrl->opts->reconnect_delay = v; in nvme_ctrl_reconnect_delay_store()
488 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_ctrl_fast_io_fail_tmo_show() local
490 if (ctrl->opts->fast_io_fail_tmo == -1) in nvme_ctrl_fast_io_fail_tmo_show()
492 return sysfs_emit(buf, "%d\n", ctrl->opts->fast_io_fail_tmo); in nvme_ctrl_fast_io_fail_tmo_show()
498 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_ctrl_fast_io_fail_tmo_store() local
499 struct nvmf_ctrl_options *opts = ctrl->opts; in nvme_ctrl_fast_io_fail_tmo_store()
504 return -EINVAL; in nvme_ctrl_fast_io_fail_tmo_store()
507 opts->fast_io_fail_tmo = -1; in nvme_ctrl_fast_io_fail_tmo_store()
509 opts->fast_io_fail_tmo = fast_io_fail_tmo; in nvme_ctrl_fast_io_fail_tmo_store()
523 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in cntrltype_show() local
525 if (ctrl->cntrltype > NVME_CTRL_ADMIN || !type[ctrl->cntrltype]) in cntrltype_show()
528 return sysfs_emit(buf, type[ctrl->cntrltype]); in cntrltype_show()
540 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in dctype_show() local
542 if (ctrl->dctype > NVME_DCTYPE_CDC || !type[ctrl->dctype]) in dctype_show()
545 return sysfs_emit(buf, type[ctrl->dctype]); in dctype_show()
553 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_ctrl_dhchap_secret_show() local
554 struct nvmf_ctrl_options *opts = ctrl->opts; in nvme_ctrl_dhchap_secret_show()
556 if (!opts->dhchap_secret) in nvme_ctrl_dhchap_secret_show()
558 return sysfs_emit(buf, "%s\n", opts->dhchap_secret); in nvme_ctrl_dhchap_secret_show()
564 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_ctrl_dhchap_secret_store() local
565 struct nvmf_ctrl_options *opts = ctrl->opts; in nvme_ctrl_dhchap_secret_store()
568 if (!ctrl->opts->dhchap_secret) in nvme_ctrl_dhchap_secret_store()
569 return -EINVAL; in nvme_ctrl_dhchap_secret_store()
571 return -EINVAL; in nvme_ctrl_dhchap_secret_store()
572 if (memcmp(buf, "DHHC-1:", 7)) in nvme_ctrl_dhchap_secret_store()
573 return -EINVAL; in nvme_ctrl_dhchap_secret_store()
577 return -ENOMEM; in nvme_ctrl_dhchap_secret_store()
579 nvme_auth_stop(ctrl); in nvme_ctrl_dhchap_secret_store()
580 if (strcmp(dhchap_secret, opts->dhchap_secret)) { in nvme_ctrl_dhchap_secret_store()
589 kfree(opts->dhchap_secret); in nvme_ctrl_dhchap_secret_store()
590 opts->dhchap_secret = dhchap_secret; in nvme_ctrl_dhchap_secret_store()
591 host_key = ctrl->host_key; in nvme_ctrl_dhchap_secret_store()
592 mutex_lock(&ctrl->dhchap_auth_mutex); in nvme_ctrl_dhchap_secret_store()
593 ctrl->host_key = key; in nvme_ctrl_dhchap_secret_store()
594 mutex_unlock(&ctrl->dhchap_auth_mutex); in nvme_ctrl_dhchap_secret_store()
598 /* Start re-authentication */ in nvme_ctrl_dhchap_secret_store()
599 dev_info(ctrl->device, "re-authenticating controller\n"); in nvme_ctrl_dhchap_secret_store()
600 queue_work(nvme_wq, &ctrl->dhchap_auth_work); in nvme_ctrl_dhchap_secret_store()
611 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_ctrl_dhchap_ctrl_secret_show() local
612 struct nvmf_ctrl_options *opts = ctrl->opts; in nvme_ctrl_dhchap_ctrl_secret_show()
614 if (!opts->dhchap_ctrl_secret) in nvme_ctrl_dhchap_ctrl_secret_show()
616 return sysfs_emit(buf, "%s\n", opts->dhchap_ctrl_secret); in nvme_ctrl_dhchap_ctrl_secret_show()
622 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_ctrl_dhchap_ctrl_secret_store() local
623 struct nvmf_ctrl_options *opts = ctrl->opts; in nvme_ctrl_dhchap_ctrl_secret_store()
626 if (!ctrl->opts->dhchap_ctrl_secret) in nvme_ctrl_dhchap_ctrl_secret_store()
627 return -EINVAL; in nvme_ctrl_dhchap_ctrl_secret_store()
629 return -EINVAL; in nvme_ctrl_dhchap_ctrl_secret_store()
630 if (memcmp(buf, "DHHC-1:", 7)) in nvme_ctrl_dhchap_ctrl_secret_store()
631 return -EINVAL; in nvme_ctrl_dhchap_ctrl_secret_store()
635 return -ENOMEM; in nvme_ctrl_dhchap_ctrl_secret_store()
637 nvme_auth_stop(ctrl); in nvme_ctrl_dhchap_ctrl_secret_store()
638 if (strcmp(dhchap_secret, opts->dhchap_ctrl_secret)) { in nvme_ctrl_dhchap_ctrl_secret_store()
647 kfree(opts->dhchap_ctrl_secret); in nvme_ctrl_dhchap_ctrl_secret_store()
648 opts->dhchap_ctrl_secret = dhchap_secret; in nvme_ctrl_dhchap_ctrl_secret_store()
649 ctrl_key = ctrl->ctrl_key; in nvme_ctrl_dhchap_ctrl_secret_store()
650 mutex_lock(&ctrl->dhchap_auth_mutex); in nvme_ctrl_dhchap_ctrl_secret_store()
651 ctrl->ctrl_key = key; in nvme_ctrl_dhchap_ctrl_secret_store()
652 mutex_unlock(&ctrl->dhchap_auth_mutex); in nvme_ctrl_dhchap_ctrl_secret_store()
656 /* Start re-authentication */ in nvme_ctrl_dhchap_ctrl_secret_store()
657 dev_info(ctrl->device, "re-authenticating controller\n"); in nvme_ctrl_dhchap_ctrl_secret_store()
658 queue_work(nvme_wq, &ctrl->dhchap_auth_work); in nvme_ctrl_dhchap_ctrl_secret_store()
702 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_dev_attrs_are_visible() local
704 if (a == &dev_attr_delete_controller.attr && !ctrl->ops->delete_ctrl) in nvme_dev_attrs_are_visible()
706 if (a == &dev_attr_address.attr && !ctrl->ops->get_address) in nvme_dev_attrs_are_visible()
708 if (a == &dev_attr_hostnqn.attr && !ctrl->opts) in nvme_dev_attrs_are_visible()
710 if (a == &dev_attr_hostid.attr && !ctrl->opts) in nvme_dev_attrs_are_visible()
712 if (a == &dev_attr_ctrl_loss_tmo.attr && !ctrl->opts) in nvme_dev_attrs_are_visible()
714 if (a == &dev_attr_reconnect_delay.attr && !ctrl->opts) in nvme_dev_attrs_are_visible()
716 if (a == &dev_attr_fast_io_fail_tmo.attr && !ctrl->opts) in nvme_dev_attrs_are_visible()
719 if (a == &dev_attr_dhchap_secret.attr && !ctrl->opts) in nvme_dev_attrs_are_visible()
721 if (a == &dev_attr_dhchap_ctrl_secret.attr && !ctrl->opts) in nvme_dev_attrs_are_visible()
725 return a->mode; in nvme_dev_attrs_are_visible()
738 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in tls_key_show() local
740 if (!ctrl->tls_pskid) in tls_key_show()
742 return sysfs_emit(buf, "%08x\n", ctrl->tls_pskid); in tls_key_show()
749 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in tls_configured_key_show() local
750 struct key *key = ctrl->opts->tls_key; in tls_configured_key_show()
759 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in tls_keyring_show() local
760 struct key *keyring = ctrl->opts->keyring; in tls_keyring_show()
762 return sysfs_emit(buf, "%s\n", keyring->description); in tls_keyring_show()
777 struct nvme_ctrl *ctrl = dev_get_drvdata(dev); in nvme_tls_attrs_are_visible() local
779 if (!ctrl->opts || strcmp(ctrl->opts->transport, "tcp")) in nvme_tls_attrs_are_visible()
783 !ctrl->opts->tls) in nvme_tls_attrs_are_visible()
786 !ctrl->opts->tls_key) in nvme_tls_attrs_are_visible()
789 !ctrl->opts->keyring) in nvme_tls_attrs_are_visible()
792 return a->mode; in nvme_tls_attrs_are_visible()
820 return sysfs_emit(buf, "%s\n", subsys->subnqn); in nvme_subsys_show_nqn()
831 switch (subsys->subtype) { in nvme_subsys_show_type()
849 (int)sizeof(subsys->field), subsys->field); \