wlan_ptt_sock_svc.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * Copyright (c) 2012-2018,2020 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /******************************************************************************
  19. * wlan_ptt_sock_svc.c
  20. *
  21. ******************************************************************************/
  22. #ifndef PTT_SOCK_SVC_H
  23. #define PTT_SOCK_SVC_H
  24. #include <wlan_nlink_srv.h>
  25. #include <qdf_types.h>
  26. #include <qdf_status.h>
  27. #include <qdf_trace.h>
  28. /*
  29. * Quarky Message Format:
  30. * The following is the messaging protocol between Quarky and PTT Socket App.
  31. * The totalMsgLen is the length from Radio till msgBody. The value of Radio
  32. * is always defaulted to 0. The MsgLen is the length from msgId till msgBody.
  33. * The length of the msgBody varies with respect to the MsgId. Buffer space
  34. * for MsgBody is already allocated in the received buffer. So in case of READ
  35. * we just need to populate the values in the received message and send it
  36. * back
  37. * +------------+-------+-------+--------+-------+---------+
  38. * |TotalMsgLen | Radio | MsgId | MsgLen |Status |MsgBody |
  39. * +------------+-------+-------|--------+-------+---------+
  40. * <------4----><--4---><---2--><---2---><---4--><--------->
  41. */
  42. /* PTT Socket App Message Ids */
  43. #define PTT_MSG_READ_REGISTER 0x3040
  44. #define PTT_MSG_WRITE_REGISTER 0x3041
  45. #define PTT_MSG_READ_MEMORY 0x3044
  46. #define PTT_MSG_WRITE_MEMORY 0x3045
  47. #define PTT_MSG_LOG_DUMP_DBG 0x32A1
  48. #define PTT_MSG_FTM_CMDS_TYPE 0x4040
  49. #define ANI_DRIVER_MSG_START 0x0001
  50. #define ANI_MSG_APP_REG_REQ (ANI_DRIVER_MSG_START + 0)
  51. #define ANI_MSG_APP_REG_RSP (ANI_DRIVER_MSG_START + 1)
  52. #define ANI_MSG_OEM_DATA_REQ (ANI_DRIVER_MSG_START + 2)
  53. #define ANI_MSG_OEM_DATA_RSP (ANI_DRIVER_MSG_START + 3)
  54. #define ANI_MSG_CHANNEL_INFO_REQ (ANI_DRIVER_MSG_START + 4)
  55. #define ANI_MSG_CHANNEL_INFO_RSP (ANI_DRIVER_MSG_START + 5)
  56. #define ANI_MSG_OEM_ERROR (ANI_DRIVER_MSG_START + 6)
  57. #define ANI_MSG_PEER_STATUS_IND (ANI_DRIVER_MSG_START + 7)
  58. #define ANI_MSG_SET_OEM_CAP_REQ (ANI_DRIVER_MSG_START + 8)
  59. #define ANI_MSG_SET_OEM_CAP_RSP (ANI_DRIVER_MSG_START + 9)
  60. #define ANI_MSG_GET_OEM_CAP_REQ (ANI_DRIVER_MSG_START + 10)
  61. #define ANI_MSG_GET_OEM_CAP_RSP (ANI_DRIVER_MSG_START + 11)
  62. #define ANI_MAX_RADIOS 3
  63. #define ANI_NL_MSG_OK 0
  64. #define ANI_NL_MSG_ERROR -1
  65. #define ANI_NL_MSG_OVERHEAD (NLMSG_SPACE(tAniHdr + 4))
  66. /*
  67. * Packet Format for READ_REGISTER & WRITE_REGISTER:
  68. * TotalMsgLen : 4 bytes [value=20 bytes]
  69. * Radio : 4 bytes
  70. * MsgId : 2 bytes
  71. * MsgLen : 2 bytes
  72. * Status : 4 bytes
  73. * Address : 4 bytes
  74. * Payload : 4 bytes
  75. */
  76. /*
  77. * Packet Format for READ_MEMORY & WRITE_MEMORY :
  78. * TotalMsgLen : 4 bytes [value= 20+LEN_PAYLOAD bytes]
  79. * Radio : 4 bytes
  80. * MsgId : 2 bytes
  81. * MsgLen : 2 bytes
  82. * Status : 4 bytes
  83. * Address : 4 bytes
  84. * Length : 4 bytes [LEN_PAYLOAD]
  85. * Payload : LEN_PAYLOAD bytes
  86. */
  87. #if defined(PTT_SOCK_SVC_ENABLE) && defined(CNSS_GENL)
  88. /**
  89. * ptt_sock_activate_svc() - API to register PTT/PUMAC command handlers
  90. *
  91. * API to register the handler for PTT/PUMAC NL messages.
  92. *
  93. * Return: None
  94. */
  95. void ptt_sock_activate_svc(void);
  96. /**
  97. * ptt_sock_deactivate_svc() - API to deregister PTT/PUMAC command handlers
  98. *
  99. * API to deregister the handler for PTT/PUMAC NL messages.
  100. *
  101. * Return: None
  102. */
  103. void ptt_sock_deactivate_svc(void);
  104. #else
  105. static inline void ptt_sock_activate_svc(void)
  106. {
  107. }
  108. static inline void ptt_sock_deactivate_svc(void)
  109. {
  110. }
  111. #endif
  112. int ptt_sock_send_msg_to_app(tAniHdr *wmsg, int radio, int src_mod, int pid);
  113. /*
  114. * Format of message exchanged between the PTT Socket App in userspace and the
  115. * WLAN Driver, in either direction. Each msg will begin with this header and
  116. * will followed by the Quarky message
  117. */
  118. struct sAniAppRegReq {
  119. tAniNlModTypes type; /* module id */
  120. int pid; /* process id */
  121. };
  122. /**
  123. * struct sptt_app_reg_req - PTT register request structure
  124. * @radio: Radio ID
  125. * @wmsg: ANI header
  126. *
  127. * payload structure received as nl data from PTT app/user space
  128. */
  129. struct sptt_app_reg_req {
  130. int radio;
  131. tAniHdr wmsg;
  132. };
  133. struct sAniNlAppRegRsp {
  134. tAniHdr wniHdr; /* Generic WNI msg header */
  135. struct sAniAppRegReq regReq; /* The original request msg */
  136. int ret; /* Return code */
  137. };
  138. #endif