1/*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2022-2024 Chelsio Communications, Inc. 5 * Written by: John Baldwin <jhb@FreeBSD.org> 6 */ 7 8#ifndef __NVMF_H__ 9#define __NVMF_H__ 10 11#include <sys/ioccom.h> 12#ifndef _KERNEL 13#include <stdbool.h> 14#endif 15 16/* 17 * Default settings in Fabrics controllers. These match values used by the 18 * Linux target. 19 */ 20#define NVMF_MAX_IO_ENTRIES (1024) 21#define NVMF_CC_EN_TIMEOUT (15) /* In 500ms units */ 22 23/* Allows for a 16k data buffer + SQE */ 24#define NVMF_IOCCSZ (sizeof(struct nvme_command) + 16 * 1024) 25#define NVMF_IORCSZ (sizeof(struct nvme_completion)) 26 27#define NVMF_NN (1024) 28 29struct nvmf_handoff_qpair_params { 30 bool admin; 31 bool sq_flow_control; 32 u_int qsize; 33 uint16_t sqhd; 34 uint16_t sqtail; /* host only */ 35 union { 36 struct { 37 int fd; 38 uint8_t rxpda; 39 uint8_t txpda; 40 bool header_digests; 41 bool data_digests; 42 uint32_t maxr2t; 43 uint32_t maxh2cdata; 44 uint32_t max_icd; 45 } tcp; 46 }; 47}; 48 49struct nvmf_handoff_host { 50 u_int trtype; 51 u_int num_io_queues; 52 u_int kato; 53 struct nvmf_handoff_qpair_params admin; 54 struct nvmf_handoff_qpair_params *io; 55 const struct nvme_controller_data *cdata; 56}; 57 58struct nvmf_reconnect_params { 59 uint16_t cntlid; 60 char subnqn[256]; 61}; 62 63struct nvmf_handoff_controller_qpair { 64 u_int trtype; 65 struct nvmf_handoff_qpair_params params; 66 const struct nvmf_fabric_connect_cmd *cmd; 67 const struct nvmf_fabric_connect_data *data; 68}; 69 70/* Operations on /dev/nvmf */ 71#define NVMF_HANDOFF_HOST _IOW('n', 200, struct nvmf_handoff_host) 72#define NVMF_DISCONNECT_HOST _IOW('n', 201, const char *) 73#define NVMF_DISCONNECT_ALL _IO('n', 202) 74 75/* Operations on /dev/nvmeX */ 76#define NVMF_RECONNECT_PARAMS _IOR('n', 203, struct nvmf_reconnect_params) 77#define NVMF_RECONNECT_HOST _IOW('n', 204, struct nvmf_handoff_host) 78 79#endif /* !__NVMF_H__ */ 80