Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/nvme/nvme_ns.c
Show First 20 Lines • Show All 488 Lines • ▼ Show 20 Lines | nvme_ns_bio_process(struct nvme_namespace *ns, struct bio *bp, | ||||
return (err); | return (err); | ||||
} | } | ||||
int | int | ||||
nvme_ns_construct(struct nvme_namespace *ns, uint32_t id, | nvme_ns_construct(struct nvme_namespace *ns, uint32_t id, | ||||
struct nvme_controller *ctrlr) | struct nvme_controller *ctrlr) | ||||
{ | { | ||||
struct make_dev_args md_args; | |||||
struct nvme_completion_poll_status status; | struct nvme_completion_poll_status status; | ||||
int res; | |||||
int unit; | int unit; | ||||
uint16_t oncs; | uint16_t oncs; | ||||
uint8_t dsm; | uint8_t dsm; | ||||
uint8_t flbas_fmt; | uint8_t flbas_fmt; | ||||
uint8_t vwc_present; | uint8_t vwc_present; | ||||
ns->ctrlr = ctrlr; | ns->ctrlr = ctrlr; | ||||
ns->id = id; | ns->id = id; | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | if (ns->cdev != NULL) | ||||
return (0); | return (0); | ||||
/* | /* | ||||
* Namespace IDs start at 1, so we need to subtract 1 to create a | * Namespace IDs start at 1, so we need to subtract 1 to create a | ||||
* correct unit number. | * correct unit number. | ||||
*/ | */ | ||||
unit = device_get_unit(ctrlr->dev) * NVME_MAX_NAMESPACES + ns->id - 1; | unit = device_get_unit(ctrlr->dev) * NVME_MAX_NAMESPACES + ns->id - 1; | ||||
ns->cdev = make_dev_credf(0, &nvme_ns_cdevsw, unit, | make_dev_args_init(&md_args); | ||||
NULL, UID_ROOT, GID_WHEEL, 0600, "nvme%dns%d", | md_args.mda_devsw = &nvme_ns_cdevsw; | ||||
md_args.mda_unit = unit; | |||||
md_args.mda_mode = 0600; | |||||
res = make_dev_s(&md_args, &ns->cdev, "nvme%dns%d", | |||||
device_get_unit(ctrlr->dev), ns->id); | device_get_unit(ctrlr->dev), ns->id); | ||||
if (res != 0) | |||||
return (ENXIO); | |||||
#ifdef NVME_UNMAPPED_BIO_SUPPORT | #ifdef NVME_UNMAPPED_BIO_SUPPORT | ||||
ns->cdev->si_flags |= SI_UNMAPPED; | ns->cdev->si_flags |= SI_UNMAPPED; | ||||
#endif | #endif | ||||
if (ns->cdev != NULL) | |||||
ns->cdev->si_drv1 = ns; | ns->cdev->si_drv1 = ns; | ||||
return (0); | return (0); | ||||
} | } | ||||
void nvme_ns_destruct(struct nvme_namespace *ns) | void nvme_ns_destruct(struct nvme_namespace *ns) | ||||
{ | { | ||||
if (ns->cdev != NULL) | if (ns->cdev != NULL) | ||||
destroy_dev(ns->cdev); | destroy_dev(ns->cdev); | ||||
} | } |