Fix for SDOCM00103115: ARM user space transport: net test router test ipsec capabilit...
authorTinku Mannan <tmannan@ti.com>
Wed, 4 Sep 2013 12:58:08 +0000 (08:58 -0400)
committerTinku Mannan <tmannan@ti.com>
Wed, 4 Sep 2013 12:58:08 +0000 (08:58 -0400)
ti/runtime/netapi/pktio.h
ti/runtime/netapi/src/pktio.c
ti/runtime/netapi/test/net_test_router.c
ti/runtime/netapi/test/net_test_sa_utils.c

index cda16cfbefe3736d4ea53d30182e207c873cccc1..7f2e6e19dc89bb553f2753c62197969846ce949d 100755 (executable)
@@ -223,7 +223,7 @@ typedef struct PKTIO_FAST_PATH_CONFIG_Tag
 /**
  * @def PKTIO_FP_ESP_PORT
  * @ingroup pktio_constants
- *      Use this define to send packet with Crypto ESP packet
+ *      Use this define to send packet with Crypto ESP packet, updates to ENET port
  */
 #define  PKTIO_FP_ESP_PORT 5
 
@@ -234,6 +234,13 @@ typedef struct PKTIO_FAST_PATH_CONFIG_Tag
  */
 #define  PKTIO_FP_AH_PORT 6
 
+/**
+ * @def PKTIO_FP_AH_PORT
+ * @ingroup pktio_constants
+ *      Use this define to send packet with Crypto ESP, IP checksum, updates to ENET port
+ */
+#define  PKTIO_FP_ESP_L3CKSUM_PORT 7
+
     nwalTxPktInfo_t   *txPktInfo;  /** <The parameters in this structure are used to 
                                          provide additional details for the outgoing packet*/
 } PKTIO_FAST_PATH_CONFIG_T;
index 12ee1b6dd1fb27cdc80db8a085c08d77e9a4c497..583b4949c843a4d8767833b39791390e58da504b 100755 (executable)
@@ -109,7 +109,7 @@ static int netapip_pktioSendL4CkSumCryptPort(struct PKTIO_HANDLE_tag * pp,
                                     pTxPktInfo->saPayloadLen, 
                                     swInfo0, 
                                     swInfo1,
-                                    0);
+                                    pTxPktInfo->enetPort);
 
         pPloadDesc = Pktlib_getDescFromPacket(pkt);
         pPloadDesc = Qmss_osalConvertDescVirtToPhy(pPloadDesc);
