Merge tag 'pull-ppc-20220526' of https://gitlab.com/danielhb/qemu into staging
[qemu.git] / hw / rdma / vmw / pvrdma_dev_ring.h
1 /*
2 * QEMU VMWARE paravirtual RDMA ring utilities
3 *
4 * Copyright (C) 2018 Oracle
5 * Copyright (C) 2018 Red Hat Inc
6 *
7 * Authors:
8 * Yuval Shaia <yuval.shaia@oracle.com>
9 * Marcel Apfelbaum <marcel@redhat.com>
10 *
11 * This work is licensed under the terms of the GNU GPL, version 2 or later.
12 * See the COPYING file in the top-level directory.
13 *
14 */
15
16 #ifndef PVRDMA_DEV_RING_H
17 #define PVRDMA_DEV_RING_H
18
19
20 #define MAX_RING_NAME_SZ 32
21
22 typedef struct PvrdmaRingState {
23 int prod_tail; /* producer tail */
24 int cons_head; /* consumer head */
25 } PvrdmaRingState;
26
27 typedef struct PvrdmaRing {
28 char name[MAX_RING_NAME_SZ];
29 PCIDevice *dev;
30 uint32_t max_elems;
31 size_t elem_sz;
32 PvrdmaRingState *ring_state; /* used only for unmap */
33 int npages;
34 void **pages;
35 } PvrdmaRing;
36
37 int pvrdma_ring_init(PvrdmaRing *ring, const char *name, PCIDevice *dev,
38 PvrdmaRingState *ring_state, uint32_t max_elems,
39 size_t elem_sz, dma_addr_t *tbl, uint32_t npages);
40 void *pvrdma_ring_next_elem_read(PvrdmaRing *ring);
41 void pvrdma_ring_read_inc(PvrdmaRing *ring);
42 void *pvrdma_ring_next_elem_write(PvrdmaRing *ring);
43 void pvrdma_ring_write_inc(PvrdmaRing *ring);
44 void pvrdma_ring_free(PvrdmaRing *ring);
45
46 #endif