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