Commit 71fb90eb authored by Keith Busch's avatar Keith Busch Committed by Jens Axboe

nvme: provide num dword helper

Various nvme commands use a zeroes based number of dwords field. Create
a helper function to convert byte lengths to this format.
Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
Reviewed-by: default avatarChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 54840bed
...@@ -530,7 +530,7 @@ static int nvme_get_stream_params(struct nvme_ctrl *ctrl, ...@@ -530,7 +530,7 @@ static int nvme_get_stream_params(struct nvme_ctrl *ctrl,
c.directive.opcode = nvme_admin_directive_recv; c.directive.opcode = nvme_admin_directive_recv;
c.directive.nsid = cpu_to_le32(nsid); c.directive.nsid = cpu_to_le32(nsid);
c.directive.numd = cpu_to_le32((sizeof(*s) >> 2) - 1); c.directive.numd = cpu_to_le32(nvme_bytes_to_numd(sizeof(*s)));
c.directive.doper = NVME_DIR_RCV_ST_OP_PARAM; c.directive.doper = NVME_DIR_RCV_ST_OP_PARAM;
c.directive.dtype = NVME_DIR_STREAMS; c.directive.dtype = NVME_DIR_STREAMS;
...@@ -2746,7 +2746,7 @@ int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, ...@@ -2746,7 +2746,7 @@ int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp,
void *log, size_t size, u64 offset) void *log, size_t size, u64 offset)
{ {
struct nvme_command c = { }; struct nvme_command c = { };
unsigned long dwlen = size / 4 - 1; u32 dwlen = nvme_bytes_to_numd(size);
c.get_log_page.opcode = nvme_admin_get_log_page; c.get_log_page.opcode = nvme_admin_get_log_page;
c.get_log_page.nsid = cpu_to_le32(nsid); c.get_log_page.nsid = cpu_to_le32(nsid);
......
...@@ -449,6 +449,14 @@ static inline sector_t nvme_lba_to_sect(struct nvme_ns *ns, u64 lba) ...@@ -449,6 +449,14 @@ static inline sector_t nvme_lba_to_sect(struct nvme_ns *ns, u64 lba)
return lba << (ns->lba_shift - SECTOR_SHIFT); return lba << (ns->lba_shift - SECTOR_SHIFT);
} }
/*
* Convert byte length to nvme's 0-based num dwords
*/
static inline u32 nvme_bytes_to_numd(size_t len)
{
return (len >> 2) - 1;
}
static inline void nvme_end_request(struct request *req, __le16 status, static inline void nvme_end_request(struct request *req, __le16 status,
union nvme_result result) union nvme_result result)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment