nvme_ns_cmd.c (248913) | nvme_ns_cmd.c (248977) |
---|---|
1/*- 2 * Copyright (C) 2012 Intel Corporation 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (C) 2012 Intel Corporation 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/dev/nvme/nvme_ns_cmd.c 248913 2013-03-29 20:34:28Z jimharris $"); | 28__FBSDID("$FreeBSD: head/sys/dev/nvme/nvme_ns_cmd.c 248977 2013-04-01 16:23:34Z jimharris $"); |
29 30#include "nvme_private.h" 31 32int 33nvme_ns_cmd_read(struct nvme_namespace *ns, void *payload, uint64_t lba, 34 uint32_t lba_count, nvme_cb_fn_t cb_fn, void *cb_arg) 35{ 36 struct nvme_request *req; --- 12 unchanged lines hidden (view full) --- 49 cmd->cdw12 = lba_count-1; 50 51 nvme_ctrlr_submit_io_request(ns->ctrlr, req); 52 53 return (0); 54} 55 56int | 29 30#include "nvme_private.h" 31 32int 33nvme_ns_cmd_read(struct nvme_namespace *ns, void *payload, uint64_t lba, 34 uint32_t lba_count, nvme_cb_fn_t cb_fn, void *cb_arg) 35{ 36 struct nvme_request *req; --- 12 unchanged lines hidden (view full) --- 49 cmd->cdw12 = lba_count-1; 50 51 nvme_ctrlr_submit_io_request(ns->ctrlr, req); 52 53 return (0); 54} 55 56int |
57nvme_ns_cmd_read_bio(struct nvme_namespace *ns, struct bio *bp, 58 nvme_cb_fn_t cb_fn, void *cb_arg) 59{ 60 struct nvme_request *req; 61 struct nvme_command *cmd; 62 uint64_t lba; 63 uint64_t lba_count; 64 65 req = nvme_allocate_request_bio(bp, cb_fn, cb_arg); 66 67 if (req == NULL) 68 return (ENOMEM); 69 cmd = &req->cmd; 70 cmd->opc = NVME_OPC_READ; 71 cmd->nsid = ns->id; 72 73 lba = bp->bio_offset / nvme_ns_get_sector_size(ns); 74 lba_count = bp->bio_bcount / nvme_ns_get_sector_size(ns); 75 76 /* TODO: create a read command data structure */ 77 *(uint64_t *)&cmd->cdw10 = lba; 78 cmd->cdw12 = lba_count-1; 79 80 nvme_ctrlr_submit_io_request(ns->ctrlr, req); 81 82 return (0); 83} 84 85int |
|
57nvme_ns_cmd_write(struct nvme_namespace *ns, void *payload, uint64_t lba, 58 uint32_t lba_count, nvme_cb_fn_t cb_fn, void *cb_arg) 59{ 60 struct nvme_request *req; 61 struct nvme_command *cmd; 62 63 req = nvme_allocate_request_vaddr(payload, lba_count*512, cb_fn, 64 cb_arg); --- 10 unchanged lines hidden (view full) --- 75 cmd->cdw12 = lba_count-1; 76 77 nvme_ctrlr_submit_io_request(ns->ctrlr, req); 78 79 return (0); 80} 81 82int | 86nvme_ns_cmd_write(struct nvme_namespace *ns, void *payload, uint64_t lba, 87 uint32_t lba_count, nvme_cb_fn_t cb_fn, void *cb_arg) 88{ 89 struct nvme_request *req; 90 struct nvme_command *cmd; 91 92 req = nvme_allocate_request_vaddr(payload, lba_count*512, cb_fn, 93 cb_arg); --- 10 unchanged lines hidden (view full) --- 104 cmd->cdw12 = lba_count-1; 105 106 nvme_ctrlr_submit_io_request(ns->ctrlr, req); 107 108 return (0); 109} 110 111int |
112nvme_ns_cmd_write_bio(struct nvme_namespace *ns, struct bio *bp, 113 nvme_cb_fn_t cb_fn, void *cb_arg) 114{ 115 struct nvme_request *req; 116 struct nvme_command *cmd; 117 uint64_t lba; 118 uint64_t lba_count; 119 120 req = nvme_allocate_request_bio(bp, cb_fn, cb_arg); 121 122 if (req == NULL) 123 return (ENOMEM); 124 cmd = &req->cmd; 125 cmd->opc = NVME_OPC_WRITE; 126 cmd->nsid = ns->id; 127 128 lba = bp->bio_offset / nvme_ns_get_sector_size(ns); 129 lba_count = bp->bio_bcount / nvme_ns_get_sector_size(ns); 130 131 /* TODO: create a write command data structure */ 132 *(uint64_t *)&cmd->cdw10 = lba; 133 cmd->cdw12 = lba_count-1; 134 135 nvme_ctrlr_submit_io_request(ns->ctrlr, req); 136 137 return (0); 138} 139 140int |
|
83nvme_ns_cmd_deallocate(struct nvme_namespace *ns, void *payload, 84 uint8_t num_ranges, nvme_cb_fn_t cb_fn, void *cb_arg) 85{ 86 struct nvme_request *req; 87 struct nvme_command *cmd; 88 89 req = nvme_allocate_request_vaddr(payload, 90 num_ranges * sizeof(struct nvme_dsm_range), cb_fn, cb_arg); --- 36 unchanged lines hidden --- | 141nvme_ns_cmd_deallocate(struct nvme_namespace *ns, void *payload, 142 uint8_t num_ranges, nvme_cb_fn_t cb_fn, void *cb_arg) 143{ 144 struct nvme_request *req; 145 struct nvme_command *cmd; 146 147 req = nvme_allocate_request_vaddr(payload, 148 num_ranges * sizeof(struct nvme_dsm_range), cb_fn, cb_arg); --- 36 unchanged lines hidden --- |