opnsense-src/sys/dev/nvmf/nvmf.h
John Baldwin 365b89e8ea nvmf: Switch several ioctls to using nvlists
For requests that handoff queues from userspace to the kernel as well
as the request to fetch reconnect parameters from the kernel, switch
from using flat structures to nvlists.  In particular, this will
permit adding support for additional transports in the future without
breaking the ABI of the structures.

Note that this is an ABI break for the ioctls used by nvmf(4) and
nvmft(4).  Since this is only present in main I did not bother
implementing compatability shims.

Inspired by:	imp (suggestion on a different review)
Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48230
2024-12-30 13:52:21 -05:00

101 lines
2.2 KiB
C

/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2022-2024 Chelsio Communications, Inc.
* Written by: John Baldwin <jhb@FreeBSD.org>
*/
#ifndef __NVMF_H__
#define __NVMF_H__
#include <sys/ioccom.h>
#ifndef _KERNEL
#include <stdbool.h>
#endif
/*
* Default settings in Fabrics controllers. These match values used by the
* Linux target.
*/
#define NVMF_MAX_IO_ENTRIES (1024)
#define NVMF_CC_EN_TIMEOUT (15) /* In 500ms units */
/* Allows for a 16k data buffer + SQE */
#define NVMF_IOCCSZ (sizeof(struct nvme_command) + 16 * 1024)
#define NVMF_IORCSZ (sizeof(struct nvme_completion))
#define NVMF_NN (1024)
/*
* (data, size) is the userspace buffer for a packed nvlist.
*
* For requests that copyout an nvlist, len is the amount of data
* copied out to *data. If size is zero, no data is copied and len is
* set to the required buffer size.
*/
struct nvmf_ioc_nv {
void *data;
size_t len;
size_t size;
};
/*
* The fields in a qpair handoff nvlist are:
*
* Transport independent:
*
* bool admin
* bool sq_flow_control
* number qsize
* number sqhd
* number sqtail host only
*
* TCP transport:
*
* number fd
* number rxpda
* number txpda
* bool header_digests
* bool data_digests
* number maxr2t
* number maxh2cdata
* number max_icd
*/
/*
* The fields in the nvlist for NVMF_HANDOFF_HOST and
* NVMF_RECONNECT_HOST are:
*
* number trtype
* number kato (optional)
* qpair handoff nvlist admin
* qpair handoff nvlist array io
* binary cdata struct nvme_controller_data
*/
/*
* The fields in the nvlist for NVMF_RECONNECT_PARAMS are:
*
* number cntlid
* string subnqn
*/
/*
* The fields in the nvlist for handing off a controller qpair are:
*
* number trtype
* qpair handoff nvlist params
* binary cmd struct nvmf_fabric_connect_cmd
* binary data struct nvmf_fabric_connect_data
*/
/* Operations on /dev/nvmf */
#define NVMF_HANDOFF_HOST _IOW('n', 200, struct nvmf_ioc_nv)
#define NVMF_DISCONNECT_HOST _IOW('n', 201, const char *)
#define NVMF_DISCONNECT_ALL _IO('n', 202)
/* Operations on /dev/nvmeX */
#define NVMF_RECONNECT_PARAMS _IOWR('n', 203, struct nvmf_ioc_nv)
#define NVMF_RECONNECT_HOST _IOW('n', 204, struct nvmf_ioc_nv)
#endif /* !__NVMF_H__ */