DTA support added for NFC Forum certification.

Bug: 63903843
Test: compiles.
Merged-In: I1ab62d0db29c7f9dd09828a3dac0494279cc0ab7
Change-Id: I1ab62d0db29c7f9dd09828a3dac0494279cc0ab7
diff --git a/src/adaptation/NfcAdaptation.cpp b/src/adaptation/NfcAdaptation.cpp
index c09339c..42bf55f 100644
--- a/src/adaptation/NfcAdaptation.cpp
+++ b/src/adaptation/NfcAdaptation.cpp
@@ -64,6 +64,7 @@
 
 uint32_t ScrProtocolTraceFlag = SCR_PROTO_TRACE_ALL;  // 0x017F00;
 uint8_t appl_trace_level = 0xff;
+uint8_t appl_dta_mode_flag = 0x00;
 char bcm_nfc_location[120];
 
 static uint8_t nfa_dm_cfg[sizeof(tNFA_DM_CFG)];
diff --git a/src/adaptation/OverrideLog.cpp b/src/adaptation/OverrideLog.cpp
index a07aab6..81beafc 100644
--- a/src/adaptation/OverrideLog.cpp
+++ b/src/adaptation/OverrideLog.cpp
@@ -93,3 +93,8 @@
 
   return ScrProtocolTraceFlag;
 }
+
+void initializeGlobalAppDtaMode() {
+  appl_dta_mode_flag = 0x01;
+  ALOGD("%s: DTA Enabled", __func__);
+}
diff --git a/src/hal/include/nci_defs.h b/src/hal/include/nci_defs.h
index 570ca61..1428e50 100644
--- a/src/hal/include/nci_defs.h
+++ b/src/hal/include/nci_defs.h
@@ -41,6 +41,7 @@
 #define NCI_MAX_CTRL_SIZE 0xFF /* max control message size */
 #define NCI_CTRL_INIT_SIZE 32  /* initial NFCC control payload size */
 #define NCI_MAX_VSC_SIZE 0xFF
+#define APPL_DTA_MODE FALSE
 /* NCI header (3) + callback function pointer(8; use 8 to be safe) + HCIT (1
  * byte) */
 #define NCI_VSC_MSG_HDR_SIZE 12
diff --git a/src/include/_OverrideLog.h b/src/include/_OverrideLog.h
index 065e271..dd412ab 100644
--- a/src/include/_OverrideLog.h
+++ b/src/include/_OverrideLog.h
@@ -40,6 +40,10 @@
 
 extern unsigned char appl_trace_level;
 extern uint32_t ScrProtocolTraceFlag;
+/* defined for run time DTA mode selection */
+extern unsigned char appl_dta_mode_flag;
+
+void initializeGlobalAppDtaMode();
 
 /*******************************************************************************
 **
diff --git a/src/include/config.h b/src/include/config.h
index db15a87..23c80fb 100644
--- a/src/include/config.h
+++ b/src/include/config.h
@@ -58,6 +58,7 @@
 #define NAME_POWER_ON_DELAY "POWER_ON_DELAY"
 #define NAME_PRE_POWER_OFF_DELAY "PRE_POWER_OFF_DELAY"
 #define NAME_POST_POWER_OFF_DELAY "POST_POWER_OFF_DELAY"
+#define NAME_APPL_DTA_MODE "APPL_DTA_MODE"
 #define NAME_CE3_PRE_POWER_OFF_DELAY "CE3_PRE_POWER_OFF_DELAY"
 #define NAME_NFA_STORAGE "NFA_STORAGE"
 #define NAME_NFA_DM_START_UP_VSC_CFG "NFA_DM_START_UP_VSC_CFG"
diff --git a/src/nfa/ce/nfa_ce_act.c b/src/nfa/ce/nfa_ce_act.c
index b89164f..6e1166b 100644
--- a/src/nfa/ce/nfa_ce_act.c
+++ b/src/nfa/ce/nfa_ce_act.c
@@ -342,6 +342,9 @@
     ARRAY_TO_BE_STREAM(p_params, t3tPMM, NCI_T3T_PMM_LEN);
   }
   tlv_size = (uint8_t)(p_params - tlv);
+  if (appl_dta_mode_flag == 0x01) {
+    nfa_dm_cb.eDtaMode |= NFA_DTA_HCEF_MODE;
+  }
   nfa_dm_check_set_config(tlv_size, (uint8_t*)tlv, false);
 }
 
diff --git a/src/nfa/dm/nfa_dm_act.c b/src/nfa/dm/nfa_dm_act.c
index d48d2ab..e3964c8 100644
--- a/src/nfa/dm/nfa_dm_act.c
+++ b/src/nfa/dm/nfa_dm_act.c
@@ -761,16 +761,21 @@
 
   /* Always allow deactivate to IDLE */
   /* Do not allow deactivate to SLEEP for T1T,NFCDEP, ISO15693 */
