155714Skris/*-
255714Skris * SPDX-License-Identifier: BSD-2-Clause
355714Skris *
455714Skris * Copyright (c) 2023-2024 Chelsio Communications, Inc.
555714Skris * Written by: John Baldwin <jhb@FreeBSD.org>
655714Skris */
755714Skris
8280304Sjkim#ifndef __FABRICS_H__
955714Skris#define	__FABRICS_H__
1055714Skris
1155714Skris/*
1255714Skris * Splits 'in_address' into separate 'address' and 'port' strings.  If
1355714Skris * a separate buffer for the address was allocated, 'tofree' is set to
1455714Skris * the allocated buffer, otherwise 'tofree' is set to NULL.
15280304Sjkim */
1655714Skrisvoid	nvmf_parse_address(const char *in_address, const char **address,
1755714Skris    const char **port, char **tofree);
1855714Skris
1955714Skrisuint16_t nvmf_parse_cntlid(const char *cntlid);
2055714Skris
2155714Skris/* Returns true if able to open a connection. */
22280304Sjkimbool	tcp_qpair_params(struct nvmf_qpair_params *params, int adrfam,
2355714Skris    const char *address, const char *port);
2455714Skris
2555714Skris/* Connect to a discovery controller and return the Admin qpair. */
2655714Skrisstruct nvmf_qpair *connect_discovery_adminq(enum nvmf_trtype trtype,
2755714Skris    const char *address, const char *port, const char *hostnqn);
2855714Skris
2955714Skris/*
3055714Skris * Connect to an NVM controller establishing an Admin qpair and one or
3155714Skris * more I/O qpairs.  The controller's controller data is returned in
3255714Skris * *cdata on success.  Returns a non-zero value from <sysexits.h> on
3355714Skris * failure.
3455714Skris */
3555714Skrisint	connect_nvm_queues(const struct nvmf_association_params *aparams,
3655714Skris    enum nvmf_trtype trtype, int adrfam, const char *address,
37280304Sjkim    const char *port, uint16_t cntlid, const char *subnqn, const char *hostnqn,
3855714Skris    uint32_t kato, struct nvmf_qpair **admin, struct nvmf_qpair **io,
3955714Skris    u_int num_io_queues, u_int queue_size, struct nvme_controller_data *cdata);
40280304Sjkim
4155714Skris#endif /* !__FABRICS_H__ */
4255714Skris