nfa_dta_int.h revision 5c65c3a0f42e174e47fecd4e569606003217ff4e
1/****************************************************************************** 2 * 3 * Copyright (C) 2003-2013 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 19 20/****************************************************************************** 21 * 22 * This is the private interface file for the NFA DTA 23 * 24 ******************************************************************************/ 25#ifndef NFA_DTA_INT_H 26#define NFA_DTA_INT_H 27 28#include "nfa_dta_api.h" 29#include "nfa_sys.h" 30#include "nfa_sys_int.h" 31#include "nfc_api.h" 32#include "rw_api.h" 33#include "ce_api.h" 34 35#if (NFA_DTA_INCLUDED == TRUE) 36 37/***************************************************************************** 38** DTA definitions 39*****************************************************************************/ 40#define NFA_DTA_PATTERN_NUMBER_INVALID 0xFFFF 41 42#define NFA_DTA_DISCOVER_PARAMS_MAX 6 43 44#define NDEF_WKT_TEXT_HDR_LEN 7 /* Header length for long NDEF text message */ 45#define NFA_DTA_T3T_WRITE_NDEF_SIZE 192 /* Size of NDEF message for T3T write-tests ([DTA] $5.5.6) */ 46#define NFA_DTA_T3T_LISTEN_SYSTEMCODE 0xBABE /* System code to use for T3T Listen mode tests */ 47 48#define NFA_PROTOCOL_RANK_INVALID 0xFF /* Maximum protocol preference rank */ 49 50#define NFA_DTA_SCRATCH_BUF_SIZE T3T_MSG_BLOCKSIZE 51 52#ifndef NFA_DTA_DEFAULT_CO_OUT_DSAP 53#define NFA_DTA_DEFAULT_CO_OUT_DSAP 0x10 /* Default SAP[LT,CO-OUT-DEST] if SDP was not performed to get SAP from the LT */ 54#endif 55 56/***************************************************************************** 57* DTA state machine definitions 58*****************************************************************************/ 59 60typedef struct { 61 BOOLEAN tp_continue; /* NFA_DTA_CFG_TP_CONTINUE */ 62 tNFA_DTA_FL_POLL_LISTEN poll_listen; /* NFA_DTA_CFG_POLL_LISTEN */ 63 BOOLEAN t4at_nfcdep_priority; /* NFA_DTA_CFG_T4AT_NFCDEP_PRIORITY */ 64 BOOLEAN reactivation; /* NFA_DTA_CFG_REACTIVATION */ 65 UINT16 total_duration; /* NFA_DTA_CFG_TOTAL_DURATION */ 66 BOOLEAN enable_dta_llcp; /* NFA_DTA_CFG_LLCP */ 67 tNFA_DTA_SNEP_MODE dta_snep_mode; /* NFA_DTA_CFG_SNEP */ 68 tNFA_DTA_EMVCO_PCD_MODE emvco_pcd_mode; /* NFA_DTA_CFG_EMVCO_PCD */ 69} tNFA_DTA_CONFIG; 70 71/***************************************************************************** 72* DTA state machine definitions 73*****************************************************************************/ 74/* DTA events */ 75enum 76{ 77 /* device manager local device API events */ 78 NFA_DTA_API_ENABLE_EVT = NFA_SYS_EVT_START (NFA_ID_DTA), 79 NFA_DTA_API_DISABLE_EVT, 80 NFA_DTA_API_CONFIG_EVT, 81 NFA_DTA_API_START_EVT, 82 NFA_DTA_API_STOP_EVT, 83 NFA_DTA_ACTIVATE_EVT, 84 NFA_DTA_DEACTIVATE_EVT, 85 NFA_DTA_DATA_CBACK_EVT, 86 87 NFA_DTA_MAX_EVT 88}; 89 90 91/* data type for NFA_DTA_API_ENABLE_EVT */ 92typedef struct 93{ 94 BT_HDR hdr; 95 BOOLEAN auto_start; 96 tNFA_DTA_CBACK *p_cback; 97} tNFA_DTA_API_ENABLE; 98 99/* data type for NFA_DTA_API_START_EVT */ 100typedef struct 101{ 102 BT_HDR hdr; 103 UINT8 pattern_number; 104 UINT8 tlv_len; 105 UINT8 *p_tlv_params; 106} tNFA_DTA_API_START; 107 108/* data type for NFA_DTA_API_CONFIG */ 109typedef struct 110{ 111 BT_HDR hdr; 112 tNFA_DTA_CFG_ITEM item; 113 tNFA_DTA_CFG cfg_data; 114} tNFA_DTA_API_CONFIG; 115 116/* data type for NFA_DTA_DATA_CBACK_EVT */ 117typedef struct 118{ 119 UINT8 event; 120 tRW_DATA data; 121} tNFA_DTA_RW_DATA; 122 123typedef struct 124{ 125 UINT8 event; 126 tCE_DATA data; 127} tNFA_DTA_CE_DATA; 128 129typedef struct 130{ 131 tNFC_CONN_EVT event; 132 tNFC_CONN data; 133} tNFA_DTA_NFCDEP_DATA; 134 135 136enum 137{ 138 NFA_DTA_LLCP_CONNECT_CO_ECHO_OUT, 139 NFA_DTA_LLCP_DISCONNECT_CO_ECHO_OUT 140}; 141typedef UINT8 tNFA_DTA_LLCP_EVT; 142 143enum 144{ 145 NFA_DTA_RW_DATA, 146 NFA_DTA_CE_DATA, 147 NFA_DTA_NFCDEP_DATA, 148 NFA_DTA_LLCP_DATA 149}; 150 151typedef UINT8 tNFA_DTA_DATA_TYPE; 152 153typedef struct 154{ 155 BT_HDR hdr; 156 tNFA_DTA_DATA_TYPE type; 157 union 158 { 159 tNFA_DTA_RW_DATA rw; 160 tNFA_DTA_CE_DATA ce; 161 tNFA_DTA_NFCDEP_DATA nfcdep; 162 tNFA_DTA_LLCP_EVT llcp_evt; 163 } data; 164} tNFA_DTA_DATA_CBACK; 165 166/* All API message type */ 167typedef union 168{ 169 BT_HDR hdr; 170 tNFA_DTA_API_ENABLE enable; 171 tNFA_DTA_API_CONFIG cfg; 172 tNFA_DTA_API_START start; 173 tNFA_DTA_DATA_CBACK data_cback; 174}tNFA_DTA_MSG; 175 176 177 178/* DTA states */ 179enum 180{ 181 NFA_DTA_ST_IDLE, 182 NFA_DTA_ST_DISCOVER, /* Polling/Listening */ 183 NFA_DTA_ST_ACTIVATED /* Activated, listen mode */ 184}; 185typedef UINT8 tNFA_DTA_STATE; 186 187/* DTA Substates (while in ACTIVATED state) - substate enumerations are found in protocol-specific files (nfa_dta_XXX.c) */ 188#define NFA_DTA_SST_IDLE 0 189typedef UINT8 tNFA_DTA_SUBSTATE; 190 191/* DTA discovery states */ 192enum 193{ 194 NFA_DTA_DISC_STATE_IDLE, 195 NFA_DTA_DISC_STATE_DISCOVERY, 196 NFA_DTA_DISC_STATE_POLL_ACTIVE, 197 NFA_DTA_DISC_STATE_W4_ALL_DISCOVERIES, 198 NFA_DTA_DISC_STATE_W4_HOST_SELECT, 199 NFA_DTA_DISC_STATE_LISTEN_ACTIVE, 200 NFA_DTA_DISC_STATE_LISTEN_SLEEP, 201 NFA_DTA_DISC_STATE_MAX 202}; 203 204/***************************************************************************** 205* DTA control block definitions 206*****************************************************************************/ 207 208/* NDEF buffer definitions */ 209enum { 210 NFA_DTA_BUF_READ, /* Buffer for RW Read requests */ 211 NFA_DTA_BUF_WRITE, /* Buffer for RW Write requests */ 212 NFA_DTA_BUF_MAX 213}; 214 215typedef struct { 216 UINT8 *p_data; 217 UINT32 max_size; 218 UINT32 cur_size; 219 UINT32 offset; /* current read/write offset */ 220} tNFA_DTA_BUF_CB; 221 222 223/* T4T listen mode test application */ 224enum { 225 NFA_DTA_T4T_CE_APP_NONE, /* Not selected */ 226 NFA_DTA_T4T_CE_APP_LOOPBACK, /* loopback test applicaiton */ 227 NFA_DTA_T4T_CE_APP_PROP /* propretary test application */ 228}; 229 230/* DTA test step command */ 231typedef tNFC_STATUS (*tNFA_DTA_CMD_FCN) (void *); 232 233/* dta control block flags */ 234#define NFA_DTA_FL_ENABLED 0x00000001 /* DTA is enabled */ 235#define NFA_DTA_FL_AUTOSTART 0x00000002 /* Automatically start discovery when NFC is enabled */ 236#define NFA_DTA_FL_STOPPING 0x00000004 /* DTA is stopping (NFA_DtaStop called) */ 237#define NFA_DTA_FL_DISABLING 0x00000008 /* DTA is being disabled (NFA_DtaDisable called) */ 238#define NFA_DTA_FL_T4T_DESELECT_DEACT 0x00000010 /* T4T/NFCDEP is deactivating to IDLE (need to DESELECT first) */ 239 240/* DTA control block */ 241typedef struct { 242 UINT32 dta_flags; /* dta_flags must be first item in structure (statically intialized to 0 on startup) */ 243 244 /* Configuration */ 245 tNFA_DTA_CONFIG cfg; 246 247 /* DTA State Machine */ 248 tNFA_DTA_STATE state; 249 tNFA_DTA_SUBSTATE substate; /* Current protocol-specific sub-state */ 250 tNFA_DTA_CBACK *p_cback; /* Applicatation for DTA event notification */ 251 252 /* DTA test parameters */ 253 UINT32 pattern_number; 254 UINT32 pattern_number_old; 255 256 /* Discovery Parameters */ 257 UINT8 disc_state; 258 UINT8 disc_params_num; 259 tNFC_DISCOVER_PARAMS disc_params[NFA_DTA_DISCOVER_PARAMS_MAX]; 260 261 /* Activation parameters */ 262 tNFC_ACTIVATE_DEVT activate_params; 263 UINT8 cur_protocol_rank; /* perference ranking of currently discovered protocol */ 264 265 tRW_CBACK *p_rw_cback; 266 tCE_CBACK *p_ce_cback; 267 268 TIMER_LIST_ENT protocol_timer; /* timer for the activated protocol if needed */ 269 270 UINT8 t4t_ce_app; /* T4T listen mode test application */ 271 tCE_T4T_AID_HANDLE t4t_dta_aid_hdl; /* T4T registration handle for proprietary dta aid */ 272 tCE_T4T_AID_HANDLE t4t_prop_aid_hdl; /* T4T registration handle for proprietary aid */ 273 UINT8 nfc_dep_wt; 274 275 BOOLEAN llcp_cl_more_to_read; /* TRUE if there is more to read in llcp cl link*/ 276 BOOLEAN llcp_co_more_to_read; /* TRUE if there is more to read in llcp recieve window*/ 277 BOOLEAN llcp_is_initiator; /* TURE if IUT is LLCP initiator */ 278 UINT16 llcp_local_link_miu; /* link MIU of IUT */ 279 UINT16 llcp_remote_link_miu; /* link MIU of LT */ 280 281 UINT8 llcp_cl_in_local_sap; /* SAP of IUT-CL-IN-DEST */ 282 UINT8 llcp_cl_out_local_sap; /* SAP of IUT-CL-OUT-SRC */ 283 UINT8 llcp_cl_out_remote_sap; /* SAP of LT-CL-OUT-DEST */ 284 285 UINT8 llcp_co_in_local_sap; /* SAP of IUT-CO-IN-DEST */ 286 UINT8 llcp_co_in_remote_sap; /* SAP of LT-CO-IN-SRC */ 287 UINT8 llcp_co_out_local_sap; /* SAP of IUT-CO-OUT-SRC */ 288 UINT8 llcp_co_out_remote_sap; /* SAP of LT-CO-OUT-DEST */ 289 290 UINT16 llcp_co_out_remote_miu; /* MIU of LT-CO-OUT-DEST */ 291 UINT8 llcp_co_out_remote_rw; /* RW of LT-CO-OUT-DEST */ 292 293#define NFA_DTA_LLCP_FLAGS_CO_OUT_CONNECTING 0x01 /* establishing outbound on connection-oriented */ 294#define NFA_DTA_LLCP_FLAGS_CO_OUT_CONNECTED 0x02 /* established outbound on connection-oriented */ 295 296 UINT8 llcp_flags; /* internal flags for LLCP echo test */ 297 UINT8 llcp_sdp_tid; /* transaction ID for SDP */ 298 299 TIMER_LIST_ENT llcp_cl_echo_timer; /* timer for the connectionless echo test application */ 300 TIMER_LIST_ENT llcp_co_echo_timer; /* timer for the connection-oriented echo test application */ 301 BUFFER_Q llcp_cl_buffer; /* buffer for the connectionless echo test application */ 302 BUFFER_Q llcp_co_buffer; /* buffer for the connection-oriented echo test application*/ 303 304 tNFA_HANDLE snep_server_handle; 305 tNFA_HANDLE snep_server_conn_handle; 306 tNFA_HANDLE snep_client_handle; 307 308#define NFA_DTA_SNEP_CLIENT_TEST_FLAGS_DEFAULT_SERVER 0x01 309#define NFA_DTA_SNEP_CLIENT_TEST_FLAGS_EXTENDED_SERVER 0x02 310#define NFA_DTA_SNEP_CLIENT_TEST_FLAGS_PUT_SHORT_NDEF 0x04 311#define NFA_DTA_SNEP_CLIENT_TEST_FLAGS_PUT_LONG_NDEF 0x08 312#define NFA_DTA_SNEP_CLIENT_TEST_FLAGS_GET 0x10 313 314 UINT8 snep_client_test_flags; 315 316 UINT8 *p_snep_short_ndef; 317 UINT32 snep_short_ndef_size; 318 UINT8 *p_snep_long_ndef; 319 UINT32 snep_long_ndef_size; 320 321 /* DTA buffer for NDEF read/write */ 322 tNFA_DTA_BUF_CB buf_cb[NFA_DTA_BUF_MAX]; 323 UINT32 ndef_size; /* Size of NDEF message from NDEF detection */ 324 325 /* Scratch buffer for miscelaneous use */ 326 UINT8 scratch_buf[NFA_DTA_SCRATCH_BUF_SIZE]; 327 328 /* DTA Test command table */ 329 tNFA_DTA_CMD_FCN *p_cur_cmd_tbl; /* Current table of commands for current test */ 330 UINT8 cur_cmd_idx; 331} tNFA_DTA_CB; 332extern tNFA_DTA_CB nfa_dta_cb; 333 334/* NFA_SYS info for DTA */ 335extern const tNFA_SYS_REG nfa_dta_sys_reg; 336 337/* DTA startup setconfig parameters */ 338extern UINT8 *p_nfa_dta_start_up_cfg; 339extern UINT8 nfa_dta_start_up_cfg_len; 340 341/***************************************************************************** 342* DTA internal funciton protoytpes 343*****************************************************************************/ 344/* Internal function prototypes */ 345void nfa_dta_deactivate (UINT8 deactivate_type); 346void nfa_dta_shutdown (void); 347void nfa_dta_discover_start (void); 348 349/* nfa_sys handler for DTA */ 350BOOLEAN nfa_dta_evt_hdlr (BT_HDR *p_msg); 351void nfa_dta_sys_disable (void); 352 353/* State machine action functions */ 354BOOLEAN nfa_dta_enable (tNFA_DTA_MSG *p_data); 355BOOLEAN nfa_dta_disable (tNFA_DTA_MSG *p_data); 356BOOLEAN nfa_dta_config (tNFA_DTA_MSG *p_data); 357BOOLEAN nfa_dta_start (tNFA_DTA_MSG *p_data); 358BOOLEAN nfa_dta_handle_deact (tNFA_DTA_MSG *p_data); 359BOOLEAN nfa_dta_stop (tNFA_DTA_MSG *p_data); 360BOOLEAN nfa_dta_run_test (tNFA_DTA_MSG *p_data); 361BOOLEAN nfa_dta_proc_data (tNFA_DTA_MSG *p_msg_data); 362 363/* Utility functions */ 364void nfa_dta_test_set_state (tNFA_DTA_STATE state); 365void nfa_dta_test_set_substate (tNFA_DTA_SUBSTATE substate); 366void nfa_dta_free_ndef_buf (UINT8 ndef_idx); 367UINT8 *nfa_dta_realloc_buf (UINT8 ndef_idx, UINT32 size); 368void nfa_dta_t3t_nfcid_rand (UINT8 nfcid2[NCI_RF_F_UID_LEN]); 369 370/* Test function entry points (in nfa_dta_XXX.c) */ 371void nfa_dta_nfcdep_poll_test_start (void); 372void nfa_dta_nfcdep_proc_data (tNFC_CONN_EVT event, tNFC_CONN *p_data); 373void nfa_dta_t1t_poll_test_start (void); 374void nfa_dta_t2t_poll_test_start (void); 375void nfa_dta_t3t_poll_test_start (void); 376void nfa_dta_t4t_poll_test_start (void); 377 378void nfa_dta_nfcdep_listen_test_start (void); 379void nfa_dta_t3t_listen_test_start (void); 380void nfa_dta_t4t_listen_test_start (void); 381 382void nfa_dta_t1t_rw_cback (UINT8 event, tRW_DATA *p_data); 383void nfa_dta_t2t_rw_cback (UINT8 event, tRW_DATA *p_data); 384void nfa_dta_t3t_rw_cback (UINT8 event, tRW_DATA *p_data); 385void nfa_dta_t4t_rw_cback (UINT8 event, tRW_DATA *p_data); 386 387void nfa_dta_t3t_ce_cback (UINT8 event, tCE_DATA *p_data); 388void nfa_dta_t4t_ce_cback (UINT8 event, tCE_DATA *p_data); 389 390void nfa_dta_ce_cback (UINT8 event, tCE_DATA *p_ce_data); 391 392void nfa_dta_t4t_register_apps (void); 393void nfa_dta_t4t_deregister_apps (void); 394 395void nfa_dta_llcp_register_echo (void); 396void nfa_dta_llcp_deregister_echo (void); 397void nfa_dta_llcp_activate_link (void); 398void nfa_dta_llcp_connect_co_echo_out (void); 399void nfa_dta_llcp_disconnect_co_echo_out (void); 400 401void nfa_dta_snep_register (void); 402void nfa_dta_snep_deregister (void); 403void nfa_dta_snep_mode (tNFA_DTA_SNEP_MODE mode); 404 405void nfa_dta_emvco_pcd_config_nfcc (BOOLEAN enable); 406void nfa_dta_emvco_pcd_start (void); 407void nfa_dta_emvco_pcd_cback (UINT8 event, tRW_DATA *p_data); 408 409extern UINT8 *p_nfa_dta_brcm_start_up_cfg; 410extern UINT8 nfa_dta_brcm_start_up_cfg_len; 411extern UINT8 *p_nfa_dta_start_up_vsc_cfg; 412 413#endif /* (NFA_DTA_INCLUDED == TRUE) */ 414#endif /* NFA_DTA_INT_H */ 415 416