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 /******************************************************************************
20 * wlan_ptt_sock_svc.c
21 *
22 ******************************************************************************/
23 #ifndef PTT_SOCK_SVC_H
24 #define PTT_SOCK_SVC_H
25 #include <wlan_nlink_srv.h>
26 #include <qdf_types.h>
27 #include <qdf_status.h>
28 #include <qdf_trace.h>
29
30 /*
31 * Quarky Message Format:
32 * The following is the messaging protocol between Quarky and PTT Socket App.
33 * The totalMsgLen is the length from Radio till msgBody. The value of Radio
34 * is always defaulted to 0. The MsgLen is the length from msgId till msgBody.
35 * The length of the msgBody varies with respect to the MsgId. Buffer space
36 * for MsgBody is already allocated in the received buffer. So in case of READ
37 * we just need to populate the values in the received message and send it
38 * back
39 * +------------+-------+-------+--------+-------+---------+
40 * |TotalMsgLen | Radio | MsgId | MsgLen |Status |MsgBody |
41 * +------------+-------+-------|--------+-------+---------+
42 * <------4----><--4---><---2--><---2---><---4--><--------->
43 */
44 /* PTT Socket App Message Ids */
45 #define PTT_MSG_READ_REGISTER 0x3040
46 #define PTT_MSG_WRITE_REGISTER 0x3041
47 #define PTT_MSG_READ_MEMORY 0x3044
48 #define PTT_MSG_WRITE_MEMORY 0x3045
49 #define PTT_MSG_LOG_DUMP_DBG 0x32A1
50 #define PTT_MSG_FTM_CMDS_TYPE 0x4040
51 #define ANI_DRIVER_MSG_START 0x0001
52 #define ANI_MSG_APP_REG_REQ (ANI_DRIVER_MSG_START + 0)
53 #define ANI_MSG_APP_REG_RSP (ANI_DRIVER_MSG_START + 1)
54 #define ANI_MSG_OEM_DATA_REQ (ANI_DRIVER_MSG_START + 2)
55 #define ANI_MSG_OEM_DATA_RSP (ANI_DRIVER_MSG_START + 3)
56 #define ANI_MSG_CHANNEL_INFO_REQ (ANI_DRIVER_MSG_START + 4)
57 #define ANI_MSG_CHANNEL_INFO_RSP (ANI_DRIVER_MSG_START + 5)
58 #define ANI_MSG_OEM_ERROR (ANI_DRIVER_MSG_START + 6)
59 #define ANI_MSG_PEER_STATUS_IND (ANI_DRIVER_MSG_START + 7)
60 #define ANI_MSG_SET_OEM_CAP_REQ (ANI_DRIVER_MSG_START + 8)
61 #define ANI_MSG_SET_OEM_CAP_RSP (ANI_DRIVER_MSG_START + 9)
62 #define ANI_MSG_GET_OEM_CAP_REQ (ANI_DRIVER_MSG_START + 10)
63 #define ANI_MSG_GET_OEM_CAP_RSP (ANI_DRIVER_MSG_START + 11)
64
65 #define ANI_MAX_RADIOS 3
66 #define ANI_NL_MSG_OK 0
67 #define ANI_NL_MSG_ERROR -1
68 #define ANI_NL_MSG_OVERHEAD (NLMSG_SPACE(tAniHdr + 4))
69 /*
70 * Packet Format for READ_REGISTER & WRITE_REGISTER:
71 * TotalMsgLen : 4 bytes [value=20 bytes]
72 * Radio : 4 bytes
73 * MsgId : 2 bytes
74 * MsgLen : 2 bytes
75 * Status : 4 bytes
76 * Address : 4 bytes
77 * Payload : 4 bytes
78 */
79 /*
80 * Packet Format for READ_MEMORY & WRITE_MEMORY :
81 * TotalMsgLen : 4 bytes [value= 20+LEN_PAYLOAD bytes]
82 * Radio : 4 bytes
83 * MsgId : 2 bytes
84 * MsgLen : 2 bytes
85 * Status : 4 bytes
86 * Address : 4 bytes
87 * Length : 4 bytes [LEN_PAYLOAD]
88 * Payload : LEN_PAYLOAD bytes
89 */
90 #if defined(PTT_SOCK_SVC_ENABLE) && defined(CNSS_GENL)
91 /**
92 * ptt_sock_activate_svc() - API to register PTT/PUMAC command handlers
93 *
94 * API to register the handler for PTT/PUMAC NL messages.
95 *
96 * Return: None
97 */
98 void ptt_sock_activate_svc(void);
99
100 /**
101 * ptt_sock_deactivate_svc() - API to deregister PTT/PUMAC command handlers
102 *
103 * API to deregister the handler for PTT/PUMAC NL messages.
104 *
105 * Return: None
106 */
107 void ptt_sock_deactivate_svc(void);
108
109 #else
ptt_sock_activate_svc(void)110 static inline void ptt_sock_activate_svc(void)
111 {
112 }
ptt_sock_deactivate_svc(void)113 static inline void ptt_sock_deactivate_svc(void)
114 {
115 }
116 #endif
117
118 int ptt_sock_send_msg_to_app(tAniHdr *wmsg, int radio, int src_mod, int pid);
119 /*
120 * Format of message exchanged between the PTT Socket App in userspace and the
121 * WLAN Driver, in either direction. Each msg will begin with this header and
122 * will followed by the Quarky message
123 */
124 struct sAniAppRegReq {
125 tAniNlModTypes type; /* module id */
126 int pid; /* process id */
127 };
128
129 /**
130 * struct sptt_app_reg_req - PTT register request structure
131 * @radio: Radio ID
132 * @wmsg: ANI header
133 *
134 * payload structure received as nl data from PTT app/user space
135 */
136 struct sptt_app_reg_req {
137 int radio;
138 tAniHdr wmsg;
139 };
140
141 struct sAniNlAppRegRsp {
142 tAniHdr wniHdr; /* Generic WNI msg header */
143 struct sAniAppRegReq regReq; /* The original request msg */
144 int ret; /* Return code */
145 };
146 #endif
147