@@ -151,11 +151,11 @@ static int netapip_pktioSendCryptPort(struct PKTIO_HANDLE_tag * pp,
     {
         nwal_mCmdSetCrypPort(pkt,
                              &p->tx_psCmdInfo,
-                              pTxPktInfo->saOffBytes, 
-                              pTxPktInfo->saPayloadLen, 
-                              swInfo0, 
+                              pTxPktInfo->saOffBytes,
+                              pTxPktInfo->saPayloadLen,
+                              swInfo0,
                               swInfo1,
-                              0);
+                              pTxPktInfo->enetPort);
 
         pPloadDesc = Pktlib_getDescFromPacket(pkt);
         pPloadDesc = Qmss_osalConvertDescVirtToPhy(pPloadDesc);
@@ -172,6 +172,58 @@ static int netapip_pktioSendCryptPort(struct PKTIO_HANDLE_tag * pp,
     return 1;
 }
 
+
+/********************************************************************
+ * FUNCTION PURPOSE: Send packet via low level NWAL API's
+ * with updates for L3 checksum, ESP Crypto and outgoing EMAC port
+ * to NetCP command.
+ ********************************************************************
+ * DESCRIPTION: Send packet via low level NWAL API's
+ * with updates for L3 checksum, ESP Crypto and outgoing EMAC port
+ * to NetCP command.
+ ********************************************************************/
+static int netapip_pktioSendL3CkSumCryptPort(struct PKTIO_HANDLE_tag * pp,
+                                     Ti_Pkt *pkt,
+                                     PKTIO_METADATA_T *m,
+                                     int * err)
+{
+    PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
+    nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
+    Cppi_HostDesc*          pPloadDesc;
+    uint32_t swInfo0, swInfo1;
+
+    NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
+
+    if (netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
+    {
+        nwal_mCmdSetL3CkSumCrypPort(pkt,
+                             &p->tx_psCmdInfo,
+                              pTxPktInfo->saOffBytes,
+                              pTxPktInfo->saPayloadLen,
+                              swInfo0,
+                              swInfo1,
+                              pTxPktInfo->enetPort);
+
+        pPloadDesc = Pktlib_getDescFromPacket(pkt);
+        pPloadDesc = Qmss_osalConvertDescVirtToPhy(pPloadDesc);
+        Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
+                                  pPloadDesc,
+                                  NWAL_DESC_SIZE);
+    }
+    else
+    {
+          *err=NETAPI_ERR_BAD_INPUT;
+          return -1;
+    }
+
+    return 1;
+}
+
+
+
+
+
+
 /********************************************************************
  * FUNCTION PURPOSE: Send packet via low level NWAL API's
  * with updates for L4 checksum,AH Crypto and outgoing EMAC port 
@@ -912,6 +964,9 @@ void netapi_pktioControl(PKTIO_HANDLE_T * p,
                             case (PKTIO_FP_ESP_PORT):
                                 p->_send = netapip_pktioSendCryptPort;
                                 break;
+                            case (PKTIO_FP_ESP_L3CKSUM_PORT):
+                                p->_send = netapip_pktioSendL3CkSumCryptPort;
+                                break;
                             case (PKTIO_FP_AH_PORT):
                                 p->_send = netapip_pktioSendAHCryptPort;
                                 break;
index 31793e93cf2e59c400d076c42c06d70ee6ff4dc6..89b292336bed2a8041f9ca05f78e68af37bc6f9d 100755 (executable)
@@ -172,7 +172,7 @@ nwalTxPktInfo_t txPktInfoESP =
     0,                                                                                                 /* saAhMacSize */
     0,                                                                                                  /* etherLenOffBytes */
     netTest_MAC_HEADER_LEN,                                                        /* ipOffBytes */
-    0,                                                                                                  /* l4OffBytes */
+    0,                          /* l4OffBytes */
     0,                         /* l4HdrLen */
     0,                                                                                   /* pseudoHdrChecksum */
     0                                                                                                   /* pLoadLen */
@@ -193,7 +193,7 @@ nwalTxPktInfo_t txPktInfoAH =
     12,                                                                                                 /* saAhMacSize */
     0,                                                                                                  /* etherLenOffBytes */
     netTest_MAC_HEADER_LEN,   /* ipOffBytes */
-    0,                                                                                                  /* l4OffBytes */
+    0,                    /* l4OffBytes */
     netTest_UDP_HEADER_LEN,                                                                            /* l4HdrLen */
     0,                                                                                                  /* pseudoHdrChecksum */
     0                                                                                                   /* pLoadLen */
@@ -232,7 +232,7 @@ void close_pktio_channels(void)
 void open_pktio_tx_channels()
 {
     int err;
-    /* open netcp default  TX channels */
+    /* open netcp default TX channels for non-ipsec*/
     netcp_tx_chan_no_crypto= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
     if (!netcp_tx_chan_no_crypto)
     {
@@ -241,17 +241,14 @@ void open_pktio_tx_channels()
     }
     else
     {
-        if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
-        {
             PKTIO_CONTROL_T control;
             control.op = PKTIO_UPDATE_FAST_PATH;
             PKTIO_CFG_T cfg;
             cfg.fast_path_cfg.fp_send_option = PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT;
             cfg.fast_path_cfg.txPktInfo= &txPktInfoNoCrypto;
             netapi_pktioControl(netcp_tx_chan_no_crypto, NULL, &cfg, &control, &err);
-        }
     }
-    /* open netcp default  TX for ESP packets */
+    /* open netcp default TX for ESP packets */
     netcp_tx_chan_esp= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
     if (!netcp_tx_chan_esp)
     {
@@ -265,7 +262,7 @@ void open_pktio_tx_channels()
             PKTIO_CONTROL_T control;
             control.op = PKTIO_UPDATE_FAST_PATH;
             PKTIO_CFG_T cfg;
-            cfg.fast_path_cfg.fp_send_option = PKTIO_FP_ESP_PORT;
+            cfg.fast_path_cfg.fp_send_option = PKTIO_FP_ESP_L3CKSUM_PORT;
             cfg.fast_path_cfg.txPktInfo= &txPktInfoESP;
             netapi_pktioControl(netcp_tx_chan_esp, NULL, &cfg, &control, &err);
         }
@@ -325,7 +322,11 @@ void slow_path_thread(uint32_t index)
     hplib_utilSetupThread(thread_num, &cpu_set);
 #endif
     worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,NULL);
-
+    if (worker_nh[thread_num] == NULL)
+    {
+        printf("slow_path_thread: netapi_init failure, exiting\n");
+        exit(1);
+    }
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[thread_num];
 
    /* open netcp RX channel */
@@ -383,7 +384,11 @@ void fast_path_thread(uint32_t index)
     hplib_utilSetupThread(thread_num, &cpu_set);
 #endif
     worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,NULL);
