Lines Matching +full:port +full:- +full:id
1 // SPDX-License-Identifier: GPL-2.0
15 static void __nvmet_disc_changed(struct nvmet_port *port, in __nvmet_disc_changed() argument
18 if (ctrl->port != port) in __nvmet_disc_changed()
28 void nvmet_port_disc_changed(struct nvmet_port *port, in nvmet_port_disc_changed() argument
36 mutex_lock(&nvmet_disc_subsys->lock); in nvmet_port_disc_changed()
37 list_for_each_entry(ctrl, &nvmet_disc_subsys->ctrls, subsys_entry) { in nvmet_port_disc_changed()
38 if (subsys && !nvmet_host_allowed(subsys, ctrl->hostnqn)) in nvmet_port_disc_changed()
41 __nvmet_disc_changed(port, ctrl); in nvmet_port_disc_changed()
43 mutex_unlock(&nvmet_disc_subsys->lock); in nvmet_port_disc_changed()
46 if (port->tr_ops && port->tr_ops->discovery_chg) in nvmet_port_disc_changed()
47 port->tr_ops->discovery_chg(port); in nvmet_port_disc_changed()
50 static void __nvmet_subsys_disc_changed(struct nvmet_port *port, in __nvmet_subsys_disc_changed() argument
56 mutex_lock(&nvmet_disc_subsys->lock); in __nvmet_subsys_disc_changed()
57 list_for_each_entry(ctrl, &nvmet_disc_subsys->ctrls, subsys_entry) { in __nvmet_subsys_disc_changed()
58 if (host && strcmp(nvmet_host_name(host), ctrl->hostnqn)) in __nvmet_subsys_disc_changed()
61 __nvmet_disc_changed(port, ctrl); in __nvmet_subsys_disc_changed()
63 mutex_unlock(&nvmet_disc_subsys->lock); in __nvmet_subsys_disc_changed()
69 struct nvmet_port *port; in nvmet_subsys_disc_changed() local
75 list_for_each_entry(port, nvmet_ports, global_entry) in nvmet_subsys_disc_changed()
76 list_for_each_entry(s, &port->subsystems, entry) { in nvmet_subsys_disc_changed()
77 if (s->subsys != subsys) in nvmet_subsys_disc_changed()
79 __nvmet_subsys_disc_changed(port, subsys, host); in nvmet_subsys_disc_changed()
83 void nvmet_referral_enable(struct nvmet_port *parent, struct nvmet_port *port) in nvmet_referral_enable() argument
86 if (list_empty(&port->entry)) { in nvmet_referral_enable()
87 list_add_tail(&port->entry, &parent->referrals); in nvmet_referral_enable()
88 port->enabled = true; in nvmet_referral_enable()
94 void nvmet_referral_disable(struct nvmet_port *parent, struct nvmet_port *port) in nvmet_referral_disable() argument
97 if (!list_empty(&port->entry)) { in nvmet_referral_disable()
98 port->enabled = false; in nvmet_referral_disable()
99 list_del_init(&port->entry); in nvmet_referral_disable()
106 struct nvmet_port *port, char *subsys_nqn, char *traddr, in nvmet_format_discovery_entry() argument
109 struct nvmf_disc_rsp_page_entry *e = &hdr->entries[numrec]; in nvmet_format_discovery_entry()
111 e->trtype = port->disc_addr.trtype; in nvmet_format_discovery_entry()
112 e->adrfam = port->disc_addr.adrfam; in nvmet_format_discovery_entry()
113 e->treq = port->disc_addr.treq; in nvmet_format_discovery_entry()
114 e->portid = port->disc_addr.portid; in nvmet_format_discovery_entry()
116 e->cntlid = cpu_to_le16(NVME_CNTLID_DYNAMIC); in nvmet_format_discovery_entry()
117 e->asqsz = cpu_to_le16(NVME_AQ_DEPTH); in nvmet_format_discovery_entry()
118 e->subtype = type; in nvmet_format_discovery_entry()
119 memcpy(e->trsvcid, port->disc_addr.trsvcid, NVMF_TRSVCID_SIZE); in nvmet_format_discovery_entry()
120 memcpy(e->traddr, traddr, NVMF_TRADDR_SIZE); in nvmet_format_discovery_entry()
121 memcpy(e->tsas.common, port->disc_addr.tsas.common, NVMF_TSAS_SIZE); in nvmet_format_discovery_entry()
122 strncpy(e->subnqn, subsys_nqn, NVMF_NQN_SIZE); in nvmet_format_discovery_entry()
126 * nvmet_set_disc_traddr - set a correct discovery log entry traddr
132 * from the req->port address in case the port in question listens
135 static void nvmet_set_disc_traddr(struct nvmet_req *req, struct nvmet_port *port, in nvmet_set_disc_traddr() argument
138 if (req->ops->disc_traddr) in nvmet_set_disc_traddr()
139 req->ops->disc_traddr(req, port, traddr); in nvmet_set_disc_traddr()
141 memcpy(traddr, port->disc_addr.traddr, NVMF_TRADDR_SIZE); in nvmet_set_disc_traddr()
146 struct nvmet_ctrl *ctrl = req->sq->ctrl; in discovery_log_entries()
151 list_for_each_entry(p, &req->port->subsystems, entry) { in discovery_log_entries()
152 if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn)) in discovery_log_entries()
156 list_for_each_entry(r, &req->port->referrals, entry) in discovery_log_entries()
164 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_disc_get_log_page()
166 u64 offset = nvmet_get_log_page_offset(req->cmd); in nvmet_execute_disc_get_log_page()
167 size_t data_len = nvmet_get_log_page_len(req->cmd); in nvmet_execute_disc_get_log_page()
179 if (req->cmd->get_log_page.lid != NVME_LOG_DISC) { in nvmet_execute_disc_get_log_page()
180 req->error_loc = in nvmet_execute_disc_get_log_page()
188 req->error_loc = in nvmet_execute_disc_get_log_page()
209 nvmet_set_disc_traddr(req, req->port, traddr); in nvmet_execute_disc_get_log_page()
211 nvmet_format_discovery_entry(hdr, req->port, in nvmet_execute_disc_get_log_page()
212 nvmet_disc_subsys->subsysnqn, in nvmet_execute_disc_get_log_page()
216 list_for_each_entry(p, &req->port->subsystems, entry) { in nvmet_execute_disc_get_log_page()
217 if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn)) in nvmet_execute_disc_get_log_page()
220 nvmet_format_discovery_entry(hdr, req->port, in nvmet_execute_disc_get_log_page()
221 p->subsys->subsysnqn, traddr, in nvmet_execute_disc_get_log_page()
226 list_for_each_entry(r, &req->port->referrals, entry) { in nvmet_execute_disc_get_log_page()
229 r->disc_addr.traddr, in nvmet_execute_disc_get_log_page()
234 hdr->genctr = cpu_to_le64(nvmet_genctr); in nvmet_execute_disc_get_log_page()
235 hdr->numrec = cpu_to_le64(numrec); in nvmet_execute_disc_get_log_page()
236 hdr->recfmt = cpu_to_le16(0); in nvmet_execute_disc_get_log_page()
250 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_disc_identify()
251 struct nvme_id_ctrl *id; in nvmet_execute_disc_identify() local
257 if (req->cmd->identify.cns != NVME_ID_CNS_CTRL) { in nvmet_execute_disc_identify()
258 req->error_loc = offsetof(struct nvme_identify, cns); in nvmet_execute_disc_identify()
263 id = kzalloc(sizeof(*id), GFP_KERNEL); in nvmet_execute_disc_identify()
264 if (!id) { in nvmet_execute_disc_identify()
269 memcpy(id->sn, ctrl->subsys->serial, NVMET_SN_MAX_SIZE); in nvmet_execute_disc_identify()
270 memset(id->fr, ' ', sizeof(id->fr)); in nvmet_execute_disc_identify()
271 memcpy_and_pad(id->mn, sizeof(id->mn), ctrl->subsys->model_number, in nvmet_execute_disc_identify()
272 strlen(ctrl->subsys->model_number), ' '); in nvmet_execute_disc_identify()
273 memcpy_and_pad(id->fr, sizeof(id->fr), in nvmet_execute_disc_identify()
276 id->cntrltype = NVME_CTRL_DISC; in nvmet_execute_disc_identify()
279 id->mdts = 0; in nvmet_execute_disc_identify()
280 id->cntlid = cpu_to_le16(ctrl->cntlid); in nvmet_execute_disc_identify()
281 id->ver = cpu_to_le32(ctrl->subsys->ver); in nvmet_execute_disc_identify()
282 id->lpa = (1 << 2); in nvmet_execute_disc_identify()
284 /* no enforcement soft-limit for maxcmd - pick arbitrary high value */ in nvmet_execute_disc_identify()
285 id->maxcmd = cpu_to_le16(NVMET_MAX_CMD(ctrl)); in nvmet_execute_disc_identify()
287 id->sgls = cpu_to_le32(1 << 0); /* we always support SGLs */ in nvmet_execute_disc_identify()
288 if (ctrl->ops->flags & NVMF_KEYED_SGLS) in nvmet_execute_disc_identify()
289 id->sgls |= cpu_to_le32(1 << 2); in nvmet_execute_disc_identify()
290 if (req->port->inline_data_size) in nvmet_execute_disc_identify()
291 id->sgls |= cpu_to_le32(1 << 20); in nvmet_execute_disc_identify()
293 id->oaes = cpu_to_le32(NVMET_DISC_AEN_CFG_OPTIONAL); in nvmet_execute_disc_identify()
295 strscpy(id->subnqn, ctrl->subsys->subsysnqn, sizeof(id->subnqn)); in nvmet_execute_disc_identify()
297 status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); in nvmet_execute_disc_identify()
299 kfree(id); in nvmet_execute_disc_identify()
306 u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10); in nvmet_execute_disc_set_features()
321 req->error_loc = in nvmet_execute_disc_set_features()
332 u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10); in nvmet_execute_disc_get_features()
346 req->error_loc = in nvmet_execute_disc_get_features()
357 struct nvme_command *cmd = req->cmd; in nvmet_parse_discovery_cmd()
359 if (unlikely(!(req->sq->ctrl->csts & NVME_CSTS_RDY))) { in nvmet_parse_discovery_cmd()
361 cmd->common.opcode); in nvmet_parse_discovery_cmd()
362 req->error_loc = in nvmet_parse_discovery_cmd()
367 switch (cmd->common.opcode) { in nvmet_parse_discovery_cmd()
369 req->execute = nvmet_execute_disc_set_features; in nvmet_parse_discovery_cmd()
372 req->execute = nvmet_execute_disc_get_features; in nvmet_parse_discovery_cmd()
375 req->execute = nvmet_execute_async_event; in nvmet_parse_discovery_cmd()
378 req->execute = nvmet_execute_keep_alive; in nvmet_parse_discovery_cmd()
381 req->execute = nvmet_execute_disc_get_log_page; in nvmet_parse_discovery_cmd()
384 req->execute = nvmet_execute_disc_identify; in nvmet_parse_discovery_cmd()
387 pr_debug("unhandled cmd %d\n", cmd->common.opcode); in nvmet_parse_discovery_cmd()
388 req->error_loc = offsetof(struct nvme_common_command, opcode); in nvmet_parse_discovery_cmd()