Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/nvme/nvme_sim.c
Show First 20 Lines • Show All 317 Lines • ▼ Show 20 Lines | |||||
err2: | err2: | ||||
cam_sim_free(sc->s_sim, /*free_devq*/TRUE); | cam_sim_free(sc->s_sim, /*free_devq*/TRUE); | ||||
err1: | err1: | ||||
free(sc, M_NVME); | free(sc, M_NVME); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
static void * | static void * | ||||
nvme_sim_ns_change(struct nvme_namespace *ns, void *sc_arg) | nvme_sim_new_ns(struct nvme_namespace *ns, void *sc_arg) | ||||
{ | { | ||||
struct nvme_sim_softc *sc = sc_arg; | struct nvme_sim_softc *sc = sc_arg; | ||||
union ccb *ccb; | union ccb *ccb; | ||||
ccb = xpt_alloc_ccb_nowait(); | ccb = xpt_alloc_ccb_nowait(); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
printf("unable to alloc CCB for rescan\n"); | printf("unable to alloc CCB for rescan\n"); | ||||
return (NULL); | return (NULL); | ||||
Show All 11 Lines | if (xpt_create_path(&ccb->ccb_h.path, /*periph*/NULL, | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
xpt_rescan(ccb); | xpt_rescan(ccb); | ||||
return (sc_arg); | return (sc_arg); | ||||
} | } | ||||
static void | static void | ||||
nvme_sim_controller_async(void *ctrlr_arg, const struct nvme_completion *async_cpl, | |||||
uint32_t log_page_id, void *log_page_buffer, uint32_t log_page_size) | |||||
{ | |||||
struct nvme_sim_softc *sc = ctrlr_arg; | |||||
switch (log_page_id) { | |||||
case NVME_LOG_CHANGED_NAMESPACE: | |||||
xpt_async(AC_GETDEV_CHANGED, sc->s_path, NULL); | |||||
imp: this is also wrong. It doesn't handle the multiple name spaces arriving or departing. It only… | |||||
wanpengqian_gmail.comAuthorUnsubmitted Done Inline ActionsI will not use async callback this time. wanpengqian_gmail.com: I will not use async callback this time. | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
} | |||||
static void | |||||
nvme_sim_controller_fail(void *ctrlr_arg) | nvme_sim_controller_fail(void *ctrlr_arg) | ||||
{ | { | ||||
struct nvme_sim_softc *sc = ctrlr_arg; | struct nvme_sim_softc *sc = ctrlr_arg; | ||||
xpt_async(AC_LOST_DEVICE, sc->s_path, NULL); | xpt_async(AC_LOST_DEVICE, sc->s_path, NULL); | ||||
xpt_free_path(sc->s_path); | xpt_free_path(sc->s_path); | ||||
xpt_bus_deregister(cam_sim_path(sc->s_sim)); | xpt_bus_deregister(cam_sim_path(sc->s_sim)); | ||||
cam_sim_free(sc->s_sim, /*free_devq*/TRUE); | cam_sim_free(sc->s_sim, /*free_devq*/TRUE); | ||||
free(sc, M_NVME); | free(sc, M_NVME); | ||||
} | } | ||||
struct nvme_consumer *consumer_cookie; | struct nvme_consumer *consumer_cookie; | ||||
static void | static void | ||||
nvme_sim_init(void) | nvme_sim_init(void) | ||||
{ | { | ||||
if (nvme_use_nvd) | if (nvme_use_nvd) | ||||
return; | return; | ||||
consumer_cookie = nvme_register_consumer(nvme_sim_ns_change, | consumer_cookie = nvme_register_consumer(nvme_sim_new_ns, | ||||
nvme_sim_new_controller, NULL, nvme_sim_controller_fail); | nvme_sim_new_controller, nvme_sim_controller_async, nvme_sim_controller_fail); | ||||
} | } | ||||
SYSINIT(nvme_sim_register, SI_SUB_DRIVERS, SI_ORDER_ANY, | SYSINIT(nvme_sim_register, SI_SUB_DRIVERS, SI_ORDER_ANY, | ||||
nvme_sim_init, NULL); | nvme_sim_init, NULL); | ||||
static void | static void | ||||
nvme_sim_uninit(void) | nvme_sim_uninit(void) | ||||
{ | { | ||||
Show All 9 Lines |
this is also wrong. It doesn't handle the multiple name spaces arriving or departing. It only handles the size change.