nvme: change global pointer g_nvme_driver to g_spdk_nvme_driver
Change-Id: I6fcd2d61ab896ef52f430a5cce1f2fd44b809725 Signed-off-by: GangCao <gang.cao@intel.com>
This commit is contained in:
parent
c04b2968a6
commit
c4afe2804b
@ -39,7 +39,7 @@ struct nvme_driver _g_nvme_driver = {
|
|||||||
.attached_ctrlrs = TAILQ_HEAD_INITIALIZER(_g_nvme_driver.attached_ctrlrs),
|
.attached_ctrlrs = TAILQ_HEAD_INITIALIZER(_g_nvme_driver.attached_ctrlrs),
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nvme_driver *g_nvme_driver = &_g_nvme_driver;
|
struct nvme_driver *g_spdk_nvme_driver = &_g_nvme_driver;
|
||||||
|
|
||||||
int32_t spdk_nvme_retry_count;
|
int32_t spdk_nvme_retry_count;
|
||||||
|
|
||||||
@ -69,13 +69,13 @@ nvme_attach(void *devhandle)
|
|||||||
int
|
int
|
||||||
spdk_nvme_detach(struct spdk_nvme_ctrlr *ctrlr)
|
spdk_nvme_detach(struct spdk_nvme_ctrlr *ctrlr)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&g_nvme_driver->lock);
|
pthread_mutex_lock(&g_spdk_nvme_driver->lock);
|
||||||
|
|
||||||
nvme_ctrlr_destruct(ctrlr);
|
nvme_ctrlr_destruct(ctrlr);
|
||||||
TAILQ_REMOVE(&g_nvme_driver->attached_ctrlrs, ctrlr, tailq);
|
TAILQ_REMOVE(&g_spdk_nvme_driver->attached_ctrlrs, ctrlr, tailq);
|
||||||
nvme_free(ctrlr);
|
nvme_free(ctrlr);
|
||||||
|
|
||||||
pthread_mutex_unlock(&g_nvme_driver->lock);
|
pthread_mutex_unlock(&g_spdk_nvme_driver->lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ struct nvme_enum_ctx {
|
|||||||
void *cb_ctx;
|
void *cb_ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This function must only be called while holding g_nvme_driver->lock */
|
/* This function must only be called while holding g_spdk_nvme_driver->lock */
|
||||||
static int
|
static int
|
||||||
nvme_enum_cb(void *ctx, struct spdk_pci_device *pci_dev)
|
nvme_enum_cb(void *ctx, struct spdk_pci_device *pci_dev)
|
||||||
{
|
{
|
||||||
@ -170,7 +170,7 @@ nvme_enum_cb(void *ctx, struct spdk_pci_device *pci_dev)
|
|||||||
struct spdk_nvme_ctrlr_opts opts;
|
struct spdk_nvme_ctrlr_opts opts;
|
||||||
|
|
||||||
/* Verify that this controller is not already attached */
|
/* Verify that this controller is not already attached */
|
||||||
TAILQ_FOREACH(ctrlr, &g_nvme_driver->attached_ctrlrs, tailq) {
|
TAILQ_FOREACH(ctrlr, &g_spdk_nvme_driver->attached_ctrlrs, tailq) {
|
||||||
/* NOTE: This assumes that the PCI abstraction layer will use the same device handle
|
/* NOTE: This assumes that the PCI abstraction layer will use the same device handle
|
||||||
* across enumerations; we could compare by BDF instead if this is not true.
|
* across enumerations; we could compare by BDF instead if this is not true.
|
||||||
*/
|
*/
|
||||||
@ -190,7 +190,7 @@ nvme_enum_cb(void *ctx, struct spdk_pci_device *pci_dev)
|
|||||||
|
|
||||||
ctrlr->opts = opts;
|
ctrlr->opts = opts;
|
||||||
|
|
||||||
TAILQ_INSERT_TAIL(&g_nvme_driver->init_ctrlrs, ctrlr, tailq);
|
TAILQ_INSERT_TAIL(&g_spdk_nvme_driver->init_ctrlrs, ctrlr, tailq);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -204,7 +204,7 @@ spdk_nvme_probe(void *cb_ctx, spdk_nvme_probe_cb probe_cb, spdk_nvme_attach_cb a
|
|||||||
struct nvme_enum_ctx enum_ctx;
|
struct nvme_enum_ctx enum_ctx;
|
||||||
struct spdk_nvme_ctrlr *ctrlr, *ctrlr_tmp;
|
struct spdk_nvme_ctrlr *ctrlr, *ctrlr_tmp;
|
||||||
|
|
||||||
pthread_mutex_lock(&g_nvme_driver->lock);
|
pthread_mutex_lock(&g_spdk_nvme_driver->lock);
|
||||||
|
|
||||||
enum_ctx.probe_cb = probe_cb;
|
enum_ctx.probe_cb = probe_cb;
|
||||||
enum_ctx.cb_ctx = cb_ctx;
|
enum_ctx.cb_ctx = cb_ctx;
|
||||||
@ -216,8 +216,8 @@ spdk_nvme_probe(void *cb_ctx, spdk_nvme_probe_cb probe_cb, spdk_nvme_attach_cb a
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Initialize all new controllers in the init_ctrlrs list in parallel. */
|
/* Initialize all new controllers in the init_ctrlrs list in parallel. */
|
||||||
while (!TAILQ_EMPTY(&g_nvme_driver->init_ctrlrs)) {
|
while (!TAILQ_EMPTY(&g_spdk_nvme_driver->init_ctrlrs)) {
|
||||||
TAILQ_FOREACH_SAFE(ctrlr, &g_nvme_driver->init_ctrlrs, tailq, ctrlr_tmp) {
|
TAILQ_FOREACH_SAFE(ctrlr, &g_spdk_nvme_driver->init_ctrlrs, tailq, ctrlr_tmp) {
|
||||||
/* Drop the driver lock while calling nvme_ctrlr_process_init()
|
/* Drop the driver lock while calling nvme_ctrlr_process_init()
|
||||||
* since it needs to acquire the driver lock internally when calling
|
* since it needs to acquire the driver lock internally when calling
|
||||||
* nvme_ctrlr_start().
|
* nvme_ctrlr_start().
|
||||||
@ -226,13 +226,13 @@ spdk_nvme_probe(void *cb_ctx, spdk_nvme_probe_cb probe_cb, spdk_nvme_attach_cb a
|
|||||||
* the functions it calls (in particular nvme_ctrlr_set_num_qpairs())
|
* the functions it calls (in particular nvme_ctrlr_set_num_qpairs())
|
||||||
* can assume it is held.
|
* can assume it is held.
|
||||||
*/
|
*/
|
||||||
pthread_mutex_unlock(&g_nvme_driver->lock);
|
pthread_mutex_unlock(&g_spdk_nvme_driver->lock);
|
||||||
start_rc = nvme_ctrlr_process_init(ctrlr);
|
start_rc = nvme_ctrlr_process_init(ctrlr);
|
||||||
pthread_mutex_lock(&g_nvme_driver->lock);
|
pthread_mutex_lock(&g_spdk_nvme_driver->lock);
|
||||||
|
|
||||||
if (start_rc) {
|
if (start_rc) {
|
||||||
/* Controller failed to initialize. */
|
/* Controller failed to initialize. */
|
||||||
TAILQ_REMOVE(&g_nvme_driver->init_ctrlrs, ctrlr, tailq);
|
TAILQ_REMOVE(&g_spdk_nvme_driver->init_ctrlrs, ctrlr, tailq);
|
||||||
nvme_ctrlr_destruct(ctrlr);
|
nvme_ctrlr_destruct(ctrlr);
|
||||||
nvme_free(ctrlr);
|
nvme_free(ctrlr);
|
||||||
rc = -1;
|
rc = -1;
|
||||||
@ -244,22 +244,22 @@ spdk_nvme_probe(void *cb_ctx, spdk_nvme_probe_cb probe_cb, spdk_nvme_attach_cb a
|
|||||||
* Controller has been initialized.
|
* Controller has been initialized.
|
||||||
* Move it to the attached_ctrlrs list.
|
* Move it to the attached_ctrlrs list.
|
||||||
*/
|
*/
|
||||||
TAILQ_REMOVE(&g_nvme_driver->init_ctrlrs, ctrlr, tailq);
|
TAILQ_REMOVE(&g_spdk_nvme_driver->init_ctrlrs, ctrlr, tailq);
|
||||||
TAILQ_INSERT_TAIL(&g_nvme_driver->attached_ctrlrs, ctrlr, tailq);
|
TAILQ_INSERT_TAIL(&g_spdk_nvme_driver->attached_ctrlrs, ctrlr, tailq);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Unlock while calling attach_cb() so the user can call other functions
|
* Unlock while calling attach_cb() so the user can call other functions
|
||||||
* that may take the driver lock, like nvme_detach().
|
* that may take the driver lock, like nvme_detach().
|
||||||
*/
|
*/
|
||||||
pthread_mutex_unlock(&g_nvme_driver->lock);
|
pthread_mutex_unlock(&g_spdk_nvme_driver->lock);
|
||||||
attach_cb(cb_ctx, ctrlr->devhandle, ctrlr, &ctrlr->opts);
|
attach_cb(cb_ctx, ctrlr->devhandle, ctrlr, &ctrlr->opts);
|
||||||
pthread_mutex_lock(&g_nvme_driver->lock);
|
pthread_mutex_lock(&g_spdk_nvme_driver->lock);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&g_nvme_driver->lock);
|
pthread_mutex_unlock(&g_spdk_nvme_driver->lock);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -465,7 +465,7 @@ struct pci_id {
|
|||||||
uint16_t sub_dev_id;
|
uint16_t sub_dev_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct nvme_driver *g_nvme_driver;
|
extern struct nvme_driver *g_spdk_nvme_driver;
|
||||||
|
|
||||||
#define nvme_min(a,b) (((a)<(b))?(a):(b))
|
#define nvme_min(a,b) (((a)<(b))?(a):(b))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user