1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2023-2024 Chelsio Communications, Inc. 5 * Written by: John Baldwin <jhb@FreeBSD.org> 6 */ 7 8 #ifndef __INTERNAL_H__ 9 #define __INTERNAL_H__ 10 11 #include <stdbool.h> 12 13 struct controller; 14 struct nvme_command; 15 struct nvme_controller_data; 16 struct nvme_ns_list; 17 struct nvmf_capsule; 18 struct nvmf_qpair; 19 20 typedef bool handle_command(const struct nvmf_capsule *, 21 const struct nvme_command *, void *); 22 23 extern bool data_digests; 24 extern bool header_digests; 25 extern bool flow_control_disable; 26 extern bool kernel_io; 27 extern uint32_t maxh2cdata; 28 29 /* controller.c */ 30 void controller_handle_admin_commands(struct controller *c, 31 handle_command *cb, void *cb_arg); 32 struct controller *init_controller(struct nvmf_qpair *qp, 33 const struct nvme_controller_data *cdata); 34 void free_controller(struct controller *c); 35 36 /* discovery.c */ 37 void init_discovery(void); 38 void handle_discovery_socket(int s); 39 void discovery_add_io_controller(int s, const char *subnqn); 40 41 /* io.c */ 42 void init_io(const char *subnqn); 43 void handle_io_socket(int s); 44 void shutdown_io(void); 45 46 /* devices.c */ 47 void register_devices(int ac, char **av); 48 u_int device_count(void); 49 void device_active_nslist(uint32_t nsid, struct nvme_ns_list *nslist); 50 bool device_identification_descriptor(uint32_t nsid, void *buf); 51 bool device_namespace_data(uint32_t nsid, struct nvme_namespace_data *nsdata); 52 void device_read(uint32_t nsid, uint64_t lba, u_int nlb, 53 const struct nvmf_capsule *nc); 54 void device_write(uint32_t nsid, uint64_t lba, u_int nlb, 55 const struct nvmf_capsule *nc); 56 void device_flush(uint32_t nsid, const struct nvmf_capsule *nc); 57 58 /* ctl.c */ 59 void init_ctl_port(const char *subnqn, 60 const struct nvmf_association_params *params); 61 void ctl_handoff_qpair(struct nvmf_qpair *qp, 62 const struct nvmf_fabric_connect_cmd *cmd, 63 const struct nvmf_fabric_connect_data *data); 64 void shutdown_ctl_port(const char *subnqn); 65 66 #endif /* !__INTERNAL_H__ */ 67