author | Tinku Mannan <tmannan@ti.com> | |
Thu, 10 Jan 2013 15:46:30 +0000 (10:46 -0500) | ||
committer | Tinku Mannan <tmannan@ti.com> | |
Thu, 10 Jan 2013 15:46:30 +0000 (10:46 -0500) |
Conflicts:
ti/runtime/netapi/netapi_sched.h
ti/runtime/netapi/netapi_tune.h
ti/runtime/netapi/pktio.h
ti/runtime/netapi/src/netapi_sec.c
ti/runtime/netapi/test/net_test.c
ti/runtime/netapi/test/net_test.h
ti/runtime/netapi/netapi_sched.h
ti/runtime/netapi/netapi_tune.h
ti/runtime/netapi/pktio.h
ti/runtime/netapi/src/netapi_sec.c
ti/runtime/netapi/test/net_test.c
ti/runtime/netapi/test/net_test.h
1 | 2 | |||
---|---|---|---|---|
ti/runtime/netapi/build/Makefile | patch | | diff1 | | diff2 | | blob | history |
ti/runtime/netapi/netapi.h | patch | | diff1 | | diff2 | | blob | history |
ti/runtime/netapi/netapi_sched.h | patch | | diff1 | | diff2 | | blob | history |
ti/runtime/netapi/netapi_tune.h | patch | | diff1 | | diff2 | | blob | history |
ti/runtime/netapi/pktio.h | patch | | diff1 | | diff2 | | blob | history |
ti/runtime/netapi/test/net_test.c | patch | | diff1 | | diff2 | | blob | history |
ti/runtime/netapi/test/net_test.h | patch | | diff1 | | diff2 | | blob | history |
diff --cc ti/runtime/netapi/build/Makefile
Simple merge
diff --cc ti/runtime/netapi/netapi.h
Simple merge
diff --cc ti/runtime/netapi/netapi_sched.h
index a58edd24087674e383d08cd8899cc230d73490a5,abc87cbf50c658b47642c17526a9742c55bfe474..7f81d67d8fdeb6955b5905a10e20911670b8082d
void * back; /**< Pointer back to NETAPI handle */
NETAPI_SCHED_CONFIG_T config; /**< NETAPI scheduler configuration */
- uint64_t start; /**< Start time of NETAPI scheduler context TBD*/
- volatile int shutdown_reason; /**< FUTURE-not implemented TBD */
+ uint64_t start; /**< Start time of NETAPI scheduler context */
+ volatile int shutdown_reason; /**< FUTURE-not implemented */
volatile uint64_t shutdown_time; /**< Time till scheduler context will be shutdown/closed */
+unsigned long long num_pkts;
+unsigned long long busy_cycles;
+unsigned long long cache_cycles;
} NETAPI_SCHED_HANDLE_T;
/**
* @ingroup sched_functions
- * @brief netapi_sched_get_stats: API to tget NETAP scheduling context statistics
+ * @brief netapi_sched_get_stats: API to get NETAP scheduling context statistics
*
* @details API to tget NETAP scheduling context statistics
- * @param[in] p_pkts TBD
- * @param[in] p_cycles TBD
- * @param[in] p_ccycles TBD
+ * @param[in] s The NETAPI scheduling context handle, @ref NETAPI_SCHED_HANDLE_T
+ * @param[in] p_pkts total number of packets processed by scheduler poll loop
+ * @param[in] p_cycles total number cycles taken by scheduler poll loop
+ * @param[in] p_ccycles total number of cache control cycles taken by scheduler poll loop
* @retval none
*/
-void netapi_sched_get_stats(unsigned long long * p_pkts,
- unsigned long long * p_cycles,
- unsigned long long * p_ccycles);
+void netapi_sched_get_stats(NETAPI_SCHED_HANDLE_T *s,
+ unsigned long long * p_pkts,
+ unsigned long long * p_cycles,
+ unsigned long long * p_ccycles);
#endif
diff --cc ti/runtime/netapi/netapi_tune.h
Simple merge
diff --cc ti/runtime/netapi/pktio.h
index c584d5bd62b71d67a61a8219bcf999b998aa6ae1,1e120eeb3cad4af56ce8595235c877a8b0902719..feab0752cf2058bcd37307c98a792b83099d5cba
/**
* @def PKTIO_DIVERT
- * This defines is used to divert to dest channel TBD
+ * This defines is used to divert to dest channel
*/
#define PKTIO_DIVERT 0x2
-
+#define PKTIO_SET_POLL_FLAGS 0x4 //control poll flags (netcp_rx only)
- int op; /**< TBD */
- PKTIO_HANDLE_T *dest; /**< Handle to PKTIO channel */
- int poll_flags;
+ int op; /**< control operation (CLEAR, DIVERT, ..) */
+ PKTIO_HANDLE_T *dest; /**< Handle to PKTIO channel (for DIVERT) */
++ int poll_flags;
} PKTIO_CONTROL_T;
diff --cc ti/runtime/netapi/test/net_test.c
index f1bbf324b3eeffbfb8f7b79c07eedbda0ba3ee69,5c79d8a2e3e750606864030966eec7da6c77b2c2..8c2c2db3d99eace6bb7abf7ff59aef6b391d5559
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************/
-#define NET_TEST_ENABLE_INFLOW_LOW_LEVEL_API
-#ifdef NET_TEST_ENABLE_INFLOW_LOW_LEVEL_API
+#define DAL_REVIEW
- #define NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
++//#define NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
+#ifdef NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
#define NWAL_ENABLE_SA
#endif
-#define NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
-#ifdef NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
+#define AH_SUPPORT
++//#define NET_TEST_ENABLE_INFLOW_LOW_LEVEL_API
++#ifdef NET_TEST_ENABLE_INFLOW_LOW_LEVEL_API
+ #define NWAL_ENABLE_SA
+ #endif
+//define this for multi-thread
+#define MULTI_THREAD
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
PKTIO_CONTROL_T zap_channel_control={PKTIO_CLEAR, NULL};
/* security objects. (for loopback mode) */
- netTestSA_t sa_info[6];
+ netTestSA_t sa_info[7];
int netapi_algorithm_set = 0;
int netapi_sec_sa_mode = 2;
-/* tmannan-end */
-//NETCP_CFG_SA_T rx_tunnel;
-//NETCP_CFG_SA_T tx_tunnel;
-NETCP_CFG_IPSEC_POLICY_T rx_policy[4];
-//void * rx_data_mode_handle;
-//void * tx_data_mode_handle;
-//void * rx_inflow_mode_handle;
-//void * tx_inflow_mode_handle;
-/* rx */
+
+NETCP_CFG_IPSEC_POLICY_T rx_policy[7];
+
NETAPI_SEC_SA_INFO_T rx_sa [7] = {
meta_tx.pAad= &p_add[0];
meta_tx.aadSize = 8;
}
- else if (p_sa_info->cipherMode == NWAL_SA_EALG_NULL)
- {
- meta_tx.pEncIV = NULL;
- }
- else
- {
- meta_tx.pEncIV = &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN + netTest_ESP_HEADER_LEN ];
- }
- /* post it to netcp sb tx channel*/
- meta_tx.appCtxId = (nwal_AppId)netapi_timing_start();
- meta.u.tx_sb_meta=&meta_tx;
+ else if (p_sa_info->cipherMode == NWAL_SA_EALG_NULL)
+ {
+ meta_tx.pEncIV = NULL;
+ }
+ else
+ {
+ meta_tx.pEncIV = &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN + netTest_ESP_HEADER_LEN ];
+ }
+ //meta_tx.authIvSize=0;
+
+ /* post it to netcp sb tx channel*/
+ meta_tx.appCtxId = (nwal_AppId)hplib_mUtilGetPmuCCNT();
+ meta.u.tx_sb_meta=&meta_tx;
- /* Use the command label which was cached during create time
+ #ifdef NET_TEST_ENABLE_SIDE_BAND_LOW_LEVEL_API
+ /* Use the command label which was cached during create time
* Update the Queue to receive output packet from SA to the local
* core Queue. Below information can be saved by application in
* per process context to avoid API overhead per packet
pPloadDesc,
NWAL_DESC_SIZE);
- }
-else
- {
- //inflow tx
- //send pkt directly, asking for IP and UDP checksum offloads AND IPSEC to be applied
- PKTIO_METADATA_T meta = {PKTIO_META_TX,{0},0};
- int err;
- nwalTxPktInfo_t meta_tx={0};
+ #else
+ pktio_send(netcp_sb_tx_chan,tip,&meta,&err);
+ #endif
+ }
+ else
+ {
+ //INFLOW TX *******************
+ //send pkt directly, asking for IP and UDP checksum offloads AND IPSEC to be applied
+ PKTIO_METADATA_T meta = {PKTIO_META_TX,{0},0};
+ int err;
+ nwalTxPktInfo_t meta_tx={0};
#define USE_COPY
#ifdef USE_COPY
//debug: see if re-using RX descriptor for TX is causing our SA lockup
-{
- int new_len=0;
- Ti_Pkt new_tip = get_pkt(0, &new_len, specialLarge , len+10 , &p_pkt[0] , len);
- if (!new_tip)
- {
- printf("net_test> new_tip NULL\n");
- }
- else
- {
- Pktlib_setPacketLen(new_tip,new_len);
- Pktlib_freePacket(tip);
- tip=new_tip;
- Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&new_len); //reset p_pkt to point to new buffer as its used below
- Cppi_setTimeStamp (Cppi_DescType_HOST, (Cppi_Desc *) tip,stats.sec_tx);
- }
-}
-if (len <1500)
-{
- eof+=1;
-}
-#endif
- meta.sa_handle=p_sa_info->tx_inflow_mode_handle; //this tells netapi that inflow crypto needs to be applied
- //meta_tx.txFlag1 = (NWAL_TX_FLAG1_DO_IPV4_CHKSUM|NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_META_DATA_VALID );
- meta_tx.txFlag1 = p_sa_info->tx_pkt_info.txFlag1;
- meta_tx.enetPort=0;
- //meta_tx.saOffBytes=14+20;
- meta_tx.saOffBytes= p_sa_info->tx_pkt_info.saOffBytes;
- meta_tx.saPayloadLen=len-14-20; //don't include tag, mac and outer header
- //meta_tx.startOffset = 0;
- meta_tx.startOffset = p_sa_info->tx_pkt_info.startOffset;
- //meta_tx.ipOffBytes = 14+20+8+16; //to inner header
- meta_tx.ipOffBytes =p_sa_info->tx_payload_info.encOffset;
- //meta_tx.l4OffBytes = 14+20+8+16+20; //to L4
- meta_tx.l4OffBytes = p_sa_info->tx_pkt_info.l4OffBytes;
- meta_tx.l4HdrLen = p_sa_info->tx_pkt_info.l4HdrLen;
- meta_tx.ploadLen = (unsigned) ((p_pkt[meta_tx.l4OffBytes+4]<<8)|p_pkt[meta_tx.l4OffBytes+4+1]) -8 ;
- meta_tx.pseudoHdrChecksum =
- test_utilGetIpv4PsudoChkSum(&p_pkt[meta_tx.ipOffBytes],8+ meta_tx.ploadLen);
+ {
+ int new_len=0;
+ Ti_Pkt new_tip = get_pkt(0, &new_len, specialLarge , len+10 , &p_pkt[0] , len);
+ if (!new_tip)
+ {
+ printf("net_test> new_tip NULL\n");
+ }
+ else
+ {
+ Pktlib_setPacketLen(new_tip,new_len);
+ Pktlib_freePacket(tip);
+ tip=new_tip;
+ Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&new_len); //reset p_pkt to point to new buffer as its used below
+// Cppi_setTimeStamp (Cppi_DescType_HOST, (Cppi_Desc *) tip,stats[coreid].sec_tx);
+ }
+ }
+ if (len <1500)
+ {
+ eof+=1;
+ }
+#endif
- /* post it to netcp tx channel*/
- meta.u.tx_meta=&meta_tx;
- if (stats.sec_tx<20) dump_descr((long *) tip, stats.sec_tx);
+ meta.sa_handle=p_sa_info->tx_inflow_mode_handle; //this tells netapi that inflow crypto needs to be applied
+ meta_tx.startOffset = p_sa_info->tx_pkt_info.startOffset;
+ meta_tx.ipOffBytes =p_sa_info->tx_payload_info.encOffset;
+ meta_tx.l4OffBytes = p_sa_info->tx_pkt_info.l4OffBytes;
+ meta_tx.l4HdrLen = p_sa_info->tx_pkt_info.l4HdrLen;
+ meta_tx.ploadLen = (unsigned) ((p_pkt[meta_tx.l4OffBytes+4]<<8)|p_pkt[meta_tx.l4OffBytes+4+1]) -8 ;
+ meta_tx.saOffBytes= p_sa_info->tx_pkt_info.saOffBytes;
+ if (pkt_type == IPSEC_AH_PKT)
+ {
+ memset(&p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN+netTest_IPSEC_AH_FIXED_HDR_SIZE],0,netTest_IPSEC_AH_FIXED_HDR_SIZE);
+ meta_tx.txFlag1 = p_sa_info->tx_pkt_info.txFlag1;
+ meta_tx.saPayloadLen=len-netTest_MAC_HEADER_LEN; //don't inlcude mac
+ meta_tx.saAhMacSize = 12;
+ meta_tx.saAhIcvOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN + netTest_IPSEC_AH_FIXED_HDR_SIZE;
++ printf("flip_and_send_pkt: enet_port %d\n", enet_port);
+ meta_tx.enetPort = enet_port;
+ }
+ else if (pkt_type == IPSEC_ESP_PKT)
+ {
+ meta_tx.txFlag1 = p_sa_info->tx_pkt_info.txFlag1;
+ meta_tx.saPayloadLen=len-netTest_MAC_HEADER_LEN-netTest_IP_HEADER_LEN; //don't include mac and ip outer header
+ meta_tx.enetPort = 0;
+ }
+ else
+ {
+ printf("flip_and_send_pkt: invalid ESP protocol\n");
+ return;
+ }
+
+ meta_tx.pseudoHdrChecksum =
+ test_utilGetIpv4PsudoChkSum(&p_pkt[meta_tx.ipOffBytes],8+ meta_tx.ploadLen);
+
+
+ /* post it to netcp tx channel*/
+ meta.u.tx_meta=&meta_tx;
+ if (stats[coreid].sec_tx<20) dump_descr((long *) tip, stats[coreid].sec_tx);
- pktio_send(netcp_tx_chan,tip,&meta,&err);
+ #ifdef NET_TEST_ENABLE_INFLOW_LOW_LEVEL_API
+ #if 0
+ nwal_mCmdSetCrypPort (tip,
+ &p_sa_info->tx_psCmdInfo,
+ p_sa_info->tx_pkt_info.saOffBytes,
+ meta_tx.saPayloadLen,
+ p_sa_info->swInfo0,
+ p_sa_info->swInfo1,
+ NWAL_ENET_PORT_UNKNOWN);
+ #endif
+ nwal_mCmdSetL4CkSumCrypPort(tip,
+ &p_sa_info->tx_psCmdInfo,
+ meta_tx.l4OffBytes,
+ meta_tx.ploadLen + meta_tx.l4HdrLen,
+ meta_tx.pseudoHdrChecksum,
+ p_sa_info->tx_pkt_info.saOffBytes,
+ meta_tx.saPayloadLen,
+ p_sa_info->swInfo0,
+ p_sa_info->swInfo1,
- NWAL_ENET_PORT_UNKNOWN);
++ enet_port);
+
+ pPloadDesc = Pktlib_getDescFromPacket(tip);
+ pPloadDesc = Qmss_osalConvertDescVirtToPhy(pPloadDesc);
+ Qmss_queuePushDescSizeRaw(p_sa_info->tx_psCmdInfo.txQueue,
+ pPloadDesc,
+ NWAL_DESC_SIZE);
+ #else
+ pktio_send(netcp_tx_chan,tip,&meta,&err);
+ #endif
- stats.tx +=1;
- stats.sec_tx +=1;
- }
-}
-else //non ipsec send pkt directly, asking for IP and UDP checksum ofload
-{
- PKTIO_METADATA_T meta2 = {PKTIO_META_TX,{0},0};
- int err;
- nwalTxPktInfo_t meta_tx2={0};
- meta2.sa_handle=nwal_HANDLE_INVALID;
- meta_tx2.txFlag1 = (NWAL_TX_FLAG1_DO_IPV4_CHKSUM|NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID );
- meta_tx2.startOffset = 0;
- meta_tx2.ipOffBytes = 14;
- meta_tx2.l4OffBytes = 14+20;
- meta_tx2.l4HdrLen = 8;
- meta_tx2.ploadLen = (unsigned) ((p_pkt[14+20+4]<<8)|p_pkt[14+20+4+1]) -8 ;
- meta_tx2.pseudoHdrChecksum =
- test_utilGetIpv4PsudoChkSum(&p_pkt[14],8+ meta_tx2.ploadLen);
-
- /* post it to netcp tx channel*/
- meta2.u.tx_meta=&meta_tx2;
- pktio_send(netcp_tx_chan,tip,&meta2,&err);
- stats.tx +=1;
-}
+ stats[coreid].tx +=1;
+ stats[coreid].sec_tx +=1;
+ }
+ }
+ else //non ipsec send pkt directly, asking for IP and UDP checksum ofload
+ {
+ PKTIO_METADATA_T meta2 = {PKTIO_META_TX,{0},0};
+ int err;
+ nwalTxPktInfo_t meta_tx2={0};
+ meta2.sa_handle=nwal_HANDLE_INVALID;
+ meta_tx2.txFlag1 = (NWAL_TX_FLAG1_DO_IPV4_CHKSUM|NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID );
+ meta_tx2.startOffset = 0;
+ meta_tx2.ipOffBytes = 14;
+ meta_tx2.l4OffBytes = 14+20;
+ meta_tx2.l4HdrLen = 8;
+ meta_tx2.ploadLen = (unsigned) ((p_pkt[14+20+4]<<8)|p_pkt[14+20+4+1]) -8 ;
+ meta_tx2.pseudoHdrChecksum =
+ test_utilGetIpv4PsudoChkSum(&p_pkt[14],8+ meta_tx2.ploadLen);
+
+ /* post it to netcp tx channel*/
+ meta2.u.tx_meta=&meta_tx2;
+ pktio_send(netcp_tx_chan,tip,&meta2,&err);
+ stats[coreid].tx +=1;
+ }
}
int main(int argc, char **argv)
{
int err,i;
+ Pktlib_HeapCfg heapCfg;
rlim_t oss,ss = 1024*1024;
struct rlimit rl;
-
- Pktlib_HeapCfg heapCfg;
int32_t errCode;
Pktlib_HeapIfTable* pPktifTable;
-
+
FILE * fpr = NULL;
-
-nwalSaIpSecId_t nwalSaIpSecId;
++ nwalSaIpSecId_t nwalSaIpSecId;
+
err= getrlimit(RLIMIT_STACK,&rl);
if (!err) printf(" stack limit = %d\n",rl.rlim_cur); else printf("getrlimit failed\n");
-#if 0
- rl.rlim_cur = ss;
- err=setrlimit(RLIMIT_STACK,&rl);
-i f (!err) printf("set stack to %d\n",rl.rlim_cur); else printf("setrlimit failed\n");
-#endif
-
if (argc>=2) np2process = atoi(argv[1]);
printf("*************** np2process %d\n", np2process);
diff --cc ti/runtime/netapi/test/net_test.h
Simple merge