wlan_ptt_sock_svc.h 5.0 KB

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