blob: 0221f36c88e081f0f26dcf803923d89fac73f78b [file] [log] [blame]
nxpandroidc7611652015-09-23 16:42:05 +05301/******************************************************************************
2 *
3 * Copyright (C) 2010-2014 Broadcom Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18
nxpandroidc7611652015-09-23 16:42:05 +053019/******************************************************************************
20 *
21 * This is the private interface file for the NFA P2P.
22 *
23 ******************************************************************************/
24#ifndef NFA_P2P_INT_H
25#define NFA_P2P_INT_H
26
nxf24591c1cbeab2018-02-21 17:32:26 +053027#if (NFA_P2P_INCLUDED == TRUE)
nxpandroidc7611652015-09-23 16:42:05 +053028#include "nfa_dm_int.h"
nxf24591c1cbeab2018-02-21 17:32:26 +053029#include "nfa_p2p_api.h"
nxpandroidc7611652015-09-23 16:42:05 +053030
31/*****************************************************************************
32** Constants and data types
33*****************************************************************************/
nxpandroidc7611652015-09-23 16:42:05 +053034
35/* NFA P2P LLCP link state */
nxpandroid8f6d0532017-07-12 18:25:30 +053036enum {
37 NFA_P2P_LLCP_STATE_IDLE,
38 NFA_P2P_LLCP_STATE_LISTENING,
nxf24591c1cbeab2018-02-21 17:32:26 +053039 NFA_P2P_LLCP_STATE_ACTIVATED
nxpandroidc7611652015-09-23 16:42:05 +053040
nxpandroidc7611652015-09-23 16:42:05 +053041};
42
nxpandroid8f6d0532017-07-12 18:25:30 +053043typedef uint8_t tNFA_P2P_LLCP_STATE;
nxpandroidc7611652015-09-23 16:42:05 +053044
45/* NFA P2P events */
nxpandroid8f6d0532017-07-12 18:25:30 +053046enum {
47 NFA_P2P_API_REG_SERVER_EVT = NFA_SYS_EVT_START(NFA_ID_P2P),
48 NFA_P2P_API_REG_CLIENT_EVT,
49 NFA_P2P_API_DEREG_EVT,
50 NFA_P2P_API_ACCEPT_CONN_EVT,
51 NFA_P2P_API_REJECT_CONN_EVT,
52 NFA_P2P_API_DISCONNECT_EVT,
53 NFA_P2P_API_CONNECT_EVT,
54 NFA_P2P_API_SEND_UI_EVT,
55 NFA_P2P_API_SEND_DATA_EVT,
56 NFA_P2P_API_SET_LOCAL_BUSY_EVT,
57 NFA_P2P_API_GET_LINK_INFO_EVT,
58 NFA_P2P_API_GET_REMOTE_SAP_EVT,
59 NFA_P2P_API_SET_LLCP_CFG_EVT,
60 NFA_P2P_INT_RESTART_RF_DISC_EVT,
nxpandroidc7611652015-09-23 16:42:05 +053061
nxpandroid8f6d0532017-07-12 18:25:30 +053062 NFA_P2P_LAST_EVT
nxpandroidc7611652015-09-23 16:42:05 +053063};
64
65/* data type for NFA_P2P_API_REG_SERVER_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +053066typedef struct {
67 NFC_HDR hdr;
68 uint8_t server_sap;
69 tNFA_P2P_LINK_TYPE link_type;
70 char service_name[LLCP_MAX_SN_LEN + 1];
71 tNFA_P2P_CBACK* p_cback;
nxpandroidc7611652015-09-23 16:42:05 +053072} tNFA_P2P_API_REG_SERVER;
73
74/* data type for NFA_P2P_API_REG_CLIENT_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +053075typedef struct {
76 NFC_HDR hdr;
77 tNFA_P2P_LINK_TYPE link_type;
78 tNFA_P2P_CBACK* p_cback;
nxpandroidc7611652015-09-23 16:42:05 +053079} tNFA_P2P_API_REG_CLIENT;
80
81/* data type for NFA_P2P_API_DEREG_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +053082typedef struct {
83 NFC_HDR hdr;
84 tNFA_HANDLE handle;
nxpandroidc7611652015-09-23 16:42:05 +053085} tNFA_P2P_API_DEREG;
86
87/* data type for NFA_P2P_API_ACCEPT_CONN_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +053088typedef struct {
89 NFC_HDR hdr;
90 tNFA_HANDLE conn_handle;
91 uint16_t miu;
92 uint8_t rw;
nxpandroidc7611652015-09-23 16:42:05 +053093} tNFA_P2P_API_ACCEPT_CONN;
94
95/* data type for NFA_P2P_API_REJECT_CONN_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +053096typedef struct {
97 NFC_HDR hdr;
98 tNFA_HANDLE conn_handle;
nxpandroidc7611652015-09-23 16:42:05 +053099} tNFA_P2P_API_REJECT_CONN;
100
101/* data type for NFA_P2P_API_DISCONNECT_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530102typedef struct {
103 NFC_HDR hdr;
104 tNFA_HANDLE conn_handle;
105 bool flush;
nxpandroidc7611652015-09-23 16:42:05 +0530106} tNFA_P2P_API_DISCONNECT;
107
108/* data type for NFA_P2P_API_CONNECT_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530109typedef struct {
110 NFC_HDR hdr;
111 tNFA_HANDLE client_handle;
112 char service_name[LLCP_MAX_SN_LEN + 1];
113 uint8_t dsap;
114 uint16_t miu;
115 uint8_t rw;
nxpandroidc7611652015-09-23 16:42:05 +0530116} tNFA_P2P_API_CONNECT;
117
118/* data type for NFA_P2P_API_SEND_UI_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530119typedef struct {
120 NFC_HDR hdr;
121 tNFA_HANDLE handle;
122 uint8_t dsap;
123 NFC_HDR* p_msg;
nxpandroidc7611652015-09-23 16:42:05 +0530124} tNFA_P2P_API_SEND_UI;
125
126/* data type for NFA_P2P_API_SEND_DATA_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530127typedef struct {
128 NFC_HDR hdr;
129 tNFA_HANDLE conn_handle;
130 NFC_HDR* p_msg;
nxpandroidc7611652015-09-23 16:42:05 +0530131} tNFA_P2P_API_SEND_DATA;
132
133/* data type for NFA_P2P_API_SET_LOCAL_BUSY_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530134typedef struct {
135 NFC_HDR hdr;
136 tNFA_HANDLE conn_handle;
137 bool is_busy;
nxpandroidc7611652015-09-23 16:42:05 +0530138} tNFA_P2P_API_SET_LOCAL_BUSY;
139
140/* data type for NFA_P2P_API_GET_LINK_INFO_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530141typedef struct {
142 NFC_HDR hdr;
143 tNFA_HANDLE handle;
nxpandroidc7611652015-09-23 16:42:05 +0530144} tNFA_P2P_API_GET_LINK_INFO;
145
146/* data type for NFA_P2P_API_GET_REMOTE_SAP_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530147typedef struct {
148 NFC_HDR hdr;
149 tNFA_HANDLE handle;
150 char service_name[LLCP_MAX_SN_LEN + 1];
nxpandroidc7611652015-09-23 16:42:05 +0530151} tNFA_P2P_API_GET_REMOTE_SAP;
152
153/* data type for NFA_P2P_API_SET_LLCP_CFG_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530154typedef struct {
155 NFC_HDR hdr;
156 uint16_t link_miu;
157 uint8_t opt;
158 uint8_t wt;
159 uint16_t link_timeout;
160 uint16_t inact_timeout_init;
161 uint16_t inact_timeout_target;
162 uint16_t symm_delay;
163 uint16_t data_link_timeout;
164 uint16_t delay_first_pdu_timeout;
nxpandroidc7611652015-09-23 16:42:05 +0530165} tNFA_P2P_API_SET_LLCP_CFG;
166
167/* union of all event data types */
nxpandroid8f6d0532017-07-12 18:25:30 +0530168typedef union {
169 NFC_HDR hdr;
170 tNFA_P2P_API_REG_SERVER api_reg_server;
171 tNFA_P2P_API_REG_CLIENT api_reg_client;
172 tNFA_P2P_API_DEREG api_dereg;
173 tNFA_P2P_API_ACCEPT_CONN api_accept;
174 tNFA_P2P_API_REJECT_CONN api_reject;
175 tNFA_P2P_API_DISCONNECT api_disconnect;
176 tNFA_P2P_API_CONNECT api_connect;
177 tNFA_P2P_API_SEND_UI api_send_ui;
178 tNFA_P2P_API_SEND_DATA api_send_data;
179 tNFA_P2P_API_SET_LOCAL_BUSY api_local_busy;
180 tNFA_P2P_API_GET_LINK_INFO api_link_info;
181 tNFA_P2P_API_GET_REMOTE_SAP api_remote_sap;
182 tNFA_P2P_API_SET_LLCP_CFG api_set_llcp_cfg;
nxpandroidc7611652015-09-23 16:42:05 +0530183} tNFA_P2P_MSG;
184
185/*****************************************************************************
186** control block
187*****************************************************************************/
nxpandroid8f6d0532017-07-12 18:25:30 +0530188/* Bit flag for connection handle */
189#define NFA_P2P_HANDLE_FLAG_CONN 0x80
nxpandroidc7611652015-09-23 16:42:05 +0530190
191/* NFA P2P Connection block */
nxpandroid8f6d0532017-07-12 18:25:30 +0530192/* Connection control block is used */
193#define NFA_P2P_CONN_FLAG_IN_USE 0x01
194/* Remote set RW to 0 (flow off) */
195#define NFA_P2P_CONN_FLAG_REMOTE_RW_ZERO 0x02
196/* data link connection is congested */
197#define NFA_P2P_CONN_FLAG_CONGESTED 0x04
nxpandroidc7611652015-09-23 16:42:05 +0530198
nxpandroid8f6d0532017-07-12 18:25:30 +0530199typedef struct {
200 uint8_t flags; /* internal flags for data link connection */
201 uint8_t local_sap; /* local SAP of data link connection */
202 uint8_t remote_sap; /* remote SAP of data link connection */
203 uint16_t remote_miu; /* MIU of remote end point */
204 uint8_t num_pending_i_pdu; /* number of tx I PDU not processed by NFA */
nxpandroidc7611652015-09-23 16:42:05 +0530205} tNFA_P2P_CONN_CB;
206
207/* NFA P2P SAP control block */
nxpandroid8f6d0532017-07-12 18:25:30 +0530208/* registered server */
209#define NFA_P2P_SAP_FLAG_SERVER 0x01
210/* registered client */
211#define NFA_P2P_SAP_FLAG_CLIENT 0x02
212/* logical link connection is congested */
213#define NFA_P2P_SAP_FLAG_LLINK_CONGESTED 0x04
nxpandroidc7611652015-09-23 16:42:05 +0530214
nxpandroid8f6d0532017-07-12 18:25:30 +0530215typedef struct {
216 uint8_t flags; /* internal flags for local SAP */
217 tNFA_P2P_CBACK* p_cback; /* callback function for local SAP */
218 uint8_t num_pending_ui_pdu; /* number of tx UI PDU not processed by NFA */
nxpandroidc7611652015-09-23 16:42:05 +0530219} tNFA_P2P_SAP_CB;
220
221/* NFA P2P SDP control block */
nxpandroid8f6d0532017-07-12 18:25:30 +0530222typedef struct {
223 uint8_t tid; /* transaction ID */
224 uint8_t local_sap;
nxpandroidc7611652015-09-23 16:42:05 +0530225} tNFA_P2P_SDP_CB;
226
nxpandroid8f6d0532017-07-12 18:25:30 +0530227#define NFA_P2P_NUM_SAP 64
nxpandroidc7611652015-09-23 16:42:05 +0530228
229/* NFA P2P control block */
nxpandroid8f6d0532017-07-12 18:25:30 +0530230typedef struct {
231 tNFA_HANDLE dm_disc_handle;
nxpandroidc7611652015-09-23 16:42:05 +0530232
nxpandroid8f6d0532017-07-12 18:25:30 +0530233 tNFA_DM_RF_DISC_STATE rf_disc_state;
234 tNFA_P2P_LLCP_STATE llcp_state;
235 bool is_initiator;
236 bool is_active_mode;
237 uint16_t local_link_miu;
238 uint16_t remote_link_miu;
nxpandroidc7611652015-09-23 16:42:05 +0530239
nxpandroid8f6d0532017-07-12 18:25:30 +0530240 tNFA_TECHNOLOGY_MASK listen_tech_mask; /* for P2P listening */
241 tNFA_TECHNOLOGY_MASK
242 listen_tech_mask_to_restore; /* to retry without active listen mode */
243 TIMER_LIST_ENT
244 active_listen_restore_timer; /* timer to restore active listen mode */
245 bool is_p2p_listening;
246 bool is_snep_listening;
nxpandroidc7611652015-09-23 16:42:05 +0530247
nxpandroid8f6d0532017-07-12 18:25:30 +0530248 tNFA_P2P_SAP_CB sap_cb[NFA_P2P_NUM_SAP];
249 tNFA_P2P_CONN_CB conn_cb[LLCP_MAX_DATA_LINK];
250 tNFA_P2P_SDP_CB sdp_cb[LLCP_MAX_SDP_TRANSAC];
nxpandroidc7611652015-09-23 16:42:05 +0530251
nxpandroid8f6d0532017-07-12 18:25:30 +0530252 uint8_t
253 total_pending_ui_pdu; /* total number of tx UI PDU not processed by NFA */
254 uint8_t
255 total_pending_i_pdu; /* total number of tx I PDU not processed by NFA */
nxpandroidc7611652015-09-23 16:42:05 +0530256} tNFA_P2P_CB;
257
258/*****************************************************************************
259** External variables
260*****************************************************************************/
261
262/* NFA P2P control block */
nxpandroidc7611652015-09-23 16:42:05 +0530263extern tNFA_P2P_CB nfa_p2p_cb;
nxpandroidc7611652015-09-23 16:42:05 +0530264
265/*****************************************************************************
266** External functions
267*****************************************************************************/
268/*
269** nfa_p2p_main.c
270*/
nxpandroid8f6d0532017-07-12 18:25:30 +0530271void nfa_p2p_init(void);
272void nfa_p2p_update_listen_tech(tNFA_TECHNOLOGY_MASK tech_mask);
273void nfa_p2p_enable_listening(tNFA_SYS_ID sys_id, bool update_wks);
274void nfa_p2p_disable_listening(tNFA_SYS_ID sys_id, bool update_wks);
275void nfa_p2p_activate_llcp(tNFC_DISCOVER* p_data);
276void nfa_p2p_deactivate_llcp(void);
277void nfa_p2p_set_config(tNFA_DM_DISC_TECH_PROTO_MASK disc_mask);
nxpandroidc7611652015-09-23 16:42:05 +0530278
279/*
280** nfa_p2p_act.c
281*/
nxpandroid8f6d0532017-07-12 18:25:30 +0530282void nfa_p2p_proc_llcp_data_ind(tLLCP_SAP_CBACK_DATA* p_data);
283void nfa_p2p_proc_llcp_connect_ind(tLLCP_SAP_CBACK_DATA* p_data);
284void nfa_p2p_proc_llcp_connect_resp(tLLCP_SAP_CBACK_DATA* p_data);
285void nfa_p2p_proc_llcp_disconnect_ind(tLLCP_SAP_CBACK_DATA* p_data);
286void nfa_p2p_proc_llcp_disconnect_resp(tLLCP_SAP_CBACK_DATA* p_data);
287void nfa_p2p_proc_llcp_congestion(tLLCP_SAP_CBACK_DATA* p_data);
288void nfa_p2p_proc_llcp_link_status(tLLCP_SAP_CBACK_DATA* p_data);
nxpandroidc7611652015-09-23 16:42:05 +0530289
nxpandroid8f6d0532017-07-12 18:25:30 +0530290bool nfa_p2p_start_sdp(char* p_service_name, uint8_t local_sap);
nxpandroidc7611652015-09-23 16:42:05 +0530291
nxpandroid8f6d0532017-07-12 18:25:30 +0530292bool nfa_p2p_reg_server(tNFA_P2P_MSG* p_msg);
293bool nfa_p2p_reg_client(tNFA_P2P_MSG* p_msg);
294bool nfa_p2p_dereg(tNFA_P2P_MSG* p_msg);
295bool nfa_p2p_accept_connection(tNFA_P2P_MSG* p_msg);
296bool nfa_p2p_reject_connection(tNFA_P2P_MSG* p_msg);
297bool nfa_p2p_disconnect(tNFA_P2P_MSG* p_msg);
298bool nfa_p2p_create_data_link_connection(tNFA_P2P_MSG* p_msg);
299bool nfa_p2p_send_ui(tNFA_P2P_MSG* p_msg);
300bool nfa_p2p_send_data(tNFA_P2P_MSG* p_msg);
301bool nfa_p2p_set_local_busy(tNFA_P2P_MSG* p_msg);
302bool nfa_p2p_get_link_info(tNFA_P2P_MSG* p_msg);
303bool nfa_p2p_get_remote_sap(tNFA_P2P_MSG* p_msg);
304bool nfa_p2p_set_llcp_cfg(tNFA_P2P_MSG* p_msg);
305bool nfa_p2p_restart_rf_discovery(tNFA_P2P_MSG* p_msg);
nxpandroidc7611652015-09-23 16:42:05 +0530306
nxpandroidc7611652015-09-23 16:42:05 +0530307#else
308
309#define nfa_p2p_init ()
nxpandroid8f6d0532017-07-12 18:25:30 +0530310#define nfa_p2p_activate_llcp (a){};
nxpandroidc7611652015-09-23 16:42:05 +0530311#define nfa_p2p_deactivate_llcp ()
312#define nfa_p2p_set_config ()
313
nxf24591c1cbeab2018-02-21 17:32:26 +0530314#endif /* (NFA_P2P_INCLUDED == TRUE) */
nxpandroidc7611652015-09-23 16:42:05 +0530315#endif /* NFA_P2P_INT_H */