]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/staging/hv/ring_buffer.h
Staging: hv: Get rid of vmbus_cleanup() function
[mirror_ubuntu-artful-kernel.git] / drivers / staging / hv / ring_buffer.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
b219b3f7 28#include <linux/scatterlist.h>
3e7ee490 29
4a1b3acc 30struct hv_ring_buffer {
3523a805 31 /* Offset in bytes from the start of ring data below */
82f8bd40 32 volatile u32 write_index;
3523a805
GKH
33
34 /* Offset in bytes from the start of ring data below */
82f8bd40 35 volatile u32 read_index;
3e7ee490 36
82f8bd40 37 volatile u32 interrupt_mask;
3523a805
GKH
38
39 /* Pad it to PAGE_SIZE so that data starts on page boundary */
82f8bd40 40 u8 reserved[4084];
3523a805
GKH
41
42 /* NOTE:
82f8bd40 43 * The interrupt_mask field is used only for channels but since our
3523a805
GKH
44 * vmbus connection also uses this data structure and its data starts
45 * here, we commented out this field.
46 */
454f18a9 47 /* volatile u32 InterruptMask; */
3523a805
GKH
48
49 /*
50 * Ring data starts here + RingDataStartOffset
51 * !!! DO NOT place any fields below this !!!
52 */
82f8bd40 53 u8 buffer[0];
3c4a9413 54} __packed;
3e7ee490 55
8a0e1c55 56struct hv_ring_buffer_info {
82f8bd40
HZ
57 struct hv_ring_buffer *ring_buffer;
58 u32 ring_size; /* Include the shared header */
a98f96ee 59 spinlock_t ring_lock;
3e7ee490 60
82f8bd40
HZ
61 u32 ring_datasize; /* < ring_size */
62 u32 ring_data_startoffset;
8a0e1c55 63};
3e7ee490 64
80682b7a 65struct hv_ring_buffer_debug_info {
82f8bd40
HZ
66 u32 current_interrupt_mask;
67 u32 current_read_index;
68 u32 current_write_index;
69 u32 bytes_avail_toread;
70 u32 bytes_avail_towrite;
80682b7a 71};
3e7ee490
HJ
72
73
454f18a9
BP
74
75/* Interface */
76
3e7ee490 77
1ac58644 78int ringbuffer_init(struct hv_ring_buffer_info *ring_info, void *buffer,
fc8c72eb 79 u32 buflen);
3523a805 80
1ac58644 81void ringbuffer_cleanup(struct hv_ring_buffer_info *ring_info);
3523a805 82
1ac58644 83int ringbuffer_write(struct hv_ring_buffer_info *ring_info,
3523a805
GKH
84 struct scatterlist *sglist,
85 u32 sgcount);
86
1ac58644 87int ringbuffer_peek(struct hv_ring_buffer_info *ring_info, void *buffer,
fc8c72eb 88 u32 buflen);
3523a805 89
1ac58644 90int ringbuffer_read(struct hv_ring_buffer_info *ring_info,
fc8c72eb
HZ
91 void *buffer,
92 u32 buflen,
93 u32 offset);
3523a805 94
1ac58644 95u32 get_ringbuffer_interrupt_mask(struct hv_ring_buffer_info *ring_info);
3523a805 96
1ac58644 97void dump_ring_info(struct hv_ring_buffer_info *ring_info, char *prefix);
3523a805 98
1ac58644 99void ringbuffer_get_debuginfo(struct hv_ring_buffer_info *ring_info,
80682b7a 100 struct hv_ring_buffer_debug_info *debug_info);
3e7ee490 101
454f18a9 102#endif /* _RING_BUFFER_H_ */