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