-
+    if (worker_nh[thread_num] == NULL)
+    {
+        printf("fast_path_thread: netapi_init failure, exiting\n");
+        exit(1);
+    }
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[thread_num];
 
    /* open netcp RX channel */
@@ -477,7 +482,11 @@ int main(int argc, char **argv)
 #endif
     /* create netapi */
     netapi_handle = netapi_init(NETAPI_SYS_MASTER, &our_netapi_default_cfg);
-
+    if (netapi_handle == NULL)
+    {
+        printf("main: netapi_init failure, exiting\n");
+        exit(1);
+    }
     /* configure expection packet handling with netapi */
     netapi_netcpCfgExceptions(netapi_handle, NETCP_CFG_ALL_EXCEPTIONS, NETCP_CFG_ACTION_DISCARD, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
     expPkt_appid = netapi_netcpCfgExceptions(netapi_handle, 7, NETCP_CFG_ACTION_TO_SW, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
@@ -586,8 +595,7 @@ static inline void send_it(Ti_Pkt *tip, int len, netTestSA_t * p_sec, int out_po
   if(p_sec)
   {   
        meta_tx2.txFlag1 |= NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO ;
-       //meta2.sa_handle = (void*)p_sec->tx_tunnel;
-       meta2.sa_handle=p_sec->tx_inflow_mode_handle;
+       meta2.sa_handle = (void*)p_sec->tx_tunnel;
        meta_tx2.saOffBytes=netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
        meta_tx2.saPayloadLen=len-netTest_MAC_HEADER_LEN - netTest_IP_HEADER_LEN;   //don't include tag, mac and outer header
        meta2.u.tx_meta=&meta_tx2;
index 38548a70a2eea9087bc781ab67de1f23c1f05a6a..1d8d6b92abe58107b6b5f202bdbcdfaf7a05a845 100755 (executable)
@@ -126,6 +126,8 @@ void  netTest_utilBuildSADB(int i)
         tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
         sa_info[i].spi =tmp_spi;
         sa_info[i].tunnel_id = tmp_tunnel;
+        sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
+        sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
 
         if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
         {
@@ -183,7 +185,8 @@ void  netTest_utilBuildSADB(int i)
         tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
         sa_info[i].spi =tmp_spi;
         sa_info[i].tunnel_id = tmp_tunnel;
-
+        sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
+        sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
         if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
         {
            trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
@@ -242,7 +245,8 @@ void  netTest_utilBuildSADB(int i)
         tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
         sa_info[i].spi =tmp_spi;
         sa_info[i].tunnel_id = tmp_tunnel;
-
+        sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
+        sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
         if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
         {
            trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
@@ -298,7 +302,8 @@ void  netTest_utilBuildSADB(int i)
         tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
         sa_info[i].spi =tmp_spi;
         sa_info[i].tunnel_id = tmp_tunnel;
-
+        sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
+        sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
         if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
         {
            trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
@@ -357,7 +362,8 @@ void  netTest_utilBuildSADB(int i)
         tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
         sa_info[i].spi =tmp_spi;
         sa_info[i].tunnel_id = tmp_tunnel;
-
+        sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
+        sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
         if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
         {
            trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
@@ -416,7 +422,8 @@ void  netTest_utilBuildSADB(int i)
         tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
         sa_info[i].spi =tmp_spi;
         sa_info[i].tunnel_id = tmp_tunnel;
-
+        sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
+        sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
         if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
         {
            trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
@@ -476,7 +483,8 @@ void  netTest_utilBuildSADB(int i)
         tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
         sa_info[i].spi =tmp_spi;
         sa_info[i].tunnel_id = tmp_tunnel;
-
+        sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
+        sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
         if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
         {
            trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
@@ -536,7 +544,8 @@ void  netTest_utilBuildSADB(int i)
         tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
         sa_info[i].spi =tmp_spi;
         sa_info[i].tunnel_id = tmp_tunnel;
-
+        sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
+        sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
         if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
         {
            trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);