From nobody Fri May 03 00:16:07 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 4VVrtw0Fvyz5KKF1; Fri, 3 May 2024 00:16:08 +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 4VVrtv5mHqz4RC8; Fri, 3 May 2024 00:16:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714695367; 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=5wiJDLMyzWu6yH78l46fh/bvZyeZGG17H0yUt/qatEg=; b=j3OkSFIGsZecgTugUTviawJc2xOlcA1TgRRr581lGGm/UtyrCbQhQ5xh9gBc1+yVlAcKuR m/ZWrlLTkCl4xi7KzKjnXbUDdonc2KKcmZS4GsD6Ef85/8blHebi8rXbMQVem9bv0+D6ug mlXgVoFtG2GSUabYPHwGPjKUMucJ2zWWqJL2xR6Z5I/vnegYLaC9tlwRFSAgJgcczJDZ8G EORprDlLAKVRB+vz0neN3Rkj1V8vm15zZepXYhpL7/aUg/S+ApJUIkZTAe4egx09clYSLl Cw/CJfZcRcWs5uaxJy4iHfkrs5QNEN4lQUb43tcoJc88P4UYSV3f1SznjnBftg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714695367; a=rsa-sha256; cv=none; b=klegX9Q7RRHiZvd0MrU21nakwwTD1FnG5c+mZl+6zXFJDFejBq/t4z1IeGuCfGg0EIrUzw DZYo6+skQjH7jWfwxIOrUco8sIS+oEVzZy2yVjYMTBAXIP3ftgXbmh3rhxj80c/wpWBDQ7 FDIk6Wzs2FZZwQGVF5/gJaOL9EsPdy63gXU45H49LlwAkEyvrRdofi/nZDoCrWv0WY/uWm nmNEdTkU36vA4nWo/MCCnqfLcYHgQUxlsDy9DWl5HTh3CIynX2BL3B7TVoiAyaP6BzpJIJ 4k2Dp0VZ+YqnrI6YRcjT2puH7BF8TWjs+/VQuOgMOzVDbTEfUqV3ffIeefsjOQ== 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=1714695367; 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=5wiJDLMyzWu6yH78l46fh/bvZyeZGG17H0yUt/qatEg=; b=gyvbmSLtjQwWvGEzJR60hn/ywrxMvxi/pSSMT9vHblN/TojHFNXh8y/74hdGzGJchV9udt zh7uUHuvIotfl2QSyHhBD6H4KHgHB/YAfNj6a+/u6I/8nK39Su/Ea3iiUxDUB3fzZErGuX 7eTqu4GqzDy7zNT1euAPqXsnnIFUcRoVMRLawE44TxGrmhOq3B2Dv7/nFYp8SxFNmKlm95 GuyKzIxtVyDDX9YZQ3OxLRsbFKD0jzgK6NZPZYn6SAQXDq3HrpVsR7EzG/G3a9u5NANGGr uZCY05wyRolwprVnisalmQLeT1qWtKsfk3d5YN4p3hmnjCIN6eFul4tCXhir7A== 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 4VVrtv5Mc3zNHn; Fri, 3 May 2024 00:16:07 +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 4430G7tr080038; Fri, 3 May 2024 00:16:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4430G7ig080035; Fri, 3 May 2024 00:16:07 GMT (envelope-from git) Date: Fri, 3 May 2024 00:16:07 GMT Message-Id: <202405030016.4430G7ig080035@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: 25bad5a2dac8 - main - ctl: Add NVMF port type and ioctls 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: 25bad5a2dac8fb79063f79b48cb6498baf8e54ff Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=25bad5a2dac8fb79063f79b48cb6498baf8e54ff commit 25bad5a2dac8fb79063f79b48cb6498baf8e54ff Author: John Baldwin AuthorDate: 2024-05-02 23:34:26 +0000 Commit: John Baldwin CommitDate: 2024-05-02 23:38:30 +0000 ctl: Add NVMF port type and ioctls - Add CTL_PORT_NVMF as a new port type. - Define a new CTL_NVMF ioctl for NVMF-specific operations similar to CTL_ISCSI. This ioctl supports a command to handoff a single queue pair, a command to enumerate active associations, and a command to disconnect one or more active associations. Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D44724 --- sys/cam/ctl/ctl.c | 17 ++++++++++++++ sys/cam/ctl/ctl.h | 1 + sys/cam/ctl/ctl_ioctl.h | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index fde873f4f7e5..fac65e155890 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -3217,6 +3217,23 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, retval = fe->ioctl(dev, cmd, addr, flag, td); break; } + case CTL_NVMF: { + struct ctl_nvmf *cn; + struct ctl_frontend *fe; + + cn = (struct ctl_nvmf *)addr; + + fe = ctl_frontend_find("nvmf"); + if (fe == NULL) { + cn->status = CTL_NVMF_ERROR; + snprintf(cn->error_str, sizeof(cn->error_str), + "Frontend \"nvmf\" not found."); + break; + } + + retval = fe->ioctl(dev, cmd, addr, flag, td); + break; + } case CTL_PORT_REQ: { struct ctl_req *req; struct ctl_frontend *fe; diff --git a/sys/cam/ctl/ctl.h b/sys/cam/ctl/ctl.h index a211e249b2dc..4b0ae45d6699 100644 --- a/sys/cam/ctl/ctl.h +++ b/sys/cam/ctl/ctl.h @@ -55,6 +55,7 @@ typedef enum { CTL_PORT_ISCSI = 0x10, CTL_PORT_SAS = 0x20, CTL_PORT_UMASS = 0x40, + CTL_PORT_NVMF = 0x80, CTL_PORT_ALL = 0xff, CTL_PORT_ISC = 0x100 // FC port for inter-shelf communication } ctl_port_type; diff --git a/sys/cam/ctl/ctl_ioctl.h b/sys/cam/ctl/ctl_ioctl.h index 9fef169c300c..326e4c931f93 100644 --- a/sys/cam/ctl/ctl_ioctl.h +++ b/sys/cam/ctl/ctl_ioctl.h @@ -48,6 +48,8 @@ #include #include +#include +#include #define CTL_DEFAULT_DEV "/dev/cam/ctl" /* @@ -761,6 +763,65 @@ struct ctl_lun_map { uint32_t lun; }; +/* + * NVMe over Fabrics status + * + * OK: Request completed successfully. + * + * ERROR: An error occurred, look at the error string for a + * description of the error. + */ +typedef enum { + CTL_NVMF_OK, + CTL_NVMF_ERROR, + CTL_NVMF_LIST_NEED_MORE_SPACE, + CTL_NVMF_ASSOCIATION_NOT_FOUND +} ctl_nvmf_status; + +typedef enum { + CTL_NVMF_HANDOFF, + CTL_NVMF_LIST, + CTL_NVMF_TERMINATE +} ctl_nvmf_type; + +struct ctl_nvmf_list_params { + uint32_t alloc_len; /* passed to kernel */ + char *conn_xml; /* filled in kernel */ + uint32_t fill_len; /* passed to userland */ + int spare[4]; +}; + +struct ctl_nvmf_terminate_params { + int cntlid; /* passed to kernel */ + char hostnqn[NVME_NQN_FIELD_SIZE]; + /* passed to kernel */ + int all; /* passed to kernel */ + int spare[4]; +}; + +union ctl_nvmf_data { + struct nvmf_handoff_controller_qpair handoff; + struct ctl_nvmf_list_params list; + struct ctl_nvmf_terminate_params terminate; +}; + +/* + * NVMe over Fabrics interface + * + * status: The status of the request. See above for the + * description of the values of this field. + * + * error_str: If the status indicates an error, this string will + * be filled in to describe the error. + */ +struct ctl_nvmf { + ctl_nvmf_type type; /* passed to kernel */ + union ctl_nvmf_data data; /* passed to kernel */ + ctl_nvmf_status status; /* passed to userland */ + char error_str[CTL_ERROR_STR_LEN]; + /* passed to userland */ +}; + #define CTL_IO _IOWR(CTL_MINOR, 0x00, union ctl_io) #define CTL_ENABLE_PORT _IOW(CTL_MINOR, 0x04, struct ctl_port_entry) #define CTL_DISABLE_PORT _IOW(CTL_MINOR, 0x05, struct ctl_port_entry) @@ -778,6 +839,7 @@ struct ctl_lun_map { #define CTL_LUN_MAP _IOW(CTL_MINOR, 0x28, struct ctl_lun_map) #define CTL_GET_LUN_STATS _IOWR(CTL_MINOR, 0x29, struct ctl_get_io_stats) #define CTL_GET_PORT_STATS _IOWR(CTL_MINOR, 0x2a, struct ctl_get_io_stats) +#define CTL_NVMF _IOWR(CTL_MINOR, 0x2b, struct ctl_nvmf) #endif /* _CTL_IOCTL_H_ */