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 SPDK_COMMON_BDEV_NVME_H
35 #define SPDK_COMMON_BDEV_NVME_H
37 #include "spdk/nvme.h"
38 #include "spdk/bdev_module.h"
40 TAILQ_HEAD(nvme_bdev_ctrlrs
, nvme_bdev_ctrlr
);
41 extern struct nvme_bdev_ctrlrs g_nvme_bdev_ctrlrs
;
42 extern pthread_mutex_t g_bdev_nvme_mutex
;
44 #define NVME_MAX_CONTROLLERS 1024
46 struct nvme_bdev_ctrlr
{
48 * points to pinned, physically contiguous memory region;
49 * contains 4KB IDENTIFY structure for controller which is
50 * target for CONTROLLER IDENTIFY command during initialization
52 struct spdk_nvme_ctrlr
*ctrlr
;
53 struct spdk_nvme_transport_id trid
;
58 * PI check flags. This flags is set to NVMe controllers created only
59 * through construct_nvme_bdev RPC or .INI config file. Hot added
60 * NVMe controllers are not included.
64 /** Array of bdevs indexed by nsid - 1 */
65 struct nvme_bdev
*bdevs
;
67 struct spdk_poller
*adminq_timer_poller
;
69 /** linked list pointer for device list */
70 TAILQ_ENTRY(nvme_bdev_ctrlr
) tailq
;
74 struct spdk_bdev disk
;
75 struct nvme_bdev_ctrlr
*nvme_bdev_ctrlr
;
78 struct spdk_nvme_ns
*ns
;
81 struct nvme_bdev_ctrlr
*nvme_bdev_ctrlr_get(const struct spdk_nvme_transport_id
*trid
);
82 struct nvme_bdev_ctrlr
*nvme_bdev_ctrlr_get_by_name(const char *name
);
83 struct nvme_bdev_ctrlr
*nvme_bdev_first_ctrlr(void);
84 struct nvme_bdev_ctrlr
*nvme_bdev_next_ctrlr(struct nvme_bdev_ctrlr
*prev
);
86 void nvme_bdev_dump_trid_json(struct spdk_nvme_transport_id
*trid
,
87 struct spdk_json_write_ctx
*w
);
89 #endif /* SPDK_COMMON_BDEV_NVME_H */