mmrm_vm_msgq.h 2.5 KB

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