]>
Commit | Line | Data |
---|---|---|
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 NVMF_SESSION_H | |
35 | #define NVMF_SESSION_H | |
36 | ||
37 | #include <stdint.h> | |
38 | #include <stdbool.h> | |
39 | ||
40 | #include "spdk/nvmf_spec.h" | |
41 | #include "spdk/queue.h" | |
42 | ||
43 | /* define a virtual controller limit to the number of QPs supported */ | |
44 | #define MAX_SESSION_IO_QUEUES 64 | |
45 | ||
46 | struct spdk_nvmf_transport; | |
47 | struct spdk_nvmf_request; | |
48 | ||
49 | enum conn_type { | |
50 | CONN_TYPE_AQ = 0, | |
51 | CONN_TYPE_IOQ = 1, | |
52 | }; | |
53 | ||
54 | struct spdk_nvmf_conn { | |
55 | const struct spdk_nvmf_transport *transport; | |
56 | struct spdk_nvmf_session *sess; | |
57 | enum conn_type type; | |
58 | ||
59 | uint16_t sq_head; | |
60 | uint16_t sq_head_max; | |
61 | ||
62 | TAILQ_ENTRY(spdk_nvmf_conn) link; | |
63 | }; | |
64 | ||
65 | /* | |
66 | * This structure maintains the NVMf virtual controller session | |
67 | * state. Each NVMf session permits some number of connections. | |
68 | * At least one admin connection and additional IOQ connections. | |
69 | */ | |
70 | struct spdk_nvmf_session { | |
71 | uint16_t cntlid; | |
72 | struct spdk_nvmf_subsystem *subsys; | |
73 | ||
74 | struct { | |
75 | union spdk_nvme_cap_register cap; | |
76 | union spdk_nvme_vs_register vs; | |
77 | union spdk_nvme_cc_register cc; | |
78 | union spdk_nvme_csts_register csts; | |
79 | } vcprop; /* virtual controller properties */ | |
80 | struct spdk_nvme_ctrlr_data vcdata; /* virtual controller data */ | |
81 | ||
82 | TAILQ_HEAD(connection_q, spdk_nvmf_conn) connections; | |
83 | int num_connections; | |
84 | int max_connections_allowed; | |
85 | uint32_t kato; | |
86 | union { | |
87 | uint32_t raw; | |
88 | struct { | |
89 | union spdk_nvme_critical_warning_state crit_warn; | |
90 | uint8_t ns_attr_notice : 1; | |
91 | uint8_t fw_activation_notice : 1; | |
92 | } bits; | |
93 | } async_event_config; | |
94 | struct spdk_nvmf_request *aer_req; | |
95 | uint8_t hostid[16]; | |
96 | const struct spdk_nvmf_transport *transport; | |
97 | ||
98 | TAILQ_ENTRY(spdk_nvmf_session) link; | |
99 | }; | |
100 | ||
101 | void spdk_nvmf_session_connect(struct spdk_nvmf_conn *conn, | |
102 | struct spdk_nvmf_fabric_connect_cmd *cmd, | |
103 | struct spdk_nvmf_fabric_connect_data *data, | |
104 | struct spdk_nvmf_fabric_connect_rsp *rsp); | |
105 | ||
106 | void | |
107 | spdk_nvmf_property_get(struct spdk_nvmf_session *session, | |
108 | struct spdk_nvmf_fabric_prop_get_cmd *cmd, | |
109 | struct spdk_nvmf_fabric_prop_get_rsp *response); | |
110 | ||
111 | void | |
112 | spdk_nvmf_property_set(struct spdk_nvmf_session *session, | |
113 | struct spdk_nvmf_fabric_prop_set_cmd *cmd, | |
114 | struct spdk_nvme_cpl *rsp); | |
115 | ||
116 | int spdk_nvmf_session_poll(struct spdk_nvmf_session *session); | |
117 | ||
118 | void spdk_nvmf_session_destruct(struct spdk_nvmf_session *session); | |
119 | ||
120 | int spdk_nvmf_session_set_features_host_identifier(struct spdk_nvmf_request *req); | |
121 | int spdk_nvmf_session_get_features_host_identifier(struct spdk_nvmf_request *req); | |
122 | ||
123 | int spdk_nvmf_session_set_features_keep_alive_timer(struct spdk_nvmf_request *req); | |
124 | int spdk_nvmf_session_get_features_keep_alive_timer(struct spdk_nvmf_request *req); | |
125 | ||
126 | int spdk_nvmf_session_set_features_number_of_queues(struct spdk_nvmf_request *req); | |
127 | int spdk_nvmf_session_get_features_number_of_queues(struct spdk_nvmf_request *req); | |
128 | ||
129 | int spdk_nvmf_session_set_features_async_event_configuration(struct spdk_nvmf_request *req); | |
130 | int spdk_nvmf_session_get_features_async_event_configuration(struct spdk_nvmf_request *req); | |
131 | ||
132 | int spdk_nvmf_session_async_event_request(struct spdk_nvmf_request *req); | |
133 | ||
134 | #endif |