-  if ((p_data->deactivate.sleep_mode == false) ||
-      ((nfa_dm_cb.disc_cb.activated_protocol != NFA_PROTOCOL_T1T) &&
-       (nfa_dm_cb.disc_cb.activated_protocol != NFA_PROTOCOL_NFC_DEP) &&
-       (nfa_dm_cb.disc_cb.activated_protocol != NFA_PROTOCOL_T5T) &&
-       (nfa_dm_cb.disc_cb.activated_protocol != NFC_PROTOCOL_KOVIO))) {
+  if (p_data->deactivate.sleep_mode == false ||
+      (nfa_dm_cb.disc_cb.activated_protocol != NFA_PROTOCOL_T1T &&
+       (nfa_dm_cb.disc_cb.activated_protocol != NFA_PROTOCOL_NFC_DEP ||
+        appl_dta_mode_flag) &&
+       nfa_dm_cb.disc_cb.activated_protocol != NFA_PROTOCOL_T5T &&
+       nfa_dm_cb.disc_cb.activated_protocol != NFC_PROTOCOL_KOVIO)) {
     deact_type = NFA_DEACTIVATE_TYPE_DISCOVERY;
     if (p_data->deactivate.sleep_mode) {
       if (nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_W4_HOST_SELECT) {
         /* Deactivate to sleep mode not allowed in this state. */
         deact_type = NFA_DEACTIVATE_TYPE_IDLE;
+      } else if (appl_dta_mode_flag == true &&
+                 (nfa_dm_cb.disc_cb.disc_state != NFA_DM_RFST_LISTEN_SLEEP ||
+                  nfa_dm_cb.disc_cb.disc_state == NFA_DM_RFST_POLL_ACTIVE)) {
+        deact_type = NFA_DEACTIVATE_TYPE_SLEEP;
       } else if (nfa_dm_cb.disc_cb.disc_state != NFA_DM_RFST_LISTEN_SLEEP) {
         deact_type = NFA_DEACTIVATE_TYPE_SLEEP;
       }
@@ -781,7 +786,8 @@
     }
 
     if ((nfa_dm_cb.disc_cb.activated_protocol == NFA_PROTOCOL_NFC_DEP) &&
-        ((nfa_dm_cb.flags & NFA_DM_FLAGS_EXCL_RF_ACTIVE) == 0x00)) {
+        ((nfa_dm_cb.flags & NFA_DM_FLAGS_EXCL_RF_ACTIVE) == 0x00) &&
+        appl_dta_mode_flag != true) {
       /* Exclusive RF control doesn't use NFA P2P */
       /* NFA P2P will deactivate NFC link after deactivating LLCP link */
       if (!(nfa_dm_cb.flags & NFA_DM_FLAGS_P2P_PAUSED)) {
@@ -861,6 +867,29 @@
   NFC_SendVsCommand(p_data->send_vsc.oid, p_cmd, p_data->send_vsc.p_cback);
 
   /* Most dm action functions return TRUE, so nfa-sys frees the GKI buffer
+   * carrying the message, This action function re-use the GKI buffer to
+   * send the VSC, so the GKI buffer can not be freed by nfa-sys */
+
+  return false;
+}
+
+/*******************************************************************************
+**
+** Function         nfa_dm_act_send_raw_vs
+**
+** Description      Send the raw vs command to the NCI command queue
+**
+** Returns          FALSE (message buffer is NOT freed by caller)
+**
+*******************************************************************************/
+bool nfa_dm_act_send_raw_vs(tNFA_DM_MSG* p_data) {
+  NFC_HDR* p_cmd = (NFC_HDR*)p_data;
+
+  p_cmd->offset = sizeof(tNFA_DM_API_SEND_VSC) - NFC_HDR_SIZE;
+  p_cmd->len = p_data->send_vsc.cmd_params_len;
+  NFC_SendRawVsCommand(p_cmd, p_data->send_vsc.p_cback);
+
+  /* Most dm action functions return TRUE, so nfa-sys frees the GKI buffer
    * carrying the message,
    * This action function re-use the GKI buffer to send the VSC, so the GKI
    * buffer can not be freed by nfa-sys */
@@ -1552,16 +1581,25 @@
         if ((nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_NFC_DEP) &&
             (nfa_dm_cb.disc_cb.activated_rf_interface ==
              NFC_INTERFACE_NFC_DEP)) {
-          if (!(nfa_dm_cb.flags & NFA_DM_FLAGS_P2P_PAUSED)) {
-            /* activate LLCP */
-            nfa_p2p_activate_llcp(p_data);
-            if (nfa_dm_cb.p_activate_ntf) {
-              GKI_freebuf(nfa_dm_cb.p_activate_ntf);
-              nfa_dm_cb.p_activate_ntf = NULL;
-            }
-          } else {
-            NFA_TRACE_DEBUG0("P2P is paused");
+          /* For P2P mode(Default DTA mode) open Raw channel to bypass LLCP
+           * layer. For LLCP DTA mode activate LLCP */
+          if ((appl_dta_mode_flag == 1) &&
+              ((nfa_dm_cb.eDtaMode & 0x0F) == NFA_DTA_DEFAULT_MODE)) {
+            /* Open raw channel in case of p2p for DTA testing */
+            NFC_SetStaticRfCback(nfa_dm_act_data_cback);
             nfa_dm_notify_activation_status(NFA_STATUS_OK, NULL);
+          } else {
+            if (!(nfa_dm_cb.flags & NFA_DM_FLAGS_P2P_PAUSED)) {
+              /* activate LLCP */
+              nfa_p2p_activate_llcp(p_data);
+              if (nfa_dm_cb.p_activate_ntf) {
+                GKI_freebuf(nfa_dm_cb.p_activate_ntf);
+                nfa_dm_cb.p_activate_ntf = NULL;
+              }
+            } else {
+              NFA_TRACE_DEBUG0("P2P is paused");
+              nfa_dm_notify_activation_status(NFA_STATUS_OK, NULL);
+            }
           }
         } else if ((nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_T1T) ||
                    (nfa_dm_cb.disc_cb.activated_protocol == NFC_PROTOCOL_T2T) ||
@@ -1644,6 +1682,19 @@
 }
 
 /*******************************************************************************
+** Function         nfa_dm_poll_disc_cback_dta_wrapper
+**
+** Description      Accessing the nfa_dm_poll_disc_cback for DTA wrapper
+**
+** Returns          None
+**
+*******************************************************************************/
+void nfa_dm_poll_disc_cback_dta_wrapper(tNFA_DM_RF_DISC_EVT event,
+                                        tNFC_DISCOVER* p_data) {
+  nfa_dm_poll_disc_cback(event, p_data);
+}
+
+/*******************************************************************************
 **
 ** Function         nfa_dm_notify_activation_status
 **
diff --git a/src/nfa/dm/nfa_dm_api.c b/src/nfa/dm/nfa_dm_api.c
index 469d358..474a525 100644
--- a/src/nfa/dm/nfa_dm_api.c
+++ b/src/nfa/dm/nfa_dm_api.c
@@ -1226,6 +1226,50 @@
 
 /*******************************************************************************
 **
+** Function         NFA_SendRawVsCommand
+**
+** Description      This function is called to send raw Vendor Specific
+**                  command to NFCC.
+**
+**                  cmd_params_len  - The command parameter len
+**                  p_cmd_params    - The command parameter
+**                  p_cback         - The callback function to receive the
+**                                    command
+**
+** Returns          NFA_STATUS_OK if successfully initiated
+**                  NFA_STATUS_FAILED otherwise
+**
+*******************************************************************************/
+tNFA_STATUS NFA_SendRawVsCommand(uint8_t cmd_params_len, uint8_t* p_cmd_params,
+                                 tNFA_VSC_CBACK* p_cback) {
+  if (cmd_params_len == 0x00 || p_cmd_params == NULL || p_cback == NULL) {
+    return NFA_STATUS_INVALID_PARAM;
+  }
+  uint16_t size = sizeof(tNFA_DM_API_SEND_VSC) + cmd_params_len;
+  tNFA_DM_API_SEND_VSC* p_msg = (tNFA_DM_API_SEND_VSC*)GKI_getbuf(size);
+
+  if (p_msg != NULL) {
+    p_msg->hdr.event = NFA_DM_API_SEND_RAW_VS_EVT;
+    p_msg->p_cback = p_cback;
+    if (cmd_params_len && p_cmd_params) {
+      p_msg->cmd_params_len = cmd_params_len;
+      p_msg->p_cmd_params = (uint8_t*)(p_msg + 1);
+      memcpy(p_msg->p_cmd_params, p_cmd_params, cmd_params_len);
+    } else {
+      p_msg->cmd_params_len = 0;
+      p_msg->p_cmd_params = NULL;
+    }
+
+    nfa_sys_sendmsg(p_msg);
+
+    return NFA_STATUS_OK;
+  }
+
+  return NFA_STATUS_FAILED;
+}
+
+/*******************************************************************************
+**
 ** Function         NFA_SetTraceLevel
 **
 ** Description      This function sets the trace level for NFA.  If called with
@@ -1239,3 +1283,17 @@
 
   return (nfa_sys_cb.trace_level);
 }
+/*******************************************************************************
+**
+** Function:        NFA_EnableDtamode
+**
+** Description:     Enable DTA Mode
+**
+** Returns:         none:
+**
+*******************************************************************************/
+void NFA_EnableDtamode(tNFA_eDtaModes eDtaMode) {
+  NFA_TRACE_API2("%s: 0x%x ", __func__, eDtaMode);
+  appl_dta_mode_flag = 0x01;
+  nfa_dm_cb.eDtaMode = eDtaMode;
+}
diff --git a/src/nfa/dm/nfa_dm_discover.c b/src/nfa/dm/nfa_dm_discover.c
index 004cafa..e28af09 100644
--- a/src/nfa/dm/nfa_dm_discover.c
+++ b/src/nfa/dm/nfa_dm_discover.c
@@ -1,6 +1,5 @@
 /******************************************************************************
  *
- *  Copyright (C) 2010-2014 Broadcom Corporation
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -1317,6 +1316,14 @@
     /* if any ISO-DEP or T3T listening even if host in LRT is not matched */
     xx = iso_dep_t3t__listen;
   }
+  if (protocol == NFC_PROTOCOL_NFC_DEP &&
+      (tech_n_mode == NFC_DISCOVERY_TYPE_LISTEN_F_ACTIVE ||
+       tech_n_mode == NFC_DISCOVERY_TYPE_LISTEN_A_ACTIVE ||
+       tech_n_mode == NFC_DISCOVERY_TYPE_LISTEN_A)) {
+    if (appl_dta_mode_flag == 1 && tech_n_mode == NFC_DISCOVERY_TYPE_LISTEN_A) {
+      NFA_TRACE_DEBUG0("DTA Mode Enabled : NFC-A Passive Listen Mode");
+    }
+  }
 
   if (xx < NFA_DM_DISC_NUM_ENTRIES) {
     nfa_dm_cb.disc_cb.activated_tech_mode = tech_n_mode;
@@ -2903,7 +2910,10 @@
         "returning from nfa_dm_p2p_prio_logic  Disable p2p_prio_logic");
     return true;
   }
-
+  if (appl_dta_mode_flag == 0x01) {
+    /*Disable the P2P Prio Logic when DTA is running*/
+    return TRUE;
+  }
   if (event == NCI_MSG_RF_DISCOVER &&
       p2p_prio_logic_data.timer_expired == true &&
       event_type == NFA_DM_P2P_PRIO_RSP) {
diff --git a/src/nfa/dm/nfa_dm_main.c b/src/nfa/dm/nfa_dm_main.c
index 7d9032d..dbc51ba 100644
--- a/src/nfa/dm/nfa_dm_main.c
+++ b/src/nfa/dm/nfa_dm_main.c
@@ -73,7 +73,8 @@
     nfa_dm_act_reg_vsc,              /* NFA_DM_API_REG_VSC_EVT               */
     nfa_dm_act_send_vsc,             /* NFA_DM_API_SEND_VSC_EVT              */
     nfa_dm_act_disable_timeout,      /* NFA_DM_TIMEOUT_DISABLE_EVT           */
-    nfa_dm_set_power_sub_state       /* NFA_DM_API_SET_POWER_SUB_STATE_EVT  */
+    nfa_dm_set_power_sub_state,      /* NFA_DM_API_SET_POWER_SUB_STATE_EVT   */
+    nfa_dm_act_send_raw_vs           /* NFA_DM_API_SEND_RAW_VS_EVT           */
 };
 
 /*****************************************************************************
@@ -369,11 +370,21 @@
           update = true;
         } else if (memcmp(p_value, p_stored, len)) {
           update = true;
+        } else if (appl_dta_mode_flag && app_init) {
+          /* In DTA mode, config update is forced so that length of config
+           * params (i.e update_len) is updated accordingly even for setconfig
+           * have only one tlv */
+          update = true;
         }
       } else if (len == max_len) /* fixed length */
       {
         if (memcmp(p_value, p_stored, len)) {
           update = true;
+        } else if (appl_dta_mode_flag && app_init) {
+          /* In DTA mode, config update is forced so that length of config
+           * params (i.e update_len) is updated accordingly even for setconfig
+           * have only one tlv */
+          update = true;
         }
       }
     }
