Commit 61eaffc9 authored by K. Y. Srinivasan's avatar K. Y. Srinivasan Committed by Greg Kroah-Hartman

Staging: hv: storvsc: Consolidate the request structure

Consolidate the request structure by getting rid of struct hv_storvsc_request.
Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 410c52ed
...@@ -236,17 +236,20 @@ enum storvsc_request_type { ...@@ -236,17 +236,20 @@ enum storvsc_request_type {
#define SRB_STATUS_ERROR 0x04 #define SRB_STATUS_ERROR 0x04
struct storvsc_cmd_request {
struct list_head entry;
struct scsi_cmnd *cmd;
unsigned int bounce_sgl_count;
struct scatterlist *bounce_sgl;
struct hv_storvsc_request {
struct hv_device *device; struct hv_device *device;
/* Synchronize the request/response if needed */ /* Synchronize the request/response if needed */
struct completion wait_event; struct completion wait_event;
unsigned char *sense_buffer; unsigned char *sense_buffer;
struct storvsc_cmd_request *cmd;
struct hv_multipage_buffer data_buffer; struct hv_multipage_buffer data_buffer;
struct vstor_packet vstor_packet; struct vstor_packet vstor_packet;
}; };
...@@ -272,8 +275,8 @@ struct storvsc_device { ...@@ -272,8 +275,8 @@ struct storvsc_device {
unsigned char target_id; unsigned char target_id;
/* Used for vsc/vsp channel reset process */ /* Used for vsc/vsp channel reset process */
struct hv_storvsc_request init_request; struct storvsc_cmd_request init_request;
struct hv_storvsc_request reset_request; struct storvsc_cmd_request reset_request;
}; };
struct stor_mem_pools { struct stor_mem_pools {
...@@ -288,16 +291,6 @@ struct hv_host_device { ...@@ -288,16 +291,6 @@ struct hv_host_device {
unsigned char target; unsigned char target;
}; };
struct storvsc_cmd_request {
struct list_head entry;
struct scsi_cmnd *cmd;
unsigned int bounce_sgl_count;
struct scatterlist *bounce_sgl;
struct hv_storvsc_request request;
};
struct storvsc_scan_work { struct storvsc_scan_work {
struct work_struct work; struct work_struct work;
struct Scsi_Host *host; struct Scsi_Host *host;
...@@ -628,7 +621,7 @@ static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl, ...@@ -628,7 +621,7 @@ static unsigned int copy_to_bounce_buffer(struct scatterlist *orig_sgl,
static int storvsc_channel_init(struct hv_device *device) static int storvsc_channel_init(struct hv_device *device)
{ {
struct storvsc_device *stor_device; struct storvsc_device *stor_device;
struct hv_storvsc_request *request; struct storvsc_cmd_request *request;
struct vstor_packet *vstor_packet; struct vstor_packet *vstor_packet;
int ret, t; int ret, t;
...@@ -643,7 +636,7 @@ static int storvsc_channel_init(struct hv_device *device) ...@@ -643,7 +636,7 @@ static int storvsc_channel_init(struct hv_device *device)
* Now, initiate the vsc/vsp initialization protocol on the open * Now, initiate the vsc/vsp initialization protocol on the open
* channel * channel
*/ */
memset(request, 0, sizeof(struct hv_storvsc_request)); memset(request, 0, sizeof(struct storvsc_cmd_request));
init_completion(&request->wait_event); init_completion(&request->wait_event);
vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION; vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION;
vstor_packet->flags = REQUEST_COMPLETION_FLAG; vstor_packet->flags = REQUEST_COMPLETION_FLAG;
...@@ -757,9 +750,8 @@ static int storvsc_channel_init(struct hv_device *device) ...@@ -757,9 +750,8 @@ static int storvsc_channel_init(struct hv_device *device)
} }
static void storvsc_command_completion(struct hv_storvsc_request *request) static void storvsc_command_completion(struct storvsc_cmd_request *cmd_request)
{ {
struct storvsc_cmd_request *cmd_request = request->cmd;
struct scsi_cmnd *scmnd = cmd_request->cmd; struct scsi_cmnd *scmnd = cmd_request->cmd;
struct hv_host_device *host_dev = shost_priv(scmnd->device->host); struct hv_host_device *host_dev = shost_priv(scmnd->device->host);
void (*scsi_done_fn)(struct scsi_cmnd *); void (*scsi_done_fn)(struct scsi_cmnd *);
...@@ -768,7 +760,7 @@ static void storvsc_command_completion(struct hv_storvsc_request *request) ...@@ -768,7 +760,7 @@ static void storvsc_command_completion(struct hv_storvsc_request *request)
struct storvsc_scan_work *wrk; struct storvsc_scan_work *wrk;
struct stor_mem_pools *memp = scmnd->device->hostdata; struct stor_mem_pools *memp = scmnd->device->hostdata;
vm_srb = &request->vstor_packet.vm_srb; vm_srb = &cmd_request->vstor_packet.vm_srb;
if (cmd_request->bounce_sgl_count) { if (cmd_request->bounce_sgl_count) {
if (vm_srb->data_in == READ_TYPE) if (vm_srb->data_in == READ_TYPE)
copy_from_bounce_buffer(scsi_sglist(scmnd), copy_from_bounce_buffer(scsi_sglist(scmnd),
...@@ -819,7 +811,7 @@ static void storvsc_command_completion(struct hv_storvsc_request *request) ...@@ -819,7 +811,7 @@ static void storvsc_command_completion(struct hv_storvsc_request *request)
} }
scsi_set_resid(scmnd, scsi_set_resid(scmnd,
request->data_buffer.len - cmd_request->data_buffer.len -
vm_srb->data_transfer_length); vm_srb->data_transfer_length);
scsi_done_fn = scmnd->scsi_done; scsi_done_fn = scmnd->scsi_done;
...@@ -834,7 +826,7 @@ static void storvsc_command_completion(struct hv_storvsc_request *request) ...@@ -834,7 +826,7 @@ static void storvsc_command_completion(struct hv_storvsc_request *request)
static void storvsc_on_io_completion(struct hv_device *device, static void storvsc_on_io_completion(struct hv_device *device,
struct vstor_packet *vstor_packet, struct vstor_packet *vstor_packet,
struct hv_storvsc_request *request) struct storvsc_cmd_request *request)
{ {
struct storvsc_device *stor_device; struct storvsc_device *stor_device;
struct vstor_packet *stor_pkt; struct vstor_packet *stor_pkt;
...@@ -906,7 +898,7 @@ static void storvsc_on_io_completion(struct hv_device *device, ...@@ -906,7 +898,7 @@ static void storvsc_on_io_completion(struct hv_device *device,
static void storvsc_on_receive(struct hv_device *device, static void storvsc_on_receive(struct hv_device *device,
struct vstor_packet *vstor_packet, struct vstor_packet *vstor_packet,
struct hv_storvsc_request *request) struct storvsc_cmd_request *request)
{ {
struct storvsc_scan_work *work; struct storvsc_scan_work *work;
struct storvsc_device *stor_device; struct storvsc_device *stor_device;
...@@ -940,7 +932,7 @@ static void storvsc_on_channel_callback(void *context) ...@@ -940,7 +932,7 @@ static void storvsc_on_channel_callback(void *context)
u32 bytes_recvd; u32 bytes_recvd;
u64 request_id; u64 request_id;
unsigned char packet[ALIGN(sizeof(struct vstor_packet), 8)]; unsigned char packet[ALIGN(sizeof(struct vstor_packet), 8)];
struct hv_storvsc_request *request; struct storvsc_cmd_request *request;
int ret; int ret;
...@@ -954,7 +946,7 @@ static void storvsc_on_channel_callback(void *context) ...@@ -954,7 +946,7 @@ static void storvsc_on_channel_callback(void *context)
&bytes_recvd, &request_id); &bytes_recvd, &request_id);
if (ret == 0 && bytes_recvd > 0) { if (ret == 0 && bytes_recvd > 0) {
request = (struct hv_storvsc_request *) request = (struct storvsc_cmd_request *)
(unsigned long)request_id; (unsigned long)request_id;
if ((request == &stor_device->init_request) || if ((request == &stor_device->init_request) ||
...@@ -1036,7 +1028,7 @@ static int storvsc_dev_remove(struct hv_device *device) ...@@ -1036,7 +1028,7 @@ static int storvsc_dev_remove(struct hv_device *device)
} }
static int storvsc_do_io(struct hv_device *device, static int storvsc_do_io(struct hv_device *device,
struct hv_storvsc_request *request) struct storvsc_cmd_request *request)
{ {
struct storvsc_device *stor_device; struct storvsc_device *stor_device;
struct vstor_packet *vstor_packet; struct vstor_packet *vstor_packet;
...@@ -1174,7 +1166,7 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd) ...@@ -1174,7 +1166,7 @@ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
struct hv_device *device = host_dev->dev; struct hv_device *device = host_dev->dev;
struct storvsc_device *stor_device; struct storvsc_device *stor_device;
struct hv_storvsc_request *request; struct storvsc_cmd_request *request;
struct vstor_packet *vstor_packet; struct vstor_packet *vstor_packet;
int ret, t; int ret, t;
...@@ -1238,7 +1230,6 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd) ...@@ -1238,7 +1230,6 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
int ret; int ret;
struct hv_host_device *host_dev = shost_priv(host); struct hv_host_device *host_dev = shost_priv(host);
struct hv_device *dev = host_dev->dev; struct hv_device *dev = host_dev->dev;
struct hv_storvsc_request *request;
struct storvsc_cmd_request *cmd_request; struct storvsc_cmd_request *cmd_request;
unsigned int request_size = 0; unsigned int request_size = 0;
int i; int i;
...@@ -1271,8 +1262,7 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd) ...@@ -1271,8 +1262,7 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
scmnd->host_scribble = (unsigned char *)cmd_request; scmnd->host_scribble = (unsigned char *)cmd_request;
request = &cmd_request->request; vm_srb = &cmd_request->vstor_packet.vm_srb;
vm_srb = &request->vstor_packet.vm_srb;
/* Build the SRB */ /* Build the SRB */
...@@ -1288,7 +1278,6 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd) ...@@ -1288,7 +1278,6 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
break; break;
} }
request->cmd = cmd_request;
vm_srb->port_number = host_dev->port; vm_srb->port_number = host_dev->port;
vm_srb->path_id = scmnd->device->channel; vm_srb->path_id = scmnd->device->channel;
...@@ -1299,10 +1288,10 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd) ...@@ -1299,10 +1288,10 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
memcpy(vm_srb->cdb, scmnd->cmnd, vm_srb->cdb_length); memcpy(vm_srb->cdb, scmnd->cmnd, vm_srb->cdb_length);
request->sense_buffer = scmnd->sense_buffer; cmd_request->sense_buffer = scmnd->sense_buffer;
request->data_buffer.len = scsi_bufflen(scmnd); cmd_request->data_buffer.len = scsi_bufflen(scmnd);
if (scsi_sg_count(scmnd)) { if (scsi_sg_count(scmnd)) {
sgl = (struct scatterlist *)scsi_sglist(scmnd); sgl = (struct scatterlist *)scsi_sglist(scmnd);
sg_count = scsi_sg_count(scmnd); sg_count = scsi_sg_count(scmnd);
...@@ -1331,21 +1320,21 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd) ...@@ -1331,21 +1320,21 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
sg_count = cmd_request->bounce_sgl_count; sg_count = cmd_request->bounce_sgl_count;
} }
request->data_buffer.offset = sgl[0].offset; cmd_request->data_buffer.offset = sgl[0].offset;
for (i = 0; i < sg_count; i++) for (i = 0; i < sg_count; i++)
request->data_buffer.pfn_array[i] = cmd_request->data_buffer.pfn_array[i] =
page_to_pfn(sg_page((&sgl[i]))); page_to_pfn(sg_page((&sgl[i])));
} else if (scsi_sglist(scmnd)) { } else if (scsi_sglist(scmnd)) {
request->data_buffer.offset = cmd_request->data_buffer.offset =
virt_to_phys(scsi_sglist(scmnd)) & (PAGE_SIZE-1); virt_to_phys(scsi_sglist(scmnd)) & (PAGE_SIZE-1);
request->data_buffer.pfn_array[0] = cmd_request->data_buffer.pfn_array[0] =
virt_to_phys(scsi_sglist(scmnd)) >> PAGE_SHIFT; virt_to_phys(scsi_sglist(scmnd)) >> PAGE_SHIFT;
} }
/* Invokes the vsc to start an IO */ /* Invokes the vsc to start an IO */
ret = storvsc_do_io(dev, &cmd_request->request); ret = storvsc_do_io(dev, cmd_request);
if (ret == -EAGAIN) { if (ret == -EAGAIN) {
/* no more space */ /* no more space */
......
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