From nobody Tue Nov 18 14:52:39 2025 X-Original-To: dev-commits-src-main@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 4d9nf16DS7z6HGTx; Tue, 18 Nov 2025 14:52:41 +0000 (UTC) (envelope-from rpokala@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 "smtp.freebsd.org", Issuer "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4d9nf141qNz42Nr; Tue, 18 Nov 2025 14:52:41 +0000 (UTC) (envelope-from rpokala@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1763477561; 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: in-reply-to:in-reply-to:references:references; bh=ExyKpNrCfojAmLkFFBN0JXx1f5RvMhUBX6VP4MEcraw=; b=hzh9HIVXiiAzmec1EqMqDzNXvxPmkKr3eMaJE1u/fmMy8wpj/kN4zm6rCaxl9iqI6i65ki pHOuQiVQI3dstSzixX6rjzOaGrKKDwxmxvQ/ES55Qh3HvKd9csWr7V2/lV7+dEZfyX+CaU II6F1HE5+AHjSQ6n2/kJNIht7efHtd1DXcbUTnq45YkBJje3jOYMcm1rLxLQu3cf9m/upi PtzrYWlkMBhNn8iVEBawWJZyfmglxD3xO/jKNP+jHn3aiIIdAWB+ZO1pXLQGerdqDb1gQL 1HBe3z+fLHR1gHMxwOqNa6kYIRfbVDsRKp495V1dENVllne5p24baVYpbrZP1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1763477561; 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: in-reply-to:in-reply-to:references:references; bh=ExyKpNrCfojAmLkFFBN0JXx1f5RvMhUBX6VP4MEcraw=; b=pTP8Si8pUcwSImunkxBiTrvu+flUkKdf+Rs4zQ6XMzqm0k4Nye15q4pb9tEoxBCD9MRPdy bbDMVz/BLOUlYzhg8B0f9K8KhPQnYkDKYCQKzvJ08WN0n6qJXL6rrRBXusoA2fVjzAn+S3 n+XxOgRmBm0cLUUFkPxpWSMB5jeEjhfNg72Z1GoG3Pc5mv6E9KXuL7nUl3oeJAAJzMdroK BE44PAh1LvbJuEbQl3RLwmeAWwipiRByOtNsAZSTINsMQo2NvxjCOGuxc2QhAw0xO9b9z5 OIsi2PL02ECcn2QGR9pZfRqMQx1kPXpLB8ba1CQvvCTafGFMq3jYCU5nCOxTBg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1763477561; a=rsa-sha256; cv=none; b=Cb1kCSaGCBvaxdhJgalyPVIX8zYjf/qcpQzjiBIjlkRFuQ67sks2ervgXVqNgs4rPhDWdl IWH3VFfMULc9zRsdtOfqEe6+6PJGO9Z3TCUKuGJSTUEWCoZFx+mD2Tdbm4/VdduTDLwzwl GeLulOGba+TdiivFvjgBgSl+yDXLFO40dD1PhXcti9zjWcAdpkc5a0zaTk0I38CmSOXpZu Ypc/UShfTK6WZc3omvWse8p8o2zEhsBjxpQUDKMDRhWyQRfph3NNMJkL3H2sDbOlyUgqYJ kNJfRCap9H9qDNEauuMYHEW50z1EfBU5W5ED8lc6M7dn6RwqvtyQnYV8bCWODA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from [192.168.1.10] (c-73-40-187-156.hsd1.pa.comcast.net [73.40.187.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: rpokala) by smtp.freebsd.org (Postfix) with ESMTPSA id 4d9nf129QmzwYc; Tue, 18 Nov 2025 14:52:41 +0000 (UTC) (envelope-from rpokala@freebsd.org) User-Agent: Microsoft-MacOutlook/16.102.25101223 Date: Tue, 18 Nov 2025 09:52:39 -0500 Subject: Re: 8d2a50bb3805 - main - nvme: Abstract out function to obtain a disk ident string from cdata From: Ravi Pokala To: John Baldwin , , , Message-ID: Thread-Topic: 8d2a50bb3805 - main - nvme: Abstract out function to obtain a disk ident string from cdata References: <202511171828.5AHISTJE016407@gitrepo.freebsd.org> In-Reply-To: <202511171828.5AHISTJE016407@gitrepo.freebsd.org> List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org Mime-version: 1.0 Content-type: text/plain; charset="UTF-8" Content-transfer-encoding: quoted-printable Hi John, LINT-NOVIMAGE fails because of this change. Specifically: > In file included from sys/cam/ctl/ctl_nvme_all.c:18: > In file included from sys/cam/nvme/nvme_all.h:31: > sys/dev/nvme/nvme.h:2009:2: error: call to undeclared function 'memmove';= ISO C99 and later do not support implicit function declarations [-Werror,-W= implicit-function-declaration] > 2009 | memmove(sn, cdata->sn, NVME_SERIAL_NUMBER_LENGTH); > | ^ > In file included from sys/cam/ctl/ctl_nvme_all.c:20: > In file included from sys/cam/ctl/ctl_io.h:49: > In file included from sys/cam/scsi/scsi_all.h:20: > In file included from sys/sys/malloc.h:40: > sys/sys/systm.h:259:7: error: conflicting types for 'memmove' > 259 | void *memmove(void * _Nonnull dest, const void * _Nonnull src,= size_t n); > | ^ > sys/dev/nvme/nvme.h:2009:2: note: previous implicit declaration is here > 2009 | memmove(sn, cdata->sn, NVME_SERIAL_NUMBER_LENGTH); > | ^ > 2 errors generated. >=20 > *** Error code 1 And > In file included from sys/cam/ctl/ctl_nvme_cmd_table.c:7: > sys/dev/nvme/nvme.h:2009:2: error: call to undeclared function 'memmove';= ISO C99 and later do not support implicit function declarations [-Werror,-W= implicit-function-declaration] > 2009 | memmove(sn, cdata->sn, NVME_SERIAL_NUMBER_LENGTH); > | ^ > In file included from sys/cam/ctl/ctl_nvme_cmd_table.c:11: > In file included from sys/cam/ctl/ctl_io.h:49: > In file included from sys/cam/scsi/scsi_all.h:20: > In file included from sys/sys/malloc.h:40: > sys/sys/systm.h:259:7: error: conflicting types for 'memmove' > 259 | void *memmove(void * _Nonnull dest, const void * _Nonnull src,= size_t n); > | ^ > sys/dev/nvme/nvme.h:2009:2: note: previous implicit declaration is here > 2009 | memmove(sn, cdata->sn, NVME_SERIAL_NUMBER_LENGTH); > | ^ > 2 errors generated. >=20 > *** Error code 1 Thanks, Ravi (rpokala@) =EF=BB=BF-----Original Message----- From: > on behalf of John Baldwin > Date: Monday, November 17, 2025 at 13:28 To: >, >, > Subject: git: 8d2a50bb3805 - main - nvme: Abstract out function to obtain a= disk ident string from cdata The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=3D8d2a50bb38051fefeb1427fdbfd249= f2829310d8 commit 8d2a50bb38051fefeb1427fdbfd249f2829310d8 Author: John Baldwin > AuthorDate: 2025-11-17 18:21:39 +0000 Commit: John Baldwin > CommitDate: 2025-11-17 18:21:39 +0000 nvme: Abstract out function to obtain a disk ident string from cdata This will permit sharing the code with nvmf(4). Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D53338 --- sys/dev/nvme/nvme.h | 19 +++++++++++++++++++ sys/dev/nvme/nvme_ctrlr.c | 21 +-------------------- sys/dev/nvme/nvme_ns.c | 2 +- sys/dev/nvme/nvme_private.h | 1 - 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h index f4ea08f129c0..22421f5600ec 100644 --- a/sys/dev/nvme/nvme.h +++ b/sys/dev/nvme/nvme.h @@ -1910,6 +1910,7 @@ void nvme_sc_sbuf(const struct nvme_completion *cpl, = struct sbuf *sbuf); void nvme_strvis(uint8_t *dst, const uint8_t *src, int dstlen, int srclen); #ifdef _KERNEL +#include struct bio; struct thread; @@ -1995,6 +1996,24 @@ nvme_ctrlr_has_dataset_mgmt(const struct nvme_contro= ller_data *cd) return (NVMEV(NVME_CTRLR_DATA_ONCS_DSM, cd->oncs) !=3D 0); } +/* + * Copy the NVME device's serial number to the provided buffer, which must= be + * at least DISK_IDENT_SIZE bytes large. + */ +static inline void +nvme_cdata_get_disk_ident(const struct nvme_controller_data *cdata, uint8_= t *sn) +{ + _Static_assert(NVME_SERIAL_NUMBER_LENGTH < DISK_IDENT_SIZE, + "NVME serial number too big for disk ident"); + + memmove(sn, cdata->sn, NVME_SERIAL_NUMBER_LENGTH); + sn[NVME_SERIAL_NUMBER_LENGTH] =3D '\0'; + for (int i =3D 0; sn[i] !=3D '\0'; i++) { + if (sn[i] < 0x20 || sn[i] >=3D 0x80) + sn[i] =3D ' '; + } +} + /* Namespace helper functions */ uint32_t nvme_ns_get_max_io_xfer_size(struct nvme_namespace *ns); uint32_t nvme_ns_get_sector_size(struct nvme_namespace *ns); diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c index e607667decf5..ab06c1d553d7 100644 --- a/sys/dev/nvme/nvme_ctrlr.c +++ b/sys/dev/nvme/nvme_ctrlr.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -1254,24 +1253,6 @@ nvme_ctrlr_poll(struct nvme_controller *ctrlr) nvme_qpair_process_completions(&ctrlr->ioq[i]); } -/* - * Copy the NVME device's serial number to the provided buffer, which must= be - * at least DISK_IDENT_SIZE bytes large. - */ -void -nvme_ctrlr_get_ident(const struct nvme_controller *ctrlr, uint8_t *sn) -{ - _Static_assert(NVME_SERIAL_NUMBER_LENGTH < DISK_IDENT_SIZE, - "NVME serial number too big for disk ident"); - - memmove(sn, ctrlr->cdata.sn, NVME_SERIAL_NUMBER_LENGTH); - sn[NVME_SERIAL_NUMBER_LENGTH] =3D '\0'; - for (int i =3D 0; sn[i] !=3D '\0'; i++) { - if (sn[i] < 0x20 || sn[i] >=3D 0x80) - sn[i] =3D ' '; - } -} - /* * Poll the single-vector interrupt case: num_io_queues will be 1 and * there's only a single vector. While we're polling, we mask further @@ -1516,7 +1497,7 @@ nvme_ctrlr_ioctl(struct cdev *cdev, u_long cmd, caddr= _t arg, int flag, break; case DIOCGIDENT: { uint8_t *sn =3D arg; - nvme_ctrlr_get_ident(ctrlr, sn); + nvme_cdata_get_disk_ident(&ctrlr->cdata, sn); break; } /* Linux Compatible (see nvme_linux.h) */ diff --git a/sys/dev/nvme/nvme_ns.c b/sys/dev/nvme/nvme_ns.c index 17684cc14ba2..f238fa552350 100644 --- a/sys/dev/nvme/nvme_ns.c +++ b/sys/dev/nvme/nvme_ns.c @@ -90,7 +90,7 @@ nvme_ns_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg,= int flag, } case DIOCGIDENT: { uint8_t *sn =3D arg; - nvme_ctrlr_get_ident(ctrlr, sn); + nvme_cdata_get_disk_ident(&ctrlr->cdata, sn); break; } case DIOCGMEDIASIZE: diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h index dd45e1acd0aa..a425a6a5ad62 100644 --- a/sys/dev/nvme/nvme_private.h +++ b/sys/dev/nvme/nvme_private.h @@ -565,7 +565,6 @@ void nvme_notify_new_controller(struct nvme_controller = *ctrlr); void nvme_notify_ns(struct nvme_controller *ctrlr, int nsid); void nvme_ctrlr_shared_handler(void *arg); -void nvme_ctrlr_get_ident(const struct nvme_controller *ctrlr, uint8_t *sn= ); void nvme_ctrlr_poll(struct nvme_controller *ctrlr); int nvme_ctrlr_suspend(struct nvme_controller *ctrlr);