@@ -396,9 +407,17 @@
 
   /* If any TVLs to update, or if the SetConfig was initiated by the
    * application, then send the SET_CONFIG command */
-  if (updated_len || app_init) {
+  if (((updated_len || app_init) &&
+       (appl_dta_mode_flag == 0x00 ||
+        (nfa_dm_cb.eDtaMode & 0x0F) == NFA_DTA_HCEF_MODE)) ||
+      (appl_dta_mode_flag && app_init)) {
     nfc_status = NFC_SetConfig(updated_len, p_tlv_list);
+
     if (nfc_status == NFC_STATUS_OK) {
+      if ((nfa_dm_cb.eDtaMode & 0x0F) == NFA_DTA_HCEF_MODE) {
+        nfa_dm_cb.eDtaMode &= ~NFA_DTA_HCEF_MODE;
+        nfa_dm_cb.eDtaMode |= NFA_DTA_DEFAULT_MODE;
+      }
       /* Keep track of whether we will need to notify NFA_DM_SET_CONFIG_EVT on
        * NFC_SET_CONFIG_REVT */
 
diff --git a/src/nfa/include/nfa_api.h b/src/nfa/include/nfa_api.h
index 16c44cb..3467fdb 100644
--- a/src/nfa/include/nfa_api.h
+++ b/src/nfa/include/nfa_api.h
@@ -314,6 +314,19 @@
 /* NFA_DM callback */
 typedef void(tNFA_DM_CBACK)(uint8_t event, tNFA_DM_CBACK_DATA* p_data);
 
+/* NFA Enable DTA Type Mode */
+typedef enum {
+  NFA_DTA_DEFAULT_MODE = 0x00000001,
+  NFA_DTA_LLCP_MODE = 0x00000002,
+  NFA_DTA_SNEP_MODE = 0x00000003,
+  NFA_DTA_HCEF_MODE = 0x00000004,
+  NFA_DTA_CR8 = 0x00000080,
+  NFA_DTA_CR9 = 0x00000090,
+  NFA_DTA_CR10 = 0x000000A0,
+  NFA_DTA_CR11 = 0x000000B0,
+  NFA_DTA_CR12 = 0x000000C0,
+} tNFA_eDtaModes;
+
 /* NFA Connection Callback Events */
 #define NFA_POLL_ENABLED_EVT 0  /* Polling enabled event */
 #define NFA_POLL_DISABLED_EVT 1 /* Polling disabled event */
@@ -1385,6 +1398,27 @@
 
 /*******************************************************************************
 **
+** Function         NFA_SendRawVsCommand
+**
+** Description      This function is called to send raw vendor specific
+**                  command to NFCC.
+**
+**                  cmd_params_len  - The command parameter len
+**                  p_cmd_params    - The command parameter
+**                  p_cback         - The callback function to receive the
+**                                    command
+**
+** Returns          NFA_STATUS_OK if successfully initiated
+**                  NFA_STATUS_FAILED otherwise
+**
+*******************************************************************************/
+
+extern tNFA_STATUS NFA_SendRawVsCommand(uint8_t cmd_params_len,
+                                        uint8_t* p_cmd_params,
+                                        tNFA_VSC_CBACK* p_cback);
+
+/*******************************************************************************
+**
 ** Function         NFA_SetTraceLevel
 **
 ** Description      This function sets the trace level for NFA.  If called with
@@ -1397,6 +1431,16 @@
 
 /*******************************************************************************
 **
+** Function:        NFA_EnableDTA_TypeMode
+**
+** Description:     Initialize and get global DTA type mode from .conf
+**
+** Returns:         none:
+**
+*******************************************************************************/
+extern void NFA_EnableDtamode(tNFA_eDtaModes eDtaMode);
+
+/*******************************************************************************
 ** Function:        NFA_SetPowerSubStateForScreenState
 **
 ** Description:     This function send the current screen state
diff --git a/src/nfa/int/nfa_dm_int.h b/src/nfa/int/nfa_dm_int.h
index 815a7e6..a527927 100644
--- a/src/nfa/int/nfa_dm_int.h
+++ b/src/nfa/int/nfa_dm_int.h
@@ -62,6 +62,7 @@
   NFA_DM_API_SEND_VSC_EVT,
   NFA_DM_TIMEOUT_DISABLE_EVT,
   NFA_DM_API_SET_POWER_SUB_STATE_EVT,
+  NFA_DM_API_SEND_RAW_VS_EVT,
   NFA_DM_MAX_EVT
 };
 
@@ -547,6 +548,7 @@
                                          sent in case of error scenerio */
 
   uint8_t power_state; /* current screen/power  state */
+  uint32_t eDtaMode;   /* To enable the DTA type modes. */
 } tNFA_DM_CB;
 
 /* Internal function prototypes */
@@ -556,6 +558,9 @@
 void nfa_dm_act_conn_cback_notify(uint8_t event, tNFA_CONN_EVT_DATA* p_data);
 void nfa_dm_notify_activation_status(tNFA_STATUS status,
                                      tNFA_TAG_PARAMS* p_params);
+
+bool nfa_dm_act_send_raw_vs(tNFA_DM_MSG* p_data);
+
 void nfa_dm_disable_complete(void);
 
 /* Internal functions from nfa_rw */
@@ -578,6 +583,10 @@
 extern uint8_t nfa_dm_num_dm_interface_mapping;
 extern bool nfa_poll_bail_out_mode;
 
+void nfa_dm_poll_disc_cback_dta_wrapper(tNFA_DM_RF_DISC_EVT event,
+                                        tNFC_DISCOVER* p_data);
+extern unsigned char appl_dta_mode_flag;
+
 /* NFA device manager control block */
 extern tNFA_DM_CB nfa_dm_cb;
 
diff --git a/src/nfa/p2p/nfa_p2p_main.c b/src/nfa/p2p/nfa_p2p_main.c
index e687895..2363033 100644
--- a/src/nfa/p2p/nfa_p2p_main.c
+++ b/src/nfa/p2p/nfa_p2p_main.c
@@ -235,10 +235,26 @@
       p2p_listen_mask |= NFA_DM_DISC_MASK_LFA_NFC_DEP;
   }
 
-  /* Configure listen technologies and protocols and register callback to NFA DM
-   * discovery */
-  nfa_p2p_cb.dm_disc_handle = nfa_dm_add_rf_discover(
-      p2p_listen_mask, NFA_DM_DISC_HOST_ID_DH, nfa_p2p_discovery_cback);
+  /* For P2P mode(Default DTA mode) open Raw channel to bypass LLCP layer. For
+   * LLCP DTA mode activate LLCP Bypassing LLCP is handled in
+   * nfa_dm_poll_disc_cback */
+
+  if (appl_dta_mode_flag == 1 &&
+      ((nfa_dm_cb.eDtaMode & 0x0F) == NFA_DTA_DEFAULT_MODE)) {
+    // Configure listen technologies and protocols and register callback to DTA
+
+    P2P_TRACE_DEBUG1(
+        "%s: DTA mode:Registering nfa_dm_poll_disc_cback to avoid LLCP in P2P",
+        __func__);
+    nfa_p2p_cb.dm_disc_handle =
+        nfa_dm_add_rf_discover(p2p_listen_mask, NFA_DM_DISC_HOST_ID_DH,
+                               nfa_dm_poll_disc_cback_dta_wrapper);
+  } else {
+    /* Configure listen technologies and protocols and register callback to NFA
+     * DM discovery */
+    nfa_p2p_cb.dm_disc_handle = nfa_dm_add_rf_discover(
+        p2p_listen_mask, NFA_DM_DISC_HOST_ID_DH, nfa_p2p_discovery_cback);
+  }
 
   /* restart RF discovery to update RF technologies */
   p_msg = (NFC_HDR*)GKI_getbuf(sizeof(NFC_HDR));
@@ -333,7 +349,13 @@
     if (reason != LLCP_LINK_RF_LINK_LOSS_ERR) /* if NFC link is still up */
     {
       if (nfa_p2p_cb.is_initiator) {
-        nfa_dm_rf_deactivate(NFA_DEACTIVATE_TYPE_DISCOVERY);
+        /*For LLCP DTA test, Deactivate to Sleep is needed to send DSL_REQ*/
+        if (appl_dta_mode_flag == 1 &&
+            ((nfa_dm_cb.eDtaMode & 0x0F) == NFA_DTA_LLCP_MODE)) {
+          nfa_dm_rf_deactivate(NFA_DEACTIVATE_TYPE_SLEEP);
+        } else {
+          nfa_dm_rf_deactivate(NFA_DEACTIVATE_TYPE_DISCOVERY);
+        }
       } else if ((nfa_p2p_cb.is_active_mode) && (reason == LLCP_LINK_TIMEOUT)) {
         /*
         ** target needs to trun off RF in case of receiving invalid
@@ -593,10 +615,26 @@
   }
 
   if (p2p_listen_mask) {
-    /* Configure listen technologies and protocols and register callback to NFA
-     * DM discovery */
-    nfa_p2p_cb.dm_disc_handle = nfa_dm_add_rf_discover(
-        p2p_listen_mask, NFA_DM_DISC_HOST_ID_DH, nfa_p2p_discovery_cback);
+    /* For P2P mode(Default DTA mode) open Raw channel to bypass LLCP layer.
+     * For LLCP DTA mode activate LLCP Bypassing LLCP is handled in
+     * nfa_dm_poll_disc_cback */
+    if (appl_dta_mode_flag == 1 &&
+        ((nfa_dm_cb.eDtaMode & 0x0F) == NFA_DTA_DEFAULT_MODE)) {
+      /* Configure listen technologies and protocols and register callback to
+       * NFA DM discovery */
+      P2P_TRACE_DEBUG1(
+          "%s: DTA mode:Registering nfa_dm_poll_disc_cback to avoid LLCP in "
+          "P2P",
+          __func__);
+      nfa_p2p_cb.dm_disc_handle =
+          nfa_dm_add_rf_discover(p2p_listen_mask, NFA_DM_DISC_HOST_ID_DH,
+                                 nfa_dm_poll_disc_cback_dta_wrapper);
+    } else {
+      /* Configure listen technologies and protocols and register callback to
+       * NFA DM discovery */
+      nfa_p2p_cb.dm_disc_handle = nfa_dm_add_rf_discover(
+          p2p_listen_mask, NFA_DM_DISC_HOST_ID_DH, nfa_p2p_discovery_cback);
+    }
   }
 }
 
@@ -667,7 +705,7 @@
     }
 
     /* restart discovery without updating sub-module status */
