1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
/*
*
* Copyright (c) 2009, Microsoft Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307 USA.
*
* Authors:
* Haiyang Zhang <haiyangz@microsoft.com>
* Hank Janssen <hjanssen@microsoft.com>
*
*/
#include <linux/kernel.h>
#include <linux/mm.h>
#include "osd.h"
#include "VmbusPrivate.h"
static int IVmbusChannelOpen(struct hv_device *device, u32 SendBufferSize,
u32 RecvRingBufferSize, void *UserData,
u32 UserDataLen,
VMBUS_CHANNEL_CALLBACK ChannelCallback,
void *Context)
{
return VmbusChannelOpen(device->context, SendBufferSize,
RecvRingBufferSize, UserData, UserDataLen,
ChannelCallback, Context);
}
static void IVmbusChannelClose(struct hv_device *device)
{
VmbusChannelClose(device->context);
}
static int IVmbusChannelSendPacket(struct hv_device *device, const void *Buffer,
u32 BufferLen, u64 RequestId, u32 Type,
u32 Flags)
{
return VmbusChannelSendPacket(device->context, Buffer, BufferLen,
RequestId, Type, Flags);
}
static int IVmbusChannelSendPacketPageBuffer(struct hv_device *device,
struct hv_page_buffer PageBuffers[],
u32 PageCount, void *Buffer,
u32 BufferLen, u64 RequestId)
{
return VmbusChannelSendPacketPageBuffer(device->context, PageBuffers,
PageCount, Buffer, BufferLen,
RequestId);
}
static int IVmbusChannelSendPacketMultiPageBuffer(struct hv_device *device,
struct hv_multipage_buffer *MultiPageBuffer,
void *Buffer, u32 BufferLen, u64 RequestId)
{
return VmbusChannelSendPacketMultiPageBuffer(device->context,
MultiPageBuffer, Buffer,
BufferLen, RequestId);
}
static int IVmbusChannelRecvPacket(struct hv_device *device, void *Buffer,
u32 BufferLen, u32 *BufferActualLen,
u64 *RequestId)
{
return VmbusChannelRecvPacket(device->context, Buffer, BufferLen,
BufferActualLen, RequestId);
}
static int IVmbusChannelRecvPacketRaw(struct hv_device *device, void *Buffer,
u32 BufferLen, u32 *BufferActualLen,
u64 *RequestId)
{
return VmbusChannelRecvPacketRaw(device->context, Buffer, BufferLen,
BufferActualLen, RequestId);
}
static int IVmbusChannelEstablishGpadl(struct hv_device *device, void *Buffer,
u32 BufferLen, u32 *GpadlHandle)
{
return VmbusChannelEstablishGpadl(device->context, Buffer, BufferLen,
GpadlHandle);
}
static int IVmbusChannelTeardownGpadl(struct hv_device *device, u32 GpadlHandle)
{
return VmbusChannelTeardownGpadl(device->context, GpadlHandle);
}
void GetChannelInterface(struct vmbus_channel_interface *iface)
{
iface->Open = IVmbusChannelOpen;
iface->Close = IVmbusChannelClose;
iface->SendPacket = IVmbusChannelSendPacket;
iface->SendPacketPageBuffer = IVmbusChannelSendPacketPageBuffer;
iface->SendPacketMultiPageBuffer =
IVmbusChannelSendPacketMultiPageBuffer;
iface->RecvPacket = IVmbusChannelRecvPacket;
iface->RecvPacketRaw = IVmbusChannelRecvPacketRaw;
iface->EstablishGpadl = IVmbusChannelEstablishGpadl;
iface->TeardownGpadl = IVmbusChannelTeardownGpadl;
iface->GetInfo = GetChannelInfo;
}
void GetChannelInfo(struct hv_device *device, struct hv_device_info *info)
{
struct vmbus_channel_debug_info debugInfo;
if (!device->context)
return;
VmbusChannelGetDebugInfo(device->context, &debugInfo);
info->ChannelId = debugInfo.RelId;
info->ChannelState = debugInfo.State;
memcpy(&info->ChannelType, &debugInfo.InterfaceType,
sizeof(struct hv_guid));
memcpy(&info->ChannelInstance, &debugInfo.InterfaceInstance,
sizeof(struct hv_guid));
info->MonitorId = debugInfo.MonitorId;
info->ServerMonitorPending = debugInfo.ServerMonitorPending;
info->ServerMonitorLatency = debugInfo.ServerMonitorLatency;
info->ServerMonitorConnectionId = debugInfo.ServerMonitorConnectionId;
info->ClientMonitorPending = debugInfo.ClientMonitorPending;
info->ClientMonitorLatency = debugInfo.ClientMonitorLatency;
info->ClientMonitorConnectionId = debugInfo.ClientMonitorConnectionId;
info->Inbound.InterruptMask = debugInfo.Inbound.CurrentInterruptMask;
info->Inbound.ReadIndex = debugInfo.Inbound.CurrentReadIndex;
info->Inbound.WriteIndex = debugInfo.Inbound.CurrentWriteIndex;
info->Inbound.BytesAvailToRead = debugInfo.Inbound.BytesAvailToRead;
info->Inbound.BytesAvailToWrite = debugInfo.Inbound.BytesAvailToWrite;
info->Outbound.InterruptMask = debugInfo.Outbound.CurrentInterruptMask;
info->Outbound.ReadIndex = debugInfo.Outbound.CurrentReadIndex;
info->Outbound.WriteIndex = debugInfo.Outbound.CurrentWriteIndex;
info->Outbound.BytesAvailToRead = debugInfo.Outbound.BytesAvailToRead;
info->Outbound.BytesAvailToWrite = debugInfo.Outbound.BytesAvailToWrite;
}
|