blob: 2fa28259ed0e6b0f30f1f61aa3d6e92f72cf95c4 [file] [log] [blame]
Hank Janssen3e7ee492009-07-13 16:02:34 -07001/*
2 *
3 * Copyright (c) 2009, Microsoft Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 * Place - Suite 330, Boston, MA 02111-1307 USA.
17 *
18 * Authors:
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
21 *
22 */
23
24
25#ifndef _CHANNEL_H_
26#define _CHANNEL_H_
27
Hank Janssen3e7ee492009-07-13 16:02:34 -070028#include "ChannelMgmt.h"
29
Greg Kroah-Hartman8dc0a062009-08-27 16:02:36 -070030/* The format must be the same as struct vmdata_gpa_direct */
Bill Pemberton0cf4fa82009-07-27 16:47:39 -040031struct VMBUS_CHANNEL_PACKET_PAGE_BUFFER {
Greg Kroah-Hartman46a05252009-08-17 17:21:31 -070032 u16 Type;
33 u16 DataOffset8;
34 u16 Length8;
35 u16 Flags;
36 u64 TransactionId;
37 u32 Reserved;
38 u32 RangeCount;
Greg Kroah-Hartmanee3d7dd2009-08-20 12:17:36 -070039 struct hv_page_buffer Range[MAX_PAGE_BUFFER_COUNT];
Greg Kroah-Hartman46a05252009-08-17 17:21:31 -070040} __attribute__((packed));
Hank Janssen3e7ee492009-07-13 16:02:34 -070041
Greg Kroah-Hartman8dc0a062009-08-27 16:02:36 -070042/* The format must be the same as struct vmdata_gpa_direct */
Bill Pemberton3fcc5232009-07-27 16:47:40 -040043struct VMBUS_CHANNEL_PACKET_MULITPAGE_BUFFER {
Greg Kroah-Hartman46a05252009-08-17 17:21:31 -070044 u16 Type;
45 u16 DataOffset8;
46 u16 Length8;
47 u16 Flags;
48 u64 TransactionId;
49 u32 Reserved;
50 u32 RangeCount; /* Always 1 in this case */
Greg Kroah-Hartmanee3d7dd2009-08-20 12:17:36 -070051 struct hv_multipage_buffer Range;
Greg Kroah-Hartman46a05252009-08-17 17:21:31 -070052} __attribute__((packed));
Hank Janssen3e7ee492009-07-13 16:02:34 -070053
Bill Pemberton454f18a2009-07-27 16:47:24 -040054
Greg Kroah-Hartmanaded71652009-08-18 15:21:19 -070055extern int VmbusChannelOpen(struct vmbus_channel *channel,
Greg Kroah-Hartman46a05252009-08-17 17:21:31 -070056 u32 SendRingBufferSize,
57 u32 RecvRingBufferSize,
58 void *UserData,
59 u32 UserDataLen,
60 PFN_CHANNEL_CALLBACK pfnOnChannelCallback,
61 void *Context);
Bill Pemberton454f18a2009-07-27 16:47:24 -040062
Greg Kroah-Hartmanaded71652009-08-18 15:21:19 -070063extern void VmbusChannelClose(struct vmbus_channel *channel);
Hank Janssen3e7ee492009-07-13 16:02:34 -070064
Greg Kroah-Hartmanaded71652009-08-18 15:21:19 -070065extern int VmbusChannelSendPacket(struct vmbus_channel *channel,
Greg Kroah-Hartman46a05252009-08-17 17:21:31 -070066 const void *Buffer,
67 u32 BufferLen,
68 u64 RequestId,
Greg Kroah-Hartman8dc0a062009-08-27 16:02:36 -070069 enum vmbus_packet_type Type,
Greg Kroah-Hartman46a05252009-08-17 17:21:31 -070070 u32 Flags);
Hank Janssen3e7ee492009-07-13 16:02:34 -070071
Greg Kroah-Hartmanaded71652009-08-18 15:21:19 -070072extern int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *channel,
Greg Kroah-Hartmanee3d7dd2009-08-20 12:17:36 -070073 struct hv_page_buffer PageBuffers[],
Greg Kroah-Hartman46a05252009-08-17 17:21:31 -070074 u32 PageCount,
75 void *Buffer,
76 u32 BufferLen,
77 u64 RequestId);
Hank Janssen3e7ee492009-07-13 16:02:34 -070078
Greg Kroah-Hartmanaded71652009-08-18 15:21:19 -070079extern int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *channel,
Greg Kroah-Hartmanee3d7dd2009-08-20 12:17:36 -070080 struct hv_multipage_buffer *mpb,
Greg Kroah-Hartman46a05252009-08-17 17:21:31 -070081 void *Buffer,
82 u32 BufferLen,
83 u64 RequestId);
Hank Janssen3e7ee492009-07-13 16:02:34 -070084
Greg Kroah-Hartmanaded71652009-08-18 15:21:19 -070085extern int VmbusChannelEstablishGpadl(struct vmbus_channel *channel,
Greg Kroah-Hartman46a05252009-08-17 17:21:31 -070086 void *Kbuffer,
87 u32 Size,
88 u32 *GpadlHandle);
Hank Janssen3e7ee492009-07-13 16:02:34 -070089
Greg Kroah-Hartmanaded71652009-08-18 15:21:19 -070090extern int VmbusChannelTeardownGpadl(struct vmbus_channel *channel,
Greg Kroah-Hartman46a05252009-08-17 17:21:31 -070091 u32 GpadlHandle);
Hank Janssen3e7ee492009-07-13 16:02:34 -070092
Greg Kroah-Hartmanaded71652009-08-18 15:21:19 -070093extern int VmbusChannelRecvPacket(struct vmbus_channel *channel,
Greg Kroah-Hartman46a05252009-08-17 17:21:31 -070094 void *Buffer,
95 u32 BufferLen,
96 u32 *BufferActualLen,
97 u64 *RequestId);
Hank Janssen3e7ee492009-07-13 16:02:34 -070098
Greg Kroah-Hartmanaded71652009-08-18 15:21:19 -070099extern int VmbusChannelRecvPacketRaw(struct vmbus_channel *channel,
Greg Kroah-Hartman46a05252009-08-17 17:21:31 -0700100 void *Buffer,
101 u32 BufferLen,
102 u32 *BufferActualLen,
103 u64 *RequestId);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700104
Greg Kroah-Hartmanaded71652009-08-18 15:21:19 -0700105extern void VmbusChannelOnChannelEvent(struct vmbus_channel *channel);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700106
Greg Kroah-Hartmanaded71652009-08-18 15:21:19 -0700107extern void VmbusChannelGetDebugInfo(struct vmbus_channel *channel,
108 struct vmbus_channel_debug_info *debug);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700109
Greg Kroah-Hartman46a05252009-08-17 17:21:31 -0700110extern void VmbusChannelOnTimer(unsigned long data);
Hank Janssen3e7ee492009-07-13 16:02:34 -0700111
Bill Pemberton454f18a2009-07-27 16:47:24 -0400112#endif /* _CHANNEL_H_ */