-    if (nfa_p2p_cb.is_p2p_listening)
+    if (nfa_p2p_cb.is_p2p_listening || appl_dta_mode_flag)
       nfa_p2p_enable_listening(NFA_ID_P2P, false);
     else if (nfa_p2p_cb.is_snep_listening)
       nfa_p2p_enable_listening(NFA_ID_SNEP, false);
diff --git a/src/nfa/rw/nfa_rw_act.c b/src/nfa/rw/nfa_rw_act.c
index a9c6f86..d369219 100644
--- a/src/nfa/rw/nfa_rw_act.c
+++ b/src/nfa/rw/nfa_rw_act.c
@@ -2537,12 +2537,19 @@
     memcpy(tag_params.t2t.uid, p_activate_params->rf_tech_param.param.pa.nfcid1,
            p_activate_params->rf_tech_param.param.pa.nfcid1_len);
   } else if (NFC_PROTOCOL_T3T == nfa_rw_cb.protocol) {
-    /* Issue command to get Felica system codes */
-    activate_notify =
-        false; /* Delay notifying upper layer of NFA_ACTIVATED_EVT until system
-                  codes are retrieved */
-    msg.op = NFA_RW_OP_T3T_GET_SYSTEM_CODES;
-    nfa_rw_handle_op_req((tNFA_RW_MSG*)&msg);
+    if (appl_dta_mode_flag) {
+      /* Incase of DTA mode Dont send commands to get system code. Just notify
+       * activation */
+      activate_notify = true;
+    } else {
+      /* Delay notifying upper layer of NFA_ACTIVATED_EVT until system codes
+       * are retrieved */
+      activate_notify = false;
+
+      /* Issue command to get Felica system codes */
+      msg.op = NFA_RW_OP_T3T_GET_SYSTEM_CODES;
+      nfa_rw_handle_op_req((tNFA_RW_MSG*)&msg);
+    }
   } else if (NFA_PROTOCOL_T5T == nfa_rw_cb.protocol) {
     /* Delay notifying upper layer of NFA_ACTIVATED_EVT to retrieve additional
      * tag infomation */
diff --git a/src/nfc/include/llcp_api.h b/src/nfc/include/llcp_api.h
index d3c507b..50b0740 100644
--- a/src/nfc/include/llcp_api.h
+++ b/src/nfc/include/llcp_api.h
@@ -668,7 +668,19 @@
 ** Returns          The new or current trace level
 **
 *******************************************************************************/
+
 extern uint8_t LLCP_SetTraceLevel(uint8_t new_level);
+/*******************************************************************************
+**
+** Function         LLCP_RegisterDtaCback
+**
+** Description      Register callback function for LLCP DTA testing
+**
+**
+** Returns          void
+**
+*******************************************************************************/
+extern void LLCP_RegisterDtaCback(tLLCP_DTA_CBACK* p_dta_cback);
 
 #if (LLCP_TEST_INCLUDED == TRUE)
 /*******************************************************************************
diff --git a/src/nfc/include/nci_hmsgs.h b/src/nfc/include/nci_hmsgs.h
index 9141144..d013cde 100644
--- a/src/nfc/include/nci_hmsgs.h
+++ b/src/nfc/include/nci_hmsgs.h
@@ -40,6 +40,7 @@
 void nci_proc_rf_management_ntf(NFC_HDR* p_msg);
 void nci_proc_ee_management_ntf(NFC_HDR* p_msg);
 void nci_proc_prop_rsp(NFC_HDR* p_msg);
+void nci_proc_prop_raw_vs_rsp(NFC_HDR* p_msg);
 void nci_proc_prop_ntf(NFC_HDR* p_msg);
 
 uint8_t nci_snd_core_reset(uint8_t reset_type);
diff --git a/src/nfc/include/nfc_api.h b/src/nfc/include/nfc_api.h
index 83c582f..2a35942 100644
--- a/src/nfc/include/nfc_api.h
+++ b/src/nfc/include/nfc_api.h
@@ -325,6 +325,14 @@
   tNFC_NFCEE_MODE mode; /* NFCEE mode       */
 } tNFC_NFCEE_MODE_SET_REVT;
 
