]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/staging/hv/RingBuffer.h
Staging: hv: Remove C99 comments
[mirror_ubuntu-bionic-kernel.git] / drivers / staging / hv / RingBuffer.h
CommitLineData
3e7ee490
HJ
1/*
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 _RING_BUFFER_H_
26#define _RING_BUFFER_H_
27
09d50ff8 28#include "include/osd.h"
3e7ee490
HJ
29
30typedef struct _SG_BUFFER_LIST {
8282c400 31 void * Data;
4d643114 32 u32 Length;
3e7ee490
HJ
33} SG_BUFFER_LIST;
34
35typedef struct _RING_BUFFER {
454f18a9
BP
36 volatile u32 WriteIndex; /* Offset in bytes from the start of ring data below */
37 volatile u32 ReadIndex; /* Offset in bytes from the start of ring data below */
3e7ee490 38
4d643114 39 volatile u32 InterruptMask;
454f18a9
BP
40 u8 Reserved[4084]; /* Pad it to PAGE_SIZE so that data starts on page boundary */
41 /* NOTE: The InterruptMask field is used only for channels but since our vmbus connection */
42 /* also uses this data structure and its data starts here, we commented out this field. */
43 /* volatile u32 InterruptMask; */
44 /* Ring data starts here + RingDataStartOffset !!! DO NOT place any fields below this !!! */
5654e932 45 u8 Buffer[0];
b211a955 46} __attribute__((packed)) RING_BUFFER;
3e7ee490
HJ
47
48typedef struct _RING_BUFFER_INFO {
49 RING_BUFFER* RingBuffer;
454f18a9 50 u32 RingSize; /* Include the shared header */
a98f96ee 51 spinlock_t ring_lock;
3e7ee490 52
454f18a9 53 u32 RingDataSize; /* < ringSize */
4d643114 54 u32 RingDataStartOffset;
3e7ee490
HJ
55
56} RING_BUFFER_INFO;
57
58
59typedef struct _RING_BUFFER_DEBUG_INFO {
4d643114
GKH
60 u32 CurrentInterruptMask;
61 u32 CurrentReadIndex;
62 u32 CurrentWriteIndex;
63 u32 BytesAvailToRead;
64 u32 BytesAvailToWrite;
3e7ee490
HJ
65}RING_BUFFER_DEBUG_INFO;
66
67
454f18a9
BP
68
69/* Interface */
70
3e7ee490 71
2be1301b 72static int
3e7ee490
HJ
73RingBufferInit(
74 RING_BUFFER_INFO *RingInfo,
8282c400 75 void * Buffer,
4d643114 76 u32 BufferLen
3e7ee490
HJ
77 );
78
2be1301b 79static void
3e7ee490
HJ
80RingBufferCleanup(
81 RING_BUFFER_INFO *RingInfo
82 );
83
2be1301b 84static int
3e7ee490
HJ
85RingBufferWrite(
86 RING_BUFFER_INFO *RingInfo,
87 SG_BUFFER_LIST SgBuffers[],
4d643114 88 u32 SgBufferCount
3e7ee490
HJ
89 );
90
2be1301b 91static int
3e7ee490
HJ
92RingBufferPeek(
93 RING_BUFFER_INFO *RingInfo,
8282c400 94 void * Buffer,
4d643114 95 u32 BufferLen
3e7ee490
HJ
96 );
97
2be1301b 98static int
3e7ee490
HJ
99RingBufferRead(
100 RING_BUFFER_INFO *RingInfo,
8282c400 101 void * Buffer,
4d643114
GKH
102 u32 BufferLen,
103 u32 Offset
3e7ee490
HJ
104 );
105
4d643114 106static u32
3e7ee490
HJ
107GetRingBufferInterruptMask(
108 RING_BUFFER_INFO *RingInfo
109 );
110
2be1301b 111static void
3e7ee490
HJ
112DumpRingInfo(
113 RING_BUFFER_INFO* RingInfo,
114 char *Prefix
115 );
116
2be1301b 117static void
3e7ee490
HJ
118RingBufferGetDebugInfo(
119 RING_BUFFER_INFO *RingInfo,
120 RING_BUFFER_DEBUG_INFO *DebugInfo
121 );
122
454f18a9 123#endif /* _RING_BUFFER_H_ */