mmrm_vm_msgq.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef __MMRM_VM_MSGQ_H__
  6. #define __MMRM_VM_MSGQ_H__
  7. #include <linux/gunyah/gh_msgq.h>
  8. #define MMRM_VM_VER_1 1 // mmrm version, for message valid check
  9. #define MMRM_VM_MAX_PKT_SZ 1024 // mmrm max gunyah packet size
  10. #define MMRM_VM_MSG_STATUS_NOTIFIER 0x01
  11. /**
  12. * mmrm_vm_pkt_type: mmrm transfer type, for message valid check
  13. * @MMRM_VM_TYPE_DATA: request/response data
  14. */
  15. enum mmrm_vm_pkt_type {
  16. MMRM_VM_TYPE_DATA = 1,
  17. };
  18. struct mmrm_vm_driver_data;
  19. /**
  20. * struct mmrm_vm_msg_hdr - mmrm vm packet header
  21. * @version: protocol version
  22. * @type: packet type; one of MMRM_VM_TYPE_* in mmrm_vm_pkt_type
  23. * @flags: Reserved for future use
  24. * @size: length of packet, excluding this header
  25. */
  26. struct mmrm_vm_msg_hdr {
  27. u8 version;
  28. u8 type;
  29. u8 flags;
  30. u8 resv;
  31. u32 size;
  32. };
  33. /**
  34. * mmrm_vm_msg - message that be received.
  35. * @link - list head
  36. * @msg_size - message size
  37. * @msg_buf - message buffer
  38. */
  39. struct mmrm_vm_msg {
  40. struct list_head link;
  41. size_t msg_size;
  42. u8 msg_buf[GH_MSGQ_MAX_MSG_SIZE_BYTES];
  43. };
  44. /**
  45. * mmrm_vm_msgq_info - gunyah info.
  46. * @peer_id: notification callback check if message is from SVM
  47. * @msgq_handle - registered msg queue handle with gunyah api
  48. * @msgq_label - message queue label
  49. * @status: indicate init status
  50. * @pvt_nb - notifier info
  51. */
  52. struct mmrm_vm_gh_msgq_info {
  53. int peer_id;
  54. void *msgq_handle;
  55. int msgq_label;
  56. int status;
  57. struct notifier_block pvt_nb;
  58. };
  59. /**
  60. * struct mmrm_vm_msg_q -- svm mmrm API caller queue that wait for mmrm API return
  61. * @link: list head
  62. * @m_req: request message pointer
  63. * @m_resp: response message buffer pointer
  64. * @complete: sync mmrm API response and caller
  65. */
  66. struct mmrm_vm_msg_q {
  67. struct list_head link;
  68. struct mmrm_vm_request_msg_pkt *m_req;
  69. struct mmrm_vm_response_msg_pkt *m_resp;
  70. struct completion complete;
  71. };
  72. /**
  73. * mmrm_vm_msgq_init - initialize display message queue: both TX and RX
  74. * @mmrm_vm - handle to mmrm_vm_data_priv
  75. */
  76. int mmrm_vm_msgq_init(struct mmrm_vm_driver_data *mmrm_vm);
  77. /**
  78. * mmrm_vm_msgq_deinit - deinitialize display message queue: both TX and RX
  79. * @mmrm_vm - handle to mmrm_vm_data_priv
  80. */
  81. int mmrm_vm_msgq_deinit(struct mmrm_vm_driver_data *mmrm_vm);
  82. /**
  83. * mmrm_vm_msgq_send - send custom messages across VM's
  84. * @mmrm_vm - handle to mmrm_vm_data_priv
  85. * @msg - payload data
  86. * @msg_size - size of the payload_data
  87. */
  88. int mmrm_vm_msgq_send(struct mmrm_vm_driver_data *mmrm_vm, void *msg, size_t msg_size);
  89. #endif // __MMRM_VM_MSGQ_H__