hcall_virtio.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2021, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __GH_HCALL_VIRTIO_H
  6. #define __GH_HCALL_VIRTIO_H
  7. #include <linux/err.h>
  8. #include <linux/types.h>
  9. #include <linux/gunyah/hcall_common.h>
  10. #include <linux/gunyah/gh_common.h>
  11. #include <asm/gunyah/hcall.h>
  12. static inline int
  13. gh_hcall_virtio_mmio_backend_assert_virq(gh_capid_t capid, u64 int_status)
  14. {
  15. struct gh_hcall_resp _resp = {0};
  16. return _gh_hcall(0x604e, (struct gh_hcall_args){ capid, int_status, 0 },
  17. &_resp);
  18. }
  19. static inline int
  20. gh_hcall_virtio_mmio_backend_set_dev_features(gh_capid_t capid,
  21. u64 features_sel, u64 features)
  22. {
  23. struct gh_hcall_resp _resp = {0};
  24. return _gh_hcall(0x604f,
  25. (struct gh_hcall_args){ capid, features_sel, features,
  26. 0 },
  27. &_resp);
  28. }
  29. static inline int
  30. gh_hcall_virtio_mmio_backend_set_queue_num_max(gh_capid_t capid,
  31. u64 queue_sel, u64 queue_num_max)
  32. {
  33. struct gh_hcall_resp _resp = {0};
  34. return _gh_hcall(0x6050,
  35. (struct gh_hcall_args){ capid, queue_sel,
  36. queue_num_max, 0 },
  37. &_resp);
  38. }
  39. static inline int
  40. gh_hcall_virtio_mmio_backend_get_drv_features(gh_capid_t capid,
  41. u64 features_sel, u64 *features)
  42. {
  43. int ret;
  44. struct gh_hcall_resp _resp = {0};
  45. ret = _gh_hcall(0x6051,
  46. (struct gh_hcall_args){ capid, features_sel, 0},
  47. &_resp);
  48. if (!ret && features)
  49. *features = _resp.resp1;
  50. return ret;
  51. }
  52. struct gh_hcall_virtio_queue_info {
  53. u64 queue_num;
  54. u64 queue_ready;
  55. u64 queue_desc;
  56. u64 queue_driver;
  57. u64 queue_device;
  58. };
  59. static inline int
  60. gh_hcall_virtio_mmio_backend_get_queue_info(gh_capid_t capid,
  61. u64 queue_sel, struct gh_hcall_virtio_queue_info *queue_info)
  62. {
  63. int ret;
  64. struct gh_hcall_resp _resp = {0};
  65. ret = _gh_hcall(0x6052,
  66. (struct gh_hcall_args){ capid, queue_sel, 0},
  67. &_resp);
  68. if (!ret && queue_info) {
  69. queue_info->queue_num = _resp.resp1;
  70. queue_info->queue_ready = _resp.resp2;
  71. queue_info->queue_desc = _resp.resp3;
  72. queue_info->queue_driver = _resp.resp4;
  73. queue_info->queue_device = _resp.resp5;
  74. }
  75. return ret;
  76. }
  77. static inline int
  78. gh_hcall_virtio_mmio_backend_get_event(gh_capid_t capid,
  79. u64 *event_data, u64 *event)
  80. {
  81. int ret;
  82. struct gh_hcall_resp _resp = {0};
  83. ret = _gh_hcall(0x6053,
  84. (struct gh_hcall_args){ capid, 0},
  85. &_resp);
  86. if (!ret && event_data)
  87. *event_data = _resp.resp1;
  88. if (!ret && event)
  89. *event = _resp.resp2;
  90. return ret;
  91. }
  92. static inline int
  93. gh_hcall_virtio_mmio_backend_ack_reset(gh_capid_t capid)
  94. {
  95. struct gh_hcall_resp _resp = {0};
  96. return _gh_hcall(0x6054,
  97. (struct gh_hcall_args){ capid, 0},
  98. &_resp);
  99. }
  100. #endif