Lines Matching full:ns
18 uint32_t nvme_namespace_get_sector_size(struct nvme_namespace *ns) in nvme_namespace_get_sector_size() argument
22 flbas_fmt = (ns->data.flbas >> NVME_NS_DATA_FLBAS_FORMAT_SHIFT) & in nvme_namespace_get_sector_size()
24 lbads = (ns->data.lbaf[flbas_fmt] >> NVME_NS_DATA_LBAF_LBADS_SHIFT) & in nvme_namespace_get_sector_size()
30 uint64_t nvme_namespace_get_num_sectors(struct nvme_namespace *ns) in nvme_namespace_get_num_sectors() argument
32 return ns->data.nsze; in nvme_namespace_get_num_sectors()
35 uint64_t nvme_namespace_get_size(struct nvme_namespace *ns) in nvme_namespace_get_size() argument
37 return nvme_namespace_get_num_sectors(ns) * in nvme_namespace_get_size()
38 nvme_namespace_get_sector_size(ns); in nvme_namespace_get_size()
41 uint32_t nvme_namespace_get_flags(struct nvme_namespace *ns) in nvme_namespace_get_flags() argument
43 return ns->flags; in nvme_namespace_get_flags()
46 const char *nvme_namespace_get_serial_number(struct nvme_namespace *ns) in nvme_namespace_get_serial_number() argument
48 return (const char *)ns->ctrlr->cdata.sn; in nvme_namespace_get_serial_number()
51 const char *nvme_namespace_get_model_number(struct nvme_namespace *ns) in nvme_namespace_get_model_number() argument
53 return (const char *)ns->ctrlr->cdata.mn; in nvme_namespace_get_model_number()
57 nvme_namespace_get_data(struct nvme_namespace *ns) in nvme_namespace_get_data() argument
59 return &ns->data; in nvme_namespace_get_data()
62 uint32_t nvme_namespace_get_stripesize(struct nvme_namespace *ns) in nvme_namespace_get_stripesize() argument
64 if (((ns->data.nsfeat >> NVME_NS_DATA_NSFEAT_NPVALID_SHIFT) & in nvme_namespace_get_stripesize()
66 uint32_t ss = nvme_namespace_get_sector_size(ns); in nvme_namespace_get_stripesize()
68 if (ns->data.npwa != 0) { in nvme_namespace_get_stripesize()
69 return (ns->data.npwa + 1) * ss; in nvme_namespace_get_stripesize()
70 } else if (ns->data.npwg != 0) { in nvme_namespace_get_stripesize()
71 return (ns->data.npwg + 1) * ss; in nvme_namespace_get_stripesize()
75 return ns->boundary; in nvme_namespace_get_stripesize()
78 int nvme_namespace_construct(struct nvme_namespace *ns, in nvme_namespace_construct() argument
87 ns->ctrlr = ctrlr; in nvme_namespace_construct()
88 ns->id = id; in nvme_namespace_construct()
90 nvme_ctrlr_cmd_identify_namespace(ctrlr, id, &ns->data, in nvme_namespace_construct()
96 LOG_DBG("Identifying NS id %d failed", id); in nvme_namespace_construct()
100 nvme_namespace_data_swapbytes(&ns->data); in nvme_namespace_construct()
102 if (nvme_namespace_get_num_sectors(ns) == 0) { in nvme_namespace_construct()
107 flbas_fmt = (ns->data.flbas >> NVME_NS_DATA_FLBAS_FORMAT_SHIFT) & in nvme_namespace_construct()
111 if (flbas_fmt > ns->data.nlbaf) { in nvme_namespace_construct()
112 LOG_DBG("NS id %d: lba format %d exceeds number supported (%d)", in nvme_namespace_construct()
113 id, flbas_fmt, ns->data.nlbaf + 1); in nvme_namespace_construct()
117 ns->boundary = ns->data.noiob * nvme_namespace_get_sector_size(ns); in nvme_namespace_construct()
120 ns->flags |= NVME_NS_DEALLOCATE_SUPPORTED; in nvme_namespace_construct()
126 ns->flags |= NVME_NS_FLUSH_SUPPORTED; in nvme_namespace_construct()
129 snprintf(ns->name, NVME_NAMESPACE_NAME_MAX_LENGTH, "nvme%dn%d", in nvme_namespace_construct()
130 ctrlr->id, ns->id-1); in nvme_namespace_construct()
132 if (nvme_namespace_disk_setup(ns, &ns->disk) != 0) { in nvme_namespace_construct()