]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*- |
2 | * BSD LICENSE | |
3 | * | |
7c673cae FG |
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 | ||
9f95a23c TL |
34 | #ifndef SPDK_COMMON_BDEV_NVME_H |
35 | #define SPDK_COMMON_BDEV_NVME_H | |
7c673cae | 36 | |
9f95a23c TL |
37 | #include "spdk/nvme.h" |
38 | #include "spdk/bdev_module.h" | |
7c673cae | 39 | |
9f95a23c TL |
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; | |
7c673cae | 43 | |
9f95a23c | 44 | #define NVME_MAX_CONTROLLERS 1024 |
7c673cae | 45 | |
9f95a23c TL |
46 | struct nvme_bdev_ctrlr { |
47 | /** | |
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 | |
51 | */ | |
52 | struct spdk_nvme_ctrlr *ctrlr; | |
53 | struct spdk_nvme_transport_id trid; | |
54 | char *name; | |
55 | int ref; | |
56 | bool destruct; | |
57 | /** | |
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. | |
61 | */ | |
62 | uint32_t prchk_flags; | |
63 | uint32_t num_ns; | |
64 | /** Array of bdevs indexed by nsid - 1 */ | |
65 | struct nvme_bdev *bdevs; | |
7c673cae | 66 | |
9f95a23c | 67 | struct spdk_poller *adminq_timer_poller; |
7c673cae | 68 | |
9f95a23c TL |
69 | /** linked list pointer for device list */ |
70 | TAILQ_ENTRY(nvme_bdev_ctrlr) tailq; | |
71 | }; | |
7c673cae | 72 | |
9f95a23c TL |
73 | struct nvme_bdev { |
74 | struct spdk_bdev disk; | |
75 | struct nvme_bdev_ctrlr *nvme_bdev_ctrlr; | |
76 | uint32_t id; | |
77 | bool active; | |
78 | struct spdk_nvme_ns *ns; | |
79 | }; | |
7c673cae | 80 | |
9f95a23c TL |
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); | |
85 | ||
86 | void nvme_bdev_dump_trid_json(struct spdk_nvme_transport_id *trid, | |
87 | struct spdk_json_write_ctx *w); | |
88 | ||
89 | #endif /* SPDK_COMMON_BDEV_NVME_H */ |