summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2018-02-01 19:07:21 +0000
committermav <mav@FreeBSD.org>2018-02-01 19:07:21 +0000
commit94bf160b70d468c1af238fb1ec973b1216a59def (patch)
tree09132aeca64cec243c8df57e4f9b091194651480
parenta250f84db852d6a625c0e7a49cf3965a0444c91e (diff)
downloadFreeBSD-src-94bf160b70d468c1af238fb1ec973b1216a59def.zip
FreeBSD-src-94bf160b70d468c1af238fb1ec973b1216a59def.tar.gz
MFC r324644 (by imp):
Closer examination shows that nvme and CAM both normally zero-fill allocations (for req and ccb, which ultimately contain the nvme_cmd). As such, we can micro-optimize these routines. Add a comment to this effect, and bzero the ccb used to make the requests for the nda dump rotuine so it more closely matches a ccb allocated with xpt_get_ccb().
-rw-r--r--sys/cam/nvme/nvme_da.c2
-rw-r--r--sys/dev/nvme/nvme.h14
2 files changed, 8 insertions, 8 deletions
diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c
index 7791369..652f330 100644
--- a/sys/cam/nvme/nvme_da.c
+++ b/sys/cam/nvme/nvme_da.c
@@ -398,6 +398,8 @@ ndadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t len
return (ENXIO);
}
+ /* xpt_get_ccb returns a zero'd allocation for the ccb, mimic that here */
+ memset(&nvmeio, 0, sizeof(nvmeio));
if (length > 0) {
xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
ccb.ccb_h.ccb_state = NDA_CCB_DUMP;
diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h
index 3e6a424..aff4fbc 100644
--- a/sys/dev/nvme/nvme.h
+++ b/sys/dev/nvme/nvme.h
@@ -1068,7 +1068,12 @@ uint32_t nvme_ns_get_stripesize(struct nvme_namespace *ns);
int nvme_ns_bio_process(struct nvme_namespace *ns, struct bio *bp,
nvme_cb_fn_t cb_fn);
-/* Command building helper functions -- shared with CAM */
+/*
+ * Command building helper functions -- shared with CAM
+ * These functions assume allocator zeros out cmd structure
+ * CAM's xpt_get_ccb and the request allocator for nvme both
+ * do zero'd allocations.
+ */
static inline
void nvme_ns_flush_cmd(struct nvme_command *cmd, uint32_t nsid)
{
@@ -1082,17 +1087,10 @@ void nvme_ns_rw_cmd(struct nvme_command *cmd, uint32_t rwcmd, uint32_t nsid,
uint64_t lba, uint32_t count)
{
cmd->opc = rwcmd;
- cmd->fuse = 0;
- cmd->rsvd1 = 0;
cmd->nsid = nsid;
- cmd->rsvd2 = 0;
- cmd->rsvd3 = 0;
cmd->cdw10 = lba & 0xffffffffu;
cmd->cdw11 = lba >> 32;
cmd->cdw12 = count-1;
- cmd->cdw13 = 0;
- cmd->cdw14 = 0;
- cmd->cdw15 = 0;
}
static inline
OpenPOWER on IntegriCloud