4 * Copyright (c) Intel Corporation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
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.
34 #ifndef NVMF_SESSION_H
35 #define NVMF_SESSION_H
40 #include "spdk/nvmf_spec.h"
41 #include "spdk/queue.h"
43 /* define a virtual controller limit to the number of QPs supported */
44 #define MAX_SESSION_IO_QUEUES 64
46 struct spdk_nvmf_transport
;
47 struct spdk_nvmf_request
;
54 struct spdk_nvmf_conn
{
55 const struct spdk_nvmf_transport
*transport
;
56 struct spdk_nvmf_session
*sess
;
62 TAILQ_ENTRY(spdk_nvmf_conn
) link
;
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.
70 struct spdk_nvmf_session
{
72 struct spdk_nvmf_subsystem
*subsys
;
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 */
82 TAILQ_HEAD(connection_q
, spdk_nvmf_conn
) connections
;
84 int max_connections_allowed
;
89 union spdk_nvme_critical_warning_state crit_warn
;
90 uint8_t ns_attr_notice
: 1;
91 uint8_t fw_activation_notice
: 1;
94 struct spdk_nvmf_request
*aer_req
;
96 const struct spdk_nvmf_transport
*transport
;
98 TAILQ_ENTRY(spdk_nvmf_session
) link
;
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
);
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
);
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
);
116 int spdk_nvmf_session_poll(struct spdk_nvmf_session
*session
);
118 void spdk_nvmf_session_destruct(struct spdk_nvmf_session
*session
);
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
);
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
);
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
);
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
);
132 int spdk_nvmf_session_async_event_request(struct spdk_nvmf_request
*req
);