From nobody Fri Jun 14 22:40:11 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 4W1DkM3yVhz5PdyZ; Fri, 14 Jun 2024 22:40:11 +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 4W1DkM1fwKz4hCJ; Fri, 14 Jun 2024 22:40:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718404811; 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=lhLsBcpaAKyxCg5lTMx/u0i0N9Sj9AKntjW2ymMD5vU=; b=IRnfuSyYjZWaIXV7oT1I7efuMUZdWWdw4BtDZdx2WXERSPBw1X9PO6wFxw73oAtvWz+PFG pXanT3v6BHJ0UOdOLWFVZQlTRBtW6ILV3cIdFQVIf34P3K1r+Js80BA8Q1DBsX6zjk2vkV wokYW4uPFCaNwAyWYfiZq7x2OaeP3gTjSzL8xPo7OXNUMeER/Uj6yLxaQGkLEl/eZJ5CYi RTU1PKCKx+V/6fspFRs9IhjS55dOHST/fvxfQnXY2WRNzz/bGQoDhNrC7JrU/KnazVtENF OUDkz3LvOdqsvNCpckJuwhJ0uEF/IZRNL2Up+qVlCpzifgkMCah7R30/Uh1Mag== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718404811; a=rsa-sha256; cv=none; b=b+bsAJx1FrZ+7xYoS5SpkhzvFwaGc/tgXZs3RMxsFsXxEJq/xyExduzOUHibHvBzx9Vq3M jkTucuYpYNbrL/J4WI/VrWVLvMchPVX75hJfscTPB36deKi7as2D29kb5G3ZNpoR3Tw5Nd E1evYkmPx4w8lpqUwv3HRos2BUIiX3ibZY/1BMscma7g4W9NPqanIpQBJS0q57u+cPGNN2 8M/r8R5mMSUduRc9BRSUQIAYE4GeIpp+NfqaElA6V56DSL+yQfSrO6LGsND6vnSaMUrSNu PWBGi+dkedyriKB8bniALVVRBWy0IpyneSJ73aei5R+Ct4pU9Kykxos40I7h/w== 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=1718404811; 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=lhLsBcpaAKyxCg5lTMx/u0i0N9Sj9AKntjW2ymMD5vU=; b=u3st3lnFmhcxoYoO1KVXswaWENBAazND6+8USD927FqTIquSdYHCcXmLcrvAT213cvCng0 V0svilj4H2D4P6sy2bSGFkQbsnl0FbDnDIJRJwR9UhfDPgzv0P917IOlfI2MmIhDOJVzoR 0BSOHFbeRsRjtbbkSDVDIb0KQG7Dy4myZPan5Fv3Q+EYFL9tPCkoaITY+cft0wQzZ0Y8hP afOJ1me9UqXjqUE1cFlLuheL1lwK2hmQJngKLwiWaU92ZqAE1FFeDs/WoPdfZpduvl4/Pb lzI+icAZOosbVJaTymOYL3IqpUnFZSf4gq7od6R5uc0XycxdN6dnqFDvg+NT6g== 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 4W1DkM1FNhzfT7; Fri, 14 Jun 2024 22:40:11 +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 45EMeBcT014412; Fri, 14 Jun 2024 22:40:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45EMeBKe014403; Fri, 14 Jun 2024 22:40:11 GMT (envelope-from git) Date: Fri, 14 Jun 2024 22:40:11 GMT Message-Id: <202406142240.45EMeBKe014403@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: ad9cc86bf60c - main - linux: Translate Linux NVME ioctls to the lower layers. 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ad9cc86bf60cee2b35e804b348840a096f66561d Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=ad9cc86bf60cee2b35e804b348840a096f66561d commit ad9cc86bf60cee2b35e804b348840a096f66561d Author: Chuck Tuffli AuthorDate: 2024-06-14 22:40:20 +0000 Commit: Warner Losh CommitDate: 2024-06-14 22:40:20 +0000 linux: Translate Linux NVME ioctls to the lower layers. The lower layers implement a ABI compatible Linux ioctl for a few of the Linux IOCTLs. Translate them and pass them down. Since they are ABI compatible, just use the nvme ioctl name. Co-Authored-by: Warner Losh Reviewed by: chuck Differential Revision: https://reviews.freebsd.org/D45416 --- sys/compat/linux/linux_ioctl.c | 35 +++++++++++++++++++++++++++++++++++ sys/compat/linux/linux_ioctl.h | 14 ++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c index 41c43f1ef8e6..aa2c9ce7f273 100644 --- a/sys/compat/linux/linux_ioctl.c +++ b/sys/compat/linux/linux_ioctl.c @@ -83,6 +83,8 @@ #include +#include + #define DEFINE_LINUX_IOCTL_SET(shortname, SHORTNAME) \ static linux_ioctl_function_t linux_ioctl_ ## shortname; \ static struct linux_ioctl_handler shortname ## _handler = { \ @@ -108,6 +110,9 @@ DEFINE_LINUX_IOCTL_SET(v4l2, VIDEO2); DEFINE_LINUX_IOCTL_SET(fbsd_usb, FBSD_LUSB); DEFINE_LINUX_IOCTL_SET(evdev, EVDEV); DEFINE_LINUX_IOCTL_SET(kcov, KCOV); +#ifndef COMPAT_LINUX32 +DEFINE_LINUX_IOCTL_SET(nvme, NVME); +#endif #undef DEFINE_LINUX_IOCTL_SET @@ -3531,6 +3536,36 @@ linux_ioctl_kcov(struct thread *td, struct linux_ioctl_args *args) return (error); } +#ifndef COMPAT_LINUX32 +static int +linux_ioctl_nvme(struct thread *td, struct linux_ioctl_args *args) +{ + + /* + * The NVMe drivers for namespace and controller implement these + * commands using their native format. All the others are not + * implemented yet. + */ + switch (args->cmd & 0xffff) { + case LINUX_NVME_IOCTL_ID: + args->cmd = NVME_IOCTL_ID; + break; + case LINUX_NVME_IOCTL_RESET: + args->cmd = NVME_IOCTL_RESET; + break; + case LINUX_NVME_IOCTL_ADMIN_CMD: + args->cmd = NVME_IOCTL_ADMIN_CMD; + break; + case LINUX_NVME_IOCTL_IO_CMD: + args->cmd = NVME_IOCTL_IO_CMD; + break; + default: + return (ENODEV); + } + return (sys_ioctl(td, (struct ioctl_args *)args)); +} +#endif + /* * main ioctl syscall function */ diff --git a/sys/compat/linux/linux_ioctl.h b/sys/compat/linux/linux_ioctl.h index 8a56e35d10c6..4ef6d4f40830 100644 --- a/sys/compat/linux/linux_ioctl.h +++ b/sys/compat/linux/linux_ioctl.h @@ -781,6 +781,20 @@ #define LINUX_KCOV_DISABLE 0x6365 #define LINUX_KCOV_REMOTE_ENABLE 0x6366 +/* + * NVMe IOCTLs defined by Linux + */ +#define LINUX_NVME_IOCTL_ID 0x4e40 +#define LINUX_NVME_IOCTL_ADMIN_CMD 0x4e41 +#define LINUX_NVME_IOCTL_SUBMIT_IO 0x4e42 +#define LINUX_NVME_IOCTL_IO_CMD 0x4e43 +#define LINUX_NVME_IOCTL_RESET 0x4e44 +#define LINUX_NVME_IOCTL_SUBSYS_RESET 0x4e45 +#define LINUX_NVME_IOCTL_RESCAN 0x4e46 + +#define LINUX_IOCTL_NVME_MIN LINUX_NVME_IOCTL_ID +#define LINUX_IOCTL_NVME_MAX LINUX_NVME_IOCTL_RESCAN + /* * Pluggable ioctl handlers */