cvp_vm_msgq.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #define CVP_VM_RESPONSE_TIMEOUT 300
  13. #define CVP_IPC_MSG_TYPE_DIR_CHECK 0x10000000 /* direction check */
  14. #define CVP_IPC_MSG_TYPE_ACT_CHECK 0x00000011 /* action check */
  15. enum CVP_IPC_MSG_TYPE {
  16. REQUEST_SESS_CTRL = 1,
  17. RELEASE_SESS_CTRL = 2,
  18. REQUEST_EVA_RESET = 3,
  19. RECLAIM_SESS_CTRL = 4, /* Only PVM can reclaim sesession control */
  20. CVP_MAX_IPC_CMD = 5,
  21. };
  22. struct cvp_ipc_msg {
  23. /* type format:
  24. * bit 31: 0->Initiated command; 1->Response to remote command
  25. * bit 2~0: CVP_IPC_MSG_TYPE
  26. */
  27. uint32_t type;
  28. uint32_t ver;
  29. uint32_t len;
  30. uint32_t resv;
  31. uint32_t data[MAX_CVP_IPC_LEN];
  32. };
  33. struct cvp_gh_msgq_config {
  34. int peer_id;
  35. int label;
  36. void *handle;
  37. struct notifier_block rm_nb;
  38. };
  39. struct cvp_msgq_ops;
  40. struct cvp_msgq_drv {
  41. struct mutex ipc_lock; /* Mutex for sending MSG */
  42. struct cvp_gh_msgq_config config;
  43. struct task_struct *receiver_thread;
  44. struct completion completions[CVP_MAX_IPC_CMD + 1];
  45. /*
  46. * pending_local_cmd: the command is being processed locally.
  47. * The command is a request sent from remote VM
  48. */
  49. struct cvp_ipc_msg pending_local_cmd;
  50. /*
  51. * pending_remote_rsp: the command is being processing remotely.
  52. * The command is a request sent by local VM
  53. */
  54. struct cvp_ipc_msg pending_remote_rsp;
  55. struct cvp_msgq_ops *ops;
  56. };
  57. struct cvp_msgq_ops {
  58. int (*msgq_init)(struct cvp_msgq_drv *msgq_drv);
  59. int (*msgq_send)(struct cvp_msgq_drv *msgq_drv, void *msg,
  60. size_t msg_size);
  61. int (*msgq_receive)(struct cvp_msgq_drv *msgq_drv);
  62. int (*msgq_deinit)(struct cvp_msgq_drv *msgq_drv);
  63. };
  64. extern struct cvp_msgq_drv cvp_ipc_msgq;
  65. #endif