Commit ddccd952 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by Martin K. Petersen

scsi: storvsc: use in place iterator function

In 4.12-rc1, new functions were added to support iterating over elements
in the vmbus event ring. This patch uses them to simplify the ring
buffer handling in virtual SCSI driver as well.
Signed-off-by: default avatarStephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 4bbd458e
......@@ -1149,13 +1149,9 @@ static void storvsc_on_receive(struct storvsc_device *stor_device,
static void storvsc_on_channel_callback(void *context)
{
struct vmbus_channel *channel = (struct vmbus_channel *)context;
const struct vmpacket_descriptor *desc;
struct hv_device *device;
struct storvsc_device *stor_device;
u32 bytes_recvd;
u64 request_id;
unsigned char packet[ALIGN(sizeof(struct vstor_packet), 8)];
struct storvsc_cmd_request *request;
int ret;
if (channel->primary_channel != NULL)
device = channel->primary_channel->device_obj;
......@@ -1166,32 +1162,22 @@ static void storvsc_on_channel_callback(void *context)
if (!stor_device)
return;
do {
ret = vmbus_recvpacket(channel, packet,
ALIGN((sizeof(struct vstor_packet) -
vmscsi_size_delta), 8),
&bytes_recvd, &request_id);
if (ret == 0 && bytes_recvd > 0) {
request = (struct storvsc_cmd_request *)
(unsigned long)request_id;
if ((request == &stor_device->init_request) ||
(request == &stor_device->reset_request)) {
memcpy(&request->vstor_packet, packet,
(sizeof(struct vstor_packet) -
vmscsi_size_delta));
complete(&request->wait_event);
} else {
storvsc_on_receive(stor_device,
(struct vstor_packet *)packet,
request);
}
foreach_vmbus_pkt(desc, channel) {
void *packet = hv_pkt_data(desc);
struct storvsc_cmd_request *request;
request = (struct storvsc_cmd_request *)
((unsigned long)desc->trans_id);
if (request == &stor_device->init_request ||
request == &stor_device->reset_request) {
memcpy(&request->vstor_packet, packet,
(sizeof(struct vstor_packet) - vmscsi_size_delta));
complete(&request->wait_event);
} else {
break;
storvsc_on_receive(stor_device, packet, request);
}
} while (1);
}
}
static int storvsc_connect_to_vsp(struct hv_device *device, u32 ring_size,
......
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