+#if (APPL_DTA_MODE == TRUE)
+/* This data type is for FW Version */
+typedef struct {
+  uint8_t rom_code_version; /* ROM code Version  */
+  uint8_t major_version;    /* Major Version */
+  uint8_t minor_version;    /* Minor Version  */
+} tNFC_FW_VERSION;
+#endif
 #define NFC_MAX_AID_LEN NCI_MAX_AID_LEN /* 16 */
 
 /* the data type associated with NFC_CE_GET_ROUTING_REVT */
@@ -1290,6 +1298,22 @@
 
 /*******************************************************************************
 **
+** Function         NFC_SendRawVsCommand
+**
+** Description      This function is called to send the given raw command to
+**                  NFCC. The response from NFCC is reported to the given
+**                  tNFC_VS_CBACK.
+**
+** Parameters       p_data - The command buffer
+**
+** Returns          tNFC_STATUS
+**
+*******************************************************************************/
+extern tNFC_STATUS NFC_SendRawVsCommand(NFC_HDR* p_data,
+                                        tNFC_VS_CBACK* p_cback);
+
+/*******************************************************************************
+**
 ** Function         NFC_TestLoopback
 **
 ** Description      This function is called to send the given data packet
@@ -1328,6 +1352,20 @@
 *******************************************************************************/
 extern tNFC_STATUS NFC_ISODEPNakPresCheck();
 
+#if (APPL_DTA_MODE == TRUE)
+/*******************************************************************************
+**
+** Function         nfc_ncif_getFWVersion
+**
+** Description      This function sets the trace level for NFC.  If called with
+**                  a value of 0xFF, it simply returns the current trace level.
+**
+** Returns          The new or current trace level
+**
+*******************************************************************************/
+extern tNFC_FW_VERSION nfc_ncif_getFWVersion();
+#endif
+
 #if (BT_TRACE_VERBOSE == TRUE)
 /*******************************************************************************
 **
diff --git a/src/nfc/include/tags_defs.h b/src/nfc/include/tags_defs.h
index 74405af..6ac16ed 100644
--- a/src/nfc/include/tags_defs.h
+++ b/src/nfc/include/tags_defs.h
@@ -291,8 +291,11 @@
 #define T2T_TLEN_MEM_CTRL_TLV 3 /* Tag len for MEM_CTRL TLV per spec */
 
 /* Maximum number of sectors supported */
+#if (APPL_DTA_MODE == TRUE)
+#define T2T_MAX_SECTOR 3
+#else
 #define T2T_MAX_SECTOR 2
-
+#endif
 /* Tlv type identifier len                */
 #define T2T_TLV_TYPE_LEN 1
 
diff --git a/src/nfc/int/llcp_int.h b/src/nfc/int/llcp_int.h
index e40a674..fdf1c70 100644
--- a/src/nfc/int/llcp_int.h
+++ b/src/nfc/int/llcp_int.h
@@ -272,6 +272,8 @@
   uint8_t total_rx_ui_pdu;   /* total number of rx UI PDU in all of ui_rx_q  */
   uint8_t total_rx_i_pdu;    /* total number of rx I PDU in all of i_rx_q    */
   bool overall_rx_congested; /* TRUE if overall rx link is congested         */
+  tLLCP_DTA_CBACK* p_dta_cback; /* callback to notify DTA when respoding SNL */
+  bool dta_snl_resp; /* TRUE if need to notify DTA when respoding SNL*/
 } tLLCP_CB;
 
 #if (LLCP_TEST_INCLUDED == TRUE) /* this is for LLCP testing */
diff --git a/src/nfc/int/nfc_int.h b/src/nfc/int/nfc_int.h
index d3de715..c3fb85c 100644
--- a/src/nfc/int/nfc_int.h
+++ b/src/nfc/int/nfc_int.h
@@ -49,6 +49,7 @@
 /* NFC Timer events */
 #define NFC_TTYPE_NCI_WAIT_RSP 0
 #define NFC_TTYPE_WAIT_2_DEACTIVATE 1
+#define NFC_WAIT_RSP_RAW_VS 0x02
 
 #define NFC_TTYPE_LLCP_LINK_MANAGER 100
 #define NFC_TTYPE_LLCP_LINK_INACT 101
@@ -225,6 +226,7 @@
 
   uint16_t nci_max_v_size; /*maximum NFC V rf frame size*/
 
+  uint8_t rawVsCbflag;
   uint8_t deact_reason;
 
 } tNFC_CB;
@@ -288,9 +290,11 @@
 extern void nfc_ncif_proc_data(NFC_HDR* p_msg);
 extern bool nfa_dm_p2p_prio_logic(uint8_t event, uint8_t* p, uint8_t ntf_rsp);
 extern void nfa_dm_p2p_timer_event();
+extern bool nfc_ncif_proc_proprietary_rsp(uint8_t mt, uint8_t gid, uint8_t oid);
 extern void nfa_dm_p2p_prio_logic_cleanup();
 extern void nfc_ncif_proc_isodep_nak_presence_check_status(uint8_t status,
                                                            bool is_ntf);
+extern void nfc_ncif_update_window(void);
 #if (NFC_RW_ONLY == FALSE)
 extern void nfc_ncif_proc_rf_field_ntf(uint8_t rf_status);
 #else
