]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/lib/nvmf/transport.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / lib / nvmf / transport.h
CommitLineData
7c673cae
FG
1/*-
2 * BSD LICENSE
3 *
4 * Copyright (c) Intel Corporation.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#ifndef SPDK_NVMF_TRANSPORT_H
35#define SPDK_NVMF_TRANSPORT_H
36
11fdf7f2 37#include "spdk/stdinc.h"
7c673cae 38
11fdf7f2 39#include "spdk/nvme.h"
7c673cae
FG
40#include "spdk/nvmf.h"
41
7c673cae 42struct spdk_nvmf_transport {
11fdf7f2
TL
43 struct spdk_nvmf_tgt *tgt;
44 const struct spdk_nvmf_transport_ops *ops;
45 struct spdk_nvmf_transport_opts opts;
46
9f95a23c
TL
47 /* A mempool for transport related data transfers */
48 struct spdk_mempool *data_buf_pool;
49
11fdf7f2
TL
50 TAILQ_ENTRY(spdk_nvmf_transport) link;
51};
52
53struct spdk_nvmf_transport_ops {
7c673cae 54 /**
11fdf7f2 55 * Transport type
7c673cae 56 */
11fdf7f2 57 enum spdk_nvme_transport_type type;
7c673cae
FG
58
59 /**
11fdf7f2 60 * Initialize transport options to default value
7c673cae 61 */
11fdf7f2 62 void (*opts_init)(struct spdk_nvmf_transport_opts *opts);
7c673cae
FG
63
64 /**
11fdf7f2 65 * Create a transport for the given transport opts
7c673cae 66 */
11fdf7f2 67 struct spdk_nvmf_transport *(*create)(struct spdk_nvmf_transport_opts *opts);
7c673cae
FG
68
69 /**
11fdf7f2 70 * Destroy the transport
7c673cae 71 */
11fdf7f2 72 int (*destroy)(struct spdk_nvmf_transport *transport);
7c673cae
FG
73
74 /**
11fdf7f2
TL
75 * Instruct the transport to accept new connections at the address
76 * provided. This may be called multiple times.
7c673cae 77 */
11fdf7f2
TL
78 int (*listen)(struct spdk_nvmf_transport *transport,
79 const struct spdk_nvme_transport_id *trid);
7c673cae
FG
80
81 /**
11fdf7f2 82 * Stop accepting new connections at the given address.
7c673cae 83 */
11fdf7f2
TL
84 int (*stop_listen)(struct spdk_nvmf_transport *transport,
85 const struct spdk_nvme_transport_id *trid);
86
87 /**
88 * Check for new connections on the transport.
89 */
90 void (*accept)(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn);
7c673cae
FG
91
92 /**
93 * Fill out a discovery log entry for a specific listen address.
94 */
11fdf7f2
TL
95 void (*listener_discover)(struct spdk_nvmf_transport *transport,
96 struct spdk_nvme_transport_id *trid,
97 struct spdk_nvmf_discovery_log_page_entry *entry);
7c673cae
FG
98
99 /**
11fdf7f2 100 * Create a new poll group
7c673cae 101 */
11fdf7f2 102 struct spdk_nvmf_transport_poll_group *(*poll_group_create)(struct spdk_nvmf_transport *transport);
7c673cae
FG
103
104 /**
11fdf7f2 105 * Destroy a poll group
7c673cae 106 */
11fdf7f2 107 void (*poll_group_destroy)(struct spdk_nvmf_transport_poll_group *group);
7c673cae
FG
108
109 /**
11fdf7f2 110 * Add a qpair to a poll group
7c673cae 111 */
11fdf7f2
TL
112 int (*poll_group_add)(struct spdk_nvmf_transport_poll_group *group,
113 struct spdk_nvmf_qpair *qpair);
7c673cae 114
9f95a23c
TL
115 /**
116 * Remove a qpair from a poll group
117 */
118 int (*poll_group_remove)(struct spdk_nvmf_transport_poll_group *group,
119 struct spdk_nvmf_qpair *qpair);
120
7c673cae 121 /**
11fdf7f2
TL
122 * Poll the group to process I/O
123 */
124 int (*poll_group_poll)(struct spdk_nvmf_transport_poll_group *group);
125
126 /*
127 * Free the request without sending a response
128 * to the originator. Release memory tied to this request.
7c673cae 129 */
11fdf7f2 130 int (*req_free)(struct spdk_nvmf_request *req);
7c673cae
FG
131
132 /*
133 * Signal request completion, which sends a response
134 * to the originator.
135 */
136 int (*req_complete)(struct spdk_nvmf_request *req);
137
138 /*
139 * Deinitialize a connection.
140 */
11fdf7f2
TL
141 void (*qpair_fini)(struct spdk_nvmf_qpair *qpair);
142
11fdf7f2
TL
143 /*
144 * Get the peer transport ID for the queue pair.
145 */
146 int (*qpair_get_peer_trid)(struct spdk_nvmf_qpair *qpair,
147 struct spdk_nvme_transport_id *trid);
7c673cae
FG
148
149 /*
11fdf7f2 150 * Get the local transport ID for the queue pair.
7c673cae 151 */
11fdf7f2
TL
152 int (*qpair_get_local_trid)(struct spdk_nvmf_qpair *qpair,
153 struct spdk_nvme_transport_id *trid);
7c673cae
FG
154
155 /*
11fdf7f2 156 * Get the listener transport ID that accepted this qpair originally.
7c673cae 157 */
11fdf7f2
TL
158 int (*qpair_get_listen_trid)(struct spdk_nvmf_qpair *qpair,
159 struct spdk_nvme_transport_id *trid);
9f95a23c
TL
160
161 /*
162 * set the submission queue size of the queue pair
163 */
164 int (*qpair_set_sqsize)(struct spdk_nvmf_qpair *qpair);
7c673cae
FG
165};
166
7c673cae 167
11fdf7f2
TL
168int spdk_nvmf_transport_stop_listen(struct spdk_nvmf_transport *transport,
169 const struct spdk_nvme_transport_id *trid);
170
171void spdk_nvmf_transport_accept(struct spdk_nvmf_transport *transport, new_qpair_fn cb_fn);
172
173void spdk_nvmf_transport_listener_discover(struct spdk_nvmf_transport *transport,
174 struct spdk_nvme_transport_id *trid,
175 struct spdk_nvmf_discovery_log_page_entry *entry);
176
177struct spdk_nvmf_transport_poll_group *spdk_nvmf_transport_poll_group_create(
178 struct spdk_nvmf_transport *transport);
179
180void spdk_nvmf_transport_poll_group_destroy(struct spdk_nvmf_transport_poll_group *group);
181
182int spdk_nvmf_transport_poll_group_add(struct spdk_nvmf_transport_poll_group *group,
183 struct spdk_nvmf_qpair *qpair);
184
9f95a23c
TL
185int spdk_nvmf_transport_poll_group_remove(struct spdk_nvmf_transport_poll_group *group,
186 struct spdk_nvmf_qpair *qpair);
187
11fdf7f2
TL
188int spdk_nvmf_transport_poll_group_poll(struct spdk_nvmf_transport_poll_group *group);
189
190int spdk_nvmf_transport_req_free(struct spdk_nvmf_request *req);
191
192int spdk_nvmf_transport_req_complete(struct spdk_nvmf_request *req);
193
194void spdk_nvmf_transport_qpair_fini(struct spdk_nvmf_qpair *qpair);
195
11fdf7f2
TL
196int spdk_nvmf_transport_qpair_get_peer_trid(struct spdk_nvmf_qpair *qpair,
197 struct spdk_nvme_transport_id *trid);
198
199int spdk_nvmf_transport_qpair_get_local_trid(struct spdk_nvmf_qpair *qpair,
200 struct spdk_nvme_transport_id *trid);
201
202int spdk_nvmf_transport_qpair_get_listen_trid(struct spdk_nvmf_qpair *qpair,
203 struct spdk_nvme_transport_id *trid);
9f95a23c 204int spdk_nvmf_transport_qpair_set_sqsize(struct spdk_nvmf_qpair *qpair);
11fdf7f2
TL
205
206bool spdk_nvmf_transport_opts_init(enum spdk_nvme_transport_type type,
207 struct spdk_nvmf_transport_opts *opts);
7c673cae 208
11fdf7f2 209extern const struct spdk_nvmf_transport_ops spdk_nvmf_transport_rdma;
9f95a23c 210extern const struct spdk_nvmf_transport_ops spdk_nvmf_transport_tcp;
7c673cae
FG
211
212#endif /* SPDK_NVMF_TRANSPORT_H */