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