diff --git a/src/nfc/int/nfc_vs.h b/src/nfc/int/nfc_vs.h
new file mode 100644
index 0000000..adc2f25
--- /dev/null
+++ b/src/nfc/int/nfc_vs.h
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * Copyright (C) 2017 NXP Semiconductors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ *  This file contains the Near Field Communication (NFC) VS related internal
+ *  function / definitions.
+ *
+ ******************************************************************************/
+
+#ifndef NFC_VS_H_
+#define NFC_VS_H_
+
+// DTA API for MW Version need to change according to release
+#define NXP_EN_PN547C2 0
+#define NXP_EN_PN65T 0
+#define NXP_EN_PN548C2 0
+#define NXP_EN_PN66T 0
+#define NXP_EN_PN551 0
+#define NXP_EN_PN67T 0
+#define NXP_EN_PN553 1
+#define NXP_EN_PN80T 1
+#define NXP_ANDROID_VER (7U)        /* NXP android version */
+#define NFC_NXP_MW_VERSION_MAJ (4U) /* MW Major Version */
+#define NFC_NXP_MW_VERSION_MIN (9U) /* MW Minor Version */
+
+#endif /* NFC_VS_H_ */
diff --git a/src/nfc/llcp/llcp_api.c b/src/nfc/llcp/llcp_api.c
index 3329bb4..9d87ec0 100644
--- a/src/nfc/llcp/llcp_api.c
+++ b/src/nfc/llcp/llcp_api.c
@@ -58,6 +58,22 @@
 
 /*******************************************************************************
 **
+** Function         LLCP_RegisterDtaCback
+**
+** Description      Register callback function for LLCP DTA testing
+**
+**
+** Returns          void
+**
+*******************************************************************************/
+void LLCP_RegisterDtaCback(tLLCP_DTA_CBACK* p_dta_cback) {
+  LLCP_TRACE_API1("%s", __func__);
+
+  llcp_cb.p_dta_cback = p_dta_cback;
+}
+
+/*******************************************************************************
+**
 ** Function         LLCP_SetConfig
 **
 ** Description      Set configuration parameters for LLCP
diff --git a/src/nfc/llcp/llcp_dlc.c b/src/nfc/llcp/llcp_dlc.c
index a5fe51c..0465a95 100644
--- a/src/nfc/llcp/llcp_dlc.c
+++ b/src/nfc/llcp/llcp_dlc.c
@@ -42,6 +42,7 @@
                                         tLLCP_DLC_EVENT event, void* p_data);
 static tLLCP_STATUS llcp_dlsm_w4_remote_dm(tLLCP_DLCB* p_dlcb,
                                            tLLCP_DLC_EVENT event, void* p_data);
+extern unsigned char appl_dta_mode_flag;
 
 #if (BT_TRACE_VERBOSE == TRUE)
 static char* llcp_dlsm_get_state_name(tLLCP_DLC_STATE state);
@@ -645,7 +646,18 @@
   /* parse CONNECT PDU and get connection parameters */
   if (llcp_util_parse_connect(p_data, length, &params) != LLCP_STATUS_SUCCESS) {
     LLCP_TRACE_ERROR0("llcp_dlc_proc_connect_pdu (): Bad format CONNECT");
-    llcp_util_send_dm(ssap, dsap, LLCP_SAP_DM_REASON_NO_SERVICE);
+    /* fix to pass TC_CTO_TAR_BI_02_x (x=5) test case
+     * As per the LLCP test specification v1.2.00 by receiving erroneous SNL PDU
+     * i'e with improper length and service name "urn:nfc:sn:dta-co-echo-in",
+     * the IUT should not send any PDU except SYMM PDU */
+
+    if (appl_dta_mode_flag == 1 &&
+        p_data[1] == strlen((const char*)&p_data[2])) {
+      LLCP_TRACE_DEBUG1("%s: Strings are not equal", __func__);
+      llcp_util_send_dm(ssap, dsap, LLCP_SAP_DM_REASON_NO_SERVICE);
+    } else {
+      llcp_util_send_dm(ssap, dsap, LLCP_SAP_DM_REASON_NO_SERVICE);
+    }
     return;
   }
 
diff --git a/src/nfc/llcp/llcp_link.c b/src/nfc/llcp/llcp_link.c
index 4be2e5f..5fa6a41 100644
--- a/src/nfc/llcp/llcp_link.c
+++ b/src/nfc/llcp/llcp_link.c
@@ -27,6 +27,7 @@
 #include "gki.h"
 #include "llcp_defs.h"
 #include "llcp_int.h"
+#include "nfa_dm_int.h"
 #include "nfc_int.h"
 #include "nfc_target.h"
 #include "trace_api.h"
@@ -76,6 +77,8 @@
 extern tLLCP_TEST_PARAMS llcp_test_params;
 #endif
 
+extern unsigned char appl_dta_mode_flag;
+
 /* debug functions type */
 #if (BT_TRACE_VERBOSE == TRUE)
 static char* llcp_pdu_type(uint8_t ptype);
@@ -183,6 +186,27 @@
   if (llcp_link_parse_gen_bytes(p_config->gen_bytes_len,
                                 p_config->p_gen_bytes) == false) {
     LLCP_TRACE_ERROR0("llcp_link_activate (): Failed to parse general bytes");
+    /* For LLCP DTA test, In case of bad magic bytes normal p2p communication is
+     * expected,but in case of wrong magic bytes in ATR_REQ, LLC layer will be
+     * disconnected but P2P connection is expected to be in connected state
+     * and non LLC PDU is expected.
+     * As per NFC forum expectation below changes is to send PDU after
+     * disconnect of LLCP PDU.
+     * This is fix for TC_MAC_TAR_BI_01 LLCP test case */
+
+    if (appl_dta_mode_flag == 1 && p_config->is_initiator == FALSE) {
+      NFC_HDR* p_msg = (NFC_HDR*)GKI_getpoolbuf(LLCP_POOL_ID);
+
+      if (p_msg) {
+        /*LLCP test scenario requires non LLC PDU to be sent in case of wrong
+          magic bytes. So sending NFC-DEP pdu with size 1 (0x00)*/
+        p_msg->len = 1;
+        p_msg->offset = NCI_MSG_OFFSET_SIZE + NCI_DATA_HDR_SIZE;
+
+        NFC_SendData(NFC_RF_CONN_ID, p_msg);
+      }
+    }
+
     (*llcp_cb.lcb.p_link_cback)(LLCP_LINK_ACTIVATION_FAILED_EVT,
                                 LLCP_LINK_BAD_GEN_BYTES);
 
@@ -206,11 +230,13 @@
         p_config->waiting_time, llcp_link_rwt[p_config->waiting_time],
         llcp_cb.lcb.peer_lto);
   }
-
-  /* extend LTO as much as internally required processing time and propagation
-   * delays */
-  llcp_cb.lcb.peer_lto += LLCP_INTERNAL_TX_DELAY + LLCP_INTERNAL_RX_DELAY;
-
+  /* For DTA mode Peer LTO Should not include TX RX Delay, Just llcp deactivate
+   * after Peer LTO time */
+  if (!appl_dta_mode_flag) {
+    /* extend LTO as much as internally required processing time and propagation
+     * delays */
+    llcp_cb.lcb.peer_lto += LLCP_INTERNAL_TX_DELAY + LLCP_INTERNAL_RX_DELAY;
+  }
   /* LLCP version number agreement */
   if (llcp_link_version_agreement() == false) {
     LLCP_TRACE_ERROR0("llcp_link_activate (): Failed to agree version");
@@ -403,8 +429,18 @@
   llcp_cb.overall_tx_congested = false;
   llcp_cb.overall_rx_congested = false;
 
+  /* As per the LLCP test specification v1.2.00 for test case TC_LLC_TAR_BV_04
+   * the receiving LLC shall commence sending an LLC PDU to the remote
+   * LLC. So, after IUT receives DISC PDU from LT(remote device), IUT shall
+   * send DISC PDU to LT. appl_dta_mode_flag condition is added to fulfil
+   * above requirement. Only in CR8, the IUT shall acknoweledge with SYMM for
+   * DISC PDU. For other CRx, send DISC PDU.
+   */
   if ((reason == LLCP_LINK_FRAME_ERROR) ||
-      (reason == LLCP_LINK_LOCAL_INITIATED)) {
+      (reason == LLCP_LINK_LOCAL_INITIATED) ||
+      (appl_dta_mode_flag && reason == LLCP_LINK_REMOTE_INITIATED &&
+       llcp_cb.lcb.is_initiator == false &&
+       (nfa_dm_cb.eDtaMode & 0xF0) != NFA_DTA_CR8)) {
     /* get rid of the data pending in NFC tx queue, so DISC PDU can be sent ASAP
      */
     NFC_FlushData(NFC_RF_CONN_ID);
@@ -836,7 +872,9 @@
   */
   llcp_link_check_congestion();
 
-  if (llcp_cb.lcb.symm_state == LLCP_LINK_SYMM_LOCAL_XMIT_NEXT) {
+  if (llcp_cb.lcb.symm_state == LLCP_LINK_SYMM_LOCAL_XMIT_NEXT ||
+      (appl_dta_mode_flag &&
+       llcp_cb.lcb.link_state == LLCP_LINK_STATE_DEACTIVATING)) {
     LLCP_TRACE_DEBUG0(
         "llcp_link_check_send_data () in state of "
         "LLCP_LINK_SYMM_LOCAL_XMIT_NEXT");
@@ -1233,7 +1271,10 @@
         (llcp_cb.lcb.sig_xmit_q.count == 0)) {
       /* this indicates that DISC PDU had been sent out to peer */
       /* initiator may wait for SYMM PDU */
-      llcp_link_process_link_timeout();
+      if (appl_dta_mode_flag == 0x01)
+        llcp_util_send_disc(LLCP_SAP_LM, LLCP_SAP_LM);
+      else
+        llcp_link_process_link_timeout();
     } else {
       if (p_msg->len < LLCP_PDU_HEADER_SIZE) {
         LLCP_TRACE_ERROR1("Received too small PDU: got %d bytes", p_msg->len);
diff --git a/src/nfc/llcp/llcp_sdp.c b/src/nfc/llcp/llcp_sdp.c
index 7253186..2c40263 100644
--- a/src/nfc/llcp/llcp_sdp.c
+++ b/src/nfc/llcp/llcp_sdp.c
@@ -28,6 +28,7 @@
 #include "llcp_api.h"
 #include "llcp_defs.h"
 #include "llcp_int.h"
+#include "nfa_dm_int.h"
 #include "nfc_target.h"
 
 /*******************************************************************************
@@ -73,6 +74,13 @@
 
     GKI_enqueue(&llcp_cb.lcb.sig_xmit_q, llcp_cb.sdp_cb.p_snl);
     llcp_cb.sdp_cb.p_snl = NULL;
+  } else {
+    /* Notify DTA after sending out SNL with SDRES not to send SNLs in AGF PDU
+     */
+    if (llcp_cb.p_dta_cback && llcp_cb.dta_snl_resp) {
+      llcp_cb.dta_snl_resp = false;
+      (*llcp_cb.p_dta_cback)();
+    }
   }
 }
 
@@ -285,6 +293,12 @@
     if ((p_app_cb) && (p_app_cb->p_app_cback) &&
         (strlen((char*)p_app_cb->p_service_name) == length) &&
         (!strncmp((char*)p_app_cb->p_service_name, p_name, length))) {
+      /* if device is under LLCP DTA testing */
+      if (llcp_cb.p_dta_cback && (!strncmp((char*)p_app_cb->p_service_name,
+                                           "urn:nfc:sn:cl-echo-in", length))) {
+        llcp_cb.dta_snl_resp = true;
+      }
+
       return (sap);
     }
   }
@@ -347,6 +361,7 @@
   }
 
   llcp_cb.sdp_cb.next_tid = 0;
+  llcp_cb.dta_snl_resp = false;
 }
 
 /*******************************************************************************
@@ -386,8 +401,29 @@
           p_value = p;
           BE_STREAM_TO_UINT8(tid, p_value);
           sap = llcp_sdp_get_sap_by_name((char*)p_value, (uint8_t)(length - 1));
-          llcp_sdp_send_sdres(tid, sap);
+          /* fix to pass TC_CTO_TAR_BI_03_x (x=5) test case
+           * As per the LLCP test specification v1.2.00 by receiving erroneous
+           * SNL PDU i'e with improper service name "urn:nfc:sn:dta-co-echo-in",
+           * the IUT should not send any PDU except SYMM PDU */
+          if (appl_dta_mode_flag == 1 && sap == 0x00) {
+            LLCP_TRACE_DEBUG2("%s: In dta mode sap == 0x00 p_value = %s",
+                              __func__, p_value);
+            if ((length - 1) == strlen((const char*)p_value)) {
+              LLCP_TRACE_DEBUG1("%s: Strings are not equal", __func__);
+              llcp_sdp_send_sdres(tid, sap);
+            }
+          } else {
+            llcp_sdp_send_sdres(tid, sap);
+          }
         } else {
+          /*For P2P in LLCP mode TC_CTO_TAR_BI_03_x(x=3) fix*/
+          if (appl_dta_mode_flag == 1 &&
+              ((nfa_dm_cb.eDtaMode & 0x0F) == NFA_DTA_LLCP_MODE)) {
+            LLCP_TRACE_ERROR1("%s: Calling llcp_sdp_send_sdres", __func__);
+            tid = 0x01;
+            sap = 0x00;
+            llcp_sdp_send_sdres(tid, sap);
+          }
           LLCP_TRACE_ERROR1(
               "llcp_sdp_proc_snl (): bad length (%d) in LLCP_SDREQ_TYPE",
               length);
diff --git a/src/nfc/nci/nci_hrcv.c b/src/nfc/nci/nci_hrcv.c
index fb58ba0..07757de 100644
--- a/src/nfc/nci/nci_hrcv.c
+++ b/src/nfc/nci/nci_hrcv.c
@@ -448,6 +448,34 @@
 
 /*******************************************************************************
 **
+** Function         nci_proc_prop_raw_vs_rsp
+**
+** Description      Process RAW VS responses
+**
+** Returns          void
+**
+*******************************************************************************/
+void nci_proc_prop_raw_vs_rsp(NFC_HDR* p_msg) {
+  uint8_t op_code;
+  tNFC_VS_CBACK* p_cback = (tNFC_VS_CBACK*)nfc_cb.p_vsc_cback;
+
+  /* find the start of the NCI message and parse the NCI header */
+  uint8_t* p_evt = (uint8_t*)(p_msg + 1) + p_msg->offset;
+  uint8_t* p = p_evt + 1;
+  NCI_MSG_PRS_HDR1(p, op_code);
+
+  /* If there's a pending/stored command, restore the associated address of the
+   * callback function */
+  if (p_cback) {
+    (*p_cback)((tNFC_VS_EVT)(NCI_RSP_BIT | op_code), p_msg->len, p_evt);
+    nfc_cb.p_vsc_cback = NULL;
+  }
+  nfc_cb.rawVsCbflag = false;
+  nfc_ncif_update_window();
+}
+
+/*******************************************************************************
+**
 ** Function         nci_proc_prop_ntf
 **
 ** Description      Process NCI notifications in the Proprietary group
diff --git a/src/nfc/nfc/nfc_ncif.cc b/src/nfc/nfc/nfc_ncif.cc
index 4b94b8c..47f49e2 100644
--- a/src/nfc/nfc/nfc_ncif.cc
+++ b/src/nfc/nfc/nfc_ncif.cc
@@ -40,10 +40,14 @@
 static const uint8_t nfc_mpl_code_to_size[] = {64, 128, 192, 254};
 
 #endif /* NFC_RW_ONLY */
-
+#if (APPL_DTA_MODE == TRUE)
+// Global Structure varibale for FW Version
+static tNFC_FW_VERSION nfc_fw_version;
+#endif
 #define NFC_PB_ATTRIB_REQ_FIXED_BYTES 1
 #define NFC_LB_ATTRIB_REQ_FIXED_BYTES 8
 
+extern unsigned char appl_dta_mode_flag;
 /*******************************************************************************
 **
 ** Function         nfc_ncif_update_window
@@ -254,14 +258,17 @@
       if (p_buf->layer_specific == NFC_WAIT_RSP_VSC) {
         /* save the callback for NCI VSCs)  */
         nfc_cb.p_vsc_cback = (void*)((tNFC_NCI_VS_MSG*)p_buf)->p_cback;
+      } else if (p_buf->layer_specific == NFC_WAIT_RSP_RAW_VS) {
+        /* save the callback for RAW VS */
+        nfc_cb.p_vsc_cback = (void*)((tNFC_NCI_VS_MSG*)p_buf)->p_cback;
+        nfc_cb.rawVsCbflag = true;
       }
 
-      /* send to HAL */
-      HAL_WRITE(p_buf);
-
       /* Indicate command is pending */
       nfc_cb.nci_cmd_window--;
 
+      /* send to HAL */
+      HAL_WRITE(p_buf);
       /* start NFC command-timeout timer */
       nfc_start_timer(&nfc_cb.nci_wait_rsp_timer,
                       (uint16_t)(NFC_TTYPE_NCI_WAIT_RSP),
@@ -299,6 +306,19 @@
   }
 }
 
+#if (APPL_DTA_MODE == TRUE)
+/*******************************************************************************
+**
+** Function         nfc_ncif_getFWVersion
+**
+** Description      This function is called to fet the FW Version
+**
+** Returns          tNFC_FW_VERSION
+**
+*******************************************************************************/
+tNFC_FW_VERSION nfc_ncif_getFWVersion() { return nfc_fw_version; }
+#endif
+
 /*******************************************************************************
 **
 ** Function         nfc_ncif_send_cmd
@@ -336,6 +356,13 @@
 
   pp = p;
   NCI_MSG_PRS_HDR0(pp, mt, pbf, gid);
+  oid = ((*pp) & NCI_OID_MASK);
+  if (nfc_cb.rawVsCbflag == true &&
+      nfc_ncif_proc_proprietary_rsp(mt, gid, oid) == true) {
+    nci_proc_prop_raw_vs_rsp(p_msg);
+    nfc_cb.rawVsCbflag = false;
+    return free;
+  }
 
   nfcsnoop_capture(p_msg, true);
   switch (mt) {
@@ -1584,3 +1611,51 @@
   }
   GKI_freebuf(p_msg);
 }
+
+/*******************************************************************************
+**
+** Function         nfc_ncif_process_proprietary_rsp
+**
+** Description      Process the response to avoid collision
+**                  while rawVsCbflag is set
+**
+** Returns          true if proprietary response else false
+**
+*******************************************************************************/
+bool nfc_ncif_proc_proprietary_rsp(uint8_t mt, uint8_t gid, uint8_t oid) {
+  bool stat = FALSE;
+  NFC_TRACE_DEBUG4("%s: mt=%u, gid=%u, oid=%u", __func__, mt, gid, oid);
+
+  switch (mt) {
+    case NCI_MT_DATA:
+      /* check for Data Response */
+      if (gid != 0x03 && oid != 0x00) stat = TRUE;
+      break;
+
+    case NCI_MT_NTF:
+      switch (gid) {
+        case NCI_GID_CORE:
+          /* check for CORE_RESET_NTF or CORE_CONN_CREDITS_NTF */
+          if (oid != 0x00 && oid != 0x06) stat = TRUE;
+          break;
+        case NCI_GID_RF_MANAGE:
+          /* check for CORE_CONN_CREDITS_NTF or NFA_EE_ACTION_NTF or
+           * NFA_EE_DISCOVERY_REQ_NTF */
+          if (oid != 0x06 && oid != 0x09 && oid != 0x0A) stat = TRUE;
+          break;
+        case NCI_GID_EE_MANAGE:
+          if (oid != 0x00) stat = TRUE;
+          break;
+        default:
+          stat = TRUE;
+          break;
+      }
+      break;
+
+    default:
+      stat = TRUE;
+      break;
+  }
+  NFC_TRACE_DEBUG2("%s: exit status=%u", __func__, stat);
+  return stat;
+}
diff --git a/src/nfc/nfc/nfc_vs.c b/src/nfc/nfc/nfc_vs.c
index 7f8be28..5e2548a 100644
--- a/src/nfc/nfc/nfc_vs.c
+++ b/src/nfc/nfc/nfc_vs.c
@@ -73,6 +73,36 @@
 
 /*******************************************************************************
 **
+** Function         NFC_SendRawVsCommand
+**
+** Description      This function is called to send the raw vendor specific
+**                  command to NFCC. The response from NFCC is reported to the
+**                  given tNFC_VS_CBACK.
+**
+** Parameters       p_data - The command buffer
+**
+** Returns          tNFC_STATUS
+**
+*******************************************************************************/
+tNFC_STATUS NFC_SendRawVsCommand(NFC_HDR* p_data, tNFC_VS_CBACK* p_cback) {
+  /* Validate parameters */
+  if (p_data == NULL || (p_data->len > NCI_MAX_VSC_SIZE)) {
+    NFC_TRACE_ERROR1("buffer offset must be >= %d", NCI_VSC_MSG_HDR_SIZE);
+    if (p_data) GKI_freebuf(p_data);
+    return NFC_STATUS_INVALID_PARAM;
+  }
+
+  p_data->event = BT_EVT_TO_NFC_NCI;
+  p_data->layer_specific = NFC_WAIT_RSP_RAW_VS;
+  /* save the callback function in the BT_HDR, to receive the response */
+  ((tNFC_NCI_VS_MSG*)p_data)->p_cback = p_cback;
+
+  nfc_ncif_check_cmd_queue(p_data);
+  return NFC_STATUS_OK;
+}
+
+/*******************************************************************************
+**
 ** Function         NFC_SendVsCommand
 **
 ** Description      This function is called to send the given vendor specific
diff --git a/src/nfc/tags/rw_t1t.c b/src/nfc/tags/rw_t1t.c
index 6d685b8..2c7e02d 100644
--- a/src/nfc/tags/rw_t1t.c
+++ b/src/nfc/tags/rw_t1t.c
@@ -32,6 +32,7 @@
 #include "rw_api.h"
 #include "rw_int.h"
 
+extern unsigned char appl_dta_mode_flag;
 /* Local Functions */
 static tRW_EVENT rw_t1t_handle_rid_rsp(NFC_HDR* p_pkt);
 static void rw_t1t_data_cback(uint8_t conn_id, tNFC_CONN_EVT event,
@@ -682,7 +683,7 @@
 
   p_t1t->state = RW_T1T_STATE_IDLE;
 #if (RW_NDEF_INCLUDED == TRUE)
-  if (p_t1t->state != RW_T1T_STATE_READ_NDEF) {
+  if (appl_dta_mode_flag == 0 && (p_t1t->state != RW_T1T_STATE_READ_NDEF)) {
     p_t1t->b_update = false;
     p_t1t->b_rseg = false;
   }