wlan_ptt_sock_svc.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Copyright (c) 2012-2017 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. #ifdef PTT_SOCK_SVC_ENABLE
  88. int ptt_sock_activate_svc(void);
  89. void ptt_sock_deactivate_svc(void);
  90. int ptt_sock_send_msg_to_app(tAniHdr *wmsg, int radio, int src_mod, int pid);
  91. #else
  92. static inline int ptt_sock_activate_svc(void) { return 0; }
  93. static inline void ptt_sock_deactivate_svc(void) { return; }
  94. static inline int ptt_sock_send_msg_to_app(tAniHdr *wmsg, int radio,
  95. int src_mod, int pid)
  96. {
  97. return 0;
  98. }
  99. #endif
  100. /*
  101. * Format of message exchanged between the PTT Socket App in userspace and the
  102. * WLAN Driver, in either direction. Each msg will begin with this header and
  103. * will followed by the Quarky message
  104. */
  105. struct sAniAppRegReq {
  106. tAniNlModTypes type; /* module id */
  107. int pid; /* process id */
  108. };
  109. /**
  110. * struct sptt_app_reg_req - PTT register request structure
  111. * @radio: Radio ID
  112. * @wmsg: ANI header
  113. *
  114. * payload structure received as nl data from PTT app/user space
  115. */
  116. struct sptt_app_reg_req {
  117. int radio;
  118. tAniHdr wmsg;
  119. };
  120. struct sAniNlAppRegRsp {
  121. tAniHdr wniHdr; /* Generic WNI msg header */
  122. struct sAniAppRegReq regReq; /* The original request msg */
  123. int ret; /* Return code */
  124. };
  125. #endif