rdma_utils.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #ifndef RDMA_UTILS_H
  17. #define RDMA_UTILS_H
  18. #include "qemu/error-report.h"
  19. #include "hw/pci/pci.h"
  20. #include "sysemu/dma.h"
  21. #define rdma_error_report(fmt, ...) \
  22. error_report("%s: " fmt, "rdma", ## __VA_ARGS__)
  23. #define rdma_warn_report(fmt, ...) \
  24. warn_report("%s: " fmt, "rdma", ## __VA_ARGS__)
  25. #define rdma_info_report(fmt, ...) \
  26. info_report("%s: " fmt, "rdma", ## __VA_ARGS__)
  27. typedef struct RdmaProtectedQList {
  28. QemuMutex lock;
  29. QList *list;
  30. } RdmaProtectedQList;
  31. typedef struct RdmaProtectedGSList {
  32. QemuMutex lock;
  33. GSList *list;
  34. } RdmaProtectedGSList;
  35. void *rdma_pci_dma_map(PCIDevice *dev, dma_addr_t addr, dma_addr_t plen);
  36. void rdma_pci_dma_unmap(PCIDevice *dev, void *buffer, dma_addr_t len);
  37. void rdma_protected_qlist_init(RdmaProtectedQList *list);
  38. void rdma_protected_qlist_destroy(RdmaProtectedQList *list);
  39. void rdma_protected_qlist_append_int64(RdmaProtectedQList *list, int64_t value);
  40. int64_t rdma_protected_qlist_pop_int64(RdmaProtectedQList *list);
  41. void rdma_protected_gslist_init(RdmaProtectedGSList *list);
  42. void rdma_protected_gslist_destroy(RdmaProtectedGSList *list);
  43. void rdma_protected_gslist_append_int32(RdmaProtectedGSList *list,
  44. int32_t value);
  45. void rdma_protected_gslist_remove_int32(RdmaProtectedGSList *list,
  46. int32_t value);
  47. static inline void addrconf_addr_eui48(uint8_t *eui, const char *addr)
  48. {
  49. memcpy(eui, addr, 3);
  50. eui[3] = 0xFF;
  51. eui[4] = 0xFE;
  52. memcpy(eui + 5, addr + 3, 3);
  53. eui[0] ^= 2;
  54. }
  55. #endif