aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/nvme-core.c
diff options
context:
space:
mode:
authorVishal Verma <vishal.l.verma@intel.com>2013-03-04 20:40:58 -0500
committerMatthew Wilcox <matthew.r.wilcox@intel.com>2013-03-28 14:50:49 -0400
commit5d0f6131a79adfa1fb51309c5f81a2a4ef879dd4 (patch)
tree746ea0e412541fc7c0cd5212cdd903f46e02c4c3 /drivers/block/nvme-core.c
parentf8ebf8409abfdaeeb8c847381629a2a8b8e3d816 (diff)
NVMe: Add nvme-scsi.c
Translates SCSI commands in SG_IO ioctl to NVMe commands. Uses the scsi-nvme translation spec from nvmexpress.org as reference. Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
Diffstat (limited to 'drivers/block/nvme-core.c')
-rw-r--r--drivers/block/nvme-core.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index d0cfb85d5582..a89f7dbefba0 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -39,7 +39,7 @@
39#include <linux/sched.h> 39#include <linux/sched.h>
40#include <linux/slab.h> 40#include <linux/slab.h>
41#include <linux/types.h> 41#include <linux/types.h>
42 42#include <scsi/sg.h>
43#include <asm-generic/io-64-nonatomic-lo-hi.h> 43#include <asm-generic/io-64-nonatomic-lo-hi.h>
44 44
45#define NVME_Q_DEPTH 1024 45#define NVME_Q_DEPTH 1024
@@ -224,12 +224,12 @@ static void *cancel_cmdid(struct nvme_queue *nvmeq, int cmdid,
224 return ctx; 224 return ctx;
225} 225}
226 226
227static struct nvme_queue *get_nvmeq(struct nvme_dev *dev) 227struct nvme_queue *get_nvmeq(struct nvme_dev *dev)
228{ 228{
229 return dev->queues[get_cpu() + 1]; 229 return dev->queues[get_cpu() + 1];
230} 230}
231 231
232static void put_nvmeq(struct nvme_queue *nvmeq) 232void put_nvmeq(struct nvme_queue *nvmeq)
233{ 233{
234 put_cpu(); 234 put_cpu();
235} 235}
@@ -290,7 +290,7 @@ nvme_alloc_iod(unsigned nseg, unsigned nbytes, gfp_t gfp)
290 return iod; 290 return iod;
291} 291}
292 292
293static void nvme_free_iod(struct nvme_dev *dev, struct nvme_iod *iod) 293void nvme_free_iod(struct nvme_dev *dev, struct nvme_iod *iod)
294{ 294{
295 const int last_prp = PAGE_SIZE / 8 - 1; 295 const int last_prp = PAGE_SIZE / 8 - 1;
296 int i; 296 int i;
@@ -339,9 +339,8 @@ static void bio_completion(struct nvme_dev *dev, void *ctx,
339} 339}
340 340
341/* length is in bytes. gfp flags indicates whether we may sleep. */ 341/* length is in bytes. gfp flags indicates whether we may sleep. */
342static int nvme_setup_prps(struct nvme_dev *dev, 342int nvme_setup_prps(struct nvme_dev *dev, struct nvme_common_command *cmd,
343 struct nvme_common_command *cmd, struct nvme_iod *iod, 343 struct nvme_iod *iod, int total_len, gfp_t gfp)
344 int total_len, gfp_t gfp)
345{ 344{
346 struct dma_pool *pool; 345 struct dma_pool *pool;
347 int length = total_len; 346 int length = total_len;
@@ -512,7 +511,7 @@ static int nvme_submit_flush(struct nvme_queue *nvmeq, struct nvme_ns *ns,
512 return 0; 511 return 0;
513} 512}
514 513
515static int nvme_submit_flush_data(struct nvme_queue *nvmeq, struct nvme_ns *ns) 514int nvme_submit_flush_data(struct nvme_queue *nvmeq, struct nvme_ns *ns)
516{ 515{
517 int cmdid = alloc_cmdid(nvmeq, (void *)CMD_CTX_FLUSH, 516 int cmdid = alloc_cmdid(nvmeq, (void *)CMD_CTX_FLUSH,
518 special_completion, NVME_IO_TIMEOUT); 517 special_completion, NVME_IO_TIMEOUT);
@@ -715,8 +714,8 @@ static void sync_completion(struct nvme_dev *dev, void *ctx,
715 * Returns 0 on success. If the result is negative, it's a Linux error code; 714 * Returns 0 on success. If the result is negative, it's a Linux error code;
716 * if the result is positive, it's an NVM Express status code 715 * if the result is positive, it's an NVM Express status code
717 */ 716 */
718static int nvme_submit_sync_cmd(struct nvme_queue *nvmeq, 717int nvme_submit_sync_cmd(struct nvme_queue *nvmeq, struct nvme_command *cmd,
719 struct nvme_command *cmd, u32 *result, unsigned timeout) 718 u32 *result, unsigned timeout)
720{ 719{
721 int cmdid; 720 int cmdid;
722 struct sync_cmd_info cmdinfo; 721 struct sync_cmd_info cmdinfo;
@@ -745,7 +744,7 @@ static int nvme_submit_sync_cmd(struct nvme_queue *nvmeq,
745 return cmdinfo.status; 744 return cmdinfo.status;
746} 745}
747 746
748static int nvme_submit_admin_cmd(struct nvme_dev *dev, struct nvme_command *cmd, 747int nvme_submit_admin_cmd(struct nvme_dev *dev, struct nvme_command *cmd,
749 u32 *result) 748 u32 *result)
750{ 749{
751 return nvme_submit_sync_cmd(dev->queues[0], cmd, result, ADMIN_TIMEOUT); 750 return nvme_submit_sync_cmd(dev->queues[0], cmd, result, ADMIN_TIMEOUT);
@@ -818,7 +817,7 @@ static int adapter_delete_sq(struct nvme_dev *dev, u16 sqid)
818 return adapter_delete_queue(dev, nvme_admin_delete_sq, sqid); 817 return adapter_delete_queue(dev, nvme_admin_delete_sq, sqid);
819} 818}
820 819
821static int nvme_identify(struct nvme_dev *dev, unsigned nsid, unsigned cns, 820int nvme_identify(struct nvme_dev *dev, unsigned nsid, unsigned cns,
822 dma_addr_t dma_addr) 821 dma_addr_t dma_addr)
823{ 822{
824 struct nvme_command c; 823 struct nvme_command c;
@@ -832,7 +831,7 @@ static int nvme_identify(struct nvme_dev *dev, unsigned nsid, unsigned cns,
832 return nvme_submit_admin_cmd(dev, &c, NULL); 831 return nvme_submit_admin_cmd(dev, &c, NULL);
833} 832}
834 833
835static int nvme_get_features(struct nvme_dev *dev, unsigned fid, unsigned nsid, 834int nvme_get_features(struct nvme_dev *dev, unsigned fid, unsigned nsid,
836 dma_addr_t dma_addr, u32 *result) 835 dma_addr_t dma_addr, u32 *result)
837{ 836{
838 struct nvme_command c; 837 struct nvme_command c;
@@ -846,8 +845,8 @@ static int nvme_get_features(struct nvme_dev *dev, unsigned fid, unsigned nsid,
846 return nvme_submit_admin_cmd(dev, &c, result); 845 return nvme_submit_admin_cmd(dev, &c, result);
847} 846}
848 847
849static int nvme_set_features(struct nvme_dev *dev, unsigned fid, 848int nvme_set_features(struct nvme_dev *dev, unsigned fid, unsigned dword11,
850 unsigned dword11, dma_addr_t dma_addr, u32 *result) 849 dma_addr_t dma_addr, u32 *result)
851{ 850{
852 struct nvme_command c; 851 struct nvme_command c;
853 852
@@ -1065,7 +1064,7 @@ static int nvme_configure_admin_queue(struct nvme_dev *dev)
1065 return result; 1064 return result;
1066} 1065}
1067 1066
1068static struct nvme_iod *nvme_map_user_pages(struct nvme_dev *dev, int write, 1067struct nvme_iod *nvme_map_user_pages(struct nvme_dev *dev, int write,
1069 unsigned long addr, unsigned length) 1068 unsigned long addr, unsigned length)
1070{ 1069{
1071 int i, err, count, nents, offset; 1070 int i, err, count, nents, offset;
@@ -1121,7 +1120,7 @@ static struct nvme_iod *nvme_map_user_pages(struct nvme_dev *dev, int write,
1121 return ERR_PTR(err); 1120 return ERR_PTR(err);
1122} 1121}
1123 1122
1124static void nvme_unmap_user_pages(struct nvme_dev *dev, int write, 1123void nvme_unmap_user_pages(struct nvme_dev *dev, int write,
1125 struct nvme_iod *iod) 1124 struct nvme_iod *iod)
1126{ 1125{
1127 int i; 1126 int i;
@@ -1257,6 +1256,10 @@ static int nvme_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
1257 return nvme_user_admin_cmd(ns->dev, (void __user *)arg); 1256 return nvme_user_admin_cmd(ns->dev, (void __user *)arg);
1258 case NVME_IOCTL_SUBMIT_IO: 1257 case NVME_IOCTL_SUBMIT_IO:
1259 return nvme_submit_io(ns, (void __user *)arg); 1258 return nvme_submit_io(ns, (void __user *)arg);
1259 case SG_GET_VERSION_NUM:
1260 return nvme_sg_get_version_num((void __user *)arg);
1261 case SG_IO:
1262 return nvme_sg_io(ns, (void __user *)arg);
1260 default: 1263 default:
1261 return -ENOTTY; 1264 return -ENOTTY;
1262 } 1265 }