xref: /freebsd/usr.sbin/nvmfd/internal.h (revision 6580f5c38dd5b01aeeaed16b370f1a12423437f0)
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 
28 /* controller.c */
29 void	controller_handle_admin_commands(struct controller *c,
30     handle_command *cb, void *cb_arg);
31 struct controller *init_controller(struct nvmf_qpair *qp,
32     const struct nvme_controller_data *cdata);
33 void	free_controller(struct controller *c);
34 
35 /* discovery.c */
36 void	init_discovery(void);
37 void	handle_discovery_socket(int s);
38 void	discovery_add_io_controller(int s, const char *subnqn);
39 
40 /* io.c */
41 void	init_io(const char *subnqn);
42 void	handle_io_socket(int s);
43 void	shutdown_io(void);
44 
45 /* devices.c */
46 void	register_devices(int ac, char **av);
47 u_int	device_count(void);
48 void	device_active_nslist(uint32_t nsid, struct nvme_ns_list *nslist);
49 bool	device_identification_descriptor(uint32_t nsid, void *buf);
50 bool	device_namespace_data(uint32_t nsid, struct nvme_namespace_data *nsdata);
51 void	device_read(uint32_t nsid, uint64_t lba, u_int nlb,
52     const struct nvmf_capsule *nc);
53 void	device_write(uint32_t nsid, uint64_t lba, u_int nlb,
54     const struct nvmf_capsule *nc);
55 void	device_flush(uint32_t nsid, const struct nvmf_capsule *nc);
56 
57 /* ctl.c */
58 void	init_ctl_port(const char *subnqn,
59     const struct nvmf_association_params *params);
60 void	ctl_handoff_qpair(struct nvmf_qpair *qp,
61     const struct nvmf_fabric_connect_cmd *cmd,
62     const struct nvmf_fabric_connect_data *data);
63 void	shutdown_ctl_port(const char *subnqn);
64 
65 #endif /* !__INTERNAL_H__ */
66