@@ -1044,7 +1044,8 @@ EXPORT_SYMBOL(vmbus_sendpacket);
int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
struct hv_page_buffer pagebuffers[],
u32 pagecount, void *buffer, u32 bufferlen,
- u64 requestid)
+ u64 requestid, u8 io_type,
+ struct hv_bounce_pkt **bounce_pkt)
{
int i;
struct vmbus_channel_packet_page_buffer desc;
@@ -1101,7 +1102,9 @@ EXPORT_SYMBOL_GPL(vmbus_sendpacket_pagebuffer);
int vmbus_sendpacket_mpb_desc(struct vmbus_channel *channel,
struct vmbus_packet_mpb_array *desc,
u32 desc_size,
- void *buffer, u32 bufferlen, u64 requestid)
+ void *buffer, u32 bufferlen, u64 requestid,
+ u32 pfn_count, u8 io_type,
+ struct hv_bounce_pkt **bounce_pkt)
{
u32 packetlen;
u32 packetlen_aligned;
@@ -57,6 +57,18 @@ union hv_monitor_trigger_state {
};
};
+/*
+ * Hyper-V bounce packet. Each in-use bounce packet is mapped to a vmbus
+ * transaction and contains a list of bounce pages for that transaction.
+ */
+struct hv_bounce_pkt {
+ /* Link to the next bounce packet, when it is in the free list */
+ struct list_head link;
+ struct list_head bounce_page_head;
+ u32 flags;
+};
+
+
/*
* All vmbus channels initially start with zero bounce pages and are required
* to set any non-zero size, if needed.
@@ -130,6 +130,7 @@ struct hv_netvsc_packet {
u32 total_bytes;
u32 send_buf_index;
u32 total_data_buflen;
+ struct hv_bounce_pkt *bounce_pkt;
};
#define NETVSC_HASH_KEYLEN 40
@@ -926,14 +926,17 @@ static inline int netvsc_send_pkt(
trace_nvsp_send_pkt(ndev, out_channel, rpkt);
+ packet->bounce_pkt = NULL;
if (packet->page_buf_cnt) {
if (packet->cp_partial)
pb += packet->rmsg_pgcnt;
+ /* The I/O type is always 'write' for netvsc */
ret = vmbus_sendpacket_pagebuffer(out_channel,
pb, packet->page_buf_cnt,
&nvmsg, sizeof(nvmsg),
- req_id);
+ req_id, IO_TYPE_WRITE,
+ &packet->bounce_pkt);
} else {
ret = vmbus_sendpacket(out_channel,
&nvmsg, sizeof(nvmsg),
@@ -31,6 +31,7 @@
#include <scsi/scsi_dbg.h>
#include <scsi/scsi_transport_fc.h>
#include <scsi/scsi_transport.h>
+#include <asm/mshyperv.h>
/*
* All wire protocol details (storage protocol between the guest and the host)
@@ -427,6 +428,7 @@ struct storvsc_cmd_request {
u32 payload_sz;
struct vstor_packet vstor_packet;
+ struct hv_bounce_pkt *bounce_pkt;
};
@@ -1390,7 +1392,8 @@ static struct vmbus_channel *get_og_chn(struct storvsc_device *stor_device,
static int storvsc_do_io(struct hv_device *device,
- struct storvsc_cmd_request *request, u16 q_num)
+ struct storvsc_cmd_request *request, u16 q_num,
+ u32 pfn_count)
{
struct storvsc_device *stor_device;
struct vstor_packet *vstor_packet;
@@ -1493,14 +1496,18 @@ static int storvsc_do_io(struct hv_device *device,
vstor_packet->operation = VSTOR_OPERATION_EXECUTE_SRB;
+ request->bounce_pkt = NULL;
if (request->payload->range.len) {
+ struct vmscsi_request *vm_srb = &request->vstor_packet.vm_srb;
ret = vmbus_sendpacket_mpb_desc(outgoing_channel,
request->payload, request->payload_sz,
vstor_packet,
(sizeof(struct vstor_packet) -
vmscsi_size_delta),
- (unsigned long)request);
+ (unsigned long)request,
+ pfn_count,
+ vm_srb->data_in, &request->bounce_pkt);
} else {
ret = vmbus_sendpacket(outgoing_channel, vstor_packet,
(sizeof(struct vstor_packet) -
@@ -1510,8 +1517,10 @@ static int storvsc_do_io(struct hv_device *device,
VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
}
- if (ret != 0)
+ if (ret != 0) {
+ request->bounce_pkt = NULL;
return ret;
+ }
atomic_inc(&stor_device->num_outstanding_req);
@@ -1825,14 +1834,16 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
cmd_request->payload_sz = payload_sz;
/* Invokes the vsc to start an IO */
- ret = storvsc_do_io(dev, cmd_request, get_cpu());
+ ret = storvsc_do_io(dev, cmd_request, get_cpu(), sg_count);
put_cpu();
- if (ret == -EAGAIN) {
+ if (ret) {
if (payload_sz > sizeof(cmd_request->mpb))
kfree(payload);
/* no more space */
- return SCSI_MLQUEUE_DEVICE_BUSY;
+ if (ret == -EAGAIN || ret == -ENOSPC)
+ return SCSI_MLQUEUE_DEVICE_BUSY;
+ return ret;
}
return 0;
@@ -1184,19 +1184,31 @@ extern int vmbus_sendpacket(struct vmbus_channel *channel,
enum vmbus_packet_type type,
u32 flags);
+#define IO_TYPE_WRITE 0
+#define IO_TYPE_READ 1
+#define IO_TYPE_UNKNOWN 2
+
+struct hv_bounce_pkt;
+
extern int vmbus_sendpacket_pagebuffer(struct vmbus_channel *channel,
struct hv_page_buffer pagebuffers[],
u32 pagecount,
void *buffer,
u32 bufferlen,
- u64 requestid);
+ u64 requestid,
+ u8 io_type,
+ struct hv_bounce_pkt **bounce_pkt);
extern int vmbus_sendpacket_mpb_desc(struct vmbus_channel *channel,
struct vmbus_packet_mpb_array *mpb,
u32 desc_size,
void *buffer,
u32 bufferlen,
- u64 requestid);
+ u64 requestid,
+ u32 pfn_count,
+ u8 io_type,
+ struct hv_bounce_pkt **bounce_pkt);
+
extern int vmbus_establish_gpadl(struct vmbus_channel *channel,
void *kbuffer,