]>
Commit | Line | Data |
---|---|---|
dcbf469a YS |
1 | /* |
2 | * RDMA device: Debug utilities | |
3 | * | |
4 | * Copyright (C) 2018 Oracle | |
5 | * Copyright (C) 2018 Red Hat Inc | |
6 | * | |
7 | * | |
8 | * Authors: | |
9 | * Yuval Shaia <yuval.shaia@oracle.com> | |
10 | * Marcel Apfelbaum <marcel@redhat.com> | |
11 | * | |
12 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | |
13 | * See the COPYING file in the top-level directory. | |
14 | * | |
15 | */ | |
16 | ||
17 | #ifndef RDMA_UTILS_H | |
18 | #define RDMA_UTILS_H | |
19 | ||
4d71b38a | 20 | #include "qemu/error-report.h" |
0efc9511 MT |
21 | #include "hw/pci/pci.h" |
22 | #include "sysemu/dma.h" | |
dcbf469a | 23 | |
4d71b38a YS |
24 | #define rdma_error_report(fmt, ...) \ |
25 | error_report("%s: " fmt, "rdma", ## __VA_ARGS__) | |
26 | #define rdma_warn_report(fmt, ...) \ | |
27 | warn_report("%s: " fmt, "rdma", ## __VA_ARGS__) | |
28 | #define rdma_info_report(fmt, ...) \ | |
29 | info_report("%s: " fmt, "rdma", ## __VA_ARGS__) | |
dcbf469a | 30 | |
bce80086 | 31 | typedef struct RdmaProtectedGQueue { |
b20fc795 | 32 | QemuMutex lock; |
bce80086 MA |
33 | GQueue *list; |
34 | } RdmaProtectedGQueue; | |
b20fc795 | 35 | |
bf441451 YS |
36 | typedef struct RdmaProtectedGSList { |
37 | QemuMutex lock; | |
38 | GSList *list; | |
39 | } RdmaProtectedGSList; | |
40 | ||
ce0a7982 | 41 | void *rdma_pci_dma_map(PCIDevice *dev, dma_addr_t addr, dma_addr_t len); |
dcbf469a | 42 | void rdma_pci_dma_unmap(PCIDevice *dev, void *buffer, dma_addr_t len); |
bce80086 MA |
43 | void rdma_protected_gqueue_init(RdmaProtectedGQueue *list); |
44 | void rdma_protected_gqueue_destroy(RdmaProtectedGQueue *list); | |
45 | void rdma_protected_gqueue_append_int64(RdmaProtectedGQueue *list, | |
46 | int64_t value); | |
47 | int64_t rdma_protected_gqueue_pop_int64(RdmaProtectedGQueue *list); | |
bf441451 YS |
48 | void rdma_protected_gslist_init(RdmaProtectedGSList *list); |
49 | void rdma_protected_gslist_destroy(RdmaProtectedGSList *list); | |
50 | void rdma_protected_gslist_append_int32(RdmaProtectedGSList *list, | |
51 | int32_t value); | |
52 | void rdma_protected_gslist_remove_int32(RdmaProtectedGSList *list, | |
53 | int32_t value); | |
dcbf469a | 54 | |
028c3f93 YS |
55 | static inline void addrconf_addr_eui48(uint8_t *eui, const char *addr) |
56 | { | |
57 | memcpy(eui, addr, 3); | |
58 | eui[3] = 0xFF; | |
59 | eui[4] = 0xFE; | |
60 | memcpy(eui + 5, addr + 3, 3); | |
61 | eui[0] ^= 2; | |
62 | } | |
63 | ||
dcbf469a | 64 | #endif |