From nobody Fri May 03 00:16:01 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VVrtp4tvbz5KJdc; Fri, 3 May 2024 00:16:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VVrtp11JVz4Qsf; Fri, 3 May 2024 00:16:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714695362; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=edZKegkp333tM2guwjH5d4F0vKAwn6NZBUgXbkMlgG8=; b=d++PcaNCdRAShBgOrKS/TKV2X9yh9/Q2hjcstgy82/O6VJPFZzzcHP8ntCa9IypULQFL7e C2M5AIO33MXlwOW60z8JyUaaGoKMqN/MGjegzy2W4S+NXkYdBCGy3q2WdNDtb+Lr2dbAHJ KzsYFbbQv5VLQWDHd/EC633vEDI6OwBJmdxz/H8hCE7sSr71irnVi6fv9PmpcK/AAIMcxv yJ4ovNNbO7x5cudTd+0hG51tvAe+EiMjs7np7bbGp19P/kLlOjnVxSgdBjzj+YO+uyxhWd 8+mSy+uw6JaKm3eHWCvjYvUboGy9uV68dsPmFssSN94ZBZyQql69E025m9scew== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714695362; a=rsa-sha256; cv=none; b=dw2UL3EWRHlJyKE427Z0u57pLIjmgLW39WtTSRDGCEyLvExIjJhl2SyHsB8VE805aa3Kmo U6yGyqK6Z+Pu7vpKwaJPhZwNGUocUw6GGnPpQ5yNxaN6FEyb/7ckPF9sNAQT9Fm8wJhuUE AggwAWvZzhevhm7eFR+MqLzUVO0sxQw65P3T56s1CyurXqQAGyDywhbYsSkG84NBureuJj ViEYeqzC49wX4z0PV+On/JSGts15KxvmOAiSCZZhoGfORN3kQQWNXdAjFXv0KfTYigBXNT gVbmCAxJxOA2mIjqz4zOpYmFiBZmn/JKwovs+zS2yXsnaX1KO5eb73zAzLEOuA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714695362; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=edZKegkp333tM2guwjH5d4F0vKAwn6NZBUgXbkMlgG8=; b=v6DIQCxpkp5rvqDMXuP9d1lx2O8WHvc4cFjDpNqT3OjVzc7uYOGiMAOKAsts7VI0frpG9o xBG7+DYnfq42HRq/5OIIanspdLCG8As4mmsIdzFXAwc9P6O892vIcP9/7uxOQXDRDOaKnl LOaqatcS3z3I21W8wbQAWp7R+1l07+hXRyiSqKSjnjZS1GKz3E0OESb18+HkOfGgj122Dj 3qNafhPNi9bJ6XBYX3H35ZNr0oU31CC2qPvjNPCBrPdlbV+tDe7SDbzE/Qr0RIatgU3d6N LWf9skja088tIOY0cWGcvYLWkMC19tGGecSHKxzGsDiq0ZGZ3YN0LABaunHn1w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VVrtp0blrzNcv; Fri, 3 May 2024 00:16:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 4430G1Uu079813; Fri, 3 May 2024 00:16:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4430G1sa079810; Fri, 3 May 2024 00:16:01 GMT (envelope-from git) Date: Fri, 3 May 2024 00:16:01 GMT Message-Id: <202405030016.4430G1sa079810@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: bef5da8ebf74 - main - ctl: Add helper routines to populate NVMe namespace data IDs for a LUN List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bef5da8ebf740d05e893f5fb92912c3ee4295e85 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=bef5da8ebf740d05e893f5fb92912c3ee4295e85 commit bef5da8ebf740d05e893f5fb92912c3ee4295e85 Author: John Baldwin AuthorDate: 2024-05-02 23:32:41 +0000 Commit: John Baldwin CommitDate: 2024-05-02 23:38:19 +0000 ctl: Add helper routines to populate NVMe namespace data IDs for a LUN These will be used by the backends to populate the unique ID fields like EUI64 in the NVMe namespace data (CNS == 0) and namespace identification descriptor list (CNS == 3). Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D44721 --- sys/cam/ctl/ctl.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++ sys/cam/ctl/ctl_backend.h | 11 ++++++ 2 files changed, 96 insertions(+) diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 039670c17529..fde873f4f7e5 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -4956,6 +4956,91 @@ ctl_lun_capacity_changed(struct ctl_be_lun *be_lun) } } +void +ctl_lun_nsdata_ids(struct ctl_be_lun *be_lun, + struct nvme_namespace_data *nsdata) +{ + struct ctl_lun *lun = (struct ctl_lun *)be_lun->ctl_lun; + struct scsi_vpd_id_descriptor *idd; + + if (lun->lun_devid == NULL) + return; + + idd = scsi_get_devid_desc((struct scsi_vpd_id_descriptor *) + lun->lun_devid->data, lun->lun_devid->len, scsi_devid_is_lun_naa); + if (idd != NULL) { + if (idd->length == 16) { + memcpy(nsdata->nguid, idd->identifier, 16); + return; + } + if (idd->length == 8) { + memcpy(nsdata->eui64, idd->identifier, 8); + return; + } + } + + idd = scsi_get_devid_desc((struct scsi_vpd_id_descriptor *) + lun->lun_devid->data, lun->lun_devid->len, scsi_devid_is_lun_eui64); + if (idd != NULL) { + if (idd->length == 8) { + memcpy(nsdata->eui64, idd->identifier, 8); + return; + } + } +} + +void +ctl_lun_nvme_ids(struct ctl_be_lun *be_lun, void *data) +{ + struct ctl_lun *lun = (struct ctl_lun *)be_lun->ctl_lun; + struct scsi_vpd_id_descriptor *naa, *eui64, *uuid; + char *p; + + memset(data, 0, 4096); + + if (lun->lun_devid == NULL) + return; + + naa = scsi_get_devid_desc((struct scsi_vpd_id_descriptor *) + lun->lun_devid->data, lun->lun_devid->len, scsi_devid_is_lun_naa); + eui64 = scsi_get_devid_desc((struct scsi_vpd_id_descriptor *) + lun->lun_devid->data, lun->lun_devid->len, scsi_devid_is_lun_eui64); + uuid = scsi_get_devid_desc((struct scsi_vpd_id_descriptor *) + lun->lun_devid->data, lun->lun_devid->len, scsi_devid_is_lun_uuid); + + p = data; + + /* EUI64 */ + if ((naa != NULL && naa->length == 8) || eui64 != NULL) { + *p++ = 1; + *p++ = 8; + p += 2; + if (naa != NULL && naa->length == 8) + memcpy(p, naa->identifier, 8); + else + memcpy(p, eui64->identifier, 8); + p += 8; + } + + /* NGUID */ + if (naa != NULL && naa->length == 16) { + *p++ = 1; + *p++ = 16; + p += 2; + memcpy(p, naa->identifier, 16); + p += 16; + } + + /* UUID */ + if (uuid != NULL) { + *p++ = 1; + *p++ = uuid->length; + p += 2; + memcpy(p, uuid->identifier, uuid->length); + p += uuid->length; + } +} + /* * Backend "memory move is complete" callback for requests that never * make it down to say RAIDCore's configuration code. diff --git a/sys/cam/ctl/ctl_backend.h b/sys/cam/ctl/ctl_backend.h index 6ebf104fb0d2..f3d65c34f2ac 100644 --- a/sys/cam/ctl/ctl_backend.h +++ b/sys/cam/ctl/ctl_backend.h @@ -242,6 +242,17 @@ int ctl_lun_secondary(struct ctl_be_lun *be_lun); */ void ctl_lun_capacity_changed(struct ctl_be_lun *be_lun); +/* + * Populate unique ID fields in NVMe namespace data for a LUN. + */ +void ctl_lun_nsdata_ids(struct ctl_be_lun *be_lun, + struct nvme_namespace_data *nsdata); + +/* + * Populate the NVMe namespace identification descriptor list for a LUN. + */ +void ctl_lun_nvme_ids(struct ctl_be_lun *be_lun, void *data); + #endif /* _KERNEL */ #endif /* _CTL_BACKEND_H_ */