• Home
  • Raw
  • Download

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
74 list_for_each_entry(port, nvmet_ports, global_entry) in nvmet_subsys_disc_changed()
75 list_for_each_entry(s, &port->subsystems, entry) { in nvmet_subsys_disc_changed()
76 if (s->subsys != subsys) in nvmet_subsys_disc_changed()
78 __nvmet_subsys_disc_changed(port, subsys, host); in nvmet_subsys_disc_changed()
82 void nvmet_referral_enable(struct nvmet_port *parent, struct nvmet_port *port) in nvmet_referral_enable() argument
85 if (list_empty(&port->entry)) { in nvmet_referral_enable()
86 list_add_tail(&port->entry, &parent->referrals); in nvmet_referral_enable()
87 port->enabled = true; in nvmet_referral_enable()
93 void nvmet_referral_disable(struct nvmet_port *parent, struct nvmet_port *port) in nvmet_referral_disable() argument
96 if (!list_empty(&port->entry)) { in nvmet_referral_disable()
97 port->enabled = false; in nvmet_referral_disable()
98 list_del_init(&port->entry); in nvmet_referral_disable()
105 struct nvmet_port *port, char *subsys_nqn, char *traddr, in nvmet_format_discovery_entry() argument
108 struct nvmf_disc_rsp_page_entry *e = &hdr->entries[numrec]; in nvmet_format_discovery_entry()
110 e->trtype = port->disc_addr.trtype; in nvmet_format_discovery_entry()
111 e->adrfam = port->disc_addr.adrfam; in nvmet_format_discovery_entry()
112 e->treq = port->disc_addr.treq; in nvmet_format_discovery_entry()
113 e->portid = port->disc_addr.portid; in nvmet_format_discovery_entry()
115 e->cntlid = cpu_to_le16(NVME_CNTLID_DYNAMIC); in nvmet_format_discovery_entry()
116 e->asqsz = cpu_to_le16(NVME_AQ_DEPTH); in nvmet_format_discovery_entry()
117 e->subtype = type; in nvmet_format_discovery_entry()
118 memcpy(e->trsvcid, port->disc_addr.trsvcid, NVMF_TRSVCID_SIZE); in nvmet_format_discovery_entry()
119 memcpy(e->traddr, traddr, NVMF_TRADDR_SIZE); in nvmet_format_discovery_entry()
120 memcpy(e->tsas.common, port->disc_addr.tsas.common, NVMF_TSAS_SIZE); in nvmet_format_discovery_entry()
121 strncpy(e->subnqn, subsys_nqn, NVMF_NQN_SIZE); in nvmet_format_discovery_entry()
125 * nvmet_set_disc_traddr - set a correct discovery log entry traddr
131 * from the req->port address in case the port in question listens
134 static void nvmet_set_disc_traddr(struct nvmet_req *req, struct nvmet_port *port, in nvmet_set_disc_traddr() argument
137 if (req->ops->disc_traddr) in nvmet_set_disc_traddr()
138 req->ops->disc_traddr(req, port, traddr); in nvmet_set_disc_traddr()
140 memcpy(traddr, port->disc_addr.traddr, NVMF_TRADDR_SIZE); in nvmet_set_disc_traddr()
145 struct nvmet_ctrl *ctrl = req->sq->ctrl; in discovery_log_entries()
150 list_for_each_entry(p, &req->port->subsystems, entry) { in discovery_log_entries()
151 if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn)) in discovery_log_entries()
155 list_for_each_entry(r, &req->port->referrals, entry) in discovery_log_entries()
163 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_disc_get_log_page()
165 u64 offset = nvmet_get_log_page_offset(req->cmd); in nvmet_execute_disc_get_log_page()
166 size_t data_len = nvmet_get_log_page_len(req->cmd); in nvmet_execute_disc_get_log_page()
177 if (req->cmd->get_log_page.lid != NVME_LOG_DISC) { in nvmet_execute_disc_get_log_page()
178 req->error_loc = in nvmet_execute_disc_get_log_page()
186 req->error_loc = in nvmet_execute_disc_get_log_page()
207 list_for_each_entry(p, &req->port->subsystems, entry) { in nvmet_execute_disc_get_log_page()
210 if (!nvmet_host_allowed(p->subsys, ctrl->hostnqn)) in nvmet_execute_disc_get_log_page()
213 nvmet_set_disc_traddr(req, req->port, traddr); in nvmet_execute_disc_get_log_page()
214 nvmet_format_discovery_entry(hdr, req->port, in nvmet_execute_disc_get_log_page()
215 p->subsys->subsysnqn, traddr, in nvmet_execute_disc_get_log_page()
220 list_for_each_entry(r, &req->port->referrals, entry) { in nvmet_execute_disc_get_log_page()
223 r->disc_addr.traddr, in nvmet_execute_disc_get_log_page()
228 hdr->genctr = cpu_to_le64(nvmet_genctr); in nvmet_execute_disc_get_log_page()
229 hdr->numrec = cpu_to_le64(numrec); in nvmet_execute_disc_get_log_page()
230 hdr->recfmt = cpu_to_le16(0); in nvmet_execute_disc_get_log_page()
244 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_disc_identify()
245 struct nvme_id_ctrl *id; in nvmet_execute_disc_identify() local
252 if (req->cmd->identify.cns != NVME_ID_CNS_CTRL) { in nvmet_execute_disc_identify()
253 req->error_loc = offsetof(struct nvme_identify, cns); in nvmet_execute_disc_identify()
258 id = kzalloc(sizeof(*id), GFP_KERNEL); in nvmet_execute_disc_identify()
259 if (!id) { in nvmet_execute_disc_identify()
264 memset(id->sn, ' ', sizeof(id->sn)); in nvmet_execute_disc_identify()
265 bin2hex(id->sn, &ctrl->subsys->serial, in nvmet_execute_disc_identify()
266 min(sizeof(ctrl->subsys->serial), sizeof(id->sn) / 2)); in nvmet_execute_disc_identify()
267 memset(id->fr, ' ', sizeof(id->fr)); in nvmet_execute_disc_identify()
268 memcpy_and_pad(id->mn, sizeof(id->mn), model, sizeof(model) - 1, ' '); in nvmet_execute_disc_identify()
269 memcpy_and_pad(id->fr, sizeof(id->fr), in nvmet_execute_disc_identify()
273 id->mdts = 0; in nvmet_execute_disc_identify()
274 id->cntlid = cpu_to_le16(ctrl->cntlid); in nvmet_execute_disc_identify()
275 id->ver = cpu_to_le32(ctrl->subsys->ver); in nvmet_execute_disc_identify()
276 id->lpa = (1 << 2); in nvmet_execute_disc_identify()
278 /* no enforcement soft-limit for maxcmd - pick arbitrary high value */ in nvmet_execute_disc_identify()
279 id->maxcmd = cpu_to_le16(NVMET_MAX_CMD); in nvmet_execute_disc_identify()
281 id->sgls = cpu_to_le32(1 << 0); /* we always support SGLs */ in nvmet_execute_disc_identify()
282 if (ctrl->ops->flags & NVMF_KEYED_SGLS) in nvmet_execute_disc_identify()
283 id->sgls |= cpu_to_le32(1 << 2); in nvmet_execute_disc_identify()
284 if (req->port->inline_data_size) in nvmet_execute_disc_identify()
285 id->sgls |= cpu_to_le32(1 << 20); in nvmet_execute_disc_identify()
287 id->oaes = cpu_to_le32(NVMET_DISC_AEN_CFG_OPTIONAL); in nvmet_execute_disc_identify()
289 strlcpy(id->subnqn, ctrl->subsys->subsysnqn, sizeof(id->subnqn)); in nvmet_execute_disc_identify()
291 status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); in nvmet_execute_disc_identify()
293 kfree(id); in nvmet_execute_disc_identify()
300 u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10); in nvmet_execute_disc_set_features()
315 req->error_loc = in nvmet_execute_disc_set_features()
326 u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10); in nvmet_execute_disc_get_features()
340 req->error_loc = in nvmet_execute_disc_get_features()
351 struct nvme_command *cmd = req->cmd; in nvmet_parse_discovery_cmd()
353 if (unlikely(!(req->sq->ctrl->csts & NVME_CSTS_RDY))) { in nvmet_parse_discovery_cmd()
355 cmd->common.opcode); in nvmet_parse_discovery_cmd()
356 req->error_loc = in nvmet_parse_discovery_cmd()
361 switch (cmd->common.opcode) { in nvmet_parse_discovery_cmd()
363 req->execute = nvmet_execute_disc_set_features; in nvmet_parse_discovery_cmd()
366 req->execute = nvmet_execute_disc_get_features; in nvmet_parse_discovery_cmd()
369 req->execute = nvmet_execute_async_event; in nvmet_parse_discovery_cmd()
372 req->execute = nvmet_execute_keep_alive; in nvmet_parse_discovery_cmd()
375 req->execute = nvmet_execute_disc_get_log_page; in nvmet_parse_discovery_cmd()
378 req->execute = nvmet_execute_disc_identify; in nvmet_parse_discovery_cmd()
381 pr_err("unhandled cmd %d\n", cmd->common.opcode); in nvmet_parse_discovery_cmd()
382 req->error_loc = offsetof(struct nvme_common_command, opcode); in nvmet_parse_discovery_cmd()