cvp_vm_msgq.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* SPDX-License-Identifier: GPL-2.0-only
  2. *
  3. * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef _CVP_VM_MSGQ_H_
  6. #define _CVP_VM_MSGQ_H_
  7. #include <linux/types.h>
  8. #include <linux/gunyah/gh_msgq.h>
  9. #include <linux/gunyah/gh_rm_drv.h>
  10. #include "cvp_comm_def.h"
  11. #define MAX_CVP_IPC_LEN 16
  12. enum CVP_IPC_MSG_TYPE {
  13. REQUEST_SESS_CTRL = 0,
  14. RELEASE_SESS_CTRL = 1,
  15. REQUEST_EVA_RESET = 2,
  16. RECLAIM_SESS_CTRL = 3, /* Only PVM can reclaim sesession control */
  17. CVP_MAX_IPC_CMD = 4,
  18. };
  19. struct cvp_ipc_msg {
  20. /* type format:
  21. * bit 31: 0->PVM initiated; 1->TVM initiated
  22. * bit 2~0: CVP_IPC_MSG_TYPE
  23. */
  24. uint32_t type;
  25. uint32_t ver;
  26. uint32_t len;
  27. uint32_t resv;
  28. uint32_t data[MAX_CVP_IPC_LEN];
  29. };
  30. struct cvp_gh_msgq_config {
  31. int peer_id;
  32. int label;
  33. void *handle;
  34. struct notifier_block rm_nb;
  35. };
  36. struct cvp_msgq_ops;
  37. struct cvp_msgq_drv {
  38. struct mutex ipc_lock; /* Mutex for sending MSG */
  39. struct cvp_gh_msgq_config config;
  40. struct task_struct *receiver_thread;
  41. struct completion completions[CVP_MAX_IPC_CMD + 1];
  42. /*
  43. * pending_local_cmd: the command is being processed locally.
  44. * The command is a request sent from remote VM
  45. */
  46. struct cvp_ipc_msg pending_local_cmd;
  47. /*
  48. * pending_remote_rsp: the command is being processing remotely.
  49. * The command is a request sent by local VM
  50. */
  51. struct cvp_ipc_msg pending_remote_rsp;
  52. struct cvp_msgq_ops *ops;
  53. };
  54. struct cvp_msgq_ops {
  55. int (*msgq_init)(struct cvp_msgq_drv *msgq_drv);
  56. int (*msgq_send)(struct cvp_msgq_drv *msgq_drv, void *msg,
  57. size_t msg_size);
  58. int (*msgq_receive)(struct cvp_msgq_drv *msgq_drv);
  59. int (*msgq_deinit)(struct cvp_msgq_drv *msgq_drv);
  60. };
  61. extern struct cvp_msgq_drv cvp_ipc_msgq;
  62. #endif