summaryrefslogtreecommitdiff
path: root/drivers/staging/hv/RingBuffer.h
diff options
context:
space:
mode:
authorHank Janssen <hjanssen@microsoft.com>2009-07-13 23:02:34 (GMT)
committerGreg Kroah-Hartman <gregkh@suse.de>2009-09-15 19:01:43 (GMT)
commit3e7ee4902fe6996048f03433dd111426db3cfa92 (patch)
treec42d158ecca25ddb0b99a400fa2682eeaa0aa82e /drivers/staging/hv/RingBuffer.h
parentab05778195b5cc1e77130424f7f6b6f848a137f1 (diff)
downloadlinux-fsl-qoriq-3e7ee4902fe6996048f03433dd111426db3cfa92.tar.xz
Staging: hv: add the Hyper-V virtual bus
This is the virtual bus that all of the Linux Hyper-V drivers use. Signed-off-by: Hank Janssen <hjanssen@microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/hv/RingBuffer.h')
-rw-r--r--drivers/staging/hv/RingBuffer.h123
1 files changed, 123 insertions, 0 deletions
diff --git a/drivers/staging/hv/RingBuffer.h b/drivers/staging/hv/RingBuffer.h
new file mode 100644
index 0000000..9af5df0
--- /dev/null
+++ b/drivers/staging/hv/RingBuffer.h
@@ -0,0 +1,123 @@
+/*
+ *
+ * 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>
+ *
+ */
+
+
+#ifndef _RING_BUFFER_H_
+#define _RING_BUFFER_H_
+
+#include "osd.h"
+
+typedef struct _SG_BUFFER_LIST {
+ PVOID Data;
+ UINT32 Length;
+} SG_BUFFER_LIST;
+
+typedef struct _RING_BUFFER {
+ volatile UINT32 WriteIndex; // Offset in bytes from the start of ring data below
+ volatile UINT32 ReadIndex; // Offset in bytes from the start of ring data below
+
+ volatile UINT32 InterruptMask;
+ UINT8 Reserved[4084]; // Pad it to PAGE_SIZE so that data starts on page boundary
+ // NOTE: The InterruptMask field is used only for channels but since our vmbus connection
+ // also uses this data structure and its data starts here, we commented out this field.
+ // volatile UINT32 InterruptMask;
+ // Ring data starts here + RingDataStartOffset !!! DO NOT place any fields below this !!!
+ UINT8 Buffer[0];
+} STRUCT_PACKED RING_BUFFER;
+
+typedef struct _RING_BUFFER_INFO {
+ RING_BUFFER* RingBuffer;
+ UINT32 RingSize; // Include the shared header
+ HANDLE RingLock;
+
+ UINT32 RingDataSize; // < ringSize
+ UINT32 RingDataStartOffset;
+
+} RING_BUFFER_INFO;
+
+
+typedef struct _RING_BUFFER_DEBUG_INFO {
+ UINT32 CurrentInterruptMask;
+ UINT32 CurrentReadIndex;
+ UINT32 CurrentWriteIndex;
+ UINT32 BytesAvailToRead;
+ UINT32 BytesAvailToWrite;
+}RING_BUFFER_DEBUG_INFO;
+
+
+//
+// Interface
+//
+
+INTERNAL int
+RingBufferInit(
+ RING_BUFFER_INFO *RingInfo,
+ PVOID Buffer,
+ UINT32 BufferLen
+ );
+
+INTERNAL void
+RingBufferCleanup(
+ RING_BUFFER_INFO *RingInfo
+ );
+
+INTERNAL int
+RingBufferWrite(
+ RING_BUFFER_INFO *RingInfo,
+ SG_BUFFER_LIST SgBuffers[],
+ UINT32 SgBufferCount
+ );
+
+INTERNAL int
+RingBufferPeek(
+ RING_BUFFER_INFO *RingInfo,
+ PVOID Buffer,
+ UINT32 BufferLen
+ );
+
+INTERNAL int
+RingBufferRead(
+ RING_BUFFER_INFO *RingInfo,
+ PVOID Buffer,
+ UINT32 BufferLen,
+ UINT32 Offset
+ );
+
+INTERNAL UINT32
+GetRingBufferInterruptMask(
+ RING_BUFFER_INFO *RingInfo
+ );
+
+INTERNAL void
+DumpRingInfo(
+ RING_BUFFER_INFO* RingInfo,
+ char *Prefix
+ );
+
+INTERNAL void
+RingBufferGetDebugInfo(
+ RING_BUFFER_INFO *RingInfo,
+ RING_BUFFER_DEBUG_INFO *DebugInfo
+ );
+
+#endif // _RING_BUFFER_H_