Lines Matching full:ns

19 uint16_t nvme_check_prinfo(NvmeNamespace *ns, uint8_t prinfo, uint64_t slba,  in nvme_check_prinfo()  argument
22 uint64_t mask = ns->pif ? 0xffffffffffff : 0xffffffff; in nvme_check_prinfo()
24 if ((NVME_ID_NS_DPS_TYPE(ns->id_ns.dps) == NVME_ID_NS_DPS_TYPE_1) && in nvme_check_prinfo()
29 if ((NVME_ID_NS_DPS_TYPE(ns->id_ns.dps) == NVME_ID_NS_DPS_TYPE_3) && in nvme_check_prinfo()
63 static void nvme_dif_pract_generate_dif_crc16(NvmeNamespace *ns, uint8_t *buf, in nvme_dif_pract_generate_dif_crc16() argument
71 if (!(ns->id_ns.dps & NVME_ID_NS_DPS_FIRST_EIGHT)) { in nvme_dif_pract_generate_dif_crc16()
72 pil = ns->lbaf.ms - nvme_pi_tuple_size(ns); in nvme_dif_pract_generate_dif_crc16()
75 trace_pci_nvme_dif_pract_generate_dif_crc16(len, ns->lbasz, in nvme_dif_pract_generate_dif_crc16()
76 ns->lbasz + pil, apptag, in nvme_dif_pract_generate_dif_crc16()
79 for (; buf < end; buf += ns->lbasz, mbuf += ns->lbaf.ms) { in nvme_dif_pract_generate_dif_crc16()
81 uint16_t crc = crc16_t10dif(0x0, buf, ns->lbasz); in nvme_dif_pract_generate_dif_crc16()
91 if (NVME_ID_NS_DPS_TYPE(ns->id_ns.dps) != NVME_ID_NS_DPS_TYPE_3) { in nvme_dif_pract_generate_dif_crc16()
97 static void nvme_dif_pract_generate_dif_crc64(NvmeNamespace *ns, uint8_t *buf, in nvme_dif_pract_generate_dif_crc64() argument
105 if (!(ns->id_ns.dps & NVME_ID_NS_DPS_FIRST_EIGHT)) { in nvme_dif_pract_generate_dif_crc64()
106 pil = ns->lbaf.ms - 16; in nvme_dif_pract_generate_dif_crc64()
109 trace_pci_nvme_dif_pract_generate_dif_crc64(len, ns->lbasz, in nvme_dif_pract_generate_dif_crc64()
110 ns->lbasz + pil, apptag, in nvme_dif_pract_generate_dif_crc64()
113 for (; buf < end; buf += ns->lbasz, mbuf += ns->lbaf.ms) { in nvme_dif_pract_generate_dif_crc64()
115 uint64_t crc = crc64_nvme(~0ULL, buf, ns->lbasz); in nvme_dif_pract_generate_dif_crc64()
131 if (NVME_ID_NS_DPS_TYPE(ns->id_ns.dps) != NVME_ID_NS_DPS_TYPE_3) { in nvme_dif_pract_generate_dif_crc64()
137 void nvme_dif_pract_generate_dif(NvmeNamespace *ns, uint8_t *buf, size_t len, in nvme_dif_pract_generate_dif() argument
141 switch (ns->pif) { in nvme_dif_pract_generate_dif()
143 return nvme_dif_pract_generate_dif_crc16(ns, buf, len, mbuf, mlen, in nvme_dif_pract_generate_dif()
146 return nvme_dif_pract_generate_dif_crc64(ns, buf, len, mbuf, mlen, in nvme_dif_pract_generate_dif()
153 static uint16_t nvme_dif_prchk_crc16(NvmeNamespace *ns, NvmeDifTuple *dif, in nvme_dif_prchk_crc16() argument
158 switch (NVME_ID_NS_DPS_TYPE(ns->id_ns.dps)) { in nvme_dif_prchk_crc16()
178 uint16_t crc = crc16_t10dif(0x0, buf, ns->lbasz); in nvme_dif_prchk_crc16()
212 static uint16_t nvme_dif_prchk_crc64(NvmeNamespace *ns, NvmeDifTuple *dif, in nvme_dif_prchk_crc64() argument
226 switch (NVME_ID_NS_DPS_TYPE(ns->id_ns.dps)) { in nvme_dif_prchk_crc64()
246 uint64_t crc = crc64_nvme(~0ULL, buf, ns->lbasz); in nvme_dif_prchk_crc64()
279 static uint16_t nvme_dif_prchk(NvmeNamespace *ns, NvmeDifTuple *dif, in nvme_dif_prchk() argument
284 switch (ns->pif) { in nvme_dif_prchk()
286 return nvme_dif_prchk_crc16(ns, dif, buf, mbuf, pil, prinfo, apptag, in nvme_dif_prchk()
289 return nvme_dif_prchk_crc64(ns, dif, buf, mbuf, pil, prinfo, apptag, in nvme_dif_prchk()
296 uint16_t nvme_dif_check(NvmeNamespace *ns, uint8_t *buf, size_t len, in nvme_dif_check() argument
305 status = nvme_check_prinfo(ns, prinfo, slba, *reftag); in nvme_dif_check()
310 if (!(ns->id_ns.dps & NVME_ID_NS_DPS_FIRST_EIGHT)) { in nvme_dif_check()
311 pil = ns->lbaf.ms - nvme_pi_tuple_size(ns); in nvme_dif_check()
314 trace_pci_nvme_dif_check(prinfo, ns->lbasz + pil); in nvme_dif_check()
316 for (bufp = buf; bufp < end; bufp += ns->lbasz, mbuf += ns->lbaf.ms) { in nvme_dif_check()
318 status = nvme_dif_prchk(ns, dif, bufp, mbuf, pil, prinfo, apptag, in nvme_dif_check()
331 g_autofree uint8_t *zeroes = g_malloc0(ns->lbasz); in nvme_dif_check()
333 if (memcmp(bufp, zeroes, ns->lbasz) == 0) { in nvme_dif_check()
334 memset(mbuf + pil, 0xff, nvme_pi_tuple_size(ns)); in nvme_dif_check()
341 if (NVME_ID_NS_DPS_TYPE(ns->id_ns.dps) != NVME_ID_NS_DPS_TYPE_3) { in nvme_dif_check()
349 uint16_t nvme_dif_mangle_mdata(NvmeNamespace *ns, uint8_t *mbuf, size_t mlen, in nvme_dif_mangle_mdata() argument
352 BlockBackend *blk = ns->blkconf.blk; in nvme_dif_mangle_mdata()
355 int64_t moffset = 0, offset = nvme_l2b(ns, slba); in nvme_dif_mangle_mdata()
359 int64_t bytes = (mlen / ns->lbaf.ms) << ns->lbaf.ds; in nvme_dif_mangle_mdata()
365 if (!(ns->id_ns.dps & NVME_ID_NS_DPS_FIRST_EIGHT)) { in nvme_dif_mangle_mdata()
366 pil = ns->lbaf.ms - nvme_pi_tuple_size(ns); in nvme_dif_mangle_mdata()
388 mlen = (pnum >> ns->lbaf.ds) * ns->lbaf.ms; in nvme_dif_mangle_mdata()
391 for (; mbufp < end; mbufp += ns->lbaf.ms) { in nvme_dif_mangle_mdata()
392 memset(mbufp + pil, 0xff, nvme_pi_tuple_size(ns)); in nvme_dif_mangle_mdata()
396 moffset += (pnum >> ns->lbaf.ds) * ns->lbaf.ms; in nvme_dif_mangle_mdata()
407 NvmeNamespace *ns = req->ns; in nvme_dif_rw_cb() local
408 BlockBackend *blk = ns->blkconf.blk; in nvme_dif_rw_cb()
427 NvmeNamespace *ns = req->ns; in nvme_dif_rw_check_cb() local
447 status = nvme_dif_mangle_mdata(ns, ctx->mdata.bounce, ctx->mdata.iov.size, in nvme_dif_rw_check_cb()
454 status = nvme_dif_check(ns, ctx->data.bounce, ctx->data.iov.size, in nvme_dif_rw_check_cb()
469 if (prinfo & NVME_PRINFO_PRACT && ns->lbaf.ms == nvme_pi_tuple_size(ns)) { in nvme_dif_rw_check_cb()
487 NvmeNamespace *ns = req->ns; in nvme_dif_rw_mdata_in_cb() local
491 size_t mlen = nvme_m2b(ns, nlb); in nvme_dif_rw_mdata_in_cb()
492 uint64_t offset = nvme_moff(ns, slba); in nvme_dif_rw_mdata_in_cb()
493 BlockBackend *blk = ns->blkconf.blk; in nvme_dif_rw_mdata_in_cb()
518 NvmeNamespace *ns = req->ns; in nvme_dif_rw_mdata_out_cb() local
521 uint64_t offset = nvme_moff(ns, slba); in nvme_dif_rw_mdata_out_cb()
522 BlockBackend *blk = ns->blkconf.blk; in nvme_dif_rw_mdata_out_cb()
541 NvmeNamespace *ns = req->ns; in nvme_dif_rw() local
542 BlockBackend *blk = ns->blkconf.blk; in nvme_dif_rw()
546 size_t len = nvme_l2b(ns, nlb); in nvme_dif_rw()
547 size_t mlen = nvme_m2b(ns, nlb); in nvme_dif_rw()
549 int64_t offset = nvme_l2b(ns, slba); in nvme_dif_rw()
576 int16_t pil = ns->lbaf.ms - nvme_pi_tuple_size(ns); in nvme_dif_rw()
588 if (ns->id_ns.dps & NVME_ID_NS_DPS_FIRST_EIGHT) { in nvme_dif_rw()
592 for (; mbuf < end; mbuf += ns->lbaf.ms) { in nvme_dif_rw()
595 switch (ns->pif) { in nvme_dif_rw()
619 switch (NVME_ID_NS_DPS_TYPE(ns->id_ns.dps)) { in nvme_dif_rw()
632 if (nvme_ns_ext(ns) && !(pract && ns->lbaf.ms == nvme_pi_tuple_size(ns))) { in nvme_dif_rw()
650 req->aiocb = blk_aio_preadv(ns->blkconf.blk, offset, &ctx->data.iov, 0, in nvme_dif_rw()
666 if (!(pract && ns->lbaf.ms == nvme_pi_tuple_size(ns))) { in nvme_dif_rw()
674 status = nvme_check_prinfo(ns, prinfo, slba, reftag); in nvme_dif_rw()
681 nvme_dif_pract_generate_dif(ns, ctx->data.bounce, ctx->data.iov.size, in nvme_dif_rw()
685 status = nvme_dif_check(ns, ctx->data.bounce, ctx->data.iov.size, in nvme_dif_rw()
696 req->aiocb = blk_aio_pwritev(ns->blkconf.blk, offset, &ctx->data.iov, 0, in nvme_dif_rw()