summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lide2016-05-03 09:57:04 -0500
committerDavid Lide2016-05-03 09:57:04 -0500
commit51981042ebe9cba4cf96ff562b179671a21ca735 (patch)
tree59232af59ccd6fdbf804b90845d29dcec4d5c31c
parent26b40f5c41e7084449406b0ccba80b653e75da7e (diff)
parent15f985b8e1562f72f1dc8e5d73e02cdff07f0cc0 (diff)
downloadnetapi-51981042ebe9cba4cf96ff562b179671a21ca735.tar.gz
netapi-51981042ebe9cba4cf96ff562b179671a21ca735.tar.xz
netapi-51981042ebe9cba4cf96ff562b179671a21ca735.zip
Merge branch 'master' of gtgit01.gt.design.ti.com:git/projects/netapi
-rwxr-xr-xCOPYING.txt61
-rwxr-xr-xti/runtime/netapi/OLD/qmsim.c113
-rwxr-xr-xti/runtime/netapi/OLD/qmsim.h64
-rwxr-xr-xti/runtime/netapi/OLD/shmtest.c118
-rwxr-xr-xti/runtime/netapi/applications/ipsec_offload/config-app/build/Makefile102
-rwxr-xr-xti/runtime/netapi/applications/ipsec_offload/config-app/build/setup_shell_env.sh10
-rwxr-xr-xti/runtime/netapi/applications/ipsec_offload/config-app/src/cmd_shell.c615
-rwxr-xr-xti/runtime/netapi/applications/ipsec_offload/config-app/src/cmd_shell_loc.h62
-rwxr-xr-xti/runtime/netapi/applications/ipsec_offload/config-app/src/cmd_shell_main.c216
-rwxr-xr-xti/runtime/netapi/applications/ipsec_offload/ipsecmgr/build/Makefile144
-rw-r--r--ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/src/netapi_ipsecmgr.c1096
-rwxr-xr-xti/runtime/netapi/applications/ipsec_offload/ipsecmgr/src/netapilib_interface.c629
-rw-r--r--ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/src/netapilib_interface.h117
-rwxr-xr-xti/runtime/netapi/build/Makefile126
-rwxr-xr-xti/runtime/netapi/build/netapi_doxygen.cfg1555
-rwxr-xr-xti/runtime/netapi/demo/build/Makefile127
-rwxr-xr-xti/runtime/netapi/demo/demo_setup_files/dpicgi1.sh16
-rwxr-xr-xti/runtime/netapi/demo/demo_setup_files/dpicgi2.sh7
-rwxr-xr-xti/runtime/netapi/demo/demo_setup_files/dpicgi3.sh7
-rwxr-xr-xti/runtime/netapi/demo/demo_setup_files/dpicgi4.sh6
-rwxr-xr-xti/runtime/netapi/demo/demo_setup_files/dpicgi5.sh6
-rwxr-xr-xti/runtime/netapi/demo/demo_setup_files/index.html26
-rw-r--r--ti/runtime/netapi/demo/demo_setup_files/stats1.awk54
-rw-r--r--ti/runtime/netapi/demo/demo_setup_files/stats2.awk56
-rw-r--r--ti/runtime/netapi/demo/demo_setup_files/stats3.awk71
-rw-r--r--ti/runtime/netapi/demo/demo_setup_files/stats4.awk104
-rw-r--r--ti/runtime/netapi/demo/demo_setup_files/tilogo.gifbin0 -> 1137 bytes
-rw-r--r--ti/runtime/netapi/demo/demo_setup_files/titagline.gifbin0 -> 653 bytes
-rwxr-xr-xti/runtime/netapi/demo/demo_setup_files/transport_dpi_demo_setup.sh51
-rwxr-xr-xti/runtime/netapi/demo/makefile_armv765
-rwxr-xr-xti/runtime/netapi/demo/src/Makefile95
-rwxr-xr-xti/runtime/netapi/demo/src/navl_external_posix.c119
-rwxr-xr-xti/runtime/netapi/demo/src/navl_wrapper.c938
-rwxr-xr-xti/runtime/netapi/demo/src/navl_wrapper.h198
-rwxr-xr-xti/runtime/netapi/demo/src/transport_dpi_demo.c1093
-rwxr-xr-xti/runtime/netapi/demo/src/transport_dpi_demo.h52
-rwxr-xr-xti/runtime/netapi/device/k2e/src/netapi_device.c68
-rwxr-xr-xti/runtime/netapi/device/k2h/src/netapi_device.c67
-rwxr-xr-xti/runtime/netapi/device/k2k/src/netapi_device.c67
-rwxr-xr-xti/runtime/netapi/device/k2l/src/netapi_device.c66
-rwxr-xr-xti/runtime/netapi/docs/tifooter.htm4
-rwxr-xr-xti/runtime/netapi/docs/tiheader.htm12
-rwxr-xr-xti/runtime/netapi/docs/tilogo.gifbin0 -> 1137 bytes
-rwxr-xr-xti/runtime/netapi/docs/titagline.gifbin0 -> 653 bytes
-rwxr-xr-xti/runtime/netapi/docs/user_space_apiv2.pptbin0 -> 1081344 bytes
-rwxr-xr-xti/runtime/netapi/makefile_armv7157
-rwxr-xr-xti/runtime/netapi/netapi.h319
-rwxr-xr-xti/runtime/netapi/netapi_sched.h359
-rwxr-xr-xti/runtime/netapi/netapi_sec.h320
-rwxr-xr-xti/runtime/netapi/netapi_tune.h335
-rwxr-xr-xti/runtime/netapi/netapi_types.h159
-rw-r--r--ti/runtime/netapi/netapi_util.h422
-rwxr-xr-xti/runtime/netapi/netapi_ver.h94
-rwxr-xr-xti/runtime/netapi/netcp_cfg.h911
-rwxr-xr-xti/runtime/netapi/netsync.h162
-rwxr-xr-xti/runtime/netapi/pktio.h816
-rwxr-xr-xti/runtime/netapi/src/netapi.c462
-rwxr-xr-xti/runtime/netapi/src/netapi_init.c1106
-rwxr-xr-xti/runtime/netapi/src/netapi_loc.h454
-rwxr-xr-xti/runtime/netapi/src/netapi_sched.c221
-rw-r--r--ti/runtime/netapi/src/netapi_sec.c900
-rwxr-xr-xti/runtime/netapi/src/netcp_cfg.c2041
-rwxr-xr-xti/runtime/netapi/src/pdkv2/netapi_navig.c303
-rwxr-xr-xti/runtime/netapi/src/pdkv3/netapi_navig.c267
-rwxr-xr-xti/runtime/netapi/src/pktio.c1310
-rwxr-xr-xti/runtime/netapi/src/pktio.c~1323
-rwxr-xr-xti/runtime/netapi/test/build/Makefile139
-rw-r--r--ti/runtime/netapi/test/eqos_config1.txt24
-rw-r--r--ti/runtime/netapi/test/eqos_config2.txt24
-rwxr-xr-xti/runtime/netapi/test/fdb.c425
-rwxr-xr-xti/runtime/netapi/test/fdb.h140
-rwxr-xr-xti/runtime/netapi/test/ifdma_test.c566
-rwxr-xr-xti/runtime/netapi/test/net_test.h61
-rwxr-xr-xti/runtime/netapi/test/net_test_bench.c743
-rwxr-xr-xti/runtime/netapi/test/net_test_config.txt68
-rw-r--r--ti/runtime/netapi/test/net_test_config_max_iface.txt143
-rw-r--r--ti/runtime/netapi/test/net_test_config_max_sa.txt155
-rwxr-xr-xti/runtime/netapi/test/net_test_loopback.c1359
-rwxr-xr-xti/runtime/netapi/test/net_test_max_params.c462
-rwxr-xr-xti/runtime/netapi/test/net_test_router.c800
-rwxr-xr-xti/runtime/netapi/test/net_test_sa_utils.c831
-rwxr-xr-xti/runtime/netapi/test/net_test_sa_utils.h73
-rwxr-xr-xti/runtime/netapi/test/net_test_thread_utils.c109
-rwxr-xr-xti/runtime/netapi/test/net_test_thread_utils.h21
-rwxr-xr-xti/runtime/netapi/test/net_test_utils.c1401
-rwxr-xr-xti/runtime/netapi/test/net_test_utils.h228
-rwxr-xr-xti/runtime/netapi/test/nt_bridge.c1225
-rwxr-xr-xti/runtime/netapi/test/router.c173
-rwxr-xr-xti/runtime/netapi/test/router.h34
-rwxr-xr-xti/runtime/netapi/test/stubs.c2
-rwxr-xr-xti/runtime/netapi/test/trie.c327
-rwxr-xr-xti/runtime/netapi/test/trie.h127
-rwxr-xr-xti/runtime/netapi/tools/armcc2
-rwxr-xr-xti/runtime/netapi/tools/armdump2
-rwxr-xr-xti/runtime/netapi/tools/davinci_clocks56
-rwxr-xr-xti/runtime/netapi/tools/dsp_core_setup.sh35
-rwxr-xr-xti/runtime/netapi/tools/dumpdesc.c132
-rwxr-xr-xti/runtime/netapi/tools/eqos/dumpqos.sh118
-rwxr-xr-xti/runtime/netapi/tools/eqos/parse_ale.awk21
-rwxr-xr-xti/runtime/netapi/tools/eqos/parse_ale.sh1
-rwxr-xr-xti/runtime/netapi/tools/ipsec_tools/aes_ccm.sh8
-rw-r--r--ti/runtime/netapi/tools/ipsec_tools/aes_ccm.txt1
-rwxr-xr-xti/runtime/netapi/tools/ipsec_tools/aes_gcm.sh8
-rw-r--r--ti/runtime/netapi/tools/ipsec_tools/aes_gcm.txt1
-rw-r--r--ti/runtime/netapi/tools/ipsec_tools/aes_xcbc.txt1
-rw-r--r--ti/runtime/netapi/tools/ipsec_tools/hmac-sha1_aes-cbc.txt1
-rw-r--r--ti/runtime/netapi/tools/ipsec_tools/hmac-sha256_aes-ctr.conf15
-rw-r--r--ti/runtime/netapi/tools/ipsec_tools/hmac-sha256_aes_ctr.txt1
-rw-r--r--ti/runtime/netapi/tools/ipsec_tools/hmac_md5_ah.txt1
-rwxr-xr-xti/runtime/netapi/tools/ipsec_tools/sample_evm_ipsec.conf83
-rwxr-xr-xti/runtime/netapi/tools/ipsec_tools/sample_pc_ipsec.conf84
-rwxr-xr-xti/runtime/netapi/tools/ipsec_tools/sectest.sh50
-rw-r--r--ti/runtime/netapi/tools/ipsec_tools/setkey_aes_xcbc.conf15
-rw-r--r--ti/runtime/netapi/tools/ipsec_tools/setkey_hmac-md5_ah.conf15
-rw-r--r--ti/runtime/netapi/tools/ipsec_tools/setkey_hmac-sha1_aes-cbc.conf15
-rw-r--r--ti/runtime/netapi/tools/ipsec_tools/setkeycleanup.conf4
-rwxr-xr-xti/runtime/netapi/tools/irqset.sh7
-rw-r--r--ti/runtime/netapi/tools/kernel_patches/0001-PA-Firmware-Update-and-dma-config.patch2453
-rw-r--r--ti/runtime/netapi/tools/kernel_patches/README.txt4
-rw-r--r--ti/runtime/netapi/tools/kernel_patches/dma_patch_2.0.0.8.txt13
-rw-r--r--ti/runtime/netapi/tools/net_test_loopback_setup.sh20
-rw-r--r--ti/runtime/netapi/tools/net_test_router_setup.sh24
-rwxr-xr-xti/runtime/netapi/tools/nt_bridge_setup.sh21
-rwxr-xr-xti/runtime/netapi/tools/parse_clocks.awk3
-rwxr-xr-xti/runtime/netapi/tools/pcsetupfornetapi.sh7
-rwxr-xr-xti/runtime/netapi/tools/udpifbin0 -> 12282 bytes
-rw-r--r--ti/runtime/netapi/tools/udpif.c272
-rw-r--r--ti/runtime/netapi/utils/netapi_util_rm.c285
-rw-r--r--ti/runtime/netapi/utils/sockutils.c260
-rw-r--r--ti/runtime/netapi/utils/sockutils.h74
130 files changed, 34617 insertions, 0 deletions
diff --git a/COPYING.txt b/COPYING.txt
new file mode 100755
index 0000000..9de3325
--- /dev/null
+++ b/COPYING.txt
@@ -0,0 +1,61 @@
1/* ===========================================================================
2 * Copyright (c) Texas Instruments Incorporated 2010-2013
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the
14 * distribution.
15 *
16 * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 NETAPI Test Source Code: trie.c, trie.h
34 Copyright (c) 2005, Simon Howard
35 All rights reserved.
36 Redistribution and use in source and binary forms, with or without
37 modification, are permitted provided that the following conditions
38 are met:
39 Redistributions of source code must retain the above copyright
40 notice, this list of conditions and the following disclaimer.
41 Redistributions in binary form must reproduce the above copyright
42 notice, this list of conditions and the following disclaimer in
43 the documentation and/or other materials provided with the
44 distribution.
45 Neither the name of the C Algorithms project nor the names of its
46 contributors may be used to endorse or promote products derived
47 from this software without specific prior written permission.
48 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
49 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
50 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
51 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
52 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
53 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
54 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
55 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
56 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
58 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
59 POSSIBILITY OF SUCH DAMAGE.
60 ALSO: TI modifications made to support binary data keys
61 Copyright (c) Texas Instruments Incorporated 2010-2011
diff --git a/ti/runtime/netapi/OLD/qmsim.c b/ti/runtime/netapi/OLD/qmsim.c
new file mode 100755
index 0000000..7791c38
--- /dev/null
+++ b/ti/runtime/netapi/OLD/qmsim.c
@@ -0,0 +1,113 @@
1/*******************************************************************
2* FILE: qmsim.c
3 *
4 * DESCRIPTION: netapi user space transport
5 * library desktop simulator for queues.
6 * (test code, not operational)
7 *
8 * REVISION HISTORY: rev 0.0.1
9 *
10 * Copyright (c) Texas Instruments Incorporated 2010-2011
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
22 * distribution.
23 *
24 * Neither the name of Texas Instruments Incorporated nor the names of
25 * its contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 ***********************************************************************/
40
41
42#include <stdlib.h>
43#include "qmsim.h"
44
45/*-------------------Simulator part ---------------*/
46
47void dumpq(Q* q)
48{
49 printf("QDUMP: %d %d %d %d\n",q->size, q->ne, q->head,q->tail);
50}
51void qsim_close(Q * q)
52{
53 if (!q) return;
54 if (q->q) free(q->q);
55 free(q);
56 printf("QSIM: freeing queue\n");
57}
58
59Q * qsim_create(nelem)
60{
61void *p;
62Q * q;
63if (!nelem) return NULL;
64q = (Q*) calloc(1,sizeof(Q));
65if (!q) return NULL;
66
67p = (void **) calloc(nelem,sizeof(void *));
68if (!p) { free(q); return NULL; }
69
70q->size=nelem;
71q->q = p ;
72 printf("QSIM CREATE .. "); dumpq(q);
73return q;
74}
75
76int qsim_push(Q *q, void *p)
77{
78 if (!q) return -1;
79 if (q->ne >= q->size) return-1;
80 q->q[q->tail] = p;
81 q->tail +=1;
82 q->ne+=1;
83 if (q->tail >= q->size) q->tail = 0;
84 //dumpq(q);
85 return 1;
86}
87void * qsim_pop(Q *q )
88{
89 void * val;
90 if (!q) return NULL;
91 if (q->ne ==0) return NULL;
92 val = q->q[q->head];
93 q->head+=1;
94 if(q->head>= q->size) q->head=0;
95 q->ne -=1;
96 //dumpq(q);
97 return val;
98}
99
100//#define TEST_QSIM
101#ifdef TEST_QSIM
102main()
103{
104 Q * q;
105 int i;
106 q= qsim_create(10);
107 for(i=1;i<11;i++) qsim_push(q, (void *) i);
108
109 for(;i<16;i++) { void * val; val = qsim_pop(q); printf("%d\n", (int) val);}
110 for(;i<21;i++) qsim_push(q, (void *) i);
111 for(;i<31;i++) { void * val; val = qsim_pop(q); printf("%d\n", (int) val);}
112}
113#endif
diff --git a/ti/runtime/netapi/OLD/qmsim.h b/ti/runtime/netapi/OLD/qmsim.h
new file mode 100755
index 0000000..9dfc3a9
--- /dev/null
+++ b/ti/runtime/netapi/OLD/qmsim.h
@@ -0,0 +1,64 @@
1/****************************
2 * qmsim.h: qmss lld, hw simulator
3 *************************************************
4 * FILE: net_test.c
5 *
6 * DESCRIPTION: netapi user space transport
7 * library test application - simulator code for desktop testing
8 *
9 * REVISION HISTORY: rev 0.0.1
10 *
11 * Copyright (c) Texas Instruments Incorporated 2010-2011
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 *
20 * Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the
23 * distribution.
24 *
25 * Neither the name of Texas Instruments Incorporated nor the names of
26 * its contributors may be used to endorse or promote products derived
27 * from this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40*****************************/
41#ifndef __QMSIM__H
42#define __QMSIM__H
43
44
45#ifndef NULL
46#define NULL (void*) 0
47#endif
48
49typedef struct Q_t
50{
51 int size;
52 int head;
53 int tail;
54 int ne;
55 void ** q;
56} Q;
57
58/*-----------------------*/
59/*--------simulator------*/
60Q * qsim_create(int nelem);
61int qsim_push(Q *, void *p);
62void * qsim_pop(Q * );
63void qsim_close(Q * );
64#endif
diff --git a/ti/runtime/netapi/OLD/shmtest.c b/ti/runtime/netapi/OLD/shmtest.c
new file mode 100755
index 0000000..f4c9479
--- /dev/null
+++ b/ti/runtime/netapi/OLD/shmtest.c
@@ -0,0 +1,118 @@
1/*************************************************
2* FILE: shmtest.c
3 *
4 * DESCRIPTION: netapi user space transport
5 * library test application (not used, kept as refenence)
6 *
7 * REVISION HISTORY: rev 0.0.1
8 *
9 * Copyright (c) Texas Instruments Incorporated 2010-2011
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 *
18 * Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the
21 * distribution.
22 *
23 * Neither the name of Texas Instruments Incorporated nor the names of
24 * its contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 **********************************************************************/
39
40
41#include <stdlib.h>
42#include <sys/shm.h>
43#include <errno.h>
44
45 char * p= NULL;
46main(int argc, char * argv[])
47{
48int fd;
49int op=0;
50int name = 0xfeed;
51int err;
52if (argc<3) {printf("shmtest (c[reate]| d[delete]| o[open]) key\n"); exit(1);}
53
54
55switch (argv[1][0])
56{
57case 'D':
58case 'd':
59 op =2; //delete
60 break;
61case 'c':
62case 'C':
63 op =0; //create
64 break;
65case 'o':
66case 'O':
67 op =1; //open
68 break;
69default:
70printf(" unknown op code %c. Need d, o, or c\n", argv[1][0]);
71exit(1);
72break;
73}
74
75name = atoi(argv[2]); printf("key = %d op=%d\n", name,op);
76switch (op)
77{
78case(1): /* open */
79default:
80 fd = shmget( (key_t) name, 100000, 0666 );
81 if (fd <0) {
82 perror(" shget open failed\n");
83 exit( 1);
84 }
85 break;
86
87case(0): /* create */
88 fd = shmget(name, 100000, IPC_CREAT | 0666 );
89 if (fd<0) {perror(" shget create failed , exiting "); exit(1);}
90 break;
91
92case(2):
93 fd = shmget( (key_t) name, 100000, 0666 );
94 if (fd <0) {
95 perror(" delete: shget open failed\n");
96 exit( 1);
97 }
98 err=shmctl(fd, IPC_RMID, 0);
99 if(err<0) {perror("ctl failed: ");}
100 exit( 0); //all we do
101 break;
102}
103
104/* map into us */
105p = shmat(fd, 0, 0);
106if (p == -1) {
107perror("shmat failed\n"); exit(1);
108}
109 else {printf("mapped to %x\n",p);}
110
111if (op==1) { printf("got something: %s\n", p);}
112else if(op==0)
113{
114sprintf(p,"created some shared memory, key=%d...\n",name);
115printf("creating shm ok: %s",p);
116}
117
118}
diff --git a/ti/runtime/netapi/applications/ipsec_offload/config-app/build/Makefile b/ti/runtime/netapi/applications/ipsec_offload/config-app/build/Makefile
new file mode 100755
index 0000000..4867929
--- /dev/null
+++ b/ti/runtime/netapi/applications/ipsec_offload/config-app/build/Makefile
@@ -0,0 +1,102 @@
1# Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
2
3space =$(empty) $(empty)
4
5export ARMV7OBJDIR ?= ./obj
6export ARMV7BINDIR ?= ./bin
7export ARMV7LIBDIR ?= ./lib
8# INCLUDE Directories
9
10NETAPI_SRC_DIR ?= $(TRANS_SDK_INSTALL_PATH)/ti/runtime/netapi
11
12CSL_DEVICE ?= -DDEVICE_K2L
13
14
15ifdef CROSS_TOOL_INSTALL_PATH
16## Support backwards compatibility with KeyStone1 approach
17 CC = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)gcc
18 AC = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)as
19 AR = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)ar
20 LD = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)gcc
21endif
22
23#QUIET_CMD=@
24EXE_NAME_PRFX=ipsecmgr_cmd_shell_$(DEVICE)
25
26###############################################################################
27# Set default options
28###############################################################################
29CFLAGS+= $(DEBUG_FLAG) -I../ -I. $(CSL_DEVICE) -D__ARMv7 -D_VIRTUAL_ADDR_SUPPORT -D__LINUX_USER_SPACE -D_LITTLE_ENDIAN=1 -DNWAL_ENABLE_SA -DMAKEFILE_BUILD -D _GNU_SOURCE
30
31OUTPUT_FILE_OPTION = -o
32
33EXE_NAME = $(EXE_NAME_PRFX).out
34
35ROOT_DIR = ..
36IPSECMGR_UTIL_IFACE_DIR?= ../../../utils/iface
37IPSECMGR_IFACE_DIR?= ../
38
39
40OBJ_DIR = obj
41NETAPI_LIB=netapi
42IPSECMGR_IPC_LIB=ipsecmgr_ipc
43IPSECMGR_SYSLOG_LIB=ipsecmgr_syslog
44IPSECMGR_SNOOP_LIB=ipsecmgr_snoop
45LD_OPTS += -pthread -lrt
46LD_OPTS += -L $(ARMV7LIBDIR) -L $(PDK_ARMV7LIBDIR) -l$(IPSECMGR_SNOOP_LIB) -l$(IPSECMGR_IPC_LIB) -l$(IPSECMGR_SYSLOG_LIB)
47
48###############################################################################
49# List of modules and their files
50###############################################################################
51CONFIG_APP_SRC_DIR ?=../src/
52CONFIG_APP_FILES = \
53 cmd_shell.c \
54 cmd_shell_main.c \
55 cmd_shell_loc.h
56
57VPATH = $(CONFIG_APP_SRC_DIR)
58FILES = $(CONFIG_APP_FILES)
59
60INCL_DIRS= $(IPSECMGR_IFACE_DIR) $(IPSECMGR_UTIL_IFACE_DIR)
61
62HEADERS = $(filter %.h, $(FILES))
63INCL = -I. $(patsubst %,-I%,$(INCL_DIRS))
64
65BIN_DIR = $(ARMV7BINDIR)/netapi/applications/ipsec_offload/config-app
66OBJ_DIR = $(ARMV7OBJDIR)/netapi/applications/ipsec_offload/config-app
67CONFIG_APP_OBJS = $(patsubst %.c,$(OBJ_DIR)/%.o,$(filter %.c, $(FILES)))
68
69
70all: app install
71
72app: $(BIN_DIR)/.created $(BIN_DIR)/$(EXE_NAME)
73###############################################################################
74# Normal make process
75###############################################################################
76
77$(OBJ_DIR)/%.o: %.c $(OBJ_DIR)/.created
78 @echo compiling $<
79 $(CC) -c $(CFLAGS) $(INCL) $< -o $@
80
81$(OBJ_DIR)/.created:
82 $(QUIET_CMD)@echo "making $@"
83 @mkdir -p $(OBJ_DIR)
84
85$(BIN_DIR)/.created:
86 @mkdir -p $(BIN_DIR)
87
88$(BIN_DIR)/$(EXE_NAME): $(CONFIG_APP_OBJS) $(BIN_DIR)/.created
89 $(QUIET_CMD)@echo "linking $@"
90 $(CC) $(CONFIG_APP_OBJS) $(LD_OPTS) -o $(BIN_DIR)/$(EXE_NAME)
91
92install:
93 install -d $(INSTALL_BIN_BASE_DIR)
94 install -c -m 755 $(BIN_DIR)/$(EXE_NAME) $(INSTALL_BIN_BASE_DIR)/$(EXE_NAME)
95
96clean:
97 rm -rf $(OBJ_DIR)
98 rm -rf $(BIN_DIR)/$(EXE_NAME)
99
100
101
102
diff --git a/ti/runtime/netapi/applications/ipsec_offload/config-app/build/setup_shell_env.sh b/ti/runtime/netapi/applications/ipsec_offload/config-app/build/setup_shell_env.sh
new file mode 100755
index 0000000..0aba750
--- /dev/null
+++ b/ti/runtime/netapi/applications/ipsec_offload/config-app/build/setup_shell_env.sh
@@ -0,0 +1,10 @@
1#!/bin/sh
2# Source this script before starting the ipsecmgr command shell
3
4# Variable to specify the local unix socket name for IPC with IPSec daemon
5export IPSECMGR_APP_SOCK_NAME="/etc/app_sock"
6# Variable to specify the unix socket name of the IPSec daemon
7export IPSECMGR_DAEMON_SOCK_NAME="/etc/ipsd_sock"
8# Variable to specify the log file to be used by the ipsecmgr library
9export IPSECMGR_LOG_FILE="/var/run/ipsecmgr_app.log"
10
diff --git a/ti/runtime/netapi/applications/ipsec_offload/config-app/src/cmd_shell.c b/ti/runtime/netapi/applications/ipsec_offload/config-app/src/cmd_shell.c
new file mode 100755
index 0000000..152a2cf
--- /dev/null
+++ b/ti/runtime/netapi/applications/ipsec_offload/config-app/src/cmd_shell.c
@@ -0,0 +1,615 @@
1/*
2 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
3 *
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
15 * distribution.
16 *
17 * Neither the name of Texas Instruments Incorporated nor the names of
18 * its contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33*/
34
35/* Standard include files */
36
37#ifndef _GNU_SOURCE
38#define _GNU_SOURCE
39#endif
40
41#include <stdio.h>
42#include <stdlib.h>
43#include <getopt.h>
44#include <string.h>
45
46/* module specific include files */
47#include <ipsecmgr_ipc.h>
48
49#include "cmd_shell_loc.h"
50
51/* For debugging */
52#define DEBUG
53#define DEBUG1
54
55#define OPTION_ID_IF_NAME 1
56#define OPTION_ID_SP_ID 2
57#define OPTION_ID_CMD_NAME 3
58#define OPTION_ID_ESN 4
59#define OPTION_ID_GTPU_TEID 5
60#define OPTION_ID_NUM_TEIDS 6
61#define OPTION_ID_SHARED_SA 7
62#define OPTION_ID_NO_EXPIRE_SA 8
63#define OPTION_ID_MAX 9
64
65enum cmd_id {
66 CMD_ID_OFFLOAD_SP = 1,
67 CMD_ID_STOP_OFFLOAD,
68 CMD_ID_HELP,
69 CMD_ID_EXIT,
70 CMD_ID_LAST
71};
72
73/* Maximum strlen() of string variables */
74#define MAX_STR_VAR_SIZE 32
75
76/* Maximum number of commands */
77#define MAX_CMDS CMD_ID_LAST
78
79typedef union {
80 unsigned long intval;
81 char strval[MAX_STR_VAR_SIZE];
82} opt_val_gen_t;
83
84typedef struct {
85 opt_val_gen_t value;
86 uint8_t is_valid;
87} opt_attr_gen_t;
88
89static opt_attr_gen_t opt_input_gen[OPTION_ID_MAX];
90
91/* Module context */
92static cmd_shell_ctx_t shell_ctx;
93
94static int parse_intval(char* int_str, opt_attr_gen_t *opt_attr) {
95 int i;
96 for (i=0; int_str[i]!= '\0'; i++) int_str[i] = (char) tolower(int_str[i]);
97 if (strncmp("0x", int_str, 2)) {
98 opt_attr->value.intval = strtoul(int_str, (char **)NULL, 10);
99 } else {
100 opt_attr->value.intval = strtoul(int_str, (char **)NULL, 16);
101 }
102 opt_attr->is_valid = 1;
103 return 0;
104}
105
106static int parse_strval(char* str, opt_attr_gen_t *opt_attr) {
107
108 strncpy(opt_attr->value.strval, str, MAX_STR_VAR_SIZE-1);
109 opt_attr->is_valid = 1;
110 return 0;
111}
112
113#define CMD_SHORT_OPTS_LEN 200
114static char short_opts[CMD_SHORT_OPTS_LEN];
115
116#define CMD_NAME_OFFLOAD_SP "offload_sp"
117#define CMD_DESC_OFFLOAD_SP "Offload an IPSec Policy to Fast Path"
118#define CMD_MIN_ARGS_OFFLOAD_SP 3
119#define CMD_SHORT_OPTS_OFFLOAD_SP snprintf(short_opts,CMD_SHORT_OPTS_LEN, "%d:%d:%d%d:%d:",\
120 OPTION_ID_SP_ID, OPTION_ID_IF_NAME, OPTION_ID_ESN,\
121 OPTION_ID_GTPU_TEID, OPTION_ID_NUM_TEIDS,\
122 OPTION_ID_SHARED_SA);
123
124static struct option offload_sp_options[] =
125{
126 {"sp_id", required_argument, 0, OPTION_ID_SP_ID},
127 {"if_name", required_argument, 0, OPTION_ID_IF_NAME},
128 {"esn", no_argument, 0, OPTION_ID_ESN},
129 {"gtpu_teid", required_argument, 0, OPTION_ID_GTPU_TEID},
130 {"num_teids", required_argument, 0, OPTION_ID_NUM_TEIDS},
131 {"shared", no_argument, 0, OPTION_ID_SHARED_SA},
132 {0, 0, 0, 0}
133};
134
135#define CMD_NAME_STOP_OFFLOAD "stop_offload"
136#define CMD_DESC_STOP_OFFLOAD "Stop Offload of an IPSec Policy"
137#define CMD_MIN_ARGS_STOP_OFFLOAD 3
138#define CMD_SHORT_OPTS_STOP_OFFLOAD snprintf(short_opts,CMD_SHORT_OPTS_LEN, "%d:%d",\
139 OPTION_ID_SP_ID, OPTION_ID_NO_EXPIRE_SA);
140static struct option stop_offload_options[] =
141{
142 {"sp_id", required_argument, 0, OPTION_ID_SP_ID},
143 {"no_expire_sa", no_argument, 0, OPTION_ID_NO_EXPIRE_SA},
144 {0, 0, 0, 0}
145};
146
147#define CMD_NAME_EXIT "exit"
148#define CMD_DESC_EXIT "Exit the netcpcfg command shell"
149#define CMD_MIN_ARGS_EXIT 1
150#define CMD_SHORT_OPTS_EXIT snprintf(short_opts,CMD_SHORT_OPTS_LEN, "");
151static struct option exit_options[] =
152{
153 {0, 0, 0, 0}
154};
155
156#define CMD_NAME_HELP "help"
157#define CMD_DESC_HELP "Help on available commands"
158#define CMD_MIN_ARGS_HELP 1
159#define CMD_SHORT_OPTS_HELP snprintf(short_opts,CMD_SHORT_OPTS_LEN, "%d:", OPTION_ID_CMD_NAME);
160static struct option help_options[] =
161{
162 {"cmd", required_argument, 0, OPTION_ID_CMD_NAME},
163 {0, 0, 0, 0}
164};
165
166struct cmd_tbl_s {
167 char *cmd_name;
168 struct option *opt_tbl;
169 char *desc;
170};
171
172struct cmd_tbl_s cmd_table[MAX_CMDS] =
173{
174 {CMD_NAME_OFFLOAD_SP, offload_sp_options, CMD_DESC_OFFLOAD_SP},
175 {CMD_NAME_STOP_OFFLOAD, stop_offload_options, CMD_DESC_STOP_OFFLOAD},
176 {CMD_NAME_EXIT, exit_options, CMD_DESC_EXIT},
177 {CMD_NAME_HELP, help_options, CMD_DESC_HELP},
178 {0, 0}
179};
180
181static void print_help (char *cmd_name)
182{
183 int i,j;
184
185 if (!cmd_name) {
186 printf ("For help on command options type \"%s --cmd <cmd name>\"\n",
187 CMD_NAME_HELP);
188 printf ("Available commands:\n");
189
190 for (i=0; ((i < MAX_CMDS) && cmd_table[i].cmd_name); i++) {
191 printf (" %s\t%s\n", cmd_table[i].cmd_name, cmd_table[i].desc);
192 }
193 return;
194 }
195
196 for (i=0; ((i < MAX_CMDS) && (cmd_table[i].cmd_name)); i++) {
197 struct option *opt = cmd_table[i].opt_tbl;
198 if (strcmp(cmd_name, cmd_table[i].cmd_name)) {
199 continue;
200 }
201
202 printf ("options for \"%s\"\n", cmd_name);
203 for (j=0; opt->name; j++, opt++) {
204 printf (" --%s\n", opt->name);
205 }
206 return;
207 }
208
209 printf ("No help available for %s\n", cmd_name);
210 return;
211}
212
213static int setargs (char *args, char **argv)
214{
215 int count = 0;
216
217 while (isspace(*args)) ++args;
218 while (*args) {
219 if (argv) argv[count] = args;
220 while (*args && !isspace(*args)) ++args;
221 if (argv && *args) *args++ = '\0';
222 while (isspace(*args)) ++args;
223 count++;
224 }
225 return count;
226}
227
228static char **parsedargs(char *args, int *argc)
229{
230 char **argv = NULL;
231 int argn = 0;
232
233 if (args && *args
234 && (args = strdup(args))
235 && (argn = setargs(args,NULL))
236 && (argv = malloc((argn+1) * sizeof(char *)))) {
237 *argv++ = args;
238 argn = setargs(args,argv);
239 }
240
241 //if (args && !argv) free(args);
242
243 *argc = argn;
244 return argv;
245}
246
247static void freeparsedargs(char **argv)
248{
249 if (argv) {
250 free(argv[-1]);
251 free(argv-1);
252 }
253}
254
255#define COMMAND_LINE_SIZE 400
256
257void* cmd_shell (void* args)
258{
259 char *line = NULL;
260 size_t len = 0;
261 ssize_t read = 0;
262 char cmd[COMMAND_LINE_SIZE];
263 int nargs, c, rargs;
264 struct option *long_options;
265 char **av;
266 enum cmd_id cmd_id;
267
268 memset(&shell_ctx, 0, sizeof(shell_ctx));
269 if (ipsecmgr_ipc_get_user_send_iface(&shell_ctx.ipc_send_if)) {
270 printf ("\ncmd_shell: Failed to get IPC send interface\n");
271 return (void*)(0);
272 }
273
274 while (1) {
275 memset(opt_input_gen, 0, sizeof(opt_input_gen));
276 cmd_id = 0;
277
278 printf ("\nIPSECMGR-CFG> ");
279
280 if (line) free(line);
281 line = malloc(COMMAND_LINE_SIZE);
282 if (line == NULL) {
283 printf("\nError allocating memory");
284 return (void*)(0);
285 }
286
287 read = getline(&line, &len, stdin);
288 if ((read == -1) || (read > COMMAND_LINE_SIZE)) {
289 printf("\nERROR: reading line");
290 continue;
291 }
292 if (!read) continue;
293 memset(cmd, 0, sizeof(cmd));
294 sscanf(line, "%s", cmd);
295
296 if ( !strcmp(cmd, "exit"))
297 exit(0);
298
299 if (!strcmp(cmd, CMD_NAME_OFFLOAD_SP)) {
300 cmd_id = CMD_ID_OFFLOAD_SP;
301 long_options = offload_sp_options;
302 CMD_SHORT_OPTS_OFFLOAD_SP;
303 rargs = CMD_MIN_ARGS_OFFLOAD_SP;
304 } else if (!strcmp(cmd, CMD_NAME_STOP_OFFLOAD)) {
305 cmd_id = CMD_ID_STOP_OFFLOAD;
306 long_options = stop_offload_options;
307 CMD_SHORT_OPTS_STOP_OFFLOAD;
308 rargs = CMD_MIN_ARGS_STOP_OFFLOAD;
309 } else if (!strcmp(cmd, CMD_NAME_HELP)) {
310 cmd_id = CMD_ID_HELP;
311 long_options = help_options;
312 CMD_SHORT_OPTS_HELP;
313 rargs = CMD_MIN_ARGS_HELP;
314 } else {
315 if (strlen(cmd))
316 printf ("Unknown command: %s\n", cmd);
317 continue;
318 }
319
320 if ((av = parsedargs(line, &nargs)) == NULL) {
321 printf ("error parsing arguments\n");
322 continue;
323 }
324
325 if (nargs < rargs) {
326 printf ("Insufficient paramaters for command \"%s\"\n", cmd);
327 print_help (cmd);
328 goto loop_over;
329 }
330
331#ifdef DEBUG1
332 {
333 int i;
334 for (i = 0; i < nargs; i++)
335 printf("[%s]\n",av[i]);
336 }
337#endif
338
339 optind = 0;
340 while (1) {
341 /* getopt_long stores the option index here. */
342 int option_index = 0;
343 c = getopt_long (nargs, av, short_opts,
344 long_options, &option_index);
345
346 /* Detect the end of the options. */
347#ifdef DEBUG1
348 printf("c=%d",c);
349#endif
350 if (c == -1)
351 break;
352
353 switch (c)
354 {
355
356 case OPTION_ID_SP_ID:
357#ifdef DEBUG
358 printf ("option sp_id with value `%s'\n", optarg);
359#endif
360 if (parse_intval(optarg, &opt_input_gen[c])) {
361 printf ("Invalid argument for sp_id\n");
362 }
363 break;
364
365 case OPTION_ID_IF_NAME:
366#ifdef DEBUG
367 printf ("option if_name with value `%s'\n", optarg);
368#endif
369 if (parse_strval(optarg, &opt_input_gen[c])) {
370 printf ("Invalid argument for if_name\n");
371 }
372 break;
373
374 case OPTION_ID_CMD_NAME:
375#ifdef DEBUG
376 printf ("option cmd with value `%s'\n", optarg);
377#endif
378 if (parse_strval(optarg, &opt_input_gen[c])) {
379 printf ("Invalid argument for cmd\n");
380 }
381 break;
382
383 case OPTION_ID_ESN:
384#ifdef DEBUG
385 printf ("option esn enabled\n");
386#endif
387 opt_input_gen[c].is_valid = 1;
388 break;
389
390 case OPTION_ID_GTPU_TEID:
391#ifdef DEBUG
392 printf ("option gtpu_teid with value `%s'\n", optarg);
393#endif
394 if (parse_intval(optarg, &opt_input_gen[c])) {
395 printf ("Invalid argument for gtpu_teid\n");
396 }
397 break;
398
399 case OPTION_ID_NUM_TEIDS:
400#ifdef DEBUG
401 printf ("option num_teids with value `%s'\n", optarg);
402#endif
403 if (parse_intval(optarg, &opt_input_gen[c])) {
404 printf ("Invalid argument for num_teids\n");
405 }
406 break;
407
408 case OPTION_ID_SHARED_SA:
409#ifdef DEBUG
410 printf ("option shared SA enabled\n");
411#endif
412 opt_input_gen[c].is_valid = 1;
413 break;
414
415 case OPTION_ID_NO_EXPIRE_SA:
416#ifdef DEBUG
417 printf ("option no_expire_sa enabled\n");
418#endif
419 opt_input_gen[c].is_valid = 1;
420 break;
421 default:
422 printf ("unknown option c=%d\n", c);
423 break;
424 }
425 }
426#ifdef DEBUG1
427 /* Print any remaining command line arguments (not options). */
428 if (optind < nargs)
429 {
430 printf ("non-option elements: ");
431 while (optind < nargs)
432 printf ("%s ", av[optind++]);
433 putchar ('\n');
434 }
435#endif
436
437 switch (cmd_id) {
438
439 case CMD_ID_HELP:
440 {
441 if (!opt_input_gen[OPTION_ID_CMD_NAME].is_valid) {
442 print_help(NULL);
443 } else {
444 print_help(opt_input_gen[OPTION_ID_CMD_NAME].value.strval);
445 }
446 break;
447 }
448
449 case CMD_ID_OFFLOAD_SP:
450 {
451 ipsecmgr_ipc_offload_sp_req_param_t req;
452 ipsecmgr_ifname_t if_name;
453 ipsecmgr_l5_selector_t l5_selector;
454
455 if (!opt_input_gen[OPTION_ID_SP_ID].is_valid) {
456 printf ("Mandatory paramater missing: sp_id\n");
457 goto loop_over;
458 }
459
460 memset(&req, 0, sizeof(req));
461 memset(&if_name, 0, sizeof(if_name));
462 memset(&l5_selector, 0, sizeof(l5_selector));
463
464 req.trans_id = ++shell_ctx.trans_id;
465
466 /* sp_id */
467 req.policy_id =
468 (uint32_t)opt_input_gen[OPTION_ID_SP_ID].value.intval;
469
470 /* if_name */
471 if (opt_input_gen[OPTION_ID_IF_NAME].is_valid) {
472 strcpy(if_name.name,
473 opt_input_gen[OPTION_ID_IF_NAME].value.strval);
474 req.if_name = &if_name;
475 }
476
477 /* esn */
478 if (opt_input_gen[OPTION_ID_ESN].is_valid) {
479 req.sa_flags |= IPSECMGR_SA_FLAGS_ESN;
480 }
481
482 /* gtpu_teid */
483 if (opt_input_gen[OPTION_ID_GTPU_TEID].is_valid) {
484 l5_selector.proto = IPSECMGR_L5_PROTO_GTPU;
485 l5_selector.value.gtpu.teid_start =
486 (uint32_t)opt_input_gen[OPTION_ID_GTPU_TEID].value.intval;
487 req.l5_selector = &l5_selector;
488 }
489
490 /* num_teids */
491 if (opt_input_gen[OPTION_ID_NUM_TEIDS].is_valid) {
492 l5_selector.value.gtpu.teid_end =
493 l5_selector.value.gtpu.teid_start - 1 +
494 (uint32_t)opt_input_gen[OPTION_ID_NUM_TEIDS].value.intval;
495 } else { /* default is 1 TEID */
496 l5_selector.value.gtpu.teid_end =
497 l5_selector.value.gtpu.teid_start;
498 }
499
500 /* shared tunnel */
501 if (opt_input_gen[OPTION_ID_SHARED_SA].is_valid) {
502 req.sa_flags |= IPSECMGR_SA_FLAGS_SHARED;
503 }
504
505 if (shell_ctx.ipc_send_if->offload_sp_req(&req)) {
506 printf("%s failed\n", CMD_NAME_OFFLOAD_SP);
507 } else {
508 printf("%s trans_id: 0x%x\n", CMD_NAME_OFFLOAD_SP,
509 shell_ctx.trans_id);
510 }
511
512 break;
513 }
514
515 case CMD_ID_STOP_OFFLOAD:
516 {
517 ipsecmgr_ipc_stop_offload_req_param_t req;
518
519 if (!opt_input_gen[OPTION_ID_SP_ID].is_valid) {
520 printf ("Mandatory paramater missing: sp_id\n");
521 goto loop_over;
522 }
523
524 memset(&req, 0, sizeof(req));
525
526 req.trans_id = ++shell_ctx.trans_id;
527
528 /* sp_id */
529 req.policy_id =
530 (uint32_t)opt_input_gen[OPTION_ID_SP_ID].value.intval;
531
532 if (opt_input_gen[OPTION_ID_NO_EXPIRE_SA].is_valid) {
533 req.no_expire_sa = 1;
534 }
535 if (shell_ctx.ipc_send_if->stop_offload_req(&req)) {
536 printf("%s failed\n", CMD_NAME_STOP_OFFLOAD);
537 } else {
538 printf("%s trans_id: 0x%x\n", CMD_NAME_STOP_OFFLOAD,
539 shell_ctx.trans_id);
540 }
541
542 break;
543 }
544
545 } /* switch cmd_id */
546
547loop_over:
548 freeparsedargs(av);
549 }
550 return (void*)(0);
551}
552
553void cmd_shell_offload_sp_rsp
554(
555 ipsecmgr_ipc_offload_sp_rsp_param_t *rsp
556)
557{
558 char resp_str[10] = {0,};
559
560 printf ("\nRecvd OFFLOAD_SP response:\n");
561 printf (" trans_id:\t0x%x\n", rsp->trans_id);
562
563 if (rsp->type & RSP_TYPE_ACK) {
564 strcpy(resp_str, "ACK");
565 } else if (rsp->type & RSP_TYPE_DONE) {
566 int slen = strlen(resp_str);
567 if (slen)
568 strcpy(&resp_str[slen], "|DONE");
569 else
570 strcpy(&resp_str[slen], "DONE");
571 }
572
573 printf (" resp_type:\t(%d) %s\n", rsp->type, resp_str);
574 printf (" result:\t(%d) %s\n", rsp->result,
575 ((rsp->result == RESULT_SUCCESS) ? "SUCCESS":"FAIL"));
576
577 if (rsp->err_code) {
578 printf (" FP lib retval:\t%d\n", rsp->err_code);
579 }
580
581 if (rsp->sa_handle)
582 printf (" sa_handle:\t0x%x\n", rsp->sa_handle);
583 if (rsp->sp_handle)
584 printf (" sp_handle:\t0x%x\n", rsp->sp_handle);
585
586 return;
587}
588
589void cmd_shell_stop_offload_rsp
590(
591 ipsecmgr_ipc_stop_offload_rsp_param_t *rsp
592)
593{
594 char resp_str[10] = {0,};
595
596 printf ("\nRecvd STOP_OFFLOAD response:\n");
597 printf (" trans_id:\t0x%x\n", rsp->trans_id);
598
599 if (rsp->type & RSP_TYPE_ACK) {
600 strcpy(resp_str, "ACK");
601 } else if (rsp->type & RSP_TYPE_DONE) {
602 int slen = strlen(resp_str);
603 if (slen)
604 strcpy(&resp_str[slen], "|DONE");
605 else
606 strcpy(&resp_str[slen], "DONE");
607 }
608
609 printf (" resp_type:\t(%d) %s\n", rsp->type, resp_str);
610 printf (" result:\t(%d) %s\n", rsp->result,
611 ((rsp->result == RESULT_SUCCESS) ? "SUCCESS":"FAIL"));
612
613 return;
614}
615
diff --git a/ti/runtime/netapi/applications/ipsec_offload/config-app/src/cmd_shell_loc.h b/ti/runtime/netapi/applications/ipsec_offload/config-app/src/cmd_shell_loc.h
new file mode 100755
index 0000000..8ee899c
--- /dev/null
+++ b/ti/runtime/netapi/applications/ipsec_offload/config-app/src/cmd_shell_loc.h
@@ -0,0 +1,62 @@
1/*
2 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
3 *
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
15 * distribution.
16 *
17 * Neither the name of Texas Instruments Incorporated nor the names of
18 * its contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33*/
34
35#ifndef __CMD_SHELL_LOC_H__
36#define __CMD_SHELL_LOC_H__
37
38#include <ipsecmgr_ipc.h>
39
40/* Module context for command shell */
41typedef struct {
42 ipsecmgr_trans_id_t trans_id;
43 ipsecmgr_ipc_user_send_if_t *ipc_send_if;
44} cmd_shell_ctx_t;
45
46/* Command line interpreter task */
47void* cmd_shell (void *args);
48
49/* OFFLOAD_SP response handler */
50void cmd_shell_offload_sp_rsp
51(
52 ipsecmgr_ipc_offload_sp_rsp_param_t *rsp
53);
54
55/* STOP_OFFLOAD response handler */
56void cmd_shell_stop_offload_rsp
57(
58 ipsecmgr_ipc_stop_offload_rsp_param_t *rsp
59);
60
61#endif
62
diff --git a/ti/runtime/netapi/applications/ipsec_offload/config-app/src/cmd_shell_main.c b/ti/runtime/netapi/applications/ipsec_offload/config-app/src/cmd_shell_main.c
new file mode 100755
index 0000000..22f34e6
--- /dev/null
+++ b/ti/runtime/netapi/applications/ipsec_offload/config-app/src/cmd_shell_main.c
@@ -0,0 +1,216 @@
1/*
2 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
3 *
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
15 * distribution.
16 *
17 * Neither the name of Texas Instruments Incorporated nor the names of
18 * its contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33*/
34
35#include <stdio.h>
36#include <stdlib.h>
37#include <sys/types.h>
38#include <time.h>
39#include <pthread.h>
40#include <string.h>
41#include <stdarg.h>
42#include <unistd.h>
43
44#include <ipsecmgr_ipc.h>
45#include <ipsecmgr_syslog.h>
46
47#include "cmd_shell_loc.h"
48
49typedef pthread_t task_handle;
50
51#define DEFAULT_STACK_SIZE 0x8000
52static int task_create ( void *(start_routine)(void*), void* args, void* handle)
53{
54 int max_priority, err;
55 pthread_t thread;
56 pthread_attr_t attr;
57 struct sched_param param;
58
59 max_priority = sched_get_priority_max(SCHED_FIFO);
60 err = pthread_attr_init(&attr);
61 if (err) {
62 ipsecmgr_syslog_msg(SYSLOG_LEVEL_ERROR,
63 "pthread_attr_init failed: (%s)\n", strerror(err));
64 return err;
65 }
66 err = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
67 if (err) {
68 ipsecmgr_syslog_msg(SYSLOG_LEVEL_ERROR,
69 "pthread_attr_setdetachstate failed: (%s)\n", strerror(err));
70 return err;
71 }
72 err = pthread_attr_setstacksize(&attr, DEFAULT_STACK_SIZE);
73 if (err) {
74 ipsecmgr_syslog_msg(SYSLOG_LEVEL_ERROR,
75 "pthread_attr_setstacksize failed: (%s)\n", strerror(err));
76 return err;
77 }
78 err = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
79 if (err) {
80 ipsecmgr_syslog_msg(SYSLOG_LEVEL_ERROR,
81 "pthread_attr_setinheritsched failed: (%s)\n", strerror(err));
82 return err;
83 }
84 err = pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
85 if (err) {
86 ipsecmgr_syslog_msg(SYSLOG_LEVEL_ERROR,
87 "pthread_attr_setschedpolicy failed: (%s)\n", strerror(err));
88 return err;
89 }
90 memset(&param, 0, sizeof(param));
91 param.sched_priority = max_priority;
92 err = pthread_attr_setschedparam(&attr, &param);
93 if (err) {
94 ipsecmgr_syslog_msg(SYSLOG_LEVEL_ERROR,
95 "pthread_attr_setschedparam failed: (%s)\n", strerror(err));
96 return err;
97 }
98 err = pthread_create(&thread, &attr, start_routine, args);
99 if (err) {
100 ipsecmgr_syslog_msg(SYSLOG_LEVEL_ERROR,
101 "pthread_create failed: (%s)\n", strerror(err));
102 return err;
103 }
104 *(pthread_t*)handle = thread;
105 return 0;
106}
107
108static void task_wait (void *handle)
109{
110 pthread_join(*((pthread_t*)handle), NULL);
111 return;
112}
113
114static void task_sleep(int time_in_msec)
115{
116 pthread_mutex_t fake_mutex = PTHREAD_MUTEX_INITIALIZER;
117 pthread_cond_t fake_cond = PTHREAD_COND_INITIALIZER;
118 struct timespec ts;
119 int rt;
120 unsigned int sec, nsec;
121
122 sec = time_in_msec/1000;
123 nsec = (time_in_msec - (sec*1000)) * 1000000;
124
125 /* Use the wall-clock time */
126 clock_gettime(CLOCK_REALTIME, &ts);
127
128 ts.tv_sec += sec;
129 ts.tv_nsec += nsec;
130
131 pthread_mutex_lock(&fake_mutex);
132 rt = pthread_cond_timedwait(&fake_cond, &fake_mutex, &ts);
133 pthread_mutex_unlock(&fake_mutex);
134}
135
136#define IPC_POLL_INTVL 1000
137
138static void *ipc_poll(void *args)
139{
140 while(1) {
141 ipsecmgr_ipc_poll();
142 task_sleep(IPC_POLL_INTVL);
143 } /* end while */
144 return (void*)(0);
145}
146
147/* usage ipsecmgr_cmd_shell
148 */
149int main(int argc, char **argv)
150{
151 ipsecmgr_ipc_cfg_t ipc_cfg;
152 ipsecmgr_ipc_user_recv_if_t recv_if;
153 task_handle cmd_th, ipc_th;
154 int status;
155 int c;
156 static char usage[] = "usage: %s -s <daemon id>\n";
157
158 memset(&ipc_cfg, 0, sizeof(ipc_cfg));
159 while ((c = getopt (argc, argv, "i:")) != -1)
160 {
161 switch (c)
162 {
163 case 'i':
164 ipc_cfg.ipc_id = (uint32_t)strtol(optarg, NULL,0);
165 if(!ipc_cfg.ipc_id)
166 {
167 printf(usage, argv[0]);
168 exit(EXIT_FAILURE);
169 }
170 break;
171 case '?':
172 printf(usage, argv[0]);
173 exit(EXIT_FAILURE);
174 default:
175 break;
176 }
177 }
178 /* Start logging module */
179 if (ipsecmgr_syslog_init()) {
180 printf ("Failed to initialize syslog\n");
181 return -1;
182 }
183
184 ipc_cfg.mode = IPC_MODE_USER_APP;
185
186 if (ipsecmgr_ipc_init(&ipc_cfg)) {
187 printf ("Failed to initialize IPC\n");
188 return -1;
189 }
190
191 recv_if.offload_sp_rsp = cmd_shell_offload_sp_rsp;
192 recv_if.stop_offload_rsp = cmd_shell_stop_offload_rsp;
193
194 if (ipsecmgr_ipc_register_user_recv_iface(&recv_if)) {
195 printf ("Failed to IPC recv interface\n");
196 return -1;
197 }
198
199 /* Create the command line interpreter task */
200 if (status = task_create(cmd_shell, NULL, &cmd_th)) {
201 ipsecmgr_syslog_msg(SYSLOG_LEVEL_ERROR,
202 "ERROR: Command shell task-create failed (%d)\n", status);
203 return (-1);
204 }
205
206 /* Create the FP IPC poll task */
207 if (status = task_create(ipc_poll, NULL, &ipc_th)) {
208 ipsecmgr_syslog_msg(SYSLOG_LEVEL_ERROR,
209 "ERROR: IPC recv task-create failed (%d)\n", status);
210 return (-1);
211 }
212
213 task_wait(&cmd_th);
214 return 0;
215}
216
diff --git a/ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/build/Makefile b/ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/build/Makefile
new file mode 100755
index 0000000..916e9ce
--- /dev/null
+++ b/ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/build/Makefile
@@ -0,0 +1,144 @@
1# Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
2
3space =$(empty) $(empty)
4
5export ARMV7OBJDIR ?= ./obj
6export ARMV7BINDIR ?= ./bin
7export ARMV7LIBDIR ?= ./lib
8export ARMV7SALIBDIR ?= ./lib
9
10# DEVICE
11export DEVICE ?= k2l
12
13# INCLUDE Directories
14SA_INSTALL_PATH ?= $(PDK_INSTALL_PATH)/ti/drv/sa
15QMSS_INC_DIR ?= $(PDK_INSTALL_PATH)/ti/drv/qmss
16CPPI_INC_DIR ?= $(PDK_INSTALL_PATH)/ti/drv/cppi
17NWAL_INSTALL_PATH ?= $(PDK_INSTALL_PATH)/ti/drv/nwal
18PKTLIB_INSTALL_PATH ?= $(PDK_INSTALL_PATH)/ti/runtime/pktlib
19
20HPLIB_INC_DIR ?= $(TRANS_SDK_INSTALL_PATH)
21NETAPI_INC_DIR ?= $(TRANS_SDK_INSTALL_PATH)
22NETAPI_SRC_DIR ?= $(TRANS_SDK_INSTALL_PATH)/ti/runtime/netapi
23
24PDK_ARMV7LIBDIR ?= ARMV7LIBDIR
25
26QMSS_LIB=qmss
27CPPI_LIB=cppi
28HPLIB_LIB=hplib_$(DEVICE)
29NETAPI_LIB=netapi_$(DEVICE)
30NWAL_LIB ?= nwalsa_$(DEVICE)
31SA_LIB=sa
32PKTLIB_LIB=pktlib
33IPSECMGR_SNOOP_LIB=ipsecmgr_snoop
34IPSECMGR_IPC_LIB=ipsecmgr_ipc
35IPSECMGR_SYSLOG_LIB=ipsecmgr_syslog
36RM_LIB = -lrm
37
38ifeq ($(DEVICE), k2h)
39CSL_DEVICE = -DDEVICE_K2H
40PA_LIB = pa
41endif
42ifeq ($(DEVICE), k2k)
43CSL_DEVICE = -DDEVICE_K2K
44PA_LIB = pa
45endif
46ifeq ($(DEVICE), k2l)
47CSL_DEVICE = -DDEVICE_K2L -DNSS_GEN2
48PA_LIB = pa2
49endif
50ifeq ($(DEVICE), k2e)
51CSL_DEVICE = -DDEVICE_K2E -DNSS_GEN2
52PA_LIB = pa2
53endif
54
55ifdef CROSS_TOOL_INSTALL_PATH
56## Support backwards compatibility with KeyStone1 approach
57 CC = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)gcc
58 AC = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)as
59 AR = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)ar
60 LD = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)gcc
61endif
62
63#QUIET_CMD=@
64EXE_NAME_PRFX=ipsecmgr_daemon_$(DEVICE)
65
66###############################################################################
67# Set default options
68###############################################################################
69CFLAGS+= $(DEBUG_FLAG) -I../ -I. $(CSL_DEVICE) -D__ARMv7 -D_VIRTUAL_ADDR_SUPPORT -D__LINUX_USER_SPACE -D_LITTLE_ENDIAN=1 -DNWAL_ENABLE_SA -DMAKEFILE_BUILD -D _GNU_SOURCE
70
71ifeq ($(ENABLE_ADD_POLICY),y)
72 CFLAGS += -DENABLE_ADD_POLICY
73endif
74OUTPUT_FILE_OPTION = -o
75
76EXE_NAME = $(EXE_NAME_PRFX).out
77
78ROOT_DIR = ..
79#IPSECMGR_IFACE_DIR?= ../../../
80IPSECMGR_UTIL_IFACE_DIR?= ../../../utils/iface
81IPSECMGR_IFACE_DIR?= ../
82
83LIBNL_LD_OPTS = -lnl-3 -lnl-xfrm -lnl-route-3
84
85LD_OPTS += -pthread -lrt
86
87LD_OPTS += -L $(ARMV7LIBDIR) -L $(PDK_ARMV7LIBDIR) -l$(IPSECMGR_SNOOP_LIB) -l$(IPSECMGR_IPC_LIB) -l$(IPSECMGR_SYSLOG_LIB) -l$(NETAPI_LIB) -l$(NWAL_LIB) -l$(PKTLIB_LIB) -l$(SA_LIB) -l$(QMSS_LIB) -l$(CPPI_LIB) -l$(PA_LIB) -l$(HPLIB_LIB) $(RM_LIB) $(LIBNL_LD_OPTS)
88###############################################################################
89# List of modules and their files
90###############################################################################
91DAEMON_SRC_DIR ?= ../src/
92UTILS_SRC_DIR ?= $(NETAPI_SRC_DIR)/utils
93
94DAEMON_FILES = \
95 netapi_ipsecmgr.c \
96 netapilib_interface.c
97
98UTIL_FILES = \
99 sockutils.c \
100 netapi_util_rm.c
101
102VPATH = $(DAEMON_SRC_DIR):$(UTILS_SRC_DIR)
103FILES = $(DAEMON_FILES) $(UTIL_FILES)
104
105INCL_DIRS= $(IPSECMGR_IFACE_DIR) $(IPSECMGR_UTIL_IFACE_DIR) $(NETAPI_INC_DIR) $(CPPI_INC_DIR) $(QMSS_INC_DIR) $(HPLIB_INC_DIR) $(SA_INSTALL_PATH) $(PDK_INSTALL_PATH) $(UTILS_SRC_DIR)
106
107HEADERS = $(filter %.h, $(FILES))
108INCL = -I. $(patsubst %,-I%,$(INCL_DIRS))
109
110
111BIN_DIR = $(ARMV7BINDIR)/netapi/applications/ipsec_offload/ipsecmgr
112OBJ_DIR = $(ARMV7OBJDIR)/netapi/applications/ipsec_offload/ipsecmgr
113DAEMON_OBJS = $(patsubst %.c,$(OBJ_DIR)/%.o,$(filter %.c, $(FILES)))
114
115
116all: app install
117
118app: $(BIN_DIR)/.created $(BIN_DIR)/$(EXE_NAME)
119###############################################################################
120# Normal make process
121###############################################################################
122
123$(OBJ_DIR)/%.o: %.c $(OBJ_DIR)/.created
124 @echo compiling $<
125 $(CC) -c $(CFLAGS) $(INCL) $< -o $@
126
127$(OBJ_DIR)/.created:
128 $(QUIET_CMD)@echo "making $@"
129 @mkdir -p $(OBJ_DIR)
130
131$(BIN_DIR)/.created:
132 @mkdir -p $(BIN_DIR)
133
134$(BIN_DIR)/$(EXE_NAME): $(DAEMON_OBJS) $(BIN_DIR)/.created
135 $(QUIET_CMD)@echo "linking $@"
136 $(QUIET_CMD)@echo "$(LD_OPTS)"
137 $(CC) $(DAEMON_OBJS) $(LD_OPTS) -o $(BIN_DIR)/$(EXE_NAME)
138
139install:
140 install -d $(INSTALL_BIN_BASE_DIR)
141 install -c -m 755 $(BIN_DIR)/$(EXE_NAME) $(INSTALL_BIN_BASE_DIR)/$(EXE_NAME)
142clean:
143 rm -rf $(OBJ_DIR)
144 rm -rf $(BIN_DIR)/$(EXE_NAME)
diff --git a/ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/src/netapi_ipsecmgr.c b/ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/src/netapi_ipsecmgr.c
new file mode 100644
index 0000000..f2a99b2
--- /dev/null
+++ b/ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/src/netapi_ipsecmgr.c
@@ -0,0 +1,1096 @@
1/*
2 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
3 *
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
15 * distribution.
16 *
17 * Neither the name of Texas Instruments Incorporated nor the names of
18 * its contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33*/
34
35
36/* IPSec Manager Include Files */
37#include "ipsecmgr_snoop.h"
38#include "ipsecmgr_ipc.h"
39#include "ipsecmgr_syslog.h"
40
41/* Local include */
42#include "netapilib_interface.h"
43
44/* Standard includes */
45#include <dlfcn.h>
46#include <stdlib.h>
47#include <signal.h>
48#include <stdarg.h>
49
50
51
52#include <arpa/inet.h>
53#include <sys/socket.h>
54#include <ifaddrs.h>
55#include <stdio.h>
56#include <stdlib.h>
57#include <unistd.h>
58
59#include <sys/types.h>
60#include <netinet/in.h>
61#include <string.h>
62
63#if defined(DEVICE_K2H)
64#include <ti/drv/qmss/device/k2h/src/qmss_device.c>
65#include <ti/drv/cppi/device/k2h/src/cppi_device.c>
66char* DTS_LOG_FILE_QUEUE_ETHx[] = {
67 "/proc/device-tree/soc/netcp@2000000/netcp-interfaces/interface-0/rx-queue"};
68#elif defined (DEVICE_K2K)
69#include <ti/drv/qmss/device/k2k/src/qmss_device.c>
70#include <ti/drv/cppi/device/k2k/src/cppi_device.c>
71char* DTS_LOG_FILE_QUEUE_ETHx[] = {
72 "/proc/device-tree/soc/netcp@2000000/netcp-interfaces/interface-0/rx-queue"};
73#elif defined (DEVICE_K2L)
74#include <ti/drv/qmss/device/k2l/src/qmss_device.c>
75#include <ti/drv/cppi/device/k2l/src/cppi_device.c>
76char* DTS_LOG_FILE_QUEUE_ETHx[] = {
77 "/proc/device-tree/soc/netcp@2600000/netcp-interfaces/interface-0/rx-queue"};
78#elif defined (DEVICE_K2E)
79#include <ti/drv/qmss/device/k2e/src/qmss_device.c>
80#include <ti/drv/cppi/device/k2e/src/cppi_device.c>
81char* DTS_LOG_FILE_QUEUE_ETHx[] = {
82 "/proc/device-tree/soc/netcp@2400000/netcp-interfaces/interface-0/rx-queue"};
83
84#else /*Default */
85#include <ti/runtime/hplib/device/k2h/src/hplib_device.c>
86#include <ti/runtime/netapi/device/k2h/src/netapi_device.c>
87#include <ti/drv/qmss/device/k2h/src/qmss_device.c>
88#include <ti/drv/cppi/device/k2h/src/cppi_device.c>
89char* DTS_LOG_FILE_QUEUE_ETHx[] = {
90 "/proc/device-tree/soc/netcp@2000000/netcp-interfaces/interface-0/rx-queue"};
91
92#endif
93
94/**********************************************************************
95 ************************** Local Definitions *************************
96 **********************************************************************/
97
98/**********************************************************************
99 ************************** Global Variables **************************
100 **********************************************************************/
101extern Rm_ServiceHandle *rmClientServiceHandle;
102
103static ipsecmgr_ipc_daemon_send_if_t *send_iface;
104NETAPI_T netapi_handle;
105
106ipsecMgrMcb_t globalDB;
107
108static int use_rm =0;
109
110/* Lock file for the daemon */
111#define LOCK_FILE "/var/lock/ipsecmgr_daemon"
112
113/* snoop task */
114static pthread_t snoop_run_th;
115
116static pthread_t stats_th;
117static NETAPI_CFG_T our_netapi_default_cfg=
118{
119 TUNE_NETAPI_PERM_MEM_SZ,
120 128, //start of packet offset for hw to place data on rx for default flow
121 TUNE_NETAPI_QM_CONFIG_MAX_DESC_NUM, //max number of descriptors in system
122 TUNE_NETAPI_NUM_GLOBAL_DESC, //total we will use
123 TUNE_NETAPI_DEFAULT_NUM_BUFFERS, //#descriptors+buffers in default heap
124 64, //#descriptors w/o buffers in default heap
125 TUNE_NETAPI_DEFAULT_BUFFER_SIZE+128+128, //size of buffers in default heap
126 128, //tail room
127 256, //extra room
128 0,
129 NULL,
130 0,
131 0
132};
133
134
135
136static int QUIT = 0;
137ipsecMgrShm_T* pIpsecMgrSaStats;
138
139/* stub functions */
140static void recv_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
141 PKTIO_METADATA_T meta[], int n_pkts,
142 uint64_t ts )
143{
144 return;
145}
146
147/* byte swap routine */
148static unsigned int swap32 (unsigned int x)
149{
150 unsigned int y;
151
152 y = (((x >> 24) & 0xff) << 0) |
153 (((x >> 16) & 0xff) << 8) |
154 (((x >> 8) & 0xff) << 16) |
155 (((x >> 0) & 0xff) << 24) ;
156
157 return (y);
158
159}
160
161void cleanup_sa_sp()
162{
163 int slot, error=0;;
164 /* delete any offloaded rx SA's and policies */
165 /* and delete any offloaded tx SA's */
166 for (slot = 0; slot < IPSECMGR_MAX_SA; slot++)
167 {
168 if(globalDB.rx_sa[slot].in_use)
169 {
170 globalDB.rx_sa[slot].in_use = 0;
171 if(globalDB.rx_sa[slot].spAppId)
172 {
173 netapi_secDelRxPolicy(netapi_handle,
174 (NETCP_CFG_IPSEC_POLICY_T) globalDB.rx_sa[slot].spAppId,
175 &error);
176 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
177 "cleanup_sa_sp: SP deleted: sp_app_id: 0x%x, slot: %d, error: %d\n",
178 globalDB.rx_sa[slot].spAppId, slot, error);
179 }
180 netapi_secDelSA(netapi_handle,
181 NETCP_CFG_NO_INTERFACE,
182 (NETCP_CFG_SA_T) globalDB.rx_sa[slot].saAppId,
183 &error);
184 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
185 "cleanup_sa_sp: SA deleted: sa_app_id: 0x%x, slot: %d, error: %d\n",
186 globalDB.rx_sa[slot].saAppId, slot, error);
187
188 }
189 if(globalDB.tx_sa[slot].in_use)
190 {
191 globalDB.tx_sa[slot].in_use = 0;
192 netapi_secDelSA(netapi_handle,
193 NETCP_CFG_NO_INTERFACE,
194 (NETCP_CFG_SA_T) globalDB.tx_sa[slot].saAppId,
195 &error);
196 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
197 "cleanup_sa_sp: SA deleted: sa_app_id: 0x%x, slot: %d, error: %d\n",
198 globalDB.tx_sa[slot].saAppId, slot, error);
199 }
200 }
201}
202
203
204static void* snoop_run_thread (void* arg)
205{
206 cpu_set_t cpu_set;
207 CPU_ZERO( &cpu_set);
208 CPU_SET( 0, &cpu_set);
209
210 hplib_utilSetupThread(0, &cpu_set, hplib_spinLock_Type_LOL);
211 ipsecmgr_syslog_msg(SYSLOG_LEVEL_INFO,
212 "snoop_run_thread: daemon entering forever event loop\n");
213
214 while (1)
215 {
216 /* Poll for message from user application */
217 ipsecmgr_ipc_poll();
218
219 /* Poll for message from Kernel */
220 ipsecmgr_snoop_run();
221 if (QUIT == 1)
222 break;
223 }
224 ipsecmgr_syslog_msg(SYSLOG_LEVEL_INFO,
225 "snoop_run_thread: calling shutdown\n");
226 ipsecmgr_snoop_shutdown ();
227 cleanup_sa_sp();
228 netapi_shutdown(netapi_handle);
229
230 closeRm();
231 return ((void*)NULL);
232}
233
234/**
235 * @b Description
236 * @n
237 * SIGTERM handler.
238 *
239 * @param[in] signum
240 * signal number to terminate deamon.
241 */
242static void sig_term_handler(int signum)
243{
244 QUIT = 1;
245}
246
247/**
248 * @b Description
249 * @n
250 * Function to implement task sleep functionality
251 * for IPSecMgr
252 *
253 * @param[in] time_in_msec
254 * Time in milliseconds to sleep
255 *
256 * @retval
257 * Not Applicable.
258 */
259static void task_sleep(uint32_t time_in_msec)
260{
261 pthread_mutex_t fake_mutex = PTHREAD_MUTEX_INITIALIZER;
262 pthread_cond_t fake_cond = PTHREAD_COND_INITIALIZER;
263 struct timespec ts;
264 int rt;
265 unsigned int sec, nsec;
266
267 sec = time_in_msec/1000;
268 nsec = (time_in_msec - (sec*1000)) * 1000000;
269
270 /* Use the wall-clock time */
271 clock_gettime(CLOCK_REALTIME, &ts);
272
273 ts.tv_sec += sec;
274 ts.tv_nsec += nsec;
275
276 pthread_mutex_lock(&fake_mutex);
277 rt = pthread_cond_timedwait(&fake_cond, &fake_mutex, &ts);
278 pthread_mutex_unlock(&fake_mutex);
279}
280
281
282/**
283 * @b Description
284 * @n
285 * NETAPI Proxy's IPSecMgr Start Offload Response
286 * message handler.
287 *
288 * This function is called by the IPSecMgr library
289 * when it has a response ready corresponding to an
290 * Start Offload SP request issued by the user application.
291 *
292 * @param[in] rsp
293 * IPSecMgr's Start Offload SP response
294 * @param[in] addr
295 * Destination address (user application) to send
296 * the response to
297 * @param[in] addr_size
298 * Size of destination address passed
299 *
300 * @retval
301 * Success - 0
302 * @retval
303 * ERROR - <0
304 */
305static int offload_sp_rsp_send
306(
307 ipsecmgr_snoop_offload_sp_rsp_param_t *rsp,
308 void *addr,
309 uint32_t addr_size
310)
311{
312 ipsecmgr_ipc_offload_sp_rsp_param_t offload_sp_rsp;
313
314 offload_sp_rsp.type = rsp->type;
315 offload_sp_rsp.result = rsp->result;
316 offload_sp_rsp.trans_id = rsp->trans_id;
317 offload_sp_rsp.err_code = rsp->err_code;
318 offload_sp_rsp.sp_handle = rsp->sp_handle;
319 offload_sp_rsp.sa_handle = rsp->sa_handle;
320
321 if (addr_size != sizeof(ipsecmgr_ipc_addr_t)) {
322 ipsecmgr_syslog_msg(SYSLOG_LEVEL_ERROR,
323 "offload_sp_rsp_send: addr size not correct\n");
324 return -1;
325 }
326
327 return send_iface->offload_sp_rsp(&offload_sp_rsp,
328 (ipsecmgr_ipc_addr_t *)addr);
329}
330static void offload_sp_req_recv
331(
332 ipsecmgr_ipc_offload_sp_req_param_t *req,
333 ipsecmgr_ipc_addr_t *src_addr
334)
335{
336 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,"offload_sp_req_recv called for policy id\n",
337 req->policy_id);
338 ipsecmgr_snoop_offload_sp_rsp_param_t rsp;
339 uint32_t addr_size = sizeof(ipsecmgr_ipc_addr_t);
340 ipsecmgr_snoop_offload_sp_req_param_t offload_sp_req;
341
342 offload_sp_req.trans_id = req->trans_id;
343 offload_sp_req.policy_id = req->policy_id;
344 offload_sp_req.sa_flags = req->sa_flags;
345 offload_sp_req.if_name = req->if_name;
346 offload_sp_req.dscp_cfg = req->dscp_cfg;
347 offload_sp_req.l5_selector = req->l5_selector;
348 //offload_sp_req.oseq_offset = req->oseq_offset;
349
350 memset(&rsp, 0, sizeof(rsp));
351 rsp.trans_id = req->trans_id;
352
353 if (ipsecmgr_snoop_offload_sp_req(&offload_sp_req, (void*)src_addr,
354 addr_size)) {
355 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
356 "offload_sp_req_recv: snoop_offload_sp_req failed\n");
357 rsp.result = RESULT_FAILURE;
358 rsp.type = RSP_TYPE_ACK | RSP_TYPE_DONE;
359 }
360 else
361 {
362 rsp.result = RESULT_SUCCESS;
363 rsp.type = RSP_TYPE_ACK;
364 }
365
366 if (offload_sp_rsp_send(&rsp, (void *)src_addr, addr_size))
367 {
368 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
369 "offload_sp_req_recv: failed to send ACK for offload_sp\n");
370 }
371 return;
372}
373
374
375/**
376 * @b Description
377 * @n
378 * NETAPI Proxy's IPSecMgr Stop Offload response message
379 * handler.
380 *
381 * This function is called by the IPSecMgr library
382 * when it has a response ready corresponding to an
383 * Stop Offload SP request issued by the user application.
384 *
385 * @param[in] rsp
386 * IPSecMgr's Stop Offload SP response
387 * @param[in] addr
388 * Destination address (user application) to send
389 * the response to
390 * @param[in] addr_size
391 * Size of destination address passed
392 *
393 * @retval
394 * Success - 0
395 * @retval
396 * ERROR - <0
397 */
398static int stop_offload_rsp_send
399(
400 ipsecmgr_snoop_stop_offload_rsp_param_t *rsp,
401 void *addr,
402 uint32_t addr_size
403)
404{
405 ipsecmgr_ipc_stop_offload_rsp_param_t stop_offload_rsp;
406
407 stop_offload_rsp.type = rsp->type;
408 stop_offload_rsp.result = rsp->result;
409 stop_offload_rsp.trans_id = rsp->trans_id;
410
411 if (addr_size != sizeof(ipsecmgr_ipc_addr_t)) {
412 ipsecmgr_syslog_msg(SYSLOG_LEVEL_ERROR,
413 "stop_offload_rsp_send: addr size not correct\n");
414 return -1;
415 }
416
417 return send_iface->stop_offload_rsp(&stop_offload_rsp,
418 (ipsecmgr_ipc_addr_t *)addr);
419}
420
421static void stop_offload_req_recv
422(
423 ipsecmgr_ipc_stop_offload_req_param_t *req,
424 ipsecmgr_ipc_addr_t *src_addr
425)
426{
427 ipsecmgr_snoop_stop_offload_req_param_t stop_offload_req;
428 uint32_t addr_size = sizeof(ipsecmgr_ipc_addr_t);
429 ipsecmgr_snoop_stop_offload_rsp_param_t rsp;
430
431 stop_offload_req.trans_id = req->trans_id;
432 stop_offload_req.policy_id = req->policy_id;
433 stop_offload_req.no_expire_sa = req->no_expire_sa;
434
435 memset(&rsp, 0, sizeof(rsp));
436 rsp.trans_id = req->trans_id;
437
438 if (ipsecmgr_snoop_stop_offload(&stop_offload_req, (void*)src_addr,
439 addr_size)) {
440 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
441 "stop_offload_req_recv: snoop_stop_offload failed\n");
442 rsp.result = RESULT_FAILURE;
443 rsp.type = RSP_TYPE_ACK | RSP_TYPE_DONE;
444 }
445 else
446 {
447 rsp.result = RESULT_SUCCESS;
448 rsp.type = RSP_TYPE_ACK;
449 }
450
451 if (stop_offload_rsp_send(&rsp, (void *)src_addr, addr_size))
452 {
453 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
454 "stop_offload_req_recv: failed to send ACK for stop_offload\n");
455 }
456 return;
457}
458
459static void stats_callback(NETAPI_T h)
460{
461 int i;
462 for (i = 0; i < IPSECMGR_MAX_SA; i++)
463 {
464 /* Statistics for RX Tunnel */
465 if(globalDB.rx_sa[i].in_use)
466 {
467 netapi_getSaStats(h,
468 globalDB.rx_sa[i].saAppId,
469 &(pIpsecMgrSaStats->netapi_sa_stats_rx[i]));
470 if (pIpsecMgrSaStats->netapi_sa_stats_rx[i].validParams & NETAPI_IPSEC_STAT_VALID)
471 {
472 memcpy(&(pIpsecMgrSaStats->info_rx[i]),
473 &(globalDB.rx_sa[i]),
474 sizeof(ipsecMgrAppId_T));
475 }
476 }
477 }
478 for (i = 0; i < IPSECMGR_MAX_SA; i++)
479 {
480 /* Statistics for TX Tunnel */
481 if (globalDB.tx_sa[i].in_use)
482 {
483 netapi_getSaStats(h,
484 globalDB.tx_sa[i].saAppId,
485 &(pIpsecMgrSaStats->netapi_sa_stats_tx[i]));
486 if (pIpsecMgrSaStats->netapi_sa_stats_tx[i].validParams & NETAPI_IPSEC_STAT_VALID)
487 {
488 memcpy(&(pIpsecMgrSaStats->info_tx[i]),
489 &(globalDB.tx_sa[i]),
490 sizeof(ipsecMgrAppId_T));
491 }
492 }
493 }
494}
495
496static void slow_path_thread(uint32_t index)
497{
498 NETAPI_T worker_nh;
499 int err, i;;
500 cpu_set_t cpu_set;
501
502 CPU_ZERO( &cpu_set);
503 CPU_SET( index, &cpu_set);
504
505 hplib_utilSetupThread(index, &cpu_set, hplib_spinLock_Type_LOL);
506 worker_nh = netapi_init(NETAPI_CORE_MASTER,NULL);
507
508 if (worker_nh == NULL)
509 {
510 exit(1);
511 }
512 while(1)
513 {
514 if (QUIT == 1)
515 {
516 break;
517 }
518 sleep(2);
519 stats_callback(worker_nh);
520 }
521
522 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
523 "slow_path_thread: calling netapi_shutdown\n");
524 netapi_shutdown(worker_nh);
525}
526/**
527 * @b Description
528 * @n
529 * Function to initialize IPSec Manager library.
530 *
531 * @retval
532 * Success - 0
533 * @retval
534 * ERROR - >0
535 */
536static int32_t init_ipsecmgr (void)
537{
538 struct ipsecmgr_snoop_fp_cfg_cb fp_cfg_cb;
539 struct ipsecmgr_snoop_mgnt_cb mgnt_cb;
540 struct ipsecmgr_snoop_platform_cb plat_cb;
541 ipsecmgr_ipc_daemon_recv_if_t recv_if;
542 ipsecmgr_ipc_cfg_t ipc_cfg;
543 int32_t status;
544 pthread_attr_t threadAttr;
545
546 /* Initializations */
547 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
548 "DEBUG: init_ipsecmgr() starting initialization\n");
549 memset(&fp_cfg_cb, 0, sizeof(fp_cfg_cb));
550 memset(&mgnt_cb, 0, sizeof(mgnt_cb));
551 memset(&plat_cb, 0, sizeof(plat_cb));
552 memset(&recv_if, 0, sizeof(recv_if));
553 memset(&ipc_cfg, 0, sizeof(ipc_cfg));
554
555 /* Initialize IPC library */
556 ipc_cfg.mode = IPC_MODE_SNOOP_DAEMON;
557 ipc_cfg.ipc_id = globalDB.ipc_id;
558 if (ipsecmgr_ipc_init(&ipc_cfg)) {
559 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
560 "init_ipsecmgr: ipc_init failed\n");
561 return -1;
562 }
563 else
564 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
565 "init_ipsecmgr: ipc_init sucess\n");
566
567 if (ipsecmgr_ipc_get_daemon_send_iface(&send_iface)) {
568 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
569 "init_ipsecmgr: ipc_get_daemon_send_iface failed\n");
570 return -1;
571 }
572 recv_if.offload_sp_req = offload_sp_req_recv;
573 recv_if.stop_offload_req = stop_offload_req_recv;
574 /* Register ipsecmgr daemon recieve i/f */
575 if (ipsecmgr_ipc_register_daemon_recv_iface(&recv_if)) {
576 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
577 "snoop_run: ipc_register_daemon_recv_iface failed\n");
578 return -1;
579 }
580
581 /* Initialize the IPSec Manager Snoop library */
582 fp_cfg_cb.add_sa = netapilib_ifAddSA;
583 fp_cfg_cb.add_sp = netapilib_ifAddSP;
584 fp_cfg_cb.del_sa = netapilib_ifDeleteSA;
585 fp_cfg_cb.del_sp = netapilib_ifDeleteSP;
586 fp_cfg_cb.get_sa_ctx = netapilib_ifGetSACtx;
587
588 plat_cb.log_msg = (ipsecmgr_snoop_log_msg_t)ipsecmgr_syslog_msg;
589 plat_cb.sleep = task_sleep;
590
591 mgnt_cb.offload_sp_rsp = offload_sp_rsp_send;
592 mgnt_cb.stop_offload_rsp= stop_offload_rsp_send;
593 mgnt_cb.rekey_event = NULL; // No explicit notifications needed on Rekey completion
594
595 if ((status = ipsecmgr_snoop_init (&fp_cfg_cb, &mgnt_cb, &plat_cb)))
596 {
597 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
598 "DEBUG: init_ipsecmgr() ipsecmgr_snoop_init failed (%d)\n", status);
599 return -1;
600 }
601
602
603
604#ifdef GDB_DEBUG
605 snoop_run_thread(NULL);
606#else
607 if (pthread_create( &stats_th, (void*)NULL, (void*)slow_path_thread,
608 (void *) 0))
609 {
610 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
611 "ERROR: stats collection thread failed to start, error code\n");
612 return -1;
613 }
614 /* Create the task context for snoop library */
615 if (pthread_create(&snoop_run_th, (void*) NULL, snoop_run_thread, NULL))
616 {
617 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
618 "ERROR: snoop run thread failed to start, error code\n");
619 return -1;
620 }
621
622 /* Setup signal handler for SIGTERM */
623 if (signal(SIGTERM, sig_term_handler) == SIG_ERR) {
624 ipsecmgr_syslog_msg(SYSLOG_LEVEL_WARN,
625 "init_ipsecmgr: cannot handle SIGTERM\n");
626 }
627 /* Wait for the NETAPI Proxy task to finish its processing and exit. */
628 pthread_join (stats_th, NULL);
629 pthread_join (snoop_run_th, NULL);
630#endif
631 return 0;
632}
633
634/**
635 * @b Description
636 * @n
637 * Utility function to daemonize the current
638 * application.
639 *
640 * @param[in] lock_file
641 * Lock file to be used by the daemon
642 */
643static void daemonize (const char *lock_file)
644{
645 pid_t pid, sid;
646 int32_t lock_fp = -1;
647 char str[10];
648
649 /* already a daemon */
650 if (getppid () == 1)
651 return;
652
653 /* Fork off the parent process */
654 if ((pid = fork ()) < 0)
655 {
656 ipsecmgr_syslog_msg(SYSLOG_LEVEL_ERROR,
657 "ERROR: daemonize() unable to fork daemon, code=%d (%s)",
658 errno,
659 strerror(errno));
660 exit (-1);
661 }
662
663 /* If we got a PID, then exit the parent process. */
664 if (pid > 0)
665 exit (0);
666
667 /* At this point we are executing as the child process */
668
669 /* Create a new SID for the child process */
670 if ((sid = setsid ()) < 0)
671 {
672 ipsecmgr_syslog_msg(SYSLOG_LEVEL_ERROR,
673 "ERROR: daemonize() unable to create a new session, code %d (%s)",
674 errno,
675 strerror(errno));
676 exit (-1);
677 }
678
679 /* Change the file mode mask */
680 umask (027);
681
682 /* Change the current working directory. This prevents the current
683 * directory from being locked; hence not being able to remove it. */
684 if ((chdir("/")) < 0)
685 {
686 ipsecmgr_syslog_msg(SYSLOG_LEVEL_ERROR,
687 "ERROR: daemonize() unable to change directory to %s, code %d (%s)",
688 "/",
689 errno,
690 strerror(errno));
691 exit (-1);
692 }
693
694 /* Create the lock file */
695 if (lock_file)
696 {
697 if ((lock_fp = open(lock_file, O_RDWR|O_CREAT, 0640)) < 0 )
698 {
699 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
700 "ERROR: daemonize() unable to create lock file %s, code=%d (%s)",
701 lock_file,
702 errno,
703 strerror(errno));
704 exit (-1);
705 }
706
707
708 if (lockf (lock_fp, F_TLOCK, 0) < 0)
709 exit(-1); /* can not lock */
710
711 /* Record pid to lockfile */
712 snprintf (str, 10,"%d\n", getpid());
713 write (lock_fp, str, strlen(str));
714 close(lock_fp);
715 }
716 /* Cancel certain signals */
717 signal (SIGCHLD, SIG_DFL); /* A child process dies */
718 signal (SIGTSTP, SIG_IGN); /* Various TTY signals */
719 signal (SIGTTOU, SIG_IGN);
720 signal (SIGTTIN, SIG_IGN);
721 signal (SIGHUP, SIG_IGN); /* Ignore hangup signal */
722 signal (SIGTERM, sig_term_handler); /* catch SIGTERM */
723
724 /* Redirect standard files to /dev/null */
725 freopen( "/dev/null", "r", stdin);
726 freopen( "/dev/null", "w", stdout);
727 freopen( "/dev/null", "w", stderr);
728
729 /* Done setting up the daemon */
730 return;
731}
732
733int get_kernel_config()
734{
735 uint32_t temp=0;
736 FILE *pDts = NULL;
737
738 pDts = fopen(DTS_LOG_FILE_QUEUE_ETHx[0], "rb");
739
740 if(pDts)
741 {
742 if(fread((void*)&temp, sizeof(uint32_t), 1, pDts))
743 {
744 globalDB.qNum = (int)swap32(temp);
745 }
746 fclose(pDts);
747 }
748 else
749 {
750 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
751 "main: error opening device tree file: %s\n",DTS_LOG_FILE_QUEUE_ETHx[0]);
752 return -1;
753 }
754#if (defined(DEVICE_K2L) || defined(DEVICE_K2E))
755 globalDB.flowId = 0;
756#else
757 globalDB.flowId = 22;
758#endif
759 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
760 "get_kernel_config: flow: 0x%x, qNum: 0x%x\n",
761 globalDB.flowId, globalDB.qNum);
762 return 0;
763}
764
765int create_pktio_channel()
766{
767 static int count = 0;
768 int error = 0;
769 char name[PKTIO_MAX_NAME];
770 PKTIO_HANDLE_T *pktio_channel;
771 PKTIO_CFG_T pktio_cfg;
772 NETCP_CFG_ROUTE_T route;
773 NETCP_CFG_FLOW_T flow;
774 NETCP_CFG_EXCEPTION_PKT_T expPkt_appid = 0;
775
776 memset(&pktio_cfg,0,sizeof(PKTIO_CFG_T));
777 memset((void *)&route, 0, sizeof (NETCP_CFG_ROUTE_T));
778 memset((void *)&flow, 0, sizeof (NETCP_CFG_FLOW_T));
779
780 snprintf(&name[0],PKTIO_MAX_NAME, "%s","offload_0");
781 pktio_cfg.qnum = globalDB.qNum;
782 pktio_cfg.flags1 = PKTIO_RX;
783 pktio_cfg.flags2 = PKTIO_GLOBAL | PKTIO_PKT;
784 pktio_cfg.max_n = 8;
785 pktio_cfg.queueType = Qmss_QueueType_GIC400_QUEUE;
786
787 globalDB.pktio_channel = netapi_pktioCreate(netapi_handle,
788 &name[0],
789 (PKTIO_CB)recv_cb,
790 &pktio_cfg,
791 &error);
792 if (!globalDB.pktio_channel)
793 {
794 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
795 "create_pktio_channel: failed\n");
796 return -1;
797 }
798
799
800 flow.dma_engine= 1;
801 flow.flowid = globalDB.flowId;
802 route.p_dest_q = globalDB.pktio_channel;
803 route.p_flow = &flow;
804 route.valid_params |= NETCP_CFG_VALID_PARAM_ROUTE_TYPE;
805 route.routeType = NWAL_ROUTE_RX_INTF_W_FLOW;
806 /* enable exception packet handling for fragmented packets */
807 expPkt_appid = netapi_netcpCfgExceptions(netapi_handle,
808 7,
809 NETCP_CFG_ACTION_TO_SW,
810 (NETCP_CFG_ROUTE_HANDLE_T) &route);
811
812 return 0;
813}
814void print_ipsec_stats(Sa_IpsecStats_t* p_saIpsecStats,
815 nwal_saAALG auth,
816 nwal_saEALG cipher,
817 uint32_t spi)
818{
819 printf("\nspi: 0x%x, Autentication mode: %d, Encryption Mode: %d\n",
820 spi, auth, cipher);
821 printf("IPSec replayOld:0x%x,replayDup:0x%x,authFail:0x%x \n",
822 p_saIpsecStats->replayOld,p_saIpsecStats->replayDup,p_saIpsecStats->authFail);
823 printf("IPSec txESN:0x%x,rxESN:0x%x,pktEncHi:0x%x,pktEncLo:0x%x,pktDecHi:0x%x,pktDecLo:0x%x \n",
824 p_saIpsecStats->txESN,p_saIpsecStats->rxESN,p_saIpsecStats->pktEncHi,
825 p_saIpsecStats->pktEncLo,p_saIpsecStats->pktDecHi,p_saIpsecStats->pktDecLo);
826}
827/**
828 * @b Description
829 * @n
830 * Entry point for the NETAPI Proxy application.
831 *
832 * @param[in] argc
833 * Number of arguments passed to the application
834 * @param[in] argv
835 * Arguments passed to the application.
836 *
837 * @retval
838 * Success - 0
839 * @retval
840 * ERROR - >0
841 */
842int32_t main (int argc, char* argv[])
843{
844 int32_t retVal;
845 int i, iface;
846 char* pTok = NULL;
847 int ip_entry_count = 0;
848 struct ifaddrs *ifaddr, *ifa;
849 int family, s;
850 char host[NI_MAXHOST];
851 struct sockaddr_in6 ipv6_addr;
852 cpu_set_t cpu_set;
853 int c;
854 int statsQueryRequest = 0;
855 void* pShmBase;
856 void* pTemp;
857 void* pShmEntry;
858 int offloaded_sa = 0;
859 static char usage[] = "usage: %s -s <outbound sequence number>\n \
860 -f <SA transmit flow Id>\n \
861 -i<daemon id>\n \
862 -t <stats collection mode\n \
863 -m <master Type ,sysMaster or procMaster >\n";
864
865 memset(&globalDB, 0, sizeof(globalDB));
866 globalDB.sa_tx_flow = -1;
867 globalDB.masterType = NETAPI_SYS_MASTER;
868 int temp;
869 while ((c = getopt (argc, argv, "s:f:i:m:t:")) != -1)
870 {
871 switch (c)
872 {
873 case 's':
874 /* check is user input 0 for oseq_offset (valid but also default)*/
875 if(strncmp("0", optarg,1) == 0)
876 {
877 globalDB.oseq_offset = 0;
878 }
879 else
880 {
881 globalDB.oseq_offset = (uint32_t)strtol(optarg, NULL,0);
882 if(!globalDB.oseq_offset)
883 {
884 printf(usage, argv[0]);
885 exit(EXIT_FAILURE);
886 }
887 }
888 break;
889 case 'f':
890 /* check is user input 0 for sa_tx_flow(valid) */
891 if(strncmp("0", optarg,1) == 0)
892 {
893 globalDB.sa_tx_flow= 0;
894 }
895 else
896 {
897 globalDB.sa_tx_flow = (uint32_t)strtol(optarg, NULL,0);
898 if(!globalDB.sa_tx_flow)
899 {
900 printf(usage, argv[0]);
901 exit(EXIT_FAILURE);
902 }
903 }
904 break;
905 case 'i':
906 /* check is user input 0 for daemon id, valid */
907 if(strncmp("0", optarg,1) == 0)
908 {
909 globalDB.ipc_id= 0;
910 }
911 else
912 {
913 globalDB.ipc_id = (uint32_t)strtol(optarg, NULL,0);
914 if(!globalDB.ipc_id)
915 {
916 printf(usage, argv[0]);
917 exit(EXIT_FAILURE);
918 }
919 }
920 break;
921 case 'm':
922 if(strcmp("sysMaster", optarg) == 0)
923 {
924 globalDB.masterType = NETAPI_SYS_MASTER;
925 }
926 else if (strcmp("procMaster", optarg) == 0)
927 {
928 globalDB.masterType = NETAPI_PROC_MASTER;
929 }
930 else
931 {
932 printf(usage, argv[0]);
933 exit(EXIT_FAILURE);
934 }
935 break;
936 case 't':
937 if(strcmp("stats", optarg) == 0)
938 /* running in stats collection mode only */
939 statsQueryRequest = 1;
940 else
941 {
942 printf(usage, argv[0]);
943 exit(EXIT_FAILURE);
944 }
945 break;
946 case '?':
947 printf(usage, argv[0]);
948 exit(EXIT_FAILURE);
949 default:
950 break;
951 }
952 }
953 if(statsQueryRequest)
954 {
955 pShmBase = hplib_shmOpen();
956 if (pShmBase)
957 {
958 if (globalDB.masterType == NETAPI_SYS_MASTER)
959 pTemp = hplib_shmGetEntry(pShmBase, APP_ENTRY_1);
960 else
961 pTemp = hplib_shmGetEntry(pShmBase, APP_ENTRY_2);
962
963 pIpsecMgrSaStats = (ipsecMgrShm_T*) pTemp;
964
965 for (i = 0; i < IPSECMGR_MAX_SA; i ++)
966 {
967 if(pIpsecMgrSaStats->info_rx[i].in_use)
968 {
969 offloaded_sa++;
970 print_ipsec_stats(&(pIpsecMgrSaStats->netapi_sa_stats_rx[i].saIpsecStats),
971 pIpsecMgrSaStats->info_rx[i].authMode,
972 pIpsecMgrSaStats->info_rx[i].cipherMode,
973 pIpsecMgrSaStats->info_rx[i].spi);
974 }
975 }
976 for (i = 0; i < IPSECMGR_MAX_SA; i ++)
977 {
978 if(pIpsecMgrSaStats->info_tx[i].in_use)
979 {
980 offloaded_sa++;
981 print_ipsec_stats(&(pIpsecMgrSaStats->netapi_sa_stats_tx[i].saIpsecStats),
982 pIpsecMgrSaStats->info_tx[i].authMode,
983 pIpsecMgrSaStats->info_tx[i].cipherMode,
984 pIpsecMgrSaStats->info_tx[i].spi);
985 }
986 }
987 }
988 if(!offloaded_sa)
989 printf("NO Offloaded SA's\n");
990 exit(EXIT_SUCCESS);
991 }
992 ipsecmgr_syslog_init();
993 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
994 "main: oseq_offset: %d, sa_tx_flow: %d\n",
995 globalDB.oseq_offset, globalDB.sa_tx_flow);
996
997 if (initRm())
998 {
999 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
1000 "main: initRm() returned error\n");
1001 exit(1);
1002 }
1003 our_netapi_default_cfg.rmHandle = rmClientServiceHandle;
1004
1005
1006 /* assign main net_test thread to run on core 0 */
1007 CPU_ZERO( &cpu_set);
1008 CPU_SET( 0, &cpu_set);
1009 hplib_utilSetupThread(0, &cpu_set, hplib_spinLock_Type_LOL);
1010 /* create netapi */
1011 netapi_handle = netapi_init(globalDB.masterType,
1012 &our_netapi_default_cfg);
1013 if(netapi_handle == NULL)
1014 {
1015 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
1016 "ERROR: netapi_init failed\n");
1017 return -1;
1018 }
1019 pShmBase = hplib_shmOpen();
1020 if (pShmBase)
1021 {
1022 if (globalDB.masterType == NETAPI_SYS_MASTER)
1023 {
1024 if (hplib_shmAddEntry(pShmBase,
1025 sizeof(ipsecMgrShm_T),
1026 APP_ENTRY_1) != hplib_OK)
1027 {
1028 return -1;
1029 }
1030 else
1031 {
1032 pShmEntry = hplib_shmGetEntry(pShmBase, APP_ENTRY_1);
1033 pIpsecMgrSaStats = (ipsecMgrShm_T*)pShmEntry;
1034 memset(pIpsecMgrSaStats,
1035 0,
1036 sizeof(ipsecMgrShm_T));
1037 }
1038 }
1039 else
1040 {
1041 if (hplib_shmAddEntry(pShmBase,
1042 sizeof(ipsecMgrShm_T),
1043 APP_ENTRY_2) != hplib_OK)
1044 {
1045 return -1;
1046 }
1047 else
1048 {
1049 pShmEntry = hplib_shmGetEntry(pShmBase, APP_ENTRY_2);
1050 pIpsecMgrSaStats = (ipsecMgrShm_T*)pShmEntry;
1051 memset(pIpsecMgrSaStats,
1052 0,
1053 sizeof(ipsecMgrShm_T));
1054 }
1055 }
1056 }
1057 else
1058 {
1059 exit(1);
1060 }
1061
1062 if (get_kernel_config())
1063 {
1064 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
1065 "ERROR: main: get_kernel_config() failed\n");
1066 return -1;
1067 }
1068 else
1069 {
1070 /* create pktio channel */
1071 if(create_pktio_channel())
1072 {
1073 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
1074 "ERROR: main: pktio channel creation failed\n");
1075 return -1;
1076 }
1077 }
1078 /*Create the proxy daemon. */
1079 ipsecmgr_syslog_msg(SYSLOG_LEVEL_INFO, "main: calling daemonize\n");
1080 daemonize (LOCK_FILE);
1081
1082 /* Initialize and start the IPSec Mgr Snoop functionality */
1083 if ((retVal = init_ipsecmgr ()) < 0)
1084 {
1085 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
1086 "ERROR: IPSec Mgr init failed, error code %d \n",
1087 retVal);
1088 return -1;
1089 }
1090 else
1091 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
1092 "main: ipsecmgr daemon shutdonw complete\n");
1093
1094 exit(EXIT_SUCCESS);
1095
1096}
diff --git a/ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/src/netapilib_interface.c b/ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/src/netapilib_interface.c
new file mode 100755
index 0000000..0b3d1be
--- /dev/null
+++ b/ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/src/netapilib_interface.c
@@ -0,0 +1,629 @@
1/*
2 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
3 *
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
15 * distribution.
16 *
17 * Neither the name of Texas Instruments Incorporated nor the names of
18 * its contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33*/
34
35/* Standard includes */
36#include <stdio.h>
37#include <arpa/inet.h>
38#include <inttypes.h>
39
40/* ipsecmgr includes */
41#include <ipsecmgr_snoop.h>
42#include <ipsecmgr_syslog.h>
43
44#include "netapilib_interface.h"
45
46
47extern ipsecMgrMcb_t globalDB;
48extern NETAPI_T netapi_handle;
49extern ipsecMgrShm_T* pIpsecMgrSaStats;
50
51/**************************************************************************
52 * FUNCTION PURPOSE: Internal function to find a free slot to store APPID
53 * in list
54 **************************************************************************
55 * DESCRIPTION: Internal internal function to find a free slot in SA list for an SA
56 ********************************************************************/
57int findFreeAppIdSlot(ipsecMgrAppId_T *pList)
58{
59 int i;
60 for(i=0;i < IPSECMGR_MAX_SA; i++)
61 {
62 if (!pList[i].in_use)
63 {
64 pList[i].in_use = 1; //pending
65 return i;
66 }
67 }
68 return -1;
69}
70
71/********************************************************************
72 * FUNCTION PURPOSE: Internal function to find a SA app id in SA list
73 * and free SA Slot entry if specified
74 ********************************************************************
75 * DESCRIPTION: Internal function to find a SA app id in SA list
76 * and free SA Slot entry if specified
77 ********************************************************************/
78int findAppIdSlot(ipsecMgrAppId_T *pList, uint32_t saAppId, int freeSlot)
79{
80 int i;
81 for(i=0; i< IPSECMGR_MAX_SA; i++)
82 {
83 if ((pList[i].in_use) && (pList[i].saAppId == saAppId))
84 {
85 if(freeSlot)
86 pList[i].in_use = 0;
87 return i;
88 }
89 }
90 return -1;
91}
92
93/**************************************************************************
94 * FUNCTION PURPOSE: The function is used to translate the SA configuration
95 * parameters received from the IPSec Snopper and call the NETAPI function
96 * to create a security association
97 ********************************************************************/
98int netapilib_ifAddSA
99(
100 ipsecmgr_af_t af,
101 ipsecmgr_sa_id_t *sa_id,
102 ipsecmgr_sa_info_t *sa_info,
103 ipsecmgr_sa_dscp_map_cfg_t *dscp_map_cfg,
104 ipsecmgr_ifname_t *if_name,
105 ipsecmgr_sa_encap_tmpl_t *encap,
106 ipsecmgr_fp_handle_t *sa_handle
107)
108{
109 int i;
110 uint8_t auth_key[36];
111 uint8_t encr_key[36];
112 int error, index,slot;
113 NETAPI_SEC_SA_INFO_T saInfo;
114 nwalSecKeyParams_t keyParams;
115 void * p_rx_inflow_mode_handle;
116 void * p_tx_inflow_mode_handle;
117 NETCP_CFG_ROUTE_T route;
118 NETCP_CFG_FLOW_T flow;
119 NETCP_CFG_SA_HANDLE_T pSaHandle;
120 char* pTok = NULL;
121 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
122 "netapilib_ifAddSA:, DEBUG: Translating SA\n");
123
124 memset((void *)&saInfo, 0, sizeof (NETAPI_SEC_SA_INFO_T));
125 memset((void *)&keyParams, 0, sizeof (nwalSecKeyParams_t));
126 memset((void *)&route, 0, sizeof (NETCP_CFG_ROUTE_T));
127 memset((void *)&flow, 0, sizeof (NETCP_CFG_FLOW_T));
128
129 /* Initialize the SA Config structure. */
130 /* Get the IP protocol version. */
131 if (af == IPSECMGR_AF_IPV4)
132 {
133 saInfo.ipType = nwal_IPV4;
134 /* Populate the source and destination IP addresses. */
135 for (index = 0; index < NWAL_IPV4_ADDR_SIZE; index++)
136 {
137 saInfo.dst.ipv4[index] = sa_id->daddr.ipv4[index];
138 saInfo.src.ipv4[index] = sa_info->saddr.ipv4[index];
139 }
140 }
141 else if (af == IPSECMGR_AF_IPV6)
142 {
143 saInfo.ipType = nwal_IPV6;
144
145 /* Populate the source and destination IP addresses. */
146 for (index = 0; index < NWAL_IPV6_ADDR_SIZE; index++)
147 {
148 saInfo.dst.ipv6[index] = sa_id->daddr.ipv6[index];
149 saInfo.src.ipv6[index] = sa_info->saddr.ipv6[index];
150 }
151 }
152 else
153 {
154 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
155 "netapilib_ifAddSA: Address family (%d) is invalid\n", af);
156 return -1;
157 }
158 /* Get the SPI. */
159 saInfo.spi = sa_id->spi;
160
161 /* Get the SA direction. */
162 if (sa_info->dir == DIR_INBOUND)
163 {
164 slot = findFreeAppIdSlot(&globalDB.rx_sa[0]);
165 if (slot == -1)
166 {
167 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
168 "netapilib_ifAddSA:, Too many INBOUND SAs already offloaded\n");
169 return -1;
170 }
171 saInfo.dir = NWAL_SA_DIR_INBOUND;
172
173 flow.dma_engine= 1;
174 flow.flowid = globalDB.flowId;
175 ipsecmgr_syslog_msg(SYSLOG_LEVEL_INFO,
176 "add_sa:flowid: %d\n",flow.flowid);
177
178 route.p_flow = &flow;
179 route.p_dest_q = globalDB.pktio_channel;
180
181 ipsecmgr_syslog_msg(SYSLOG_LEVEL_INFO,
182 "add_sa: p_dest_q: 0x%x, flowId: 0x%x\n",
183 route.p_dest_q,
184 route.p_flow->flowid);
185 route.valid_params |= NETCP_CFG_VALID_PARAM_ROUTE_TYPE;
186 route.routeType = NWAL_ROUTE_RX_INTF_W_FLOW;
187 }
188 else if (sa_info->dir == DIR_OUTBOUND)
189 {
190 slot = findFreeAppIdSlot(&globalDB.tx_sa[0]);
191 if (slot == -1)
192 {
193 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
194 "netapilib_ifAddSA:, Too many OUTBOUND SAs already offloaded\n");
195 return -1;
196 }
197 saInfo.dir = NWAL_SA_DIR_OUTBOUND;
198 }
199 else
200 {
201 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
202 "netapilib_ifAddSA: IPSec direction (%d) is invalid\n", sa_info->dir);
203 return -1;
204 }
205
206
207 /* Get the replay Window */
208 saInfo.replayWindow = sa_info->replay_window;
209
210 /* Get the IPSec protocol. */
211 if (sa_id->proto == SA_PROTO_AH)
212 saInfo.proto = nwal_IpSecProtoAH;
213 else if (sa_id->proto == SA_PROTO_ESP)
214 saInfo.proto = nwal_IpSecProtoESP;
215 else
216 {
217 ipsecmgr_syslog_msg(SYSLOG_LEVEL_INFO,
218 "netapilib_ifAddSA: IPSec protocol (%d) is invalid.\n", sa_id->proto);
219 return -1;
220 }
221 /* Get the IPSec mode. */
222 if (sa_info->mode == SA_MODE_TRANSPORT)
223 saInfo.saMode = nwal_SA_MODE_TRANSPORT;
224 else if (sa_info->mode == SA_MODE_TUNNEL)
225 saInfo.saMode = nwal_SA_MODE_TUNNEL;
226 else
227 {
228 ipsecmgr_syslog_msg(SYSLOG_LEVEL_ERROR,
229 "netapilib_ifAddSA: IPSec mode (%d) is invalid.\n", sa_info->mode);
230 return -1;
231 }
232 /* Get the authentication mode algorithm. */
233 if (sa_info->auth.algo == SA_AALG_HMAC_SHA1)
234 saInfo.authMode = NWAL_SA_AALG_HMAC_SHA1;
235 else if (sa_info->auth.algo == SA_AALG_HMAC_MD5)
236 saInfo.authMode = NWAL_SA_AALG_HMAC_MD5;
237 else if (sa_info->auth.algo == SA_AALG_AES_XCBC)
238 saInfo.authMode = NWAL_SA_AALG_AES_XCBC;
239 else if (sa_info->auth.algo == SA_AALG_HMAC_SHA2_256)
240 saInfo.authMode = NWAL_SA_AALG_HMAC_SHA2_256;
241 else if (sa_info->auth.algo == SA_AALG_NONE || sa_info->auth.algo == SA_AALG_NULL)
242 saInfo.authMode = NWAL_SA_AALG_NULL;
243 else
244 {
245 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
246 "netapilib_ifAddSA: Authentication algorithm (%d) is invalid\n", sa_info->auth.algo);
247 return -1;
248 }
249
250 /* Get the encryption mode algorithm. */
251 if (sa_info->enc.algo == SA_EALG_NULL)
252 saInfo.cipherMode = NWAL_SA_EALG_NULL;
253 else if (sa_info->enc.algo == SA_EALG_AES_CTR)
254 saInfo.cipherMode = NWAL_SA_EALG_AES_CTR;
255 else if (sa_info->enc.algo == SA_EALG_AES_CBC)
256 saInfo.cipherMode = NWAL_SA_EALG_AES_CBC;
257 else if (sa_info->enc.algo == SA_EALG_3DES_CBC)
258 saInfo.cipherMode = NWAL_SA_EALG_3DES_CBC;
259 else if (sa_info->enc.algo == SA_EALG_DES_CBC)
260 saInfo.cipherMode = NWAL_SA_EALG_DES_CBC;
261 else if (sa_info->enc.algo == SA_EALG_AES_GCM)
262 saInfo.cipherMode = NWAL_SA_EALG_AES_GCM;
263 else
264 {
265 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
266 "netapilib_ifAddSA: Encryption algorithm (%d) is invalid\n", sa_info->enc.algo);
267 return -1;
268 }
269 /* Validate the key lengths. */
270 if ((keyParams.macKeySize = sa_info->auth_key_len) > 32)
271 {
272 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
273 "netapilib_ifAddSA: Authentication key size (%d) is invalid.\n", sa_info->auth_key_len);
274 return -1;
275 }
276 if ((keyParams.encKeySize = sa_info->enc_key_len) > 32)
277 {
278 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
279 "netapilib_ifAddSA: Encryption key size (%d) is invalid.\n", sa_info->enc_key_len);
280 return -1;
281 }
282
283 /* Get the authentication/encryption keys. */
284 keyParams.pAuthKey = &sa_info->auth_key[0];
285 keyParams.pEncKey = &sa_info->enc_key[0];
286
287 if (saInfo.dir == NWAL_SA_DIR_INBOUND)
288 {
289 /* Inbound == RX */
290 globalDB.rx_sa[slot].saAppId = netapi_secAddSA(netapi_handle,
291 NETCP_CFG_NO_INTERFACE,
292 &saInfo,
293 &keyParams,
294 NETAPI_SEC_SA_INFLOW,
295 (NETCP_CFG_ROUTE_HANDLE_T)&route,
296 &p_rx_inflow_mode_handle,
297 &p_tx_inflow_mode_handle,
298 NULL, &error);
299
300 if (error == NETAPI_ERR_OK)
301 {
302 *sa_handle = globalDB.rx_sa[slot].saAppId;
303 globalDB.rx_sa[slot].authMode = saInfo.authMode;
304 globalDB.rx_sa[slot].cipherMode = saInfo.cipherMode;
305 globalDB.rx_sa[slot].spi = saInfo.spi;
306 }
307 else
308 {
309 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
310 "netapilib_ifAddSA: netapi_secAddSA returned error: %d.\n",
311 error);
312 return -1;
313 }
314 }
315 else
316 {
317 saInfo.esnLo = sa_info->esnlo + globalDB.oseq_offset;
318
319 /* OUTBOUND == TX */
320 globalDB.tx_sa[slot].saAppId = netapi_secAddSA(netapi_handle,
321 NETCP_CFG_NO_INTERFACE,
322 &saInfo,
323 &keyParams,
324 NETAPI_SEC_SA_INFLOW,
325 (NETCP_CFG_ROUTE_HANDLE_T)NULL,
326 &p_rx_inflow_mode_handle,
327 &p_tx_inflow_mode_handle,
328 NULL, &error);
329 if (error == NETAPI_ERR_OK)
330 {
331 *sa_handle = globalDB.tx_sa[slot].saAppId;
332 globalDB.tx_sa[slot].authMode = saInfo.authMode;
333 globalDB.tx_sa[slot].cipherMode = saInfo.cipherMode;
334 globalDB.tx_sa[slot].spi = saInfo.spi;
335 }
336 else
337 {
338 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
339 "netapilib_ifAddSA: netapi_secAddSA returned error: %d.\n",
340 error);
341 return -1;
342 }
343 }
344
345 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
346 "netapilib_ifAddSA: Translation of SA successful, app_id: 0x%x\n", *sa_handle);
347
348 /* SA was created successfully. */
349 return 0;
350}
351
352/**************************************************************************
353 * FUNCTION PURPOSE: The function is used to translate the SA configuration
354 * parameters received from the IPSec Snopper and call the NETAPI function
355 * to delete a security association
356 ********************************************************************/
357int netapilib_ifDeleteSA (ipsecmgr_fp_handle_t sa_handle)
358{
359 int error = 0;
360 int slot = 0;
361
362 slot = findAppIdSlot(&globalDB.rx_sa[0],sa_handle, 1);
363
364 /* Determine if rx_sa or tx_sa is being deleted */
365 if (slot != -1)
366 {
367 pIpsecMgrSaStats->info_rx[slot].in_use = 0;
368 /* found rx SA, see if there is policy assoicated with rx SA
369 if so, then delete it first*/
370 if (globalDB.rx_sa[slot].spAppId)
371 {
372 netapi_secDelRxPolicy(netapi_handle,
373 (NETCP_CFG_IPSEC_POLICY_T) globalDB.rx_sa[slot].spAppId,
374 &error);
375 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
376 "netapilib_ifDeleteSA: SP deleted: sp_app_id: 0x%x, slot: %d, error: %d\n",
377 globalDB.rx_sa[slot].spAppId, slot, error);
378 }
379 netapi_secDelSA(netapi_handle,
380 NETCP_CFG_NO_INTERFACE,
381 (NETCP_CFG_SA_T) sa_handle,
382 &error);
383 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
384 "netapilib_ifDeleteSA: SA deleted: sa_app_id: 0x%x, slot: %d, error: %d\n",
385 sa_handle, slot, error);
386
387
388 }
389 else
390 {
391 /* not rx SA, check for tx_sa */
392 slot = findAppIdSlot(&globalDB.tx_sa[0], sa_handle, 1);
393
394 if (slot != -1)
395 {
396 pIpsecMgrSaStats->info_tx[slot].in_use = 0;
397 /* found tx SA, delete it now */
398 netapi_secDelSA(netapi_handle,
399 NETCP_CFG_NO_INTERFACE,
400 (NETCP_CFG_SA_T) sa_handle,
401 &error);
402 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
403 "netapilib_ifDeleteSA: SA deleted: sa_app_id: 0x%x, slot: %d, error: %d\n",
404 sa_handle, slot, error);
405 }
406 else
407 {
408 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
409 "netapilib_ifDeleteSA: sa_app_id 0x%x not found in internal list\n",
410 sa_handle);
411 return -1;
412 }
413 }
414
415 return error;
416}
417
418/**************************************************************************
419 * FUNCTION PURPOSE: The function is used to translate the SP configuration
420 * parameters received from the IPSec Snopper and call the NETAPI function
421 * to create a security policy
422 ********************************************************************/
423int32_t netapilib_ifAddSP
424(
425 ipsecmgr_af_t af,
426 ipsecmgr_selector_t *sel,
427 ipsecmgr_dir_t dir,
428 uint32_t reqid,
429 ipsecmgr_fp_handle_t sa_handle,
430 ipsecmgr_policy_id_t policy_id,
431 ipsecmgr_fp_handle_t *sp_handle
432)
433{
434#ifdef ENABLE_ADD_POLICY
435#warning "ENABLE_ADD_POLICY"
436 NETCP_CFG_IPSEC_POLICY_T spAppIdIn;
437 int error, index, slot;
438 nwal_IpType ipType;
439 nwalIpAddr_t src_ip_addr;
440 nwalIpAddr_t dst_ip_addr;
441 nwalIpOpt_t ip_qualifiers;
442 NETCP_CFG_SA_T sa =(NETCP_CFG_SA_T)sa_handle;
443 NETCP_CFG_ROUTE_T route;
444 NETCP_CFG_FLOW_T flow;
445 NETCP_CFG_PA_HANDLE_T pPaHandleOuterIP;
446 NETCP_CFG_PA_HANDLE_T pPaHandleInnerIP;
447 NETCP_CFG_SA_HANDLE_T pSaHandle;
448
449 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,"netapilib_ifAddSP: called\n");
450
451
452 if (dir == DIR_OUTBOUND)
453 {
454 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
455 "netapilib_ifAddSP: called for outbound SA, no RX policy required\n");
456 return 0;
457 }
458 slot = findAppIdSlot(&globalDB.rx_sa[0],sa_handle, 0);
459 if (slot == -1)
460 {
461 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
462 "netapilib_ifAddSA:, SA app_id not found\n");
463 return -1;
464 }
465
466
467
468 flow.dma_engine= 1;
469 flow.flowid = globalDB.flowId;
470 route.p_flow = &flow;
471 route.p_dest_q = globalDB.pktio_channel;
472
473
474 /* Get the IP protocol version. */
475 if (af == IPSECMGR_AF_IPV4)
476 {
477 ipType = nwal_IPV4;
478 /* Populate the source and destination IP addresses. */
479 for (index = 0; index < NWAL_IPV4_ADDR_SIZE; index++)
480 {
481 dst_ip_addr.ipv4[index] = sel->daddr.ipv4[index];
482 src_ip_addr.ipv4[index] = sel->saddr.ipv4[index];
483 }
484 }
485 else if (af == IPSECMGR_AF_IPV6)
486 {
487 ipType = nwal_IPV6;
488 /* Populate the source and destination IP addresses. */
489 for (index = 0; index < NWAL_IPV6_ADDR_SIZE; index++)
490 {
491 dst_ip_addr.ipv6[index] = sel->daddr.ipv6[index];
492 src_ip_addr.ipv6[index] = sel->saddr.ipv6[index];
493 }
494 }
495 else
496 {
497 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
498 "netapilib_ifAddSP: Address family (%d) is invalid\n", af);
499 return -1;
500 }
501
502 globalDB.rx_sa[slot].spAppId = netapi_secAddRxPolicy(netapi_handle,
503 (NETCP_CFG_SA_T) sa_handle,
504 ipType,
505 &src_ip_addr,
506 &dst_ip_addr,
507 NULL,
508 (NETCP_CFG_ROUTE_HANDLE_T)&route,
509 NULL,
510 &error);
511
512 if (error == NETAPI_ERR_OK)
513 {
514 *sp_handle = globalDB.rx_sa[slot].spAppId;
515 }
516 else
517 {
518 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
519 "netapilib_ifAddSA: netapi_secAddRxPolicy returned error: %d.\n",
520 error);
521 return -1;
522 }
523 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
524 "netapilib_ifAddSA: Translation of SP successful, app_id: 0x%x\n", *sp_handle);
525
526#endif
527 return 0;
528}
529
530/**************************************************************************
531 * FUNCTION PURPOSE: The function is used to translate the SP configuration
532 * parameters received from the IPSec Snopper and call the NETAPI function
533 * to delete a security association
534 ********************************************************************/
535int32_t netapilib_ifDeleteSP
536(
537 ipsecmgr_fp_handle_t sp_handle,
538 ipsecmgr_policy_id_t policy_id,
539 ipsecmgr_dir_t dir
540)
541{
542 /* Security Policy is deleted as part of deleting SA */
543 return 0;
544#if 0
545 int error =0;
546 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,"netapilib_ifDeleteSP: called\n");
547
548 if (dir == DIR_OUTBOUND)
549 {
550 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
551 "netapilib_ifDeleteSP: called for outbound SA, no RX policy to delete\n");
552 return 0;
553 }
554 netapi_secDelRxPolicy(netapi_handle,
555 (NETCP_CFG_IPSEC_POLICY_T) sp_handle,
556 &error);
557
558 return 0;
559#endif
560}
561
562/**************************************************************************
563 * FUNCTION PURPOSE: The function is used to translate the SA configuration
564 * parameters received from the IPSec Snopper and retrieve SA context
565 * information for SA.
566 *************************************************************************/
567int netapilib_ifGetSACtx
568(
569 ipsecmgr_fp_handle_t sa_handle,
570 ipsecmgr_sa_hw_ctx_t* hw_ctx
571)
572{
573 uint32_t swInfo0 = 0;
574 uint32_t swInfo1 = 0;
575 nwalGlobCxtInfo_t info;
576 nwal_RetValue retVal;
577
578 memset(&info, 0, sizeof(nwalGlobCxtInfo_t));
579 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) netapi_handle;
580 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,"netapilib_ifGetSACtx: called\n");
581
582
583 if(netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context,
584 (NETCP_CFG_SA_T) sa_handle,
585 &swInfo0,
586 &swInfo1))
587 {
588 hw_ctx->swinfo[0] = swInfo0;
589 hw_ctx->swinfo[1] = swInfo1;
590 }
591 hw_ctx->swinfo_sz = 2;
592
593
594 if(globalDB.sa_tx_flow == -1)
595 {
596 retVal = nwal_getGlobCxtInfo(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
597 &info);
598 if (retVal != nwal_OK)
599 {
600 ipsecmgr_syslog_msg (SYSLOG_LEVEL_ERROR,
601 "netapilib_ifGetSACtx: nwal_getGlobCxtInfo returned error: 0x%x\n", retVal);
602 return -1;
603 }
604 hw_ctx->flow_id = info.rxSaPaFlowId;
605 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
606 "netapilib_ifGetSACtx: rxPaSaflowId: 0x%x, rxSaPaflowId: 0x%x\n",
607 info.rxPaSaFlowId,
608 info.rxSaPaFlowId);
609 }
610 else
611 {
612 hw_ctx->flow_id = globalDB.sa_tx_flow;
613 }
614
615 ipsecmgr_syslog_msg (SYSLOG_LEVEL_INFO,
616 "netapilib_ifGetSACtx: swInfo0: 0x%x, swInfo1: 0x%x, flowId: 0x%x\n",
617 hw_ctx->swinfo[0],
618 hw_ctx->swinfo[1],
619 hw_ctx->flow_id);
620
621 /* return success */
622 return 0;
623}
624
625
626
627
628
629
diff --git a/ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/src/netapilib_interface.h b/ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/src/netapilib_interface.h
new file mode 100644
index 0000000..8784732
--- /dev/null
+++ b/ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/src/netapilib_interface.h
@@ -0,0 +1,117 @@
1/*
2 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
3 *
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
15 * distribution.
16 *
17 * Neither the name of Texas Instruments Incorporated nor the names of
18 * its contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33*/
34
35#ifndef __FPLIB_INTERFACE_H__
36#define __FPLIB_INTERFACE_H__
37
38#include "ti/runtime/netapi/netapi.h"
39#include <netdb.h>
40
41
42#define IPSECMGR_MAX_SA 64
43/* Container for applicaion ID's for offloaded SA's */
44typedef struct {
45 int in_use;
46 uint32_t saAppId;
47 uint32_t spAppId;
48 uint32_t spi;
49 nwal_saAALG authMode; /**< Authentication Algorithm */
50 nwal_saEALG cipherMode; /**< Encryption Algorithm */
51} ipsecMgrAppId_T;
52
53typedef struct {
54 ipsecMgrAppId_T info_rx[IPSECMGR_MAX_SA];
55 ipsecMgrAppId_T info_tx[IPSECMGR_MAX_SA];
56 NETAPI_SA_STATS_T netapi_sa_stats_rx[IPSECMGR_MAX_SA];
57 NETAPI_SA_STATS_T netapi_sa_stats_tx[IPSECMGR_MAX_SA];
58} ipsecMgrShm_T;
59typedef struct {
60 int flowId;
61 int qNum;
62 PKTIO_HANDLE_T* pktio_channel;
63
64 /* list to store offloaded RX SA appIds and RX Policies */
65 ipsecMgrAppId_T rx_sa[IPSECMGR_MAX_SA];
66 /* list to store offloaded TX SA appIds */
67 ipsecMgrAppId_T tx_sa[IPSECMGR_MAX_SA];
68 uint32_t oseq_offset; /* offset to outbound/egress sequence number */
69 int sa_tx_flow; /* flow SA to use to transmit packet */
70 int ipc_id; /* ipc_id to give name uniqueness to socket
71 connection with command shell */
72 int masterType; /* Specifies to run the daemon as NETAPI_SYS_MASTER or
73 NETAPI_PROC_MASTER */
74} ipsecMgrMcb_t;
75
76int netapilib_ifAddSA
77(
78 ipsecmgr_af_t af,
79 ipsecmgr_sa_id_t *sa_id,
80 ipsecmgr_sa_info_t *sa_info,
81 ipsecmgr_sa_dscp_map_cfg_t *dscp_map_cfg,
82 ipsecmgr_ifname_t *if_name,
83 ipsecmgr_sa_encap_tmpl_t *encap,
84 ipsecmgr_fp_handle_t *sa_handle
85);
86
87int netapilib_ifAddSP
88(
89 ipsecmgr_af_t af,
90 ipsecmgr_selector_t *sel,
91 ipsecmgr_dir_t dir,
92 uint32_t reqid,
93 ipsecmgr_fp_handle_t sa_handle,
94 ipsecmgr_policy_id_t policy_id,
95 ipsecmgr_fp_handle_t *sp_handle
96);
97
98int netapilib_ifDeleteSP
99(
100 ipsecmgr_fp_handle_t sp_handle,
101 ipsecmgr_policy_id_t policy_id,
102 ipsecmgr_dir_t dir
103);
104
105int netapilib_ifDeleteSA
106(
107 ipsecmgr_fp_handle_t sa_handle
108);
109
110int netapilib_ifGetSACtx
111(
112 ipsecmgr_fp_handle_t sa_handle,
113 ipsecmgr_sa_hw_ctx_t *hw_ctx
114);
115
116#endif
117
diff --git a/ti/runtime/netapi/build/Makefile b/ti/runtime/netapi/build/Makefile
new file mode 100755
index 0000000..87c6868
--- /dev/null
+++ b/ti/runtime/netapi/build/Makefile
@@ -0,0 +1,126 @@
1# Macro definitions referenced below
2#
3empty =
4space =$(empty) $(empty)
5
6# INCLUDE Directories
7QMSS_INC_DIR ?= $(PDK_INSTALL_PATH)/ti/drv/qmss
8SA_INSTALL_PATH ?= $(PDK_INSTALL_PATH)/ti/drv/sa
9CPPI_INC_DIR ?= $(PDK_INSTALL_PATH)/ti/drv/cppi
10
11
12NETAPI_INC_DIR ?= $(TRANS_SDK_INSTALL_PATH)
13NETAPI_SRC_DIR ?= $(TRANS_SDK_INSTALL_PATH)/ti/runtime/netapi
14
15#HPLIB_INC_DIR = $(HPLIB_INSTALL_PATH)/ti/runtime/hplib
16
17HPLIB_INC_DIR ?= $(PDK_INSTALL_PATH)/ti/runtime/hplib
18INCDIR := $(PDK_INSTALL_PATH);$(QMSS_INC_DIR);$(CPPI_INC_DIR);$(HPLIB_INC_DIR);$(NETAPI_INC_DIR)
19
20export PDK_VER ?= v3
21NETAPI_NAVIG_INIT_SRC=$(NETAPI_SRC_DIR)/src/pdk$(PDK_VER)
22
23ifeq ($(CPU), cortex-a8)
24 CFLAGS += -DCORTEX_A8
25endif
26
27export DEVICE?= k2h
28ifeq ($(PDK_VER),v3)
29QMSS_DEV_DIR = $(PDK_INSTALL_PATH)/ti/drv/qmss/device/$(DEVICE)/src
30CPPI_DEV_DIR = $(PDK_INSTALL_PATH)/ti/drv/cppi/device/$(DEVICE)/src
31endif
32ifeq ($(PDK_VER),v2)
33QMSS_DEV_DIR = $(PDK_INSTALL_PATH)/ti/drv/qmss/device
34CPPI_DEV_DIR = $(PDK_INSTALL_PATH)/ti/drv/cppi/device
35endif
36
37# Set NETAPI INSTALL PATH to Transport SDK for default
38export NETAPI_INSTALL_PATH ?= $(TRANS_SDK_INSTALL_PATH)
39
40NETAPI_DOCS_DIR := $(NETAPI_INSTALL_PATH)/ti/runtime/netapi/docs
41
42#NETAPI dirs
43OBJEXT = o
44INTERNALLINKDEFS =
45SRCDIR = ./src
46#VPATH=$(SRCDIR):$(NETAPI_NAVIG_INIT_SRC)
47VPATH=$(SRCDIR):./src/pdk$(PDK_VER)
48
49ifdef CROSS_TOOL_INSTALL_PATH
50## Support backwards compatibility with KeyStone1 approach
51 CC = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)gcc
52 AC = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)as
53 AR = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)ar
54 LD = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)gcc
55endif
56#Cross tools
57#CC = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)gcc -c
58#AR = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)ar -r
59
60
61#List the COMMONSRC Files
62COMMONSRCC = \
63 netapi.c \
64 netapi_sec.c \
65 netapi_init.c \
66 netapi_sched.c \
67 netcp_cfg.c \
68 pktio.c \
69 netapi_navig.c\
70
71CFLAGS+= $(DEBUG_FLAG) -I. -I $(SRCDIR) -I$(PDK_INSTALL_PATH) -I$(NWAL_INSTALL_PATH) -I$(PKTLIB_INSTALL_PATH) -I$(TRANS_SDK_INSTALL_PATH) -I$(QMSS_INC_DIR) -I$(CPPI_INC_DIR) -I$(HPLIB_INC_DIR) -I$(QMSS_DEV_DIR) -I$(CPPI_DEV_DIR) -I$(NETAPI_NAVIG_INIT_SRC) -I$(SA_INSTALL_PATH) $(CSL_DEVICE) -D__ARMv7 -D_VIRTUAL_ADDR_SUPPORT -D__LINUX_USER_SPACE -D_LITTLE_ENDIAN=1 -DMAKEFILE_BUILD -DNWAL_ENABLE_SA -pthread -D _GNU_SOURCE
72
73
74
75INCS = -I$(strip $(subst ;, -I,$(subst $(space),\$(space),$(INCDIR))))
76all: lib
77
78lib: $(ARMV7LIBDIR)/libnetapi_$(DEVICE).a
79
80
81# Make Rule for the COMMONSRC Files
82COMMONSRCCOBJS = $(patsubst %.c, $(ARMV7OBJDIR)/%.$(OBJEXT), $(COMMONSRCC))
83COMMONSRCCOBJS_SO = $(patsubst %.c, $(ARMV7OBJDIR_SO)/%.$(OBJEXT), $(COMMONSRCC))
84
85$(COMMONSRCCOBJS): $(ARMV7OBJDIR)/%.$(OBJEXT): %.c
86 -@echo compiling $< ........
87 -@echo vpath = $(VPATH)
88 @mkdir -p $(ARMV7OBJDIR)
89 $(CC) -c $(CFLAGS) $(INCS) $< -o $@
90
91$(COMMONSRCCOBJS_SO): $(ARMV7OBJDIR_SO)/%.$(OBJEXT): %.c
92 -@echo **** compiling this file $< ...
93 @mkdir -p $(ARMV7OBJDIR_SO)
94 $(CC) -c $(CFLAGS) -fPIC $(INCS) $< -o $@
95
96$(ARMV7LIBDIR)/libnetapi_$(DEVICE).a: $(COMMONSRCCOBJS)
97 @mkdir -p $(ARMV7LIBDIR)
98 @echo archiving $? into $@ ...
99 @$(AR) -r $@ $?
100
101
102libnetapi_$(DEVICE).so: $(COMMONSRCCOBJS_SO)
103 -@echo archiving $? into $(ARMV7LIBDIR)/$@.1 ...
104 @$(CC) $(DEBUG_FLAG) -ggdb2 -Wl,-soname=$@.1 -shared -fPIC ${LDFLAGS} -o $@.1.0.0 $^
105 @ln -s $@.1.0.0 $@.1
106 @ln -s $@.1 $@
107 mkdir -p $(ARMV7LIBDIR)
108 @mv -f $@.1.0.0 $(ARMV7LIBDIR)/$@.1.0.0
109 @mv -f $@.1 $(ARMV7LIBDIR)/$@.1
110 @mv -f $@ $(ARMV7LIBDIR)/$@
111
112clean:
113 rm -f $(ARMV7OBJDIR)/*.o
114 rm -f $(ARMV7OBJDIR_SO)/*.o
115 rm -f $(ARMV7LIBDIR)/libnetapi_$(DEVICE).a
116 rm -f $(ARMV7LIBDIR)/libnetapi_$(DEVICE).so*
117
118doxygen:
119 rm -rf $(NETAPI_DOCS_DIR)/html
120 rm -rf $(NETAPI_DOCS_DIR)/latex
121 doxygen netapi_doxygen.cfg
122
123clean_doxygen:
124 rm -rf $(NETAPI_DOCS_DIR)/html
125 rm -rf $(NETAPI_DOCS_DIR)/latex
126
diff --git a/ti/runtime/netapi/build/netapi_doxygen.cfg b/ti/runtime/netapi/build/netapi_doxygen.cfg
new file mode 100755
index 0000000..9eff4f5
--- /dev/null
+++ b/ti/runtime/netapi/build/netapi_doxygen.cfg
@@ -0,0 +1,1555 @@
1# Doxyfile 1.6.3
2
3# This file describes the settings to be used by the documentation system
4# doxygen (www.doxygen.org) for a project
5#
6# All text after a hash (#) is considered a comment and will be ignored
7# The format is:
8# TAG = value [value, ...]
9# For lists items can also be appended using:
10# TAG += value [value, ...]
11# Values that contain spaces should be placed between quotes (" ")
12
13#---------------------------------------------------------------------------
14# Project related configuration options
15#---------------------------------------------------------------------------
16
17# This tag specifies the encoding used for all characters in the config file
18# that follow. The default is UTF-8 which is also the encoding used for all
19# text before the first occurrence of this tag. Doxygen uses libiconv (or the
20# iconv built into libc) for the transcoding. See
21# http://www.gnu.org/software/libiconv for the list of possible encodings.
22
23DOXYFILE_ENCODING = UTF-8
24
25# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
26# by quotes) that should identify the project.
27
28PROJECT_NAME = netapi
29
30# The PROJECT_NUMBER tag can be used to enter a project or revision number.
31# This could be handy for archiving the generated documentation or
32# if some version control system is used.
33
34PROJECT_NUMBER =
35
36# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
37# base path where the generated documentation will be put.
38# If a relative path is entered, it will be relative to the location
39# where doxygen was started. If left blank the current directory will be used.
40
41OUTPUT_DIRECTORY = ../docs/doxygen
42
43# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
44# 4096 sub-directories (in 2 levels) under the output directory of each output
45# format and will distribute the generated files over these directories.
46# Enabling this option can be useful when feeding doxygen a huge amount of
47# source files, where putting all generated files in the same directory would
48# otherwise cause performance problems for the file system.
49
50CREATE_SUBDIRS = NO
51
52# The OUTPUT_LANGUAGE tag is used to specify the language in which all
53# documentation generated by doxygen is written. Doxygen will use this
54# information to generate all constant output in the proper language.
55# The default language is English, other supported languages are:
56# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
57# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
58# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
59# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
60# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
61# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
62
63OUTPUT_LANGUAGE = English
64
65# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
66# include brief member descriptions after the members that are listed in
67# the file and class documentation (similar to JavaDoc).
68# Set to NO to disable this.
69
70BRIEF_MEMBER_DESC = YES
71
72# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
73# the brief description of a member or function before the detailed description.
74# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
75# brief descriptions will be completely suppressed.
76
77REPEAT_BRIEF = YES
78
79# This tag implements a quasi-intelligent brief description abbreviator
80# that is used to form the text in various listings. Each string
81# in this list, if found as the leading text of the brief description, will be
82# stripped from the text and the result after processing the whole list, is
83# used as the annotated text. Otherwise, the brief description is used as-is.
84# If left blank, the following values are used ("$name" is automatically
85# replaced with the name of the entity): "The $name class" "The $name widget"
86# "The $name file" "is" "provides" "specifies" "contains"
87# "represents" "a" "an" "the"
88
89ABBREVIATE_BRIEF =
90
91# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
92# Doxygen will generate a detailed section even if there is only a brief
93# description.
94
95ALWAYS_DETAILED_SEC = NO
96
97# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
98# inherited members of a class in the documentation of that class as if those
99# members were ordinary class members. Constructors, destructors and assignment
100# operators of the base classes will not be shown.
101
102INLINE_INHERITED_MEMB = NO
103
104# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
105# path before files name in the file list and in the header files. If set
106# to NO the shortest path that makes the file name unique will be used.
107
108FULL_PATH_NAMES = NO
109
110# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
111# can be used to strip a user-defined part of the path. Stripping is
112# only done if one of the specified strings matches the left-hand part of
113# the path. The tag can be used to show relative paths in the file list.
114# If left blank the directory from which doxygen is run is used as the
115# path to strip.
116
117STRIP_FROM_PATH =
118
119# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
120# the path mentioned in the documentation of a class, which tells
121# the reader which header file to include in order to use a class.
122# If left blank only the name of the header file containing the class
123# definition is used. Otherwise one should specify the include paths that
124# are normally passed to the compiler using the -I flag.
125
126STRIP_FROM_INC_PATH =
127
128# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
129# (but less readable) file names. This can be useful is your file systems
130# doesn't support long names like on DOS, Mac, or CD-ROM.
131
132SHORT_NAMES = NO
133
134# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
135# will interpret the first line (until the first dot) of a JavaDoc-style
136# comment as the brief description. If set to NO, the JavaDoc
137# comments will behave just like regular Qt-style comments
138# (thus requiring an explicit @brief command for a brief description.)
139
140JAVADOC_AUTOBRIEF = NO
141
142# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
143# interpret the first line (until the first dot) of a Qt-style
144# comment as the brief description. If set to NO, the comments
145# will behave just like regular Qt-style comments (thus requiring
146# an explicit \brief command for a brief description.)
147
148QT_AUTOBRIEF = NO
149
150# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
151# treat a multi-line C++ special comment block (i.e. a block of //! or ///
152# comments) as a brief description. This used to be the default behaviour.
153# The new default is to treat a multi-line C++ comment block as a detailed
154# description. Set this tag to YES if you prefer the old behaviour instead.
155
156MULTILINE_CPP_IS_BRIEF = NO
157
158# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
159# member inherits the documentation from any documented member that it
160# re-implements.
161
162INHERIT_DOCS = YES
163
164# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
165# a new page for each member. If set to NO, the documentation of a member will
166# be part of the file/class/namespace that contains it.
167
168SEPARATE_MEMBER_PAGES = NO
169
170# The TAB_SIZE tag can be used to set the number of spaces in a tab.
171# Doxygen uses this value to replace tabs by spaces in code fragments.
172
173TAB_SIZE = 8
174
175# This tag can be used to specify a number of aliases that acts
176# as commands in the documentation. An alias has the form "name=value".
177# For example adding "sideeffect=\par Side Effects:\n" will allow you to
178# put the command \sideeffect (or @sideeffect) in the documentation, which
179# will result in a user-defined paragraph with heading "Side Effects:".
180# You can put \n's in the value part of an alias to insert newlines.
181
182ALIASES =
183
184# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
185# sources only. Doxygen will then generate output that is more tailored for C.
186# For instance, some of the names that are used will be different. The list
187# of all members will be omitted, etc.
188
189OPTIMIZE_OUTPUT_FOR_C = NO
190
191# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
192# sources only. Doxygen will then generate output that is more tailored for
193# Java. For instance, namespaces will be presented as packages, qualified
194# scopes will look different, etc.
195
196OPTIMIZE_OUTPUT_JAVA = NO
197
198# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
199# sources only. Doxygen will then generate output that is more tailored for
200# Fortran.
201
202OPTIMIZE_FOR_FORTRAN = NO
203
204# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
205# sources. Doxygen will then generate output that is tailored for
206# VHDL.
207
208OPTIMIZE_OUTPUT_VHDL = NO
209
210# Doxygen selects the parser to use depending on the extension of the files it parses.
211# With this tag you can assign which parser to use for a given extension.
212# Doxygen has a built-in mapping, but you can override or extend it using this tag.
213# The format is ext=language, where ext is a file extension, and language is one of
214# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
215# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
216# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
217# use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
218
219EXTENSION_MAPPING =
220
221# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
222# to include (a tag file for) the STL sources as input, then you should
223# set this tag to YES in order to let doxygen match functions declarations and
224# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
225# func(std::string) {}). This also make the inheritance and collaboration
226# diagrams that involve STL classes more complete and accurate.
227
228BUILTIN_STL_SUPPORT = NO
229
230# If you use Microsoft's C++/CLI language, you should set this option to YES to
231# enable parsing support.
232
233CPP_CLI_SUPPORT = NO
234
235# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
236# Doxygen will parse them like normal C++ but will assume all classes use public
237# instead of private inheritance when no explicit protection keyword is present.
238
239SIP_SUPPORT = NO
240
241# For Microsoft's IDL there are propget and propput attributes to indicate getter
242# and setter methods for a property. Setting this option to YES (the default)
243# will make doxygen to replace the get and set methods by a property in the
244# documentation. This will only work if the methods are indeed getting or
245# setting a simple type. If this is not the case, or you want to show the
246# methods anyway, you should set this option to NO.
247
248IDL_PROPERTY_SUPPORT = YES
249
250# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
251# tag is set to YES, then doxygen will reuse the documentation of the first
252# member in the group (if any) for the other members of the group. By default
253# all members of a group must be documented explicitly.
254
255DISTRIBUTE_GROUP_DOC = NO
256
257# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
258# the same type (for instance a group of public functions) to be put as a
259# subgroup of that type (e.g. under the Public Functions section). Set it to
260# NO to prevent subgrouping. Alternatively, this can be done per class using
261# the \nosubgrouping command.
262
263SUBGROUPING = YES
264
265# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
266# is documented as struct, union, or enum with the name of the typedef. So
267# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
268# with name TypeT. When disabled the typedef will appear as a member of a file,
269# namespace, or class. And the struct will be named TypeS. This can typically
270# be useful for C code in case the coding convention dictates that all compound
271# types are typedef'ed and only the typedef is referenced, never the tag name.
272
273TYPEDEF_HIDES_STRUCT = NO
274
275# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
276# determine which symbols to keep in memory and which to flush to disk.
277# When the cache is full, less often used symbols will be written to disk.
278# For small to medium size projects (<1000 input files) the default value is
279# probably good enough. For larger projects a too small cache size can cause
280# doxygen to be busy swapping symbols to and from disk most of the time
281# causing a significant performance penality.
282# If the system has enough physical memory increasing the cache will improve the
283# performance by keeping more symbols in memory. Note that the value works on
284# a logarithmic scale so increasing the size by one will rougly double the
285# memory usage. The cache size is given by this formula:
286# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
287# corresponding to a cache size of 2^16 = 65536 symbols
288
289SYMBOL_CACHE_SIZE = 0
290
291#---------------------------------------------------------------------------
292# Build related configuration options
293#---------------------------------------------------------------------------
294
295# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
296# documentation are documented, even if no documentation was available.
297# Private class members and static file members will be hidden unless
298# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
299
300EXTRACT_ALL = NO
301
302# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
303# will be included in the documentation.
304
305EXTRACT_PRIVATE = NO
306
307# If the EXTRACT_STATIC tag is set to YES all static members of a file
308# will be included in the documentation.
309
310EXTRACT_STATIC = YES
311
312# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
313# defined locally in source files will be included in the documentation.
314# If set to NO only classes defined in header files are included.
315
316EXTRACT_LOCAL_CLASSES = YES
317
318# This flag is only useful for Objective-C code. When set to YES local
319# methods, which are defined in the implementation section but not in
320# the interface are included in the documentation.
321# If set to NO (the default) only methods in the interface are included.
322
323EXTRACT_LOCAL_METHODS = NO
324
325# If this flag is set to YES, the members of anonymous namespaces will be
326# extracted and appear in the documentation as a namespace called
327# 'anonymous_namespace{file}', where file will be replaced with the base
328# name of the file that contains the anonymous namespace. By default
329# anonymous namespace are hidden.
330
331EXTRACT_ANON_NSPACES = NO
332
333# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
334# undocumented members of documented classes, files or namespaces.
335# If set to NO (the default) these members will be included in the
336# various overviews, but no documentation section is generated.
337# This option has no effect if EXTRACT_ALL is enabled.
338
339HIDE_UNDOC_MEMBERS = NO
340
341# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
342# undocumented classes that are normally visible in the class hierarchy.
343# If set to NO (the default) these classes will be included in the various
344# overviews. This option has no effect if EXTRACT_ALL is enabled.
345
346HIDE_UNDOC_CLASSES = NO
347
348# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
349# friend (class|struct|union) declarations.
350# If set to NO (the default) these declarations will be included in the
351# documentation.
352
353HIDE_FRIEND_COMPOUNDS = NO
354
355# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
356# documentation blocks found inside the body of a function.
357# If set to NO (the default) these blocks will be appended to the
358# function's detailed documentation block.
359
360HIDE_IN_BODY_DOCS = NO
361
362# The INTERNAL_DOCS tag determines if documentation
363# that is typed after a \internal command is included. If the tag is set
364# to NO (the default) then the documentation will be excluded.
365# Set it to YES to include the internal documentation.
366
367INTERNAL_DOCS = NO
368
369# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
370# file names in lower-case letters. If set to YES upper-case letters are also
371# allowed. This is useful if you have classes or files whose names only differ
372# in case and if your file system supports case sensitive file names. Windows
373# and Mac users are advised to set this option to NO.
374
375CASE_SENSE_NAMES = YES
376
377# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
378# will show members with their full class and namespace scopes in the
379# documentation. If set to YES the scope will be hidden.
380
381HIDE_SCOPE_NAMES = NO
382
383# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
384# will put a list of the files that are included by a file in the documentation
385# of that file.
386
387SHOW_INCLUDE_FILES = YES
388
389# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
390# will list include files with double quotes in the documentation
391# rather than with sharp brackets.
392
393FORCE_LOCAL_INCLUDES = NO
394
395# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
396# is inserted in the documentation for inline members.
397
398INLINE_INFO = YES
399
400# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
401# will sort the (detailed) documentation of file and class members
402# alphabetically by member name. If set to NO the members will appear in
403# declaration order.
404
405SORT_MEMBER_DOCS = YES
406
407# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
408# brief documentation of file, namespace and class members alphabetically
409# by member name. If set to NO (the default) the members will appear in
410# declaration order.
411
412SORT_BRIEF_DOCS = NO
413
414# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the (brief and detailed) documentation of class members so that constructors and destructors are listed first. If set to NO (the default) the constructors will appear in the respective orders defined by SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
415
416SORT_MEMBERS_CTORS_1ST = NO
417
418# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
419# hierarchy of group names into alphabetical order. If set to NO (the default)
420# the group names will appear in their defined order.
421
422SORT_GROUP_NAMES = NO
423
424# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
425# sorted by fully-qualified names, including namespaces. If set to
426# NO (the default), the class list will be sorted only by class name,
427# not including the namespace part.
428# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
429# Note: This option applies only to the class list, not to the
430# alphabetical list.
431
432SORT_BY_SCOPE_NAME = NO
433
434# The GENERATE_TODOLIST tag can be used to enable (YES) or
435# disable (NO) the todo list. This list is created by putting \todo
436# commands in the documentation.
437
438GENERATE_TODOLIST = YES
439
440# The GENERATE_TESTLIST tag can be used to enable (YES) or
441# disable (NO) the test list. This list is created by putting \test
442# commands in the documentation.
443
444GENERATE_TESTLIST = YES
445
446# The GENERATE_BUGLIST tag can be used to enable (YES) or
447# disable (NO) the bug list. This list is created by putting \bug
448# commands in the documentation.
449
450GENERATE_BUGLIST = YES
451
452# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
453# disable (NO) the deprecated list. This list is created by putting
454# \deprecated commands in the documentation.
455
456GENERATE_DEPRECATEDLIST= YES
457
458# The ENABLED_SECTIONS tag can be used to enable conditional
459# documentation sections, marked by \if sectionname ... \endif.
460
461ENABLED_SECTIONS =
462
463# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
464# the initial value of a variable or define consists of for it to appear in
465# the documentation. If the initializer consists of more lines than specified
466# here it will be hidden. Use a value of 0 to hide initializers completely.
467# The appearance of the initializer of individual variables and defines in the
468# documentation can be controlled using \showinitializer or \hideinitializer
469# command in the documentation regardless of this setting.
470
471MAX_INITIALIZER_LINES = 30
472
473# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
474# at the bottom of the documentation of classes and structs. If set to YES the
475# list will mention the files that were used to generate the documentation.
476
477SHOW_USED_FILES = YES
478
479# If the sources in your project are distributed over multiple directories
480# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
481# in the documentation. The default is NO.
482
483SHOW_DIRECTORIES = NO
484
485# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
486# This will remove the Files entry from the Quick Index and from the
487# Folder Tree View (if specified). The default is YES.
488
489SHOW_FILES = YES
490
491# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
492# Namespaces page.
493# This will remove the Namespaces entry from the Quick Index
494# and from the Folder Tree View (if specified). The default is YES.
495
496SHOW_NAMESPACES = YES
497
498# The FILE_VERSION_FILTER tag can be used to specify a program or script that
499# doxygen should invoke to get the current version for each file (typically from
500# the version control system). Doxygen will invoke the program by executing (via
501# popen()) the command <command> <input-file>, where <command> is the value of
502# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
503# provided by doxygen. Whatever the program writes to standard output
504# is used as the file version. See the manual for examples.
505
506FILE_VERSION_FILTER =
507
508# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
509# doxygen. The layout file controls the global structure of the generated output files
510# in an output format independent way. The create the layout file that represents
511# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
512# file name after the option, if omitted DoxygenLayout.xml will be used as the name
513# of the layout file.
514
515LAYOUT_FILE =
516
517#---------------------------------------------------------------------------
518# configuration options related to warning and progress messages
519#---------------------------------------------------------------------------
520
521# The QUIET tag can be used to turn on/off the messages that are generated
522# by doxygen. Possible values are YES and NO. If left blank NO is used.
523
524QUIET = NO
525
526# The WARNINGS tag can be used to turn on/off the warning messages that are
527# generated by doxygen. Possible values are YES and NO. If left blank
528# NO is used.
529
530WARNINGS = YES
531
532# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
533# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
534# automatically be disabled.
535
536WARN_IF_UNDOCUMENTED = YES
537
538# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
539# potential errors in the documentation, such as not documenting some
540# parameters in a documented function, or documenting parameters that
541# don't exist or using markup commands wrongly.
542
543WARN_IF_DOC_ERROR = YES
544
545# This WARN_NO_PARAMDOC option can be abled to get warnings for
546# functions that are documented, but have no documentation for their parameters
547# or return value. If set to NO (the default) doxygen will only warn about
548# wrong or incomplete parameter documentation, but not about the absence of
549# documentation.
550
551WARN_NO_PARAMDOC = NO
552
553# The WARN_FORMAT tag determines the format of the warning messages that
554# doxygen can produce. The string should contain the $file, $line, and $text
555# tags, which will be replaced by the file and line number from which the
556# warning originated and the warning text. Optionally the format may contain
557# $version, which will be replaced by the version of the file (if it could
558# be obtained via FILE_VERSION_FILTER)
559
560WARN_FORMAT = "$file:$line: $text"
561
562# The WARN_LOGFILE tag can be used to specify a file to which warning
563# and error messages should be written. If left blank the output is written
564# to stderr.
565
566WARN_LOGFILE =
567
568#---------------------------------------------------------------------------
569# configuration options related to the input files
570#---------------------------------------------------------------------------
571
572# The INPUT tag can be used to specify the files and/or directories that contain
573# documented source files. You may enter file names like "myfile.cpp" or
574# directories like "/usr/src/myproject". Separate the files or directories
575# with spaces.
576
577INPUT = ../netapi.h ../netcp_cfg.h ../netapi_sec.h ../netapi_tune.h ../netapi_sched.h ../pktio.h ../netapi_types.h ../netapi_ver.h
578
579# This tag can be used to specify the character encoding of the source files
580# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
581# also the default input encoding. Doxygen uses libiconv (or the iconv built
582# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
583# the list of possible encodings.
584
585INPUT_ENCODING = UTF-8
586
587# If the value of the INPUT tag contains directories, you can use the
588# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
589# and *.h) to filter out the source-files in the directories. If left
590# blank the following patterns are tested:
591# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
592# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
593
594FILE_PATTERNS = *.h
595
596# The RECURSIVE tag can be used to turn specify whether or not subdirectories
597# should be searched for input files as well. Possible values are YES and NO.
598# If left blank NO is used.
599
600RECURSIVE = NO
601
602# The EXCLUDE tag can be used to specify files and/or directories that should
603# excluded from the INPUT source files. This way you can easily exclude a
604# subdirectory from a directory tree whose root is specified with the INPUT tag.
605
606EXCLUDE =
607
608# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
609# directories that are symbolic links (a Unix filesystem feature) are excluded
610# from the input.
611
612EXCLUDE_SYMLINKS = NO
613
614# If the value of the INPUT tag contains directories, you can use the
615# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
616# certain files from those directories. Note that the wildcards are matched
617# against the file with absolute path, so to exclude all test directories
618# for example use the pattern */test/*
619
620EXCLUDE_PATTERNS =
621
622# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
623# (namespaces, classes, functions, etc.) that should be excluded from the
624# output. The symbol name can be a fully qualified name, a word, or if the
625# wildcard * is used, a substring. Examples: ANamespace, AClass,
626# AClass::ANamespace, ANamespace::*Test
627
628EXCLUDE_SYMBOLS =
629
630# The EXAMPLE_PATH tag can be used to specify one or more files or
631# directories that contain example code fragments that are included (see
632# the \include command).
633
634EXAMPLE_PATH =
635
636# If the value of the EXAMPLE_PATH tag contains directories, you can use the
637# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
638# and *.h) to filter out the source-files in the directories. If left
639# blank all files are included.
640
641EXAMPLE_PATTERNS =
642
643# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
644# searched for input files to be used with the \include or \dontinclude
645# commands irrespective of the value of the RECURSIVE tag.
646# Possible values are YES and NO. If left blank NO is used.
647
648EXAMPLE_RECURSIVE = NO
649
650# The IMAGE_PATH tag can be used to specify one or more files or
651# directories that contain image that are included in the documentation (see
652# the \image command).
653
654IMAGE_PATH =
655
656# The INPUT_FILTER tag can be used to specify a program that doxygen should
657# invoke to filter for each input file. Doxygen will invoke the filter program
658# by executing (via popen()) the command <filter> <input-file>, where <filter>
659# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
660# input file. Doxygen will then use the output that the filter program writes
661# to standard output.
662# If FILTER_PATTERNS is specified, this tag will be
663# ignored.
664
665INPUT_FILTER =
666
667# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
668# basis.
669# Doxygen will compare the file name with each pattern and apply the
670# filter if there is a match.
671# The filters are a list of the form:
672# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
673# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
674# is applied to all files.
675
676FILTER_PATTERNS =
677
678# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
679# INPUT_FILTER) will be used to filter the input files when producing source
680# files to browse (i.e. when SOURCE_BROWSER is set to YES).
681
682FILTER_SOURCE_FILES = NO
683
684#---------------------------------------------------------------------------
685# configuration options related to source browsing
686#---------------------------------------------------------------------------
687
688# If the SOURCE_BROWSER tag is set to YES then a list of source files will
689# be generated. Documented entities will be cross-referenced with these sources.
690# Note: To get rid of all source code in the generated output, make sure also
691# VERBATIM_HEADERS is set to NO.
692
693SOURCE_BROWSER = NO
694
695# Setting the INLINE_SOURCES tag to YES will include the body
696# of functions and classes directly in the documentation.
697
698INLINE_SOURCES = NO
699
700# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
701# doxygen to hide any special comment blocks from generated source code
702# fragments. Normal C and C++ comments will always remain visible.
703
704STRIP_CODE_COMMENTS = YES
705
706# If the REFERENCED_BY_RELATION tag is set to YES
707# then for each documented function all documented
708# functions referencing it will be listed.
709
710REFERENCED_BY_RELATION = NO
711
712# If the REFERENCES_RELATION tag is set to YES
713# then for each documented function all documented entities
714# called/used by that function will be listed.
715
716REFERENCES_RELATION = NO
717
718# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
719# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
720# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
721# link to the source code.
722# Otherwise they will link to the documentation.
723
724REFERENCES_LINK_SOURCE = YES
725
726# If the USE_HTAGS tag is set to YES then the references to source code
727# will point to the HTML generated by the htags(1) tool instead of doxygen
728# built-in source browser. The htags tool is part of GNU's global source
729# tagging system (see http://www.gnu.org/software/global/global.html). You
730# will need version 4.8.6 or higher.
731
732USE_HTAGS = NO
733
734# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
735# will generate a verbatim copy of the header file for each class for
736# which an include is specified. Set to NO to disable this.
737
738VERBATIM_HEADERS = YES
739
740#---------------------------------------------------------------------------
741# configuration options related to the alphabetical class index
742#---------------------------------------------------------------------------
743
744# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
745# of all compounds will be generated. Enable this if the project
746# contains a lot of classes, structs, unions or interfaces.
747
748ALPHABETICAL_INDEX = NO
749
750# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
751# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
752# in which this list will be split (can be a number in the range [1..20])
753
754COLS_IN_ALPHA_INDEX = 5
755
756# In case all classes in a project start with a common prefix, all
757# classes will be put under the same header in the alphabetical index.
758# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
759# should be ignored while generating the index headers.
760
761IGNORE_PREFIX =
762
763#---------------------------------------------------------------------------
764# configuration options related to the HTML output
765#---------------------------------------------------------------------------
766
767# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
768# generate HTML output.
769
770GENERATE_HTML = YES
771
772# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
773# If a relative path is entered the value of OUTPUT_DIRECTORY will be
774# put in front of it. If left blank `html' will be used as the default path.
775
776HTML_OUTPUT = html
777
778# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
779# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
780# doxygen will generate files with .html extension.
781
782HTML_FILE_EXTENSION = .html
783
784# The HTML_HEADER tag can be used to specify a personal HTML header for
785# each generated HTML page. If it is left blank doxygen will generate a
786# standard header.
787
788HTML_HEADER = ../docs/tiheader.htm
789
790# The HTML_FOOTER tag can be used to specify a personal HTML footer for
791# each generated HTML page. If it is left blank doxygen will generate a
792# standard footer.
793
794HTML_FOOTER = ../docs/tifooter.htm
795
796# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
797# style sheet that is used by each HTML page. It can be used to
798# fine-tune the look of the HTML output. If the tag is left blank doxygen
799# will generate a default style sheet. Note that doxygen will try to copy
800# the style sheet file to the HTML output directory, so don't put your own
801# stylesheet in the HTML output directory as well, or it will be erased!
802
803HTML_STYLESHEET =
804
805# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
806# page will contain the date and time when the page was generated. Setting
807# this to NO can help when comparing the output of multiple runs.
808
809HTML_TIMESTAMP = YES
810
811# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
812# files or namespaces will be aligned in HTML using tables. If set to
813# NO a bullet list will be used.
814
815HTML_ALIGN_MEMBERS = YES
816
817# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
818# documentation will contain sections that can be hidden and shown after the
819# page has loaded. For this to work a browser that supports
820# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
821# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
822
823HTML_DYNAMIC_SECTIONS = NO
824
825# If the GENERATE_DOCSET tag is set to YES, additional index files
826# will be generated that can be used as input for Apple's Xcode 3
827# integrated development environment, introduced with OSX 10.5 (Leopard).
828# To create a documentation set, doxygen will generate a Makefile in the
829# HTML output directory. Running make will produce the docset in that
830# directory and running "make install" will install the docset in
831# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
832# it at startup.
833# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
834
835GENERATE_DOCSET = NO
836
837# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
838# feed. A documentation feed provides an umbrella under which multiple
839# documentation sets from a single provider (such as a company or product suite)
840# can be grouped.
841
842DOCSET_FEEDNAME = "Doxygen generated docs"
843
844# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
845# should uniquely identify the documentation set bundle. This should be a
846# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
847# will append .docset to the name.
848
849DOCSET_BUNDLE_ID = org.doxygen.Project
850
851# If the GENERATE_HTMLHELP tag is set to YES, additional index files
852# will be generated that can be used as input for tools like the
853# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
854# of the generated HTML documentation.
855
856GENERATE_HTMLHELP = NO
857
858# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
859# be used to specify the file name of the resulting .chm file. You
860# can add a path in front of the file if the result should not be
861# written to the html output directory.
862
863CHM_FILE =
864
865# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
866# be used to specify the location (absolute path including file name) of
867# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
868# the HTML help compiler on the generated index.hhp.
869
870HHC_LOCATION =
871
872# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
873# controls if a separate .chi index file is generated (YES) or that
874# it should be included in the master .chm file (NO).
875
876GENERATE_CHI = NO
877
878# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
879# is used to encode HtmlHelp index (hhk), content (hhc) and project file
880# content.
881
882CHM_INDEX_ENCODING =
883
884# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
885# controls whether a binary table of contents is generated (YES) or a
886# normal table of contents (NO) in the .chm file.
887
888BINARY_TOC = NO
889
890# The TOC_EXPAND flag can be set to YES to add extra items for group members
891# to the contents of the HTML help documentation and to the tree view.
892
893TOC_EXPAND = NO
894
895# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
896# are set, an additional index file will be generated that can be used as input for
897# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
898# HTML documentation.
899
900GENERATE_QHP = NO
901
902# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
903# be used to specify the file name of the resulting .qch file.
904# The path specified is relative to the HTML output folder.
905
906QCH_FILE =
907
908# The QHP_NAMESPACE tag specifies the namespace to use when generating
909# Qt Help Project output. For more information please see
910# http://doc.trolltech.com/qthelpproject.html#namespace
911
912QHP_NAMESPACE = org.doxygen.Project
913
914# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
915# Qt Help Project output. For more information please see
916# http://doc.trolltech.com/qthelpproject.html#virtual-folders
917
918QHP_VIRTUAL_FOLDER = doc
919
920# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
921# For more information please see
922# http://doc.trolltech.com/qthelpproject.html#custom-filters
923
924QHP_CUST_FILTER_NAME =
925
926# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
927# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
928
929QHP_CUST_FILTER_ATTRS =
930
931# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
932# filter section matches.
933# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
934
935QHP_SECT_FILTER_ATTRS =
936
937# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
938# be used to specify the location of Qt's qhelpgenerator.
939# If non-empty doxygen will try to run qhelpgenerator on the generated
940# .qhp file.
941
942QHG_LOCATION =
943
944# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
945# will be generated, which together with the HTML files, form an Eclipse help
946# plugin. To install this plugin and make it available under the help contents
947# menu in Eclipse, the contents of the directory containing the HTML and XML
948# files needs to be copied into the plugins directory of eclipse. The name of
949# the directory within the plugins directory should be the same as
950# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before the help appears.
951
952GENERATE_ECLIPSEHELP = NO
953
954# A unique identifier for the eclipse help plugin. When installing the plugin
955# the directory name containing the HTML and XML files should also have
956# this name.
957
958ECLIPSE_DOC_ID = org.doxygen.Project
959
960# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
961# top of each HTML page. The value NO (the default) enables the index and
962# the value YES disables it.
963
964DISABLE_INDEX = NO
965
966# This tag can be used to set the number of enum values (range [1..20])
967# that doxygen will group on one line in the generated HTML documentation.
968
969ENUM_VALUES_PER_LINE = 4
970
971# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
972# structure should be generated to display hierarchical information.
973# If the tag value is set to YES, a side panel will be generated
974# containing a tree-like index structure (just like the one that
975# is generated for HTML Help). For this to work a browser that supports
976# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
977# Windows users are probably better off using the HTML help feature.
978
979GENERATE_TREEVIEW = NO
980
981# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
982# and Class Hierarchy pages using a tree view instead of an ordered list.
983
984USE_INLINE_TREES = NO
985
986# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
987# used to set the initial width (in pixels) of the frame in which the tree
988# is shown.
989
990TREEVIEW_WIDTH = 250
991
992# Use this tag to change the font size of Latex formulas included
993# as images in the HTML documentation. The default is 10. Note that
994# when you change the font size after a successful doxygen run you need
995# to manually remove any form_*.png images from the HTML output directory
996# to force them to be regenerated.
997
998FORMULA_FONTSIZE = 10
999
1000# When the SEARCHENGINE tag is enabled doxygen will generate a search box for the HTML output. The underlying search engine uses javascript
1001# and DHTML and should work on any modern browser. Note that when using HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) there is already a search function so this one should
1002# typically be disabled. For large projects the javascript based search engine
1003# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
1004
1005SEARCHENGINE = YES
1006
1007# When the SERVER_BASED_SEARCH tag is enabled the search engine will be implemented using a PHP enabled web server instead of at the web client using Javascript. Doxygen will generate the search PHP script and index
1008# file to put on the web server. The advantage of the server based approach is that it scales better to large projects and allows full text search. The disadvances is that it is more difficult to setup
1009# and does not have live searching capabilities.
1010
1011SERVER_BASED_SEARCH = NO
1012
1013#---------------------------------------------------------------------------
1014# configuration options related to the LaTeX output
1015#---------------------------------------------------------------------------
1016
1017# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
1018# generate Latex output.
1019
1020GENERATE_LATEX = YES
1021
1022# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
1023# If a relative path is entered the value of OUTPUT_DIRECTORY will be
1024# put in front of it. If left blank `latex' will be used as the default path.
1025
1026LATEX_OUTPUT = latex
1027
1028# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
1029# invoked. If left blank `latex' will be used as the default command name.
1030# Note that when enabling USE_PDFLATEX this option is only used for
1031# generating bitmaps for formulas in the HTML output, but not in the
1032# Makefile that is written to the output directory.
1033
1034LATEX_CMD_NAME = latex
1035
1036# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
1037# generate index for LaTeX. If left blank `makeindex' will be used as the
1038# default command name.
1039
1040MAKEINDEX_CMD_NAME = makeindex
1041
1042# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
1043# LaTeX documents. This may be useful for small projects and may help to
1044# save some trees in general.
1045
1046COMPACT_LATEX = NO
1047
1048# The PAPER_TYPE tag can be used to set the paper type that is used
1049# by the printer. Possible values are: a4, a4wide, letter, legal and
1050# executive. If left blank a4wide will be used.
1051
1052PAPER_TYPE = a4wide
1053
1054# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
1055# packages that should be included in the LaTeX output.
1056
1057EXTRA_PACKAGES =
1058
1059# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
1060# the generated latex document. The header should contain everything until
1061# the first chapter. If it is left blank doxygen will generate a
1062# standard header. Notice: only use this tag if you know what you are doing!
1063
1064LATEX_HEADER =
1065
1066# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
1067# is prepared for conversion to pdf (using ps2pdf). The pdf file will
1068# contain links (just like the HTML output) instead of page references
1069# This makes the output suitable for online browsing using a pdf viewer.
1070
1071PDF_HYPERLINKS = YES
1072
1073# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
1074# plain latex in the generated Makefile. Set this option to YES to get a
1075# higher quality PDF documentation.
1076
1077USE_PDFLATEX = YES
1078
1079# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
1080# command to the generated LaTeX files. This will instruct LaTeX to keep
1081# running if errors occur, instead of asking the user for help.
1082# This option is also used when generating formulas in HTML.
1083
1084LATEX_BATCHMODE = NO
1085
1086# If LATEX_HIDE_INDICES is set to YES then doxygen will not
1087# include the index chapters (such as File Index, Compound Index, etc.)
1088# in the output.
1089
1090LATEX_HIDE_INDICES = NO
1091
1092# If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER.
1093
1094LATEX_SOURCE_CODE = NO
1095
1096#---------------------------------------------------------------------------
1097# configuration options related to the RTF output
1098#---------------------------------------------------------------------------
1099
1100# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
1101# The RTF output is optimized for Word 97 and may not look very pretty with
1102# other RTF readers or editors.
1103
1104GENERATE_RTF = NO
1105
1106# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
1107# If a relative path is entered the value of OUTPUT_DIRECTORY will be
1108# put in front of it. If left blank `rtf' will be used as the default path.
1109
1110RTF_OUTPUT = rtf
1111
1112# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
1113# RTF documents. This may be useful for small projects and may help to
1114# save some trees in general.
1115
1116COMPACT_RTF = NO
1117
1118# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
1119# will contain hyperlink fields. The RTF file will
1120# contain links (just like the HTML output) instead of page references.
1121# This makes the output suitable for online browsing using WORD or other
1122# programs which support those fields.
1123# Note: wordpad (write) and others do not support links.
1124
1125RTF_HYPERLINKS = NO
1126
1127# Load stylesheet definitions from file. Syntax is similar to doxygen's
1128# config file, i.e. a series of assignments. You only have to provide
1129# replacements, missing definitions are set to their default value.
1130
1131RTF_STYLESHEET_FILE =
1132
1133# Set optional variables used in the generation of an rtf document.
1134# Syntax is similar to doxygen's config file.
1135
1136RTF_EXTENSIONS_FILE =
1137
1138#---------------------------------------------------------------------------
1139# configuration options related to the man page output
1140#---------------------------------------------------------------------------
1141
1142# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
1143# generate man pages
1144
1145GENERATE_MAN = NO
1146
1147# The MAN_OUTPUT tag is used to specify where the man pages will be put.
1148# If a relative path is entered the value of OUTPUT_DIRECTORY will be
1149# put in front of it. If left blank `man' will be used as the default path.
1150
1151MAN_OUTPUT = man
1152
1153# The MAN_EXTENSION tag determines the extension that is added to
1154# the generated man pages (default is the subroutine's section .3)
1155
1156MAN_EXTENSION = .3
1157
1158# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
1159# then it will generate one additional man file for each entity
1160# documented in the real man page(s). These additional files
1161# only source the real man page, but without them the man command
1162# would be unable to find the correct page. The default is NO.
1163
1164MAN_LINKS = NO
1165
1166#---------------------------------------------------------------------------
1167# configuration options related to the XML output
1168#---------------------------------------------------------------------------
1169
1170# If the GENERATE_XML tag is set to YES Doxygen will
1171# generate an XML file that captures the structure of
1172# the code including all documentation.
1173
1174GENERATE_XML = NO
1175
1176# The XML_OUTPUT tag is used to specify where the XML pages will be put.
1177# If a relative path is entered the value of OUTPUT_DIRECTORY will be
1178# put in front of it. If left blank `xml' will be used as the default path.
1179
1180XML_OUTPUT = xml
1181
1182# The XML_SCHEMA tag can be used to specify an XML schema,
1183# which can be used by a validating XML parser to check the
1184# syntax of the XML files.
1185
1186XML_SCHEMA =
1187
1188# The XML_DTD tag can be used to specify an XML DTD,
1189# which can be used by a validating XML parser to check the
1190# syntax of the XML files.
1191
1192XML_DTD =
1193
1194# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
1195# dump the program listings (including syntax highlighting
1196# and cross-referencing information) to the XML output. Note that
1197# enabling this will significantly increase the size of the XML output.
1198
1199XML_PROGRAMLISTING = YES
1200
1201#---------------------------------------------------------------------------
1202# configuration options for the AutoGen Definitions output
1203#---------------------------------------------------------------------------
1204
1205# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
1206# generate an AutoGen Definitions (see autogen.sf.net) file
1207# that captures the structure of the code including all
1208# documentation. Note that this feature is still experimental
1209# and incomplete at the moment.
1210
1211GENERATE_AUTOGEN_DEF = NO
1212
1213#---------------------------------------------------------------------------
1214# configuration options related to the Perl module output
1215#---------------------------------------------------------------------------
1216
1217# If the GENERATE_PERLMOD tag is set to YES Doxygen will
1218# generate a Perl module file that captures the structure of
1219# the code including all documentation. Note that this
1220# feature is still experimental and incomplete at the
1221# moment.
1222
1223GENERATE_PERLMOD = NO
1224
1225# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
1226# the necessary Makefile rules, Perl scripts and LaTeX code to be able
1227# to generate PDF and DVI output from the Perl module output.
1228
1229PERLMOD_LATEX = NO
1230
1231# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
1232# nicely formatted so it can be parsed by a human reader.
1233# This is useful
1234# if you want to understand what is going on.
1235# On the other hand, if this
1236# tag is set to NO the size of the Perl module output will be much smaller
1237# and Perl will parse it just the same.
1238
1239PERLMOD_PRETTY = YES
1240
1241# The names of the make variables in the generated doxyrules.make file
1242# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
1243# This is useful so different doxyrules.make files included by the same
1244# Makefile don't overwrite each other's variables.
1245
1246PERLMOD_MAKEVAR_PREFIX =
1247
1248#---------------------------------------------------------------------------
1249# Configuration options related to the preprocessor
1250#---------------------------------------------------------------------------
1251
1252# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
1253# evaluate all C-preprocessor directives found in the sources and include
1254# files.
1255
1256ENABLE_PREPROCESSING = YES
1257
1258# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
1259# names in the source code. If set to NO (the default) only conditional
1260# compilation will be performed. Macro expansion can be done in a controlled
1261# way by setting EXPAND_ONLY_PREDEF to YES.
1262
1263MACRO_EXPANSION = NO
1264
1265# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
1266# then the macro expansion is limited to the macros specified with the
1267# PREDEFINED and EXPAND_AS_DEFINED tags.
1268
1269EXPAND_ONLY_PREDEF = NO
1270
1271# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
1272# in the INCLUDE_PATH (see below) will be search if a #include is found.
1273
1274SEARCH_INCLUDES = YES
1275
1276# The INCLUDE_PATH tag can be used to specify one or more directories that
1277# contain include files that are not input files but should be processed by
1278# the preprocessor.
1279
1280INCLUDE_PATH = ..
1281
1282# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
1283# patterns (like *.h and *.hpp) to filter out the header-files in the
1284# directories. If left blank, the patterns specified with FILE_PATTERNS will
1285# be used.
1286
1287INCLUDE_FILE_PATTERNS = *.h
1288
1289# The PREDEFINED tag can be used to specify one or more macro names that
1290# are defined before the preprocessor is started (similar to the -D option of
1291# gcc). The argument of the tag is a list of macros of the form: name
1292# or name=definition (no spaces). If the definition and the = are
1293# omitted =1 is assumed. To prevent a macro definition from being
1294# undefined via #undef or recursively expanded use the := operator
1295# instead of the = operator.
1296
1297PREDEFINED =
1298
1299# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
1300# this tag can be used to specify a list of macro names that should be expanded.
1301# The macro definition that is found in the sources will be used.
1302# Use the PREDEFINED tag if you want to use a different macro definition.
1303
1304EXPAND_AS_DEFINED =
1305
1306# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
1307# doxygen's preprocessor will remove all function-like macros that are alone
1308# on a line, have an all uppercase name, and do not end with a semicolon. Such
1309# function macros are typically used for boiler-plate code, and will confuse
1310# the parser if not removed.
1311
1312SKIP_FUNCTION_MACROS = YES
1313
1314#---------------------------------------------------------------------------
1315# Configuration::additions related to external references
1316#---------------------------------------------------------------------------
1317
1318# The TAGFILES option can be used to specify one or more tagfiles.
1319# Optionally an initial location of the external documentation
1320# can be added for each tagfile. The format of a tag file without
1321# this location is as follows:
1322#
1323# TAGFILES = file1 file2 ...
1324# Adding location for the tag files is done as follows:
1325#
1326# TAGFILES = file1=loc1 "file2 = loc2" ...
1327# where "loc1" and "loc2" can be relative or absolute paths or
1328# URLs. If a location is present for each tag, the installdox tool
1329# does not have to be run to correct the links.
1330# Note that each tag file must have a unique name
1331# (where the name does NOT include the path)
1332# If a tag file is not located in the directory in which doxygen
1333# is run, you must also specify the path to the tagfile here.
1334
1335TAGFILES =
1336
1337# When a file name is specified after GENERATE_TAGFILE, doxygen will create
1338# a tag file that is based on the input files it reads.
1339
1340GENERATE_TAGFILE =
1341
1342# If the ALLEXTERNALS tag is set to YES all external classes will be listed
1343# in the class index. If set to NO only the inherited external classes
1344# will be listed.
1345
1346ALLEXTERNALS = NO
1347
1348# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
1349# in the modules index. If set to NO, only the current project's groups will
1350# be listed.
1351
1352EXTERNAL_GROUPS = YES
1353
1354# The PERL_PATH should be the absolute path and name of the perl script
1355# interpreter (i.e. the result of `which perl').
1356
1357PERL_PATH = /usr/bin/perl
1358
1359#---------------------------------------------------------------------------
1360# Configuration options related to the dot tool
1361#---------------------------------------------------------------------------
1362
1363# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
1364# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
1365# or super classes. Setting the tag to NO turns the diagrams off. Note that
1366# this option is superseded by the HAVE_DOT option below. This is only a
1367# fallback. It is recommended to install and use dot, since it yields more
1368# powerful graphs.
1369
1370CLASS_DIAGRAMS = YES
1371
1372# You can define message sequence charts within doxygen comments using the \msc
1373# command. Doxygen will then run the mscgen tool (see
1374# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
1375# documentation. The MSCGEN_PATH tag allows you to specify the directory where
1376# the mscgen tool resides. If left empty the tool is assumed to be found in the
1377# default search path.
1378
1379MSCGEN_PATH =
1380
1381# If set to YES, the inheritance and collaboration graphs will hide
1382# inheritance and usage relations if the target is undocumented
1383# or is not a class.
1384
1385HIDE_UNDOC_RELATIONS = YES
1386
1387# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
1388# available from the path. This tool is part of Graphviz, a graph visualization
1389# toolkit from AT&T and Lucent Bell Labs. The other options in this section
1390# have no effect if this option is set to NO (the default)
1391
1392HAVE_DOT = NO
1393
1394# By default doxygen will write a font called FreeSans.ttf to the output
1395# directory and reference it in all dot files that doxygen generates. This
1396# font does not include all possible unicode characters however, so when you need
1397# these (or just want a differently looking font) you can specify the font name
1398# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
1399# which can be done by putting it in a standard location or by setting the
1400# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
1401# containing the font.
1402
1403DOT_FONTNAME = FreeSans
1404
1405# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
1406# The default size is 10pt.
1407
1408DOT_FONTSIZE = 10
1409
1410# By default doxygen will tell dot to use the output directory to look for the
1411# FreeSans.ttf font (which doxygen will put there itself). If you specify a
1412# different font using DOT_FONTNAME you can set the path where dot
1413# can find it using this tag.
1414
1415DOT_FONTPATH =
1416
1417# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
1418# will generate a graph for each documented class showing the direct and
1419# indirect inheritance relations. Setting this tag to YES will force the
1420# the CLASS_DIAGRAMS tag to NO.
1421
1422CLASS_GRAPH = YES
1423
1424# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
1425# will generate a graph for each documented class showing the direct and
1426# indirect implementation dependencies (inheritance, containment, and
1427# class references variables) of the class with other documented classes.
1428
1429COLLABORATION_GRAPH = YES
1430
1431# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
1432# will generate a graph for groups, showing the direct groups dependencies
1433
1434GROUP_GRAPHS = YES
1435
1436# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
1437# collaboration diagrams in a style similar to the OMG's Unified Modeling
1438# Language.
1439
1440UML_LOOK = NO
1441
1442# If set to YES, the inheritance and collaboration graphs will show the
1443# relations between templates and their instances.
1444
1445TEMPLATE_RELATIONS = NO
1446
1447# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
1448# tags are set to YES then doxygen will generate a graph for each documented
1449# file showing the direct and indirect include dependencies of the file with
1450# other documented files.
1451
1452INCLUDE_GRAPH = YES
1453
1454# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
1455# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
1456# documented header file showing the documented files that directly or
1457# indirectly include this file.
1458
1459INCLUDED_BY_GRAPH = YES
1460
1461# If the CALL_GRAPH and HAVE_DOT options are set to YES then
1462# doxygen will generate a call dependency graph for every global function
1463# or class method. Note that enabling this option will significantly increase
1464# the time of a run. So in most cases it will be better to enable call graphs
1465# for selected functions only using the \callgraph command.
1466
1467CALL_GRAPH = NO
1468
1469# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
1470# doxygen will generate a caller dependency graph for every global function
1471# or class method. Note that enabling this option will significantly increase
1472# the time of a run. So in most cases it will be better to enable caller
1473# graphs for selected functions only using the \callergraph command.
1474
1475CALLER_GRAPH = NO
1476
1477# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
1478# will graphical hierarchy of all classes instead of a textual one.
1479
1480GRAPHICAL_HIERARCHY = YES
1481
1482# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
1483# then doxygen will show the dependencies a directory has on other directories
1484# in a graphical way. The dependency relations are determined by the #include
1485# relations between the files in the directories.
1486
1487DIRECTORY_GRAPH = YES
1488
1489# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
1490# generated by dot. Possible values are png, jpg, or gif
1491# If left blank png will be used.
1492
1493DOT_IMAGE_FORMAT = png
1494
1495# The tag DOT_PATH can be used to specify the path where the dot tool can be
1496# found. If left blank, it is assumed the dot tool can be found in the path.
1497
1498DOT_PATH =
1499
1500# The DOTFILE_DIRS tag can be used to specify one or more directories that
1501# contain dot files that are included in the documentation (see the
1502# \dotfile command).
1503
1504DOTFILE_DIRS =
1505
1506# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
1507# nodes that will be shown in the graph. If the number of nodes in a graph
1508# becomes larger than this value, doxygen will truncate the graph, which is
1509# visualized by representing a node as a red box. Note that doxygen if the
1510# number of direct children of the root node in a graph is already larger than
1511# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
1512# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
1513
1514DOT_GRAPH_MAX_NODES = 50
1515
1516# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
1517# graphs generated by dot. A depth value of 3 means that only nodes reachable
1518# from the root by following a path via at most 3 edges will be shown. Nodes
1519# that lay further from the root node will be omitted. Note that setting this
1520# option to 1 or 2 may greatly reduce the computation time needed for large
1521# code bases. Also note that the size of a graph can be further restricted by
1522# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
1523
1524MAX_DOT_GRAPH_DEPTH = 0
1525
1526# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
1527# background. This is disabled by default, because dot on Windows does not
1528# seem to support this out of the box. Warning: Depending on the platform used,
1529# enabling this option may lead to badly anti-aliased labels on the edges of
1530# a graph (i.e. they become hard to read).
1531
1532DOT_TRANSPARENT = NO
1533
1534# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
1535# files in one run (i.e. multiple -o and -T options on the command line). This
1536# makes dot run faster, but since only newer versions of dot (>1.8.10)
1537# support this, this feature is disabled by default.
1538
1539DOT_MULTI_TARGETS = YES
1540
1541# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
1542# generate a legend page explaining the meaning of the various boxes and
1543# arrows in the dot generated graphs.
1544
1545GENERATE_LEGEND = YES
1546
1547# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
1548# remove the intermediate dot files that are used to generate
1549# the various graphs.
1550
1551DOT_CLEANUP = YES
1552#---------------------------------------------------------------------------
1553# Configuration::additions related to the search engine
1554#---------------------------------------------------------------------------
1555SEARCHENGINE = NO
diff --git a/ti/runtime/netapi/demo/build/Makefile b/ti/runtime/netapi/demo/build/Makefile
new file mode 100755
index 0000000..c85ee5b
--- /dev/null
+++ b/ti/runtime/netapi/demo/build/Makefile
@@ -0,0 +1,127 @@
1#
2empty =
3space =$(empty) $(empty)
4
5export ARMV7OBJDIR ?= ./obj
6export ARMV7BINDIR ?= ./bin
7export ARMV7LIBDIR ?= ./lib
8export ARMV7SALIBDIR ?= ./lib
9
10DPI_DEMO_SRC_DIR ?= $(PWD)
11# INCLUDE Directories
12SA_INSTALL_PATH ?= $(PDK_INSTALL_PATH)/ti/drv/sa
13QMSS_INC_DIR ?= $(PDK_INSTALL_PATH)/ti/drv/qmss
14CPPI_INC_DIR ?= $(PDK_INSTALL_PATH)/ti/drv/cppi
15RM_INC_DIR ?= $(PDK_INSTALL_PATH)/ti/drv/rm
16NETAPI_SRC_DIR ?= $(TRANS_SDK_INSTALL_PATH)/ti/runtime/netapi
17NETAPI_INC_DIR ?= $(TRANS_SDK_INSTALL_PATH)
18HPLIB_INC_DIR ?= $(HPLIB_INSTALL_PATH)
19NWAL_INSTALL_PATH ?= $(PDK_INSTALL_PATH)/ti/drv/nwal
20PKTLIB_INSTALL_PATH ?= $(PDK_INSTALL_PATH)/ti/runtime/pktlib
21
22
23ifndef NAVL_INSTALL_PATH
24 $(error NAVL_INSTALL_PATH is undefined)
25else
26NAVL_INSTALL_PATH ?= /home/a0868410/git
27NAVL_LIB_DIR ?= $(NAVL_INSTALL_PATH)/navl/lib
28NAVL_INC_DIR ?= $(NAVL_INSTALL_PATH)
29endif
30
31#TRIE_OBJS=$(ARMV7OBJDIR)/netapi/test/trie.o
32
33NT_RM_OBJS = $(ARMV7OBJDIR)/netapi/utils/sockutils.o $(ARMV7OBJDIR)/netapi/utils/netapi_util_rm.o
34
35DPI_DEMO_OBJS= $(ARMV7OBJDIR)/netapi/demo/src/transport_dpi_demo.o $(ARMV7OBJDIR)/netapi/demo/src/navl_wrapper.o $(ARMV7OBJDIR)/netapi/demo/src/navl_external_posix.o
36
37# Support Libraries used by dpi-demo
38CSL_DEVICE ?= -DDEVICE_K2E -DNSS_GEN2
39QMSS_LIB = -lqmss
40CPPI_LIB = -lcppi
41PA_LIB = -lpa2
42NWAL_LIB = -lnwalsa_k2e
43SA_LIB = -lsa
44RM_LIB = -lrm
45PKTLIB_LIB = -lpktlib
46NETAPI_LIB =-lnetapi_k2e
47HP_LIB = -lhplib_k2e
48NAVL_LIB = -lnavl
49
50local_base=/usr/local
51LDFLAGS = -L. -L$(local_base)/lib
52
53LIBS = -static $(QMSS_LIB) $(CPPI_LIB) $(PA_LIB) $(PKTLIB_LIB) $(NETAPI_LIB) $(HP_LIB) $(SA_LIB) $(NWAL_LIB) $(RM_LIB) -Wl,-Bdynamic
54
55LIBS += $(NAVL_LIB) -lstdc++ -lgcc_s
56
57SYSTYPE:=$(shell uname)
58ifeq ($(SYSTYPE), Linux)
59LIBS += -ldl -lm
60else
61LIBS += -lexecinfo
62endif
63
64ifdef CROSS_TOOL_INSTALL_PATH
65## Support backwards compatibility with KeyStone1 approach
66 CC = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)gcc
67 AC = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)as
68 AR = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)ar
69 LD = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)gcc
70endif
71
72INCLUDE = -I. -I$(local_base)/include -I../ -I$(HPLIB_INC_DIR) -I$(NETAPI_INC_DIR) -I$(PDK_INSTALL_PATH) -I$(NWAL_INSTALL_PATH) -I$(PKTLIB_INSTALL_PATH) -I$(SA_INSTALL_PATH) -I$(QMSS_INC_DIR) -I$(CPPI_INC_DIR) -I$(RM_INC_DIR) -I$(NAVL_INC_DIR) $(CSL_DEVICE)
73
74CFLAGS += $(DEBUG_FLAG) -D__ARMv7 -D_VIRTUAL_ADDR_SUPPORT -D__LINUX_USER_SPACE -D_LITTLE_ENDIAN=1 -DNWAL_ENABLE_SA -DMAKEFILE_BUILD -D _GNU_SOURCE
75# Linker options
76INTERNALLINKDEFS = -Wl,--start-group $(LIBS) -Wl,--end-group -lrt -pthread -L$(ARMV7LIBDIR) -L$(ARMV7SALIBDIR) -L$(NAVL_LIB_DIR)
77
78EXE_NAME=transport_dpi_demo
79BIN_DIR = $(ARMV7BINDIR)/netapi/demo
80all: demo install
81
82demo: $(ARMV7BINDIR)/netapi/demo/.created $(BIN_DIR)/$(EXE_NAME)
83
84clean:
85 rm -f $(ARMV7OBJDIR)/netapi/demo/src/*.o
86 rm -f $(ARMV7BINDIR)/netapi/demo/*
87
88
89#$(ARMV7OBJDIR)/netapi/demo/src/%.o: %.c $(NETAPI_SRC_DIR)/demo/src/%.c $(ARMV7OBJDIR)/netapi/demo/src/.created
90$(ARMV7OBJDIR)/netapi/demo/src/%.o: $(NETAPI_SRC_DIR)/demo/src/%.c $(ARMV7OBJDIR)/netapi/demo/src/.created
91 @echo compiling $<
92 $(CC) -c $(CFLAGS) $(INCLUDE) $< -o $@
93
94$(ARMV7OBJDIR)/netapi/demo/src/.created:
95 @mkdir -p $(ARMV7OBJDIR)/netapi/demo/src/
96
97$(ARMV7BINDIR)/netapi/demo/.created:
98 @mkdir -p $(ARMV7BINDIR)/netapi/demo/
99
100$(ARMV7BINDIR)/netapi/demo/$(EXE_NAME): $(NT_RM_OBJS) $(DPI_DEMO_OBJS)
101 $(CC) $(LDFLAGS) $(DPI_DEMO_OBJS) $(NT_RM_OBJS) $(INTERNALLINKDEFS) $(INCLUDE) -o $(BIN_DIR)/$(EXE_NAME)
102
103
104$(ARMV7OBJDIR)/netapi/utils/%.o: $(NETAPI_SRC_DIR)/utils/%.c $(ARMV7OBJDIR)/netapi/utils/.created
105 @echo compiling $<
106 $(CC) -c $(CFLAGS) $(INCLUDE) $< -o $@
107
108$(ARMV7OBJDIR)/netapi/utils/.created:
109 @mkdir -p $(ARMV7OBJDIR)/netapi/utils/
110
111install:
112 install -d $(INSTALL_BIN_BASE_DIR)
113 install -c -m 755 $(BIN_DIR)/$(EXE_NAME) $(INSTALL_BIN_BASE_DIR)/$(EXE_NAME)
114 install -d $(SYSCONFDIR)/transportnetlib
115 install -c -m 755 demo/demo_setup_files/transport_dpi_demo_setup.sh $(SYSCONFDIR)/transportnetlib
116 install -c -m 755 demo/demo_setup_files/index.html $(SYSCONFDIR)/transportnetlib
117 install -c -m 755 demo/demo_setup_files/dpicgi1.sh $(SYSCONFDIR)/transportnetlib
118 install -c -m 755 demo/demo_setup_files/dpicgi2.sh $(SYSCONFDIR)/transportnetlib
119 install -c -m 755 demo/demo_setup_files/dpicgi3.sh $(SYSCONFDIR)/transportnetlib
120 install -c -m 755 demo/demo_setup_files/dpicgi4.sh $(SYSCONFDIR)/transportnetlib
121 install -c -m 755 demo/demo_setup_files/dpicgi5.sh $(SYSCONFDIR)/transportnetlib
122 install -c demo/demo_setup_files/stats1.awk $(SYSCONFDIR)/transportnetlib
123 install -c demo/demo_setup_files/stats2.awk $(SYSCONFDIR)/transportnetlib
124 install -c demo/demo_setup_files/stats3.awk $(SYSCONFDIR)/transportnetlib
125 install -c demo/demo_setup_files/stats4.awk $(SYSCONFDIR)/transportnetlib
126 install -c demo/demo_setup_files/tilogo.gif $(SYSCONFDIR)/transportnetlib
127 install -c demo/demo_setup_files/titagline.gif $(SYSCONFDIR)/transportnetlib
diff --git a/ti/runtime/netapi/demo/demo_setup_files/dpicgi1.sh b/ti/runtime/netapi/demo/demo_setup_files/dpicgi1.sh
new file mode 100755
index 0000000..e817deb
--- /dev/null
+++ b/ti/runtime/netapi/demo/demo_setup_files/dpicgi1.sh
@@ -0,0 +1,16 @@
1#!/bin/bash
2#dump mac addresses from switch
3echo Content-type: text/html
4echo
5echo
6echo "<HTML>"
7echo "<HEAD>"
8echo "</HEAD>"
9echo "<BODY>"
10echo "<H2> MAC Addresses From Switch ALE </H2>"
11echo "<PRE>"
12cat /sys/devices/soc.0/24000000.netcp/ale_table | grep "touched" | grep "addr" | cut -d ' ' -f 10-
13echo "</PRE>"
14echo "<A href=\"\index.html\"> <p><u>RETURN</u></p> </A>"
15echo "</BODY>"
16echo "</HTML>" \ No newline at end of file
diff --git a/ti/runtime/netapi/demo/demo_setup_files/dpicgi2.sh b/ti/runtime/netapi/demo/demo_setup_files/dpicgi2.sh
new file mode 100755
index 0000000..a749a35
--- /dev/null
+++ b/ti/runtime/netapi/demo/demo_setup_files/dpicgi2.sh
@@ -0,0 +1,7 @@
1#!/bin/bash
2echo Content-type: text/html
3echo
4echo
5#dump proto seen stat
6#awk -f ../stats1.awk ../stats2.txt
7/usr/bin/transport_dpi_demo stats | awk -f ../stats1.awk
diff --git a/ti/runtime/netapi/demo/demo_setup_files/dpicgi3.sh b/ti/runtime/netapi/demo/demo_setup_files/dpicgi3.sh
new file mode 100755
index 0000000..2df8654
--- /dev/null
+++ b/ti/runtime/netapi/demo/demo_setup_files/dpicgi3.sh
@@ -0,0 +1,7 @@
1#!/bin/bash
2echo Content-type: text/html
3echo
4echo
5#dump proto cycles stats
6#awk -f ../stats2.awk ../stats1.txt
7/usr/bin/transport_dpi_demo stats | awk -f ../stats2.awk
diff --git a/ti/runtime/netapi/demo/demo_setup_files/dpicgi4.sh b/ti/runtime/netapi/demo/demo_setup_files/dpicgi4.sh
new file mode 100755
index 0000000..5e487f9
--- /dev/null
+++ b/ti/runtime/netapi/demo/demo_setup_files/dpicgi4.sh
@@ -0,0 +1,6 @@
1#!/bin/bash
2echo Content-type: text/html
3echo
4echo
5#dump mem stat
6/usr/bin/transport_dpi_demo stats | awk -f ../stats3.awk
diff --git a/ti/runtime/netapi/demo/demo_setup_files/dpicgi5.sh b/ti/runtime/netapi/demo/demo_setup_files/dpicgi5.sh
new file mode 100755
index 0000000..e98940f
--- /dev/null
+++ b/ti/runtime/netapi/demo/demo_setup_files/dpicgi5.sh
@@ -0,0 +1,6 @@
1#!/bin/bash
2echo Content-type: text/html
3echo
4echo
5#dump bridge stats
6/usr/bin/transport_dpi_demo stats | awk -f ../stats4.awk
diff --git a/ti/runtime/netapi/demo/demo_setup_files/index.html b/ti/runtime/netapi/demo/demo_setup_files/index.html
new file mode 100755
index 0000000..c228083
--- /dev/null
+++ b/ti/runtime/netapi/demo/demo_setup_files/index.html
@@ -0,0 +1,26 @@
1<html>
2<script type="text/javascript">
3function hello(msg) {
4 var msg= "this is the net_test_dpi home page";
5 document.open();
6 document.write(msg);
7 document.writeln("<A href=\"/index.html\"> <p><u>RETURN</u></p> </A>");
8 document.close();
9}
10</script>
11<head><title> NET_TEST_DPI </title></head>
12<body >
13<img src="tilogo.gif">
14<text> <p> Hi there. Welcome to the <b>Texas Instruments DPI</b> demo </p>
15<p>
16featuring <b> Procera Networks Deep Packet Inspection Library </b> and <b> Texas Instruments TransportNetLib </b>
17</text>
18<A href="cgi-bin/dpicgi1.sh"> <p>List of Mac Addresses</p> </A>
19<A href="cgi-bin/dpicgi5.sh"> <p>Packet Forwarding Stats</p> </A>
20<A href="cgi-bin/dpicgi2.sh"> <p>Protocols Seen</p> </A>
21<A href="cgi-bin/dpicgi3.sh"> <p>Cycles by Protocol</p> </A>
22<A href="cgi-bin/dpicgi4.sh"> <p>Memory Usage</p> </A>
23<img src="titagline.gif">
24</body>
25</html>
26
diff --git a/ti/runtime/netapi/demo/demo_setup_files/stats1.awk b/ti/runtime/netapi/demo/demo_setup_files/stats1.awk
new file mode 100644
index 0000000..e21232f
--- /dev/null
+++ b/ti/runtime/netapi/demo/demo_setup_files/stats1.awk
@@ -0,0 +1,54 @@
1#--------------------------------------
2# awk script to process stats
3# output from dpidemo and build
4# web page
5# stats1-> dump navl proto stats (part1)
6#_____________________________________
7
8
9BEGIN { state=0;
10 thread=1;
11 printf("<HTML>\n");
12 printf("</HEAD>\n");
13 printf("<BODY>\n");
14 printf("<H2> DPI Protocol Statistics </H2>\n");
15
16 }
17
18$0 ~ "NAVL DPI stats" {
19 if (state==0)
20 {
21 state=1;
22 printf("<p><b> DPI Thread %d: </b> </p>\n", thread);
23 printf("<table>\n");
24 printf("<tr>\n");
25# printf("<th> colspan="6" <b>Results</b> </th> </tr> \n");
26 }
27}
28 // {
29 if ((state==1)&&(NF>=8))
30 {
31 printf("<tr> ");
32 for(i=1;i<=6;i++) printf("<td> <b> %s </b> </td> ",$i);
33 printf("</tr> \n");
34 }
35 else if ((state==2) && (NF>=6))
36 {
37 printf("<tr> ");
38 for(i=1;i<=6;i++) if (i==1) printf("<td> <b>%s</b> </td> ", $i); else printf("<td> %s </td> ", $i);
39 printf("</tr> \n");
40 }
41}
42/--------/ { if (state==1) state=2}
43/packets captured/ {if (state==2) {state=0; thread+=1; printf("</table>\n"); printf("%s\n\n",$0);}}
44
45
46
47END {
48 printf("</PRE>\n");
49 printf("<A href=\"\\index.html\"> <p><u> RETURN </u> </p> </A>\n");
50 printf("</BODY>\n");
51 printf("</HTML>\n");
52
53
54}
diff --git a/ti/runtime/netapi/demo/demo_setup_files/stats2.awk b/ti/runtime/netapi/demo/demo_setup_files/stats2.awk
new file mode 100644
index 0000000..9c9266b
--- /dev/null
+++ b/ti/runtime/netapi/demo/demo_setup_files/stats2.awk
@@ -0,0 +1,56 @@
1#--------------------------------------
2# awk script to process stats
3# output from dpidemo and build
4# web page
5# stats2-> dump navl proto stats (part2)
6#_____________________________________
7
8
9BEGIN { state=0;
10 thread=1;
11 printf("<HTML>\n");
12 printf("</HEAD>\n");
13 printf("<BODY>\n");
14 printf("<H2> DPI Cycle Statistics by Protocol </H2>\n");
15
16 }
17
18$0 ~ "NAVL DPI stats" {
19 if (state==0)
20 {
21 state=1;
22 printf("<p><b> DPI Thread %d: </b> </p>\n", thread);
23 printf("<table>\n");
24 printf("<tr>\n");
25# printf("<th> colspan="6" <b>Results</b> </th> </tr> \n");
26 }
27}
28 // {
29 if ((state==1)&&(NF>=8))
30 {
31 printf("<tr> ");
32 printf("<td> <b> %s </b> </td> ",$1);
33 for(i=7;i<=19;i++) printf("<td> <b> %s </b> </td> ",$i);
34 printf("</tr> \n");
35 }
36 else if ((state==2) && (NF>=6))
37 {
38 printf("<tr> ");
39 printf("<td> <b> %s </b> </td> ",$1);
40 for(i=7;i<=19;i++) printf("<td> %s </td> ", $i);
41 printf("</tr> \n");
42 }
43}
44/--------/ { if (state==1) state=2}
45/packets captured/ {if (state==2) {state=0; thread+=1; printf("</table>\n");}}
46
47
48
49END {
50 printf("</PRE>\n");
51 printf("<A href=\"\\index.html\"> <p><u> RETURN </u> </p> </A>\n");
52 printf("</BODY>\n");
53 printf("</HTML>\n");
54
55
56}
diff --git a/ti/runtime/netapi/demo/demo_setup_files/stats3.awk b/ti/runtime/netapi/demo/demo_setup_files/stats3.awk
new file mode 100644
index 0000000..fdc52e5
--- /dev/null
+++ b/ti/runtime/netapi/demo/demo_setup_files/stats3.awk
@@ -0,0 +1,71 @@
1#--------------------------------------
2# awk script to process stats
3# output from dpidemo and build
4# web page
5# stats3-> dump navl mem stata
6#_____________________________________
7
8
9BEGIN { state=0;
10 thread=1;
11 printf("<HTML>\n");
12 printf("</HEAD>\n");
13 printf("<BODY>\n");
14 }
15
16 // {
17 if (state==1)
18 {
19 if ($0 ~"-------------")
20 {
21 }
22 else if ($0 ~ "NAVL DPI")
23 {
24 }
25 else if (NF==1)
26 {
27 printf("<tr> ");
28 printf("<td> %s </td> ",$1);
29 printf("</tr> \n");
30 }
31 else if (NF==3)
32 {
33 printf("<tr> ");
34 printf("<td> </td> \n");
35 printf("<td> </td> \n");
36 for(i=1;i<=NF;i++) {
37 printf("<td> <b> %s </b> </td> ",$i);
38 }
39 printf("</tr> \n");
40 }
41
42
43 else
44 {
45 printf("<tr> ");
46 printf("<td> </td> \n");
47 for(i=1;i<=NF;i++) {
48 printf("<td> %s </td> ",$i);
49 }
50 printf("</tr> \n");
51 }
52}
53}
54/packets captured/ {
55 if (state==0)
56 {
57 state=1;
58 printf("<H2> DPI Memory Utilization Statistics Thread %d </H2>\n", thread);
59 printf("<table>\n");}
60}
61/NAVL DPI/ {if(state==1) {state=0; printf("</table>"); thread+=1;}}
62
63
64
65END {
66 printf("</table>\n");
67 printf("</PRE>\n");
68 printf("<A href=\"\\index.html\"> <p><u> RETURN </u> </p> </A>\n");
69 printf("</BODY>\n");
70 printf("</HTML>\n");
71}
diff --git a/ti/runtime/netapi/demo/demo_setup_files/stats4.awk b/ti/runtime/netapi/demo/demo_setup_files/stats4.awk
new file mode 100644
index 0000000..dd41c99
--- /dev/null
+++ b/ti/runtime/netapi/demo/demo_setup_files/stats4.awk
@@ -0,0 +1,104 @@
1#--------------------------------------
2# awk script to process stats
3# output from dpidemo and build
4# web page
5# stats3-> dump navl mem stata
6#_____________________________________
7
8
9BEGIN { state=0;
10 printf("<HTML>\n");
11 printf("</HEAD>\n");
12 printf("<BODY>\n");
13 printf("<H2> Packet Summary : </H2>\n");
14 lookup["nops"]="Number DPI Operations"
15 lookup["nclass"]="Number Packets Classified";
16 lookup["#mallocs"]="Number Malloc calls";
17 lookup["#mbytes"]="Bytes Malloc'd";
18 lookup["n_err"]="Number of errors";
19 lookup["fops"]= "tbd";
20 lookup["mCycles"]= "Malloc Cycles";
21 lookup["fCycles"]= "tbd";
22 tx[2]=0;
23
24 }
25/****stats/ {state=1;}
26/NAVL DPI/ {state=0;}
27
28/dpi stats:/ {
29
30 printf("<table>\n");
31 printf("<tr>\n");
32 printf("<td> <b> Statistic </b> </td> <td> <b> Value </b> </td>\n");
33 printf("</tr>\n");
34 for(i=1;i<=NF;i++)
35 {
36 #printf("index = %d for %s\n", index($i,"="), $i);
37 if (index($i,"=")!=0)
38 {
39 split($i, val,"=");
40 if (val[1] ~ "cycle")
41 {
42 val[1]= $(i-1) " cycle/pkt"
43 }
44 else
45 {
46 val[1] = lookup[val[1]];
47 }
48 printf("<tr><td>%s</td> <td> %d </td> </tr> \n",val[1],val[2]);
49 }
50 }
51 }
52 /busy_cycles/ { }
53 // { if(state==1) {
54 for(i=1; i<=NF;i++) {
55 if ($i ~ "sb_rx=") {}
56 else if ($i ~ "sb_tx=") {}
57 else if ($i ~ "itx=") {}
58 else if ($i ~ "+tx=") {}
59 else if ($i ~ "min_rx=") {}
60 else if ($i ~ "sec_tx=") {}
61 else if ($i ~ "min_tx=") {}
62 else if ($i ~ "rx=")
63 {
64 split($i, rx , "=");
65 }
66 else if ($i ~ "tx=")
67 {
68 if (tx[2] == 0)
69 {
70 split($i, tx , "=");
71 }
72 }
73 else if ($i ~ "if")
74 {
75 if0 = $5;
76 if1 = $6;
77 }
78 else if ($i ~ "core")
79 {
80 rx1 = $4;
81 rx2 = $5;
82 }
83
84 }
85 }
86}
87
88
89END {
90printf("<tr><td>Thread 1 RX</td><td> %d </td> </tr> \n",rx1);
91printf("<tr><td>Thread 2 RX</td><td> %d </td> </tr> \n",rx2);
92printf("<tr><td>Interface 0 RX</td><td> %d </td> </tr> \n",if0);
93printf("<tr><td>Interface 1 RX</td><td> %d </td> </tr> \n",if1);
94printf("<tr><td>RX Total</td><td> %d </td> </tr> \n",rx[2]);
95printf("<tr><td>TX Total</td><td> %d </td> </tr> \n",tx[2]);
96printf("</table>\n\n");
97
98 printf("</PRE>\n");
99 printf("<A href=\"\\index.html\"> <p><u> RETURN </u> </p> </A>\n");
100 printf("</BODY>\n");
101 printf("</HTML>\n");
102
103
104}
diff --git a/ti/runtime/netapi/demo/demo_setup_files/tilogo.gif b/ti/runtime/netapi/demo/demo_setup_files/tilogo.gif
new file mode 100644
index 0000000..f2fab2d
--- /dev/null
+++ b/ti/runtime/netapi/demo/demo_setup_files/tilogo.gif
Binary files differ
diff --git a/ti/runtime/netapi/demo/demo_setup_files/titagline.gif b/ti/runtime/netapi/demo/demo_setup_files/titagline.gif
new file mode 100644
index 0000000..743a024
--- /dev/null
+++ b/ti/runtime/netapi/demo/demo_setup_files/titagline.gif
Binary files differ
diff --git a/ti/runtime/netapi/demo/demo_setup_files/transport_dpi_demo_setup.sh b/ti/runtime/netapi/demo/demo_setup_files/transport_dpi_demo_setup.sh
new file mode 100755
index 0000000..53098eb
--- /dev/null
+++ b/ti/runtime/netapi/demo/demo_setup_files/transport_dpi_demo_setup.sh
@@ -0,0 +1,51 @@
1#!/bin/sh
2
3export KERNEL_VER=$(uname -r)
4
5# configure thttpd to run cgi scripts
6sed -e 's|8080|8080 -c cgi-bin/*|g' -i /etc/init.d/thttpd
7# reload the thttpd server
8cd /etc/init.d
9./thttpd restart
10
11# start Resource Manager Server
12/usr/bin/rmServer.out /usr/bin/device/k2e/global-resource-list.dtb /usr/bin/device/k2e/policy_dsp_arm.dtb
13#copy over web files
14
15cp /etc/transportnetlib/dpi_demo/index.html /srv/www/index.html
16chmod -x /srv/www/index.html
17cp /etc/transportnetlib/dpi_demo/stats1.awk /srv/www/stats1.awk
18cp /etc/transportnetlib/dpi_demo/stats2.awk /srv/www/stats2.awk
19cp /etc/transportnetlib/dpi_demo/stats3.awk /srv/www/stats3.awk
20cp /etc/transportnetlib/dpi_demo/stats3.awk /srv/www/stats4.awk
21cp /etc/transportnetlib/dpi_demo/*.gif /srv/www/
22cp /etc/transportnetlib/dpi_demo/dpicgi1.sh /srv/www/cgi-bin/dpicgi1.sh
23cp /etc/transportnetlib/dpi_demo/dpicgi2.sh /srv/www/cgi-bin/dpicgi2.sh
24cp /etc/transportnetlib/dpi_demo/dpicgi3.sh /srv/www/cgi-bin/dpicgi3.sh
25cp /etc/transportnetlib/dpi_demo/dpicgi4.sh /srv/www/cgi-bin/dpicgi4.sh
26cp /etc/transportnetlib/dpi_demo/dpicgi4.sh /srv/www/cgi-bin/dpicgi5.sh
27chmod +x /srv/www/cgi-bin/dpicfgi*.sh
28
29
30#install kernel module
31echo $KERNEL_VER
32insmod /lib/modules/$KERNEL_VER/extra/hplibmod.ko
33#
34# setup linux kernel bridge to handle broadcast packets
35ifconfig eth0 0.0.0.0
36#
37ifconfig eth1 0.0.0.0
38#create bridge
39brctl addbr br0
40#add i/fs to bridge
41brctl addif br0 eth0
42#
43brctl addif br0 eth1
44#
45dhclient br0
46#
47ifconfig br0
48# run transport_dpi_demo application
49cd /usr/bin
50./transport_dpi_demo
51
diff --git a/ti/runtime/netapi/demo/makefile_armv7 b/ti/runtime/netapi/demo/makefile_armv7
new file mode 100755
index 0000000..7be82df
--- /dev/null
+++ b/ti/runtime/netapi/demo/makefile_armv7
@@ -0,0 +1,65 @@
1#*******************************************************************************
2#* FILE PURPOSE: Top level makefile for Creating Component Libraries for ARM
3#* architectures
4#*******************************************************************************
5#* FILE NAME: makefile
6#*
7#* DESCRIPTION: Defines Compiler tools paths, libraries , Build Options
8#*
9#*
10#*******************************************************************************
11#*
12# (Mandatory) Specify where various tools are installed.
13
14# Output for prebuilt generated libraries
15export ARMV7LIBDIR ?= ./lib
16
17#Enable the following to build for tci6614
18
19
20# ROOT Directory
21export ROOTDIR := ../../..
22
23
24# INCLUDE Directory
25export INCDIR := ../;$(PDK_INSTALL_PATH);$(ROOTDIR)
26
27# Common Macros used in make
28
29ifndef RM
30export RM = rm -f
31endif
32
33ifndef CP
34export CP = cp -p
35endif
36
37export MKDIR = mkdir -p
38
39ifndef RMDIR
40export RMDIR = rm -rf
41endif
42
43ifndef SED
44export SED = sed
45endif
46
47ifndef MAKE
48export MAKE = make
49endif
50
51
52# PHONY Targets
53.PHONY: all install
54
55# all rule
56all: install
57
58install:
59 install -d $(INSTALL_BIN_BASE_DIR)/plugins
60 $(CP) -r plugins/* $(INSTALL_INC_BASE_DIR)/plugins
61 install -d $(INSTALL_INC_BASE_DIR)/navl/include
62 $(CP) include/navl.h $(INSTALL_INC_BASE_DIR)/navl/include
63 install -d $(INSTALL_LIB_BASE_DIR)
64 $(CP) -rp lib/libnavl.so* $(INSTALL_LIB_BASE_DIR)
65
diff --git a/ti/runtime/netapi/demo/src/Makefile b/ti/runtime/netapi/demo/src/Makefile
new file mode 100755
index 0000000..aa84b3a
--- /dev/null
+++ b/ti/runtime/netapi/demo/src/Makefile
@@ -0,0 +1,95 @@
1#
2empty =
3space =$(empty) $(empty)
4
5export ARMV7OBJDIR ?= ./obj
6export ARMV7BINDIR ?= ./bin
7export ARMV7LIBDIR ?= ./lib
8export ARMV7SALIBDIR ?= ./lib
9
10DPI_DEMO_SRC_DIR ?= $(PWD)
11# INCLUDE Directories
12SA_INSTALL_PATH ?= $(PDK_INSTALL_PATH)/ti/drv/sa
13QMSS_INC_DIR ?= $(PDK_INSTALL_PATH)/ti/drv/qmss
14CPPI_INC_DIR ?= $(PDK_INSTALL_PATH)/ti/drv/cppi
15RM_INC_DIR ?= $(PDK_INSTALL_PATH)/ti/drv/rm
16#NETAPI_INC_DIR ?= $(NETAPI_INSTALL_PATH)/ti/runtime/netapi
17NETAPI_INC_DIR ?= $(NETAPI_INSTALL_PATH)
18#HPLIB_INC_DIR ?= $(HPLIB_INSTALL_PATH)/ti/runtime/hplib
19HPLIB_INC_DIR ?= $(HPLIB_INSTALL_PATH)
20NWAL_INSTALL_PATH ?= $(PDK_INSTALL_PATH)/ti/drv/nwal
21PKTLIB_INSTALL_PATH ?= $(PDK_INSTALL_PATH)/ti/runtime/pktlib
22NAVL_LIB_DIR ?= $(DPI_DEMO_SRC_DIR)/../lib
23# Set NETAPI INSTALL PATH to Transport SDK for default
24
25#NT_RM_OBJS = $(ARMV7OBJDIR)/netapi/utils/sockutils.o $(ARMV7OBJDIR)/netapi/utils/netapi_util_rm.o
26
27#TRIE_OBJS=$(ARMV7OBJDIR)/netapi/test/trie.o
28
29
30DPI_DEMO_OBJS= $(ARMV7OBJDIR)/dpi_demo_git/src/dpi_demo.o $(ARMV7OBJDIR)/dpi_demo_git/src/navl_wrapper.o $(ARMV7OBJDIR)/dpi_demo_git/src/navl_external_posix.o
31
32# Support Libraries used by dpi-demo
33CSL_DEVICE ?= -DDEVICE_K2E -DNSS_GEN2
34QMSS_LIB = -lqmss
35CPPI_LIB = -lcppi
36PA_LIB = -lpa2
37NWAL_LIB = -lnwalsa_k2e
38SA_LIB = -lsa
39RM_LIB = -lrm
40PKTLIB_LIB = -lpktlib
41NETAPI_LIB =-lnetapi_k2e
42HP_LIB = -lhplib_k2e
43NAVL_LIB = -lnavl
44
45local_base=/usr/local
46LDFLAGS = -L. -L$(local_base)/lib
47
48LIBS = -static $(QMSS_LIB) $(CPPI_LIB) $(PA_LIB) $(PKTLIB_LIB) $(NETAPI_LIB) $(HP_LIB) $(SA_LIB) $(NWAL_LIB) $(RM_LIB) -Wl,-Bdynamic
49
50LIBS += $(NAVL_LIB) -lstdc++ -lgcc_s
51EXE_EXTN =
52
53SYSTYPE:=$(shell uname)
54ifeq ($(SYSTYPE), Linux)
55LIBS += -ldl -lm
56else
57LIBS += -lexecinfo
58endif
59
60ifdef CROSS_TOOL_INSTALL_PATH
61## Support backwards compatibility with KeyStone1 approach
62 CC = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)gcc
63 AC = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)as
64 AR = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)ar
65 LD = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)gcc
66endif
67
68INCLUDE = -I. -I$(local_base)/include -I../ -I$(HPLIB_INC_DIR) -I$(NETAPI_INC_DIR) -I$(PDK_INSTALL_PATH) -I$(NWAL_INSTALL_PATH) -I$(PKTLIB_INSTALL_PATH) -I$(SA_INSTALL_PATH) -I$(QMSS_INC_DIR) -I$(CPPI_INC_DIR) -I$(RM_INC_DIR) $(CSL_DEVICE)
69
70CFLAGS += $(DEBUG_FLAG) -D__ARMv7 -D_VIRTUAL_ADDR_SUPPORT -D__LINUX_USER_SPACE -D_LITTLE_ENDIAN=1 -DNWAL_ENABLE_SA -DMAKEFILE_BUILD -D _GNU_SOURCE
71# Linker options
72INTERNALLINKDEFS = -Wl,--start-group $(LIBS) -Wl,--end-group -lrt -pthread -L$(ARMV7LIBDIR) -L$(ARMV7SALIBDIR) -L$(NAVL_LIB_DIR)
73
74all: tests
75
76tests: $(ARMV7BINDIR)/dpi_demo_git/demo/.created $(ARMV7BINDIR)/dpi_demo_git/demo/dpi_demo_$(DEVICE)
77
78clean:
79 rm -f $(ARMV7OBJDIR)/dpi_demo/demo/*.o
80 rm -f $(ARMV7BINDIR)/dpi_demo/demo/*
81
82$(ARMV7OBJDIR)/dpi_demo_git/src/%.o: %.c $(ARMV7OBJDIR)/dpi_demo_git/src/.created
83 @echo compiling $<
84 $(CC) -c $(CFLAGS) $(INCLUDE) $< -o $@
85
86$(ARMV7OBJDIR)/dpi_demo_git/src/.created:
87 @mkdir -p $(ARMV7OBJDIR)/dpi_demo_git/src/
88
89$(ARMV7BINDIR)/dpi_demo_git/demo/.created:
90 @mkdir -p $(ARMV7BINDIR)/dpi_demo_git/demo/
91
92$(ARMV7BINDIR)/dpi_demo_git/demo/dpi_demo_$(DEVICE): $(DPI_DEMO_OBJS)
93 echo 'test123'
94 #$(CC) $(LDFLAGS) $(DPI_DEMO_OBJS) $(INTERNALLINKDEFS) $(INCLUDE) -rdynamic ../lib/libnavl.so -o $(ARMV7BINDIR)/dpi_demo_git/demo/dpi_demo_$(DEVICE)$(EXE_EXTN)
95 $(CC) $(LDFLAGS) $(DPI_DEMO_OBJS) $(INTERNALLINKDEFS) $(INCLUDE) -o $(ARMV7BINDIR)/dpi_demo_git/demo/dpi_demo_$(DEVICE)$(EXE_EXTN)
diff --git a/ti/runtime/netapi/demo/src/navl_external_posix.c b/ti/runtime/netapi/demo/src/navl_external_posix.c
new file mode 100755
index 0000000..8ee00ab
--- /dev/null
+++ b/ti/runtime/netapi/demo/src/navl_external_posix.c
@@ -0,0 +1,119 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <ctype.h>
4#include <string.h>
5#include <time.h>
6#include <arpa/inet.h>
7#include <sys/time.h>
8#include <math.h>
9#include <pthread.h>
10#include <unistd.h>
11#include <stdarg.h>
12#include <sys/types.h>
13#include <sys/socket.h>
14#include <netinet/in.h>
15#include <arpa/inet.h>
16#include "navl/navl.h"
17#include "navl_wrapper.h"
18extern navl_global_dpi_stats *pDpiStats;
19
20
21void* our_malloc(size_t n)
22{
23 pDpiStats->malloc_inst+=1;
24 pDpiStats->malloc_bytes+= n;
25 return (malloc(n));
26}
27int null_log_message(const char *level, const char *func, const char *format, ... )
28{
29 return 0;
30}
31
32int printf_log_message(const char *level, const char *func, const char *format, ... )
33{
34 int res = 0;
35 char buf[4096];
36 va_list va;
37 va_start(va, format);
38
39 res = snprintf(buf, 4096, "%s: %s: ", level, func);
40 res += vsnprintf(buf + res, 4096 - res, format, va);
41 navl_diag_printf(buf);
42 va_end(va);
43 return res;
44}
45
46void bind_navl_externals()
47{
48 /* memory allocation */
49 navl_malloc_local = our_malloc;
50 navl_free_local = free;
51 navl_malloc_shared = our_malloc;
52 navl_free_shared = free;
53
54 /* ctype */
55 navl_islower = islower;
56 navl_isupper = isupper;
57 navl_tolower = tolower;
58 navl_toupper = toupper;
59 navl_isalnum = isalnum;
60 navl_isspace = isspace;
61 navl_isdigit = isdigit;
62
63 /* string functions */
64 navl_atoi = atoi;
65 navl_memcpy = memcpy;
66 navl_memcmp = memcmp;
67 navl_memset = memset;
68 navl_strcasecmp = strcasecmp;
69 navl_strchr = (const char* (*)(const char*, int))strchr;
70 navl_strrchr = (const char* (*)(const char*, int))strrchr;
71 navl_strcmp = strcmp;
72 navl_strncmp = strncmp;
73 navl_strcpy = strcpy;
74 navl_strncpy = strncpy;
75 navl_strerror = strerror;
76 navl_strftime = (size_t (*)(char*, size_t, const char*, const struct navl_tm*))strftime;
77 navl_strlen = strlen;
78 navl_strpbrk = (const char* (*)(const char*, const char*))strpbrk;
79 navl_strstr = (const char* (*)(const char*, const char*))strstr;
80 navl_strtol = strtol;
81
82 /* input/output */
83 navl_printf = printf;
84 navl_sprintf = sprintf;
85 navl_snprintf = snprintf;
86 navl_sscanf = sscanf;
87 navl_putchar = putchar;
88 navl_puts = puts;
89 navl_diag_printf = printf;
90
91 /* time */
92 navl_gettimeofday = (int (*)(struct navl_timeval*, void*))gettimeofday;
93 navl_mktime = (navl_time_t (*)(struct navl_tm*))mktime;
94
95 /* math */
96 navl_log = log;
97 navl_fabs = fabs;
98
99#if 0
100 /* network */
101#ifndef __mips__
102 navl_htonl = htonl;
103 navl_htons = htons;
104 navl_ntohl = ntohl;
105 navl_ntohs = ntohs;
106#endif
107#endif
108 /* system */
109 navl_abort = abort;
110 navl_get_thread_id = (unsigned long (*)(void))pthread_self;
111
112 /* navl specific */
113#ifdef DEBUG
114 navl_log_message = printf_log_message;
115#else
116 navl_log_message = null_log_message;
117#endif
118}
119
diff --git a/ti/runtime/netapi/demo/src/navl_wrapper.c b/ti/runtime/netapi/demo/src/navl_wrapper.c
new file mode 100755
index 0000000..8e26cc4
--- /dev/null
+++ b/ti/runtime/netapi/demo/src/navl_wrapper.c
@@ -0,0 +1,938 @@
1#define __STDC_FORMAT_MACROS
2#include <inttypes.h>
3#include <stdio.h>
4#include <stdlib.h>
5#include <string.h>
6#include <signal.h>
7#include <getopt.h>
8#include <errno.h>
9#include <assert.h>
10#include <stdarg.h>
11#include "ti/runtime/hplib/hplib.h"
12#include "ti/runtime/netapi/netapi_types.h"
13#include "navl_wrapper.h"
14/* timing */
15
16#define netapi_timing_start hplib_mUtilGetPmuCCNT
17
18navl_wrapper_cfg_info_t *pNavlCfg;
19navl_global_dpi_stats *pDpiStats;
20void* pShmBase;
21void *pShmEntry;
22
23//int free_inst=0;
24
25static unsigned long long timing=0LL;
26
27static char last_url[256];
28int class=0;
29void clear_pkt_stats();
30void navl_clear_stats(void)
31{
32 memset(pDpiStats, 0, sizeof(navl_global_dpi_stats));
33 pDpiStats->min_time=100000000;
34 clear_pkt_stats();
35}
36void navl_return_stats(int * Pn_ops, int * Pn_class, unsigned long * Pmin_time, unsigned long * Pmax_time, unsigned long long *Ptiming, int * Pmalloc_inst, int *Pmalloc_bytes, int * Pn_err, int *Pfree_inst, unsigned long *Pmalloc_cycles, unsigned long *Pfree_cycles)
37{
38 *Pn_ops=pDpiStats->n_ops;
39 *Pn_class=pDpiStats->n_class;
40 *Pmin_time=pDpiStats->min_time;
41 *Pmax_time=pDpiStats->max_time;
42 *Ptiming=timing;
43 *Pmalloc_inst = pDpiStats->malloc_inst;
44 *Pmalloc_bytes= pDpiStats->malloc_bytes;
45 *Pn_err=pDpiStats->n_err;
46 *Pfree_inst = pDpiStats->free_inst;
47 *Pmalloc_cycles= pDpiStats->malloc_inst ? pDpiStats->malloc_cycles/pDpiStats->malloc_inst: 0;
48 *Pfree_cycles= pDpiStats->free_inst? pDpiStats->free_cycles/pDpiStats->free_inst : 0;
49}
50
51//#define MAX_BIN 10
52static long bins[MAX_BIN]={10000, 12500, 15000,17500,20000, 25000,30000,35000,40000,50000};
53static char* binStr[MAX_BIN]={"10K", "12.5K", "15K","17.5K","20K","25K","30K","35K","40K","50K"};
54
55void add2bin(long cycles, long p_bins[])
56{
57 int i;
58 for(i=0;i<MAX_BIN-1;i++)
59 if (cycles<bins[i]) {p_bins[i]+=1;return;}
60 p_bins[MAX_BIN-1] += 1; //max
61}
62
63
64
65navl_mcb_t *g_reader = NULL;
66const char *g_exename = NULL;
67
68static int navl_wrapper_init(int argc, char *argv[]);
69static void *navl_wrapper_malloc(size_t);
70static void navl_wrapper_free(void *);
71static int navl_wrapper_log_message(const char *level, const char *func, const char *format, ...);
72
73static int navl_classify_callback(navl_handle_t handle, navl_result_t result, navl_state_t state, navl_conn_t conn, void *arg, int error);
74
75static void navl_wrapper_mem_stat_print(int threadId);
76
77/* external definitions */
78void bind_navl_externals();
79
80void navl_set_verbose(void)
81{
82 g_reader->option_verbose=!g_reader->option_verbose;
83 printf(">**DPI Now in %s mode\n",g_reader->option_verbose?"verbose":"nonverbose");
84}
85void navl_dump_conn_info()
86{
87navl_diag(g_reader->navl, "TCP", NULL);
88}
89
90
91#define navl_wrapper_error() \
92do { \
93 fprintf(stderr, "%s failed in %s:%u", g_exename, __FUNCTION__, __LINE__); \
94 if (g_reader) { \
95 if (g_reader->error_navl) \
96 fprintf(stderr, " with navl error %s", get_error_string(navl_error_get(g_reader->navl))); \
97 } \
98 fprintf(stderr, "\n"); \
99} while (0)
100
101int navl_setup(void)
102{
103 return (navl_wrapper_init(0, NULL));
104}
105
106
107static const char *
108get_state_string(navl_state_t state)
109{
110switch (state)
111 {
112 case NAVL_STATE_INSPECTING:
113 return "INSPECTING";
114 case NAVL_STATE_MONITORING:
115 return "MONITORING";
116 case NAVL_STATE_CLASSIFIED:
117 return "CLASSIFIED";
118 case NAVL_STATE_TERMINATED:
119 return "TERMINATED";
120 default:
121 return "UNKNOWN";
122 }
123}
124
125static const char *
126get_confidence_string(int confidence)
127{
128 switch (confidence)
129 {
130 case 50:
131 return "PORT";
132 case 100:
133 return "DPI";
134 default:
135 return "NONE";
136 }
137}
138
139static const char *
140get_error_string(int error)
141{
142 switch (error)
143 {
144 case 0:
145 return "None";
146 case ENOMEM:
147 return "No memory available";
148 case EPROTO:
149 return "Protocol error";
150 case ENOTCONN:
151 return "No connection allocated";
152 case EEXIST:
153 return "Object exists";
154 case EINVAL:
155 return "Invalid parameter";
156 case ECANCELED:
157 return "Operation cancelled";
158 case ENOENT:
159 return "No such file or directory";
160 case EPROTONOSUPPORT:
161 return "Protocol not supported";
162 default:
163 return "Unknown";
164 }
165}
166
167static int
168navl_wrapper_init(int argc, char *argv[])
169{
170 static navl_mcb_t reader;
171
172 int ret;
173 int i,j;
174
175 g_reader = &reader;
176
177 g_reader->navl = -1;
178
179 g_reader->config_capfile = NULL;
180 g_reader->config_plugins = "plugins";
181 g_reader->config_num_proto = 0;
182 g_reader->config_conn_id_attr = 0;
183 g_reader->config_http_attr = 0;
184 g_reader->config_num_memctx = NUM_MEM_CTX;
185 g_reader->config_num_memobj = NUM_MEM_OBJ;
186
187 g_reader->option_dpi = 1;
188 g_reader->option_simple = 0;
189 g_reader->option_track_memory = 1;
190 g_reader->option_limit_memory = 0;
191 g_reader->option_realtime_mode = 1;
192 g_reader->option_verbose = 0;
193
194 g_reader->error_navl = 0;
195
196 for(j=0;j< NUM_FP_PROCS;j++)
197 g_reader->stats_pkt[j] = NULL;
198
199 g_reader->stats_conns = 0;
200
201 g_reader->running = 1;
202 g_reader->alloc_curr = 0;
203 g_reader->alloc_peak = 0;
204
205 g_exename = "dpi_demo";
206
207
208 /* allocate segment for shared memory for packet stats */
209 /* allocate packet statistics */
210 pShmBase = hplib_shmOpen();
211 if (pShmBase)
212 {
213 pShmEntry = hplib_shmGetEntry(pShmBase, APP_ENTRY_1);
214 pNavlCfg = (navl_wrapper_cfg_info_t*)pShmEntry;
215 memset(pNavlCfg,
216 0,
217 sizeof(navl_wrapper_pkt_stat_t) * MAX_PROTOCOLS *NUM_FP_PROCS+ sizeof(navl_wrapper_cfg_info_t));
218 pNavlCfg = (navl_wrapper_cfg_info_t*)pShmEntry;
219 pNavlCfg->num_protocols = g_reader->config_num_proto;
220 g_reader->stats_pkt[0] = pShmEntry + sizeof(navl_wrapper_cfg_info_t);
221
222 g_reader->stats_pkt[1] = pShmEntry + sizeof(navl_wrapper_cfg_info_t) +
223 (sizeof(navl_wrapper_pkt_stat_t)*MAX_PROTOCOLS);
224
225 for (j = 0; j < NUM_FP_PROCS; j++)
226 {
227 for(i=0;i< MAX_PROTOCOLS;i++)
228 {
229 g_reader->stats_pkt[j][i].cycles_min=10000000;
230 g_reader->stats_pkt[j][i].cycles_max=0;
231
232 }
233 }
234 pShmEntry = hplib_shmGetEntry(pShmBase, APP_ENTRY_2);
235 pDpiStats = (navl_global_dpi_stats*) pShmEntry;
236
237 pShmEntry = hplib_shmGetEntry(pShmBase, APP_ENTRY_3);
238 g_reader->stats_mem = (navl_wrapper_mem_stats_t*) pShmEntry;
239 }
240 else
241 {
242 printf("navl_wrapper_init: hplib_shmOpen failure\n");
243 return NETAPI_ERR_NOMEM;
244 }
245
246
247 /* EXTERNAL BINDINGS GO HERE */
248 {
249 /* Bind the platform specific functions. */
250 bind_navl_externals();
251
252 /* Private overrides for this example application. */
253 navl_log_message = navl_wrapper_log_message;
254 if (g_reader->option_track_memory)
255 {
256 navl_malloc_local = navl_wrapper_malloc;
257 navl_free_local = navl_wrapper_free;
258 navl_malloc_shared = navl_wrapper_malloc;
259 navl_free_shared = navl_wrapper_free;
260 }
261 }
262
263 /* open the navl library */
264 if ((g_reader->navl = navl_open(g_reader->config_plugins)) == -1)
265 navl_wrapper_error();
266
267 /* set logging level to "error | fatal" */
268 if (navl_config_set(g_reader->navl, "system.loglevel", "48") == -1)
269 navl_wrapper_error();
270
271 /* determine the max protocol index */
272 if ((ret = navl_proto_max_index(g_reader->navl)) == -1)
273 {
274 printf("navl_proto_max_index error\n");
275 navl_wrapper_error();
276 }
277
278 /* the number of protocols is the max + 1 */
279 g_reader->config_num_proto = (ret + 1);
280 pNavlCfg->num_protocols = g_reader->config_num_proto;
281
282 return NETAPI_ERR_OK;
283}
284
285//per thread init. Call this in worker thread context
286int navl_per_thread_init(uint32_t thread_num)
287{
288 int ret;
289 int c;
290
291 /* initialize this thread for classification */
292 if (navl_init(g_reader->navl))
293 {
294 printf("navl_init error\n");
295 navl_wrapper_error();
296 }
297#if 0
298 /* enable connection tracking */
299 if (navl_attr_enable(g_reader->navl, "conn.id", 1) == -1)
300 navl_wrapper_error();
301
302#ifdef HTTP_ATTRIB
303 /* enable http url */
304 if (navl_attr_enable(g_reader->navl, "http.request.url",1) == -1)
305 navl_wrapper_error();
306#endif
307
308 /* lookup the key for conn.id */
309 if ((g_reader->config_conn_id_attr = navl_attr_key_get(g_reader->navl, "conn.id")) == -1)
310 navl_wrapper_error();
311#ifdef HTTP_ATTRIB
312 /* lookup the key for http.request.host */
313 if ((g_reader->config_http_attr = navl_attr_key_get(g_reader->navl, "http.request.url")) == -1)
314 navl_wrapper_error();
315#endif
316#endif
317 /* simulated realtime */
318 if (g_reader->option_realtime_mode == 2)
319 navl_clock_set_mode(g_reader->navl, 1);
320
321
322#if 0
323 /* determine the max protocol index */
324 if ((ret = navl_proto_max_index(g_reader->navl)) == -1)
325 {
326 printf("navl_proto_max_index error\n");
327 navl_wrapper_error();
328 }
329
330 /* the number of protocols is the max + 1 */
331 g_reader->config_num_proto = (ret + 1);
332#endif
333
334
335 /* now fetch all the protocol name ahead of time do we don't have to lookup them up on each packet */
336 for (ret = 0; ret != g_reader->config_num_proto; ret++)
337 navl_proto_get_name(g_reader->navl, ret,
338 g_reader->stats_pkt[thread_num-1][ret].name,
339 sizeof(g_reader->stats_pkt[thread_num-1][ret].name));
340
341
342 /* fetch all the memory tag names */
343 for (c = 0; c < NUM_MEM_CTX; c++)
344 navl_memory_ctx_name(g_reader->navl, c, g_reader->stats_mem->ctx_name[thread_num-1][c],
345 sizeof(g_reader->stats_mem->ctx_name[thread_num-1][c]));
346 //navl_memory_ctx_name(g_reader->navl, c, g_reader->ctx_name[c], sizeof(g_reader->ctx_name[c]));
347 for (c = 0; c < NUM_MEM_OBJ; c++)
348 navl_memory_obj_name(g_reader->navl, c, g_reader->stats_mem->obj_name[thread_num-1][c],
349 sizeof(g_reader->stats_mem->obj_name[thread_num-1][c]));
350
351 //navl_memory_obj_name(g_reader->navl, c, g_reader->obj_name[c], sizeof(g_reader->obj_name[c]));
352
353 return 1;
354}
355
356
357static uint64_t
358msec_time(struct timeval *tv)
359{
360 return ((uint64_t)tv->tv_sec * 1000) + (tv->tv_usec / 1000);
361}
362
363static void
364msec_delay(uint64_t msecs)
365{
366 struct timeval tv = { msecs / 1000, (msecs % 1000) * 1000 };
367 select(0, 0, 0, 0, &tv);
368}
369
370#if 1
371typedef struct
372{
373 const uint8_t *data;
374 uint32_t size;
375 uint32_t sequence;
376 int32_t appidx;
377 uint64_t connid;
378} navl_wrapper_packet_t;
379#else
380typedef struct
381{
382 const uint8_t *data;
383 uint32_t size;
384 uint32_t sequence;
385 int32_t appidx;
386 int32_t num_cb;
387} navl_wrapper_packet_t;
388#endif
389
390
391#if 1
392static int
393navl_classify_callback(navl_handle_t handle,
394 navl_result_t result,
395 navl_state_t state,
396 navl_conn_t conn,
397 void *arg,
398 int error)
399{
400 int idx, protoid = 0, confidence = 0;
401 char buf[256] = {0};
402 navl_iterator_t it;
403 navl_wrapper_packet_t *packet = (navl_wrapper_packet_t *)arg;
404 int threadId =Osal_nwalGetProcId();
405
406 packet->appidx = navl_app_get(g_reader->navl, result, &confidence);
407 if((state==NAVL_STATE_CLASSIFIED) ||
408 (state==NAVL_STATE_TERMINATED) ||
409 (state==NAVL_STATE_MONITORING))
410 {
411 pDpiStats->n_class+=1;
412 class =1;
413 }
414 else
415 class=0;
416#if 0
417 if (navl_proto_find_index(g_reader->navl, "HTTP") == packet->appidx)
418 {
419 it = navl_proto_find(g_reader->navl, result, navl_proto_find_index(g_reader->navl, "HTTP"));
420 if (navl_proto_valid(g_reader->navl, it))
421 navl_attr_get(g_reader->navl,
422 it,
423 g_reader->config_http_attr,
424 &last_url,
425 sizeof(last_url));
426 }
427#endif
428 if (g_reader->option_verbose)
429 {
430 /* Build the stack string */
431 for (idx = 0, it = navl_proto_first(g_reader->navl, result); navl_proto_valid(g_reader->navl, it); navl_proto_next(g_reader->navl, it))
432 {
433 protoid = navl_proto_get_index(g_reader->navl, it);
434 if (!packet->connid)
435 {
436 if (navl_proto_find_index(g_reader->navl, "IP") == protoid)
437 {
438#if 0
439 navl_attr_get(g_reader->navl, it, g_reader->config_conn_id_attr, &packet->connid, sizeof(packet->connid));
440 if (packet->connid > g_reader->stats_conns)
441 g_reader->stats_conns = packet->connid;
442#endif
443 }
444 }
445 idx += sprintf(&buf[idx], "/%s", g_reader->stats_pkt[threadId-1][protoid].name);
446 }
447 printf(" Pkt: %u (%u bytes), Conn: %" PRIu64 ", App: %s (%s), State: %s, Stack: %s, Error: %s\n", packet->sequence
448 , packet->size, packet->connid, g_reader->stats_pkt[threadId-1][packet->appidx].name
449 , get_confidence_string(confidence), get_state_string(state), buf, get_error_string(error));
450 }
451
452 /* Continue tracking the flow */
453 return 0;
454}
455#else
456static int
457navl_classify_callback(navl_handle_t handle,
458 navl_result_t result,
459 navl_state_t state,
460 navl_conn_t conn,
461 void *arg,
462 int error)
463{
464 int idx, protoid = 0, confidence = 0;
465 char buf[256] = {0};
466 navl_iterator_t it;
467 navl_conn_id_t conn_id = navl_conn_id_get(handle, conn);
468 navl_wrapper_packet_t *packet = (navl_wrapper_packet_t *)arg;
469
470 /* Always display the outer packet; optionally display encapsulated data */
471 if (!packet->num_cb || g_reader->option_tunnel)
472 {
473 packet->appidx = navl_app_get(g_reader->navl, result, &confidence);
474
475 if (g_reader->option_verbose)
476 {
477 if (conn_id > g_reader->stats_conns)
478 g_reader->stats_conns = conn_id;
479
480 /* Build the stack string */
481 for (idx = 0, it = navl_proto_first(g_reader->navl, result); navl_proto_valid(g_reader->navl, it); navl_proto_next(g_reader->navl, it))
482 {
483 protoid = navl_proto_get_index(g_reader->navl, it);
484 idx += sprintf(&buf[idx], "/%s", g_reader->stats_pkt[fp_thread][protoid].name);
485 }
486
487 printf(" Pkt: %u (%u bytes), Conn: %" PRIu64 ", App: %s (%s), State: %s, Stack: %s, Error: %s\n"
488 , packet->sequence, packet->size, conn_id, g_reader->stats_pkt[fp_thread][packet->appidx].name
489 , get_confidence_string(confidence), get_state_string(state), buf, get_error_string(error));
490 }
491 }
492
493 packet->num_cb++;
494
495 /* Continue tracking the flow */
496 return 0;
497}
498#endif
499
500//process the packet
501__thread navl_wrapper_packet_t packet = { NULL, 0, 0 };
502int navl_process_pkt(unsigned char *p_pkt, int len)
503{
504 volatile unsigned long v1;
505 volatile unsigned long v2;
506 unsigned long temp=0;
507 uint64_t last = 0;
508 uint64_t next = 0;
509 unsigned long long mf1;
510 unsigned long long mf2;
511 int threadId =Osal_nwalGetProcId();
512 mf1= pDpiStats->malloc_cycles+pDpiStats->free_cycles;
513
514 v1 = netapi_timing_start();
515
516/* update the current packet */
517 packet.sequence++;
518 packet.size = len;
519 packet.appidx = 0;
520 //packet.connid = 0;
521 packet.data=p_pkt;
522
523 /* "real" realtime */
524 if (g_reader->option_realtime_mode == 1)
525 {
526 //next = msec_time(0LL);//dal -> get ts here
527 next=0LL;
528 if (last)
529 msec_delay(next - last);
530 last = next;
531 }
532 if (navl_classify(g_reader->navl,
533 NAVL_ENCAP_ETH,
534 packet.data,
535 packet.size,
536 NULL,
537 0,
538 navl_classify_callback,
539 &packet) == -1)
540 printf(" Pkt: %u (%u bytes), Error: %s\n", packet.sequence,
541 packet.size,
542 get_error_string(navl_error_get(g_reader->navl)));
543
544 /* Update the stats. If classification was not enabled, then the appidx will be 0 and all packets
545 * captured will be accumulated there */
546 g_reader->stats_pkt[threadId-1][packet.appidx].packets++;
547 g_reader->stats_pkt[threadId-1][packet.appidx].bytes += packet.size;
548 if(class)
549 g_reader->stats_pkt[threadId-1][packet.appidx].class++;
550 //update timing
551 v2 = netapi_timing_start();
552 temp=v2-v1;
553 mf2= pDpiStats->malloc_cycles + pDpiStats->free_cycles;
554 timing+= (unsigned long long) temp;
555 g_reader->stats_pkt[threadId-1][packet.appidx].cycles += (unsigned long long) temp;
556 g_reader->stats_pkt[threadId-1][packet.appidx].cycles_nomem += ((unsigned long long) temp - (mf2-mf1));
557
558 if (g_reader->stats_pkt[threadId-1][packet.appidx].cycles_min > temp)
559 g_reader->stats_pkt[threadId-1][packet.appidx].cycles_min = temp;
560
561 if (g_reader->stats_pkt[threadId-1][packet.appidx].cycles_max < temp)
562 {
563 g_reader->stats_pkt[threadId-1][packet.appidx].cycles_max = temp;
564
565 }
566
567
568 add2bin((temp - (unsigned long)(mf2-mf1)),&g_reader->stats_pkt[threadId-1][packet.appidx].bin_cycles[0]);
569 pDpiStats->n_ops+=1;
570 if (temp > pDpiStats->max_time) pDpiStats->max_time = temp;
571 if (temp< pDpiStats->min_time) pDpiStats->min_time = temp;
572 return 1;
573}
574
575int navl_done(void)
576{
577 navl_fini(g_reader->navl);
578 navl_close(g_reader->navl);
579 return 1;
580}
581
582void navl_results(int fp_thread)
583{
584 int idx;
585 int i;
586 uint64_t total_packets, total_bytes;
587 void* pShmEntry;
588
589 total_packets = 0;
590 total_bytes = 0;
591
592 if (g_reader->option_dpi)
593 {
594 printf("\n NAVL DPI stats for CORE ID %d\n", fp_thread + 1);
595 printf("\n AppProto Packets Class Bytes Cycles/Pkt Cyclesnomem/Pkt (min) (max) ");
596 for(i=0;i<MAX_BIN;i++)
597 printf("<%s ",binStr[i]);
598 printf("\n ----------------------------------------------------------------------------------------------------------------------------------------------------\n");
599 }
600
601 //for (idx = 0; idx < g_reader->config_num_proto; idx++)
602 for (idx = 0; idx < pNavlCfg->num_protocols; idx++)
603 {
604 if (g_reader->option_dpi)
605 {
606 if (g_reader->stats_pkt[fp_thread][idx].packets)
607 {
608 /* We need to provide protocol definitions */
609 printf(" %-12s%-12" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %ld %ld " ,
610 g_reader->stats_pkt[fp_thread][idx].name,
611 g_reader->stats_pkt[fp_thread][idx].packets,
612 g_reader->stats_pkt[fp_thread][idx].class,
613 g_reader->stats_pkt[fp_thread][idx].bytes,
614 g_reader->stats_pkt[fp_thread][idx].cycles/g_reader->stats_pkt[fp_thread][idx].packets,
615 g_reader->stats_pkt[fp_thread][idx].cycles_nomem/g_reader->stats_pkt[fp_thread][idx].packets,
616 g_reader->stats_pkt[fp_thread][idx].cycles_min,
617 g_reader->stats_pkt[fp_thread][idx].cycles_max);
618 for(i=0;i<MAX_BIN;i++) printf("%ld ",g_reader->stats_pkt[fp_thread][idx].bin_cycles[i]);
619 printf("\n");
620 }
621 }
622
623 total_packets += g_reader->stats_pkt[fp_thread][idx].packets;
624 total_bytes += g_reader->stats_pkt[fp_thread][idx].bytes;
625 }
626
627 if (!total_packets)
628 printf("\n No packets captured.\n");
629 else
630 printf("\n %" PRIu64 " packets captured (%" PRIu64 " bytes)\n", total_packets, total_bytes);
631
632 if (g_reader->stats_conns)
633 printf(" %" PRIu64 " connections tracked\n", g_reader->stats_conns);
634
635 printf("\n");
636 if (g_reader->option_track_memory)
637 navl_wrapper_mem_stat_print(fp_thread);
638
639
640 if (pNavlCfg->alloc_curr != 0)
641 printf("Bytes not freed: %" PRIi64 "\n", pNavlCfg->alloc_curr);
642
643 if (g_reader->alloc_peak != 0)
644 printf("Peak allocated: %" PRIi64 "\n", g_reader->alloc_peak);
645
646 printf("attr test: last http utl= %s\n",last_url);
647}
648
649static void
650navl_wrapper_mem_stat_print(int threadId)
651{
652 int i, j;
653 navl_wrapper_stat_t *stat;
654 char *name;
655
656 printf(" Curr Peak Fail \n");
657 printf("-----------------------------------------------------------------------");
658
659 for (i = 0; i < NUM_MEM_CTX; i++)
660 {
661 stat = &g_reader->stats_mem->mstats[threadId][i][0];
662 if (stat->peak == 0)
663 continue;
664
665 printf("\n\t%s\n", g_reader->stats_mem->ctx_name[threadId][i]);
666 //printf("\n\t%s\n", g_reader->ctx_name[i]);
667
668 for (j = NUM_MEM_OBJ - 1; j >= 0; j--)
669 {
670 navl_wrapper_stat_t *stat = &g_reader->stats_mem->mstats[threadId][i][j];
671 if (stat->peak == 0)
672 continue;
673 name = j ? g_reader->stats_mem->obj_name[threadId][j] : (char *)"other";
674
675 //name = j ? g_reader->obj_name[j] : (char *)"other";
676
677 if (stat->peak || stat->fail)
678 printf("\t\t%-20s%10" PRIu64 "%10" PRIu64 "%10" PRIu64 "\n", name, stat->curr, stat->peak, stat->fail);
679 }
680 }
681 printf("\n\n");
682}
683
684
685void navl_results2(int fp_thread)
686{
687 int idx;
688 int i,j;
689 uint64_t total_packets, total_bytes;
690 void* pShmEntry;
691 void* pShmBase;
692 void* pTemp;
693 navl_wrapper_cfg_info_t *pNavlCfg;
694 navl_wrapper_pkt_stat_t *pStats1;
695 navl_wrapper_pkt_stat_t *pStats2;
696 navl_mcb_t g_reader;
697 navl_wrapper_stat_t *stat;
698 char *name;
699
700 pShmBase = hplib_shmOpen();
701 if (pShmBase)
702 {
703 pTemp = hplib_shmGetEntry(pShmBase, APP_ENTRY_1);
704 pNavlCfg = (navl_wrapper_cfg_info_t*)pTemp;
705
706 g_reader.stats_pkt[0] = pTemp + sizeof(navl_wrapper_cfg_info_t);
707
708
709 g_reader.stats_pkt[1] = pTemp + sizeof(navl_wrapper_cfg_info_t) +
710 (sizeof(navl_wrapper_pkt_stat_t)*pNavlCfg->num_protocols);
711
712 pTemp = hplib_shmGetEntry(pShmBase, APP_ENTRY_3);
713 g_reader.stats_mem = (navl_wrapper_mem_stats_t*) pTemp;
714 }
715 total_packets = 0;
716 total_bytes = 0;
717
718 //if (g_reader->option_dpi)
719 {
720 printf("\n NAVL DPI stats for CORE ID %d\n", fp_thread);
721 printf("\n AppProto Packets Class Bytes Cycles/Pkt Cyclesnomem/Pkt (min) (max) ");
722 for(i=0;i<MAX_BIN;i++)
723 printf("<%s ",binStr[i]);
724 printf("\n ----------------------------------------------------------------------------------------------------------------------------------------------------\n");
725 }
726
727 //for (idx = 0; idx < g_reader->config_num_proto; idx++)
728 for (idx = 0; idx < pNavlCfg->num_protocols; idx++)
729 {
730 //if (g_reader->option_dpi)
731 {
732 if (g_reader.stats_pkt[fp_thread][idx].packets)
733 {
734 /* We need to provide protocol definitions */
735 printf(" %-12s%-12" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %ld %ld " ,
736 g_reader.stats_pkt[fp_thread][idx].name,
737 g_reader.stats_pkt[fp_thread][idx].packets,
738 g_reader.stats_pkt[fp_thread][idx].class,
739 g_reader.stats_pkt[fp_thread][idx].bytes,
740 g_reader.stats_pkt[fp_thread][idx].cycles/g_reader.stats_pkt[fp_thread][idx].packets,
741 g_reader.stats_pkt[fp_thread][idx].cycles_nomem/g_reader.stats_pkt[fp_thread][idx].packets,
742 g_reader.stats_pkt[fp_thread][idx].cycles_min,
743 g_reader.stats_pkt[fp_thread][idx].cycles_max);
744 for(i=0;i<MAX_BIN;i++) printf("%ld ",g_reader.stats_pkt[fp_thread][idx].bin_cycles[i]);
745 printf("\n");
746 }
747 }
748
749 total_packets += g_reader.stats_pkt[fp_thread][idx].packets;
750 total_bytes += g_reader.stats_pkt[fp_thread][idx].bytes;
751 }
752
753 if (!total_packets)
754 printf("\n No packets captured.\n");
755 else
756 printf("\n %" PRIu64 " packets captured (%" PRIu64 " bytes)\n", total_packets, total_bytes);
757
758
759 printf("\n");
760 //if (g_reader.option_track_memory)
761 printf(" Curr Peak Fail \n");
762 printf("-----------------------------------------------------------------------");
763
764 for (i = 0; i < NUM_MEM_CTX; i++)
765 {
766 stat = &g_reader.stats_mem->mstats[fp_thread][i][0];
767 if (stat->peak == 0)
768 continue;
769
770 printf("\n\t%s\n", g_reader.stats_mem->ctx_name[fp_thread][i]);
771 //printf("\n\t%s\n", g_reader->ctx_name[i]);
772
773 for (j = NUM_MEM_OBJ - 1; j >= 0; j--)
774 {
775 navl_wrapper_stat_t *stat = &g_reader.stats_mem->mstats[fp_thread][i][j];
776 if (stat->peak == 0)
777 continue;
778 name = j ? g_reader.stats_mem->obj_name[fp_thread][j] : (char *)"other";
779
780 //name = j ? g_reader->obj_name[j] : (char *)"other";
781
782 if (stat->peak || stat->fail)
783 printf("\t\t%-20s%10" PRIu64 "%10" PRIu64 "%10" PRIu64 "\n", name, stat->curr, stat->peak, stat->fail);
784 }
785 }
786 printf("\n\n");
787
788#if 0
789 if (g_reader.stats_conns)
790 printf(" %" PRIu64 " connections tracked\n", g_reader.stats_conns);
791
792 if (pNavlCfg->alloc_curr != 0)
793 printf("Bytes not freed: %" PRIi64 "\n", pNavlCfg->alloc_curr);
794
795 if (g_reader.alloc_peak != 0)
796 printf("Peak allocated: %" PRIi64 "\n", g_reader.alloc_peak);
797
798 printf("attr test: last http utl= %s\n",last_url);
799#endif
800}
801
802
803
804/* Private memory stamp type for tracking memory with navl_wrapper_malloc/free */
805typedef struct
806{
807 size_t size; /* size of allocation */
808 short ctx_tag; /* ctx axis */
809 short obj_tag; /* obj axis */
810 char mem[0];
811} memstamp_t;
812
813static void *navl_wrapper_malloc(size_t size)
814{
815 navl_handle_t handle;
816 navl_wrapper_stat_t *stat_mem;
817 int tag;
818 int ctx_tag, obj_tag;
819 unsigned long t1;
820 unsigned long t2;
821 int threadId =Osal_nwalGetProcId();
822 pDpiStats->malloc_inst+=1;
823 pDpiStats->malloc_bytes+=size;
824 t1=netapi_timing_start();
825
826 assert(size);
827
828 /* In this context, the handle should be read using navl_handle_get() since
829 * the application cached handle (in this case g_reader->navl) will not be set
830 * until navl_open() returns. For this simple test we just assert that the handle
831 * is infact valid. */
832 handle = navl_handle_get();
833 assert(handle != 0);
834
835 /* Fetch the tags associated with this allocation. They will be used below to record
836 * statistics about allocations within the library on 2 axis. The upper 16 bits contain
837 * a memory obj tag and the lower 16 bits contain the allocation context tag. These
838 * tags are indices, the upper of which is available through navl_memory_ctx_num()
839 * and navl_memory_obj_num() resp. They are generated dynamically and may differ between
840 * configurations. These total number of indices are available ONLY AFTER navl_open()
841 * returns.
842 */
843 tag = navl_memory_tag_get(handle);
844 obj_tag = (tag >> 16);
845 ctx_tag = (tag & 0x0000FFFF);
846
847 /* You could do something better here and reallocate the matrix */
848 if (ctx_tag >= g_reader->config_num_memctx || obj_tag >= g_reader->config_num_memobj)
849 {
850 assert(0);
851 return NULL;
852 }
853
854 stat_mem = &g_reader->stats_mem->mstats[threadId][ctx_tag][obj_tag];
855
856 /* check limits */
857 if (!g_reader->option_limit_memory || (pNavlCfg->alloc_curr + size < g_reader->option_limit_memory))
858 {
859 memstamp_t *ptr = (memstamp_t *)malloc(size + sizeof(memstamp_t));
860 if (ptr)
861 {
862 /* track peak values */
863 if ((pNavlCfg->alloc_curr += size) > g_reader->alloc_peak)
864 g_reader->alloc_peak = pNavlCfg->alloc_curr;
865
866 if ((stat_mem->curr += size) > stat_mem->peak)
867 stat_mem->peak = stat_mem->curr;
868
869 ptr->size = size;
870 ptr->ctx_tag = ctx_tag;
871 ptr->obj_tag = obj_tag;
872 t2=netapi_timing_start();
873 pDpiStats->malloc_cycles += (unsigned long long) (t2-t1);
874 return ptr->mem;
875 }
876 }
877 stat_mem->fail += size;
878 return NULL;
879}
880
881static void
882navl_wrapper_free(void *p)
883{
884 unsigned long t1;
885 unsigned long t2;
886 int threadId =Osal_nwalGetProcId();
887 pDpiStats->free_inst += 1;
888 t1=netapi_timing_start();
889 if (!p)
890 return;
891
892 memstamp_t *ptr = (memstamp_t *)((char *)p - offsetof(memstamp_t, mem));
893 navl_wrapper_stat_t *stat_mem = &g_reader->stats_mem->mstats[threadId][ptr->ctx_tag][ptr->obj_tag];
894
895 assert(p == ptr->mem);
896
897 stat_mem->curr -= ptr->size;
898 pNavlCfg->alloc_curr -= ptr->size;
899
900 free(ptr);
901 t2=netapi_timing_start();
902 pDpiStats->free_cycles += (unsigned long long) (t2-t1);
903}
904
905static int
906navl_wrapper_log_message(const char *level, const char *func, const char *format, ... )
907{
908 int res = 0;
909 char buf[4096];
910 va_list va;
911 va_start(va, format);
912
913 res = snprintf(buf, 4096, "%s: %s: ", level, func);
914 res += vsnprintf(buf + res, 4096 - res, format, va);
915 printf("%s\n", buf);
916 va_end(va);
917 return res;
918}
919
920//clear stats
921void clear_pkt_stats()
922{
923 int ret, i;
924
925
926 for (i=0;i < NUM_FP_PROCS;i++)
927 {
928 memset(g_reader->stats_pkt[i], 0, (sizeof(navl_wrapper_pkt_stat_t)*MAX_PROTOCOLS));
929 /* now fetch all the protocol name ahead of time do we don't have to lookup them up on each packet */
930 for (ret = 0; ret != MAX_PROTOCOLS; ret++)
931 {
932 g_reader->stats_pkt[i][ret].cycles_min=10000000;
933 navl_proto_get_name(g_reader->navl, ret,
934 g_reader->stats_pkt[i][ret].name,
935 sizeof(g_reader->stats_pkt[i][ret].name));
936 }
937 }
938}
diff --git a/ti/runtime/netapi/demo/src/navl_wrapper.h b/ti/runtime/netapi/demo/src/navl_wrapper.h
new file mode 100755
index 0000000..aba6f8e
--- /dev/null
+++ b/ti/runtime/netapi/demo/src/navl_wrapper.h
@@ -0,0 +1,198 @@
1/******************************************************************************
2 * FILE PURPOSE: User space access to transport resources on SOC
3 ******************************************************************************
4 * FILE NAME: navl_wrapper.h
5 *
6 * DESCRIPTION: NAVL Wrapper definitions and data structures
7 *
8 * REVISION HISTORY:
9 *
10 * Copyright (c) Texas Instruments Incorporated 2014
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
22 * distribution.
23 *
24 * Neither the name of Texas Instruments Incorporated nor the names of
25 * its contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 */
41/* ============================================================= */
42/**
43 * @file netapi.h
44 *
45 * path ti/runtime/netapi/demo/src/navl_wrapper.h
46 *
47 * @brief
48 *
49 */
50
51
52
53#ifndef __NAVL_WRAPPER_H
54#define __NAVL_WRAPPER_H
55
56#ifdef __cplusplus
57extern "C" {
58#endif
59
60#include <stdio.h>
61#include <stdint.h>
62#include <stdlib.h>
63#include <stddef.h>
64#include <string.h>
65#include <navl/navl.h>
66
67#define NUM_PROCS 3
68
69#define NUM_FP_PROCS 2
70
71#define MAX_PROTOCOLS 1500
72#define NUM_MEM_CTX 50
73#define NUM_MEM_OBJ 50
74
75#define MAX_BIN 10
76typedef struct
77{
78 uint32_t num_threads;
79 uint32_t num_protocols;
80 uint32_t enable_dpi;
81 int64_t alloc_curr;
82} navl_wrapper_cfg_info_t;
83
84
85
86
87typedef struct
88{
89unsigned long n_ops;
90unsigned long n_class;
91unsigned long min_time;
92unsigned long max_time;
93unsigned long long tot;
94unsigned long m_op;
95unsigned long m_bytes;
96unsigned long n_err;
97unsigned long f_op;
98unsigned long m_cycles;
99unsigned long f_cycles;
100unsigned long long malloc_cycles;
101unsigned long long free_cycles;
102int malloc_inst;
103int malloc_bytes;
104int free_inst;
105} navl_global_dpi_stats;
106
107
108
109
110/* for tracking packet stats */
111typedef struct
112{
113 uint64_t packets;
114 uint64_t bytes;
115 char name[9];
116 uint64_t cycles;
117 uint64_t cycles_nomem;
118 unsigned long cycles_max;
119 unsigned long cycles_min;
120 uint64_t class; //# packets classified
121 long bin_cycles[MAX_BIN];
122 uint32_t pad[3];
123} navl_wrapper_pkt_stat_t;
124
125
126
127/* for tracking packets per thread/core basis */
128typedef struct
129{
130 navl_wrapper_cfg_info_t navl_cfg;
131 navl_wrapper_pkt_stat_t stats_pkt[NUM_FP_PROCS];
132} navl_wrapper_shm_pkt_stats_t;
133
134
135
136
137/* for tracking memory stats */
138typedef struct
139{
140 int64_t curr;
141 int64_t peak;
142 int64_t fail;
143} navl_wrapper_stat_t;
144
145typedef struct
146{
147 navl_wrapper_stat_t mstats[NUM_FP_PROCS][NUM_MEM_CTX][NUM_MEM_OBJ];
148 char ctx_name[NUM_FP_PROCS][NUM_MEM_CTX][64];
149 char obj_name[NUM_FP_PROCS][NUM_MEM_OBJ][64];
150} navl_wrapper_mem_stats_t;
151
152
153
154/* instance variables */
155typedef struct {
156/* handles */
157 navl_handle_t navl;
158
159 /* configuration */
160 const char *config_capfile;
161 const char *config_plugins;
162 int config_num_proto;
163 int config_conn_id_attr;
164 int config_http_attr;
165 int config_num_memctx;
166 int config_num_memobj;
167
168 /* options */
169 int option_dpi;
170 int option_simple;
171 int option_track_memory;
172 int option_limit_memory;
173 int option_tunnel;
174 int option_realtime_mode;
175 int option_verbose;
176
177 /* diagnostics */
178 int error_navl;
179
180 /* statistics */
181//#define NUM_MEM_CTX 50
182//#define NUM_MEM_OBJ 50
183 navl_wrapper_mem_stats_t *stats_mem;
184 //char ctx_name[NUM_MEM_CTX][64];
185 //char obj_name[NUM_MEM_OBJ][64];
186 navl_wrapper_pkt_stat_t *stats_pkt[NUM_FP_PROCS];
187 uint64_t stats_conns;
188
189 /* misc vars */
190 int running;
191 int64_t alloc_curr;
192 int64_t alloc_peak;
193} navl_mcb_t;
194
195#ifdef __cplusplus
196}
197#endif
198#endif
diff --git a/ti/runtime/netapi/demo/src/transport_dpi_demo.c b/ti/runtime/netapi/demo/src/transport_dpi_demo.c
new file mode 100755
index 0000000..0a887ef
--- /dev/null
+++ b/ti/runtime/netapi/demo/src/transport_dpi_demo.c
@@ -0,0 +1,1093 @@
1/******************************************
2 * File: nt_bench.c
3 * Purpose: benchmarks for NT.
4 **************************************************************
5 * FILE: nt_bench.c
6 *
7 * DESCRIPTION: netapi user space transport
8 * library test application : benchmarks
9 *
10 * REVISION HISTORY: rev 0.0.1
11 *
12 * Copyright (c) Texas Instruments Incorporated 2010-2011
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
42 *****************************************/
43
44#include <stdio.h>
45#include <stdlib.h>
46#include <unistd.h>
47#include <string.h>
48#include <signal.h>
49#include <pthread.h>
50#include <sched.h>
51
52//#include "trie.h"
53#include <ti/runtime/netapi/netapi.h>
54#include <ti/runtime/hplib/hplib.h>
55#include "ti/runtime/netapi/pktio.h"
56#include "transport_dpi_demo.h"
57#include "navl_wrapper.h"
58//#include "ti/runtime/netapi/test/net_test.h"
59#include <ti/drv/sa/salld.h>
60
61#include <ti/drv/qmss/device/k2e/src/qmss_device.c>
62#include <ti/drv/cppi/device/k2e/src/cppi_device.c>
63
64extern Rm_ServiceHandle *rmClientServiceHandle;
65extern NETCP_CFG_EXCEPTION_PKT_T expPkt_appid;
66
67
68#define netapi_timing_start hplib_mUtilGetPmuCCNT
69
70navl_wrapper_cfg_info_t *pNavlCfg;
71navl_wrapper_pkt_stat_t *pStats1;
72navl_wrapper_pkt_stat_t *pStats2;
73navl_global_dpi_stats *pGlobDpiStats;
74navl_wrapper_mem_stats_t *pNavlMemStats;
75
76
77void* pTemp;
78
79
80STATS_T stats;
81paSysStats_t netcp_stats;
82//struct dpi_stats dpis;
83
84#define VDPI
85#ifdef VDPI
86static int DPI=0; //1 to enable
87static int DUMP_DPI_CONN=0;
88#endif
89
90
91void* pShmBase;
92void *pShmEntry;
93
94
95
96static int scnt=0;
97volatile static int QUIT=0;
98static int XMIT=0;
99static int CAP=0;
100volatile int RESET=0; //to reset stats
101static int NTH=1;
102volatile static int PKTGEN=0;
103int pkt_len=64;
104
105
106
107NETCP_CFG_MACIF_T mac[NUM_PROCS];
108NETCP_CFG_MACIF_T mac0;
109NETCP_CFG_MACIF_T mac1;
110
111hplib_spinLock_T dpi_demo_thread_lock;
112
113
114static char usage[] = "usage: %s -s \n";
115
116
117
118
119//int procs =2;
120
121#define HPLIB_THREADID 0 // for main: HPLIB THREAD INSTANCE
122//__thread int our_core;
123static unsigned char dummy_mac[]={0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x01,0x02,0x03,0x04,0x05,0x08,0x00};
124
125void house(NETAPI_SCHED_HANDLE_T *s);
126void our_stats_cb_mt(NETAPI_T h, paSysStats_t* pPaStats);
127void our_stats_cb(NETAPI_T h, paSysStats_t* pPaStats);
128
129//sig handler
130void netTest_utilMySig(int x)
131{
132 QUIT=1;
133 scnt+=1;
134 printf(">net_test_dpi: recv'd signal %d cnt=%d\n",x,scnt);
135 if (scnt > 10) {printf(">dpi-demo: WARNING EXITING WITH PROPER SHUTDOWN LUTS LEFT ACTIVE\n");exit(1);}
136
137}
138
139
140void recv_cb_bridge(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
141 PKTIO_METADATA_T meta[], int n_pkts,
142 uint64_t ts );
143
144
145/*************debug********************/
146void netTest_utilDumpDescr(unsigned long *p, int n)
147{
148 printf("--------dump of descriptor %d %x\n", n, (int) p);
149 printf("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
150 printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
151 printf("-----------------------------\n");
152}
153void netTest_utilDumpHeader(unsigned long *p, int n, int a, int r)
154{
155 printf("--------dump of header %d %x appID=%x flag1=%x\n", n, (int) p,a,r);
156 printf("> %0x %0x %0x %0x %0x %0x %0x %0x\n",
157 ntohl(p[0]),ntohl(p[1]),ntohl(p[2]),ntohl(p[3]),
158 ntohl(p[4]),ntohl(p[5]),ntohl(p[6]),ntohl(p[7]) );
159#if 0
160 printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
161 printf("> %x %x %x %x %x %x %x %x\n",p[16],p[17],p[18],p[19],p[20],p[21],p[22],p[23]);
162 printf("> %x %x %x %x %x %x %x %x\n",p[24],p[25],p[26],p[27],p[28],p[29],p[30],p[31]);
163#endif
164 printf("-----------------------------\n");
165}
166/*****************************************/
167
168void house(NETAPI_SCHED_HANDLE_T * s)
169{
170 int err;
171 NETAPI_SCHED_SHUTDOWN_T sched_shutdown;
172 int coreid; //who we are
173 NETAPI_T nh= netapi_schedGetHandle(s);
174 coreid=(int) netapi_getCookie(nh);
175
176 if (QUIT)
177 {
178 sched_shutdown.shutdown_type = NETAPI_SCHED_SHUTDOWN_NOW;
179 netapi_schedClose(s,&sched_shutdown,&err);
180 return;
181 }
182
183
184#ifdef VDPI
185 if (DUMP_DPI_CONN )
186 navl_dump_conn_info();
187#endif
188
189
190 /* only slow path threads get netcp stats, this needs to be set in cookie
191 during slow path thread creation*/
192 if (coreid & SP_THREAD_MASK)
193 {
194 netapi_netcpCfgReqStats(nh, our_stats_cb_mt, 0,&err);
195 }
196
197}
198
199unsigned long long CALIB=0;
200unsigned long long calibrate_idle(void)
201{
202 volatile unsigned long long at1;
203 volatile unsigned long long at2;
204 volatile unsigned long pt1;
205 volatile unsigned long pt2;
206 unsigned long long calib;
207 at1 = hplib_mUtilGetTimestamp();
208 pt1=netapi_timing_start();
209 for(;;)
210 {
211 pt2=netapi_timing_start() ;
212 if ((pt2-pt1) >= 100000) break;
213 }
214 at2 = hplib_mUtilGetTimestamp();
215
216 calib = ((unsigned long long) (pt2-pt1))/(at2-at1);
217 printf("calibrate: arm time=%lld -> arm cycles=%d calib=%lld\n", at2-at1, pt2-pt1, calib);
218
219 return calib;
220}
221
222/*******************************************
223 *************NETAPI OBJECTS***************
224 *****************************************/
225static NETAPI_CFG_T our_netapi_default_cfg=
226{
227TUNE_NETAPI_PERM_MEM_SZ,
228128, //start of packet offset for hw to place data on rx for default flow
229TUNE_NETAPI_QM_CONFIG_MAX_DESC_NUM, //max number of descriptors in system
230TUNE_NETAPI_NUM_GLOBAL_DESC, //total we will use
231TUNE_NETAPI_DEFAULT_NUM_BUFFERS, //#descriptors+buffers in default heap
23264, //#descriptors w/o buffers in default heap
233TUNE_NETAPI_DEFAULT_BUFFER_SIZE+128+128, //size of buffers in default heap
234128, //tail room
235256, //extra room
2360,
237NULL
238};
239
240Pktlib_HeapHandle OurHeap; //default heap, used by producer
241PKTIO_HANDLE_T * netcp_rx_chan;
242PKTIO_HANDLE_T * netcp_rx_chan2;
243PKTIO_HANDLE_T * netcp_tx_chan;
244
245PKTIO_CFG_T our_chan_cfg={PKTIO_RX_TX, PKTIO_LOCAL, PKTIO_Q_ANY, 8};
246PKTIO_CFG_T netcp_rx_cfg={PKTIO_RX, PKTIO_NA, PKTIO_NA, 8};
247PKTIO_CFG_T netcp_rx_cfg2={PKTIO_RX, (PKTIO_GLOBAL|PKTIO_PKT), PKTIO_Q_ANY, 8};
248PKTIO_CFG_T netcp_tx_cfg={PKTIO_TX, PKTIO_NA, PKTIO_NA, 8};
249NETAPI_T netapi_handle;
250NETAPI_SCHED_HANDLE_T * our_sched;
251NETAPI_SCHED_HANDLE_T * scheduler[TUNE_NETAPI_NUM_CORES];
252NETAPI_SCHED_CONFIG_T our_sched_cfg={
253 NETAPI_SCHED_DURATION|NETAPI_SCHED_CBV, 0, house, 5000000 //every 5000000 poll loops
254};
255
256NETCP_CFG_IP_T ip_rule0;
257NETCP_CFG_IP_T ip_rule1;
258
259
260PKTIO_CFG_T direct_to_cpsw_cfg={PKTIO_TX, PKTIO_GLOBAL, 648, 8};
261PKTIO_HANDLE_T * cpsw_tx_chan;
262
263PKTIO_CONTROL_T zap_channel_control={PKTIO_CLEAR, NULL};
264PKTIO_CONTROL_T poll_cannel_control={PKTIO_SET_POLL_FLAGS, NULL, nwal_POLL_DEFAULT_GLOB_PKT_Q};
265
266//template for fast path
267nwalTxPktInfo_t txPktInfoNoCrypto =
268{
269 NULL, /* p_pkt */
270 NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
271 0, /* lpbackPass */
272 0, /* enetport */
273 0, /* msuSize */
274 0, /* startOffset */
275 0, /* saOffBytes */
276 0, /* saPayLoadLen */
277 0 , /* saAhIcvOffBytes */
278 0, /* saAhMacSize */
279 0, /* etherLenOffBytes */
280 MAC_HEADER_LEN, /* ipOffBytes */
281 MAC_HEADER_LEN + IP_HEADER_LEN, /* l4OffBytes */
282 UDP_HEADER_LEN, /* l4HdrLen */
283 0, /* pseudoHdrChecksum */
284 0 /* pLoadLen */
285};
286
287
288NETCP_CFG_ROUTE_T test_route=
289{
2900,
291NULL,
292NULL,
2930,
2940,
2950,
2961
297};
298
299NETCP_CFG_FLOW_HANDLE_T kernelFlow22;
300NETCP_CFG_FLOW_HANDLE_T kernelFlow23;
301
302/*************************END NETAPI OBJECTS***********************/
303
304static unsigned char all_mac[]={0,0,0,0,0,0};
305nwalIpAddr_t all_ip={0,0 , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
306
307
308static unsigned char all_dest[]={0xff,0xff,0xff,0xff,0xff,0xff};
309
310
311
312
313static unsigned long last_header[32/sizeof(unsigned long)];
314static unsigned long last_desc[64/sizeof(unsigned long)];
315
316//stats
317#define MAX_CORE 4
318int pkt_rx[MAX_CORE];
319int pkt_tx[MAX_CORE];
320unsigned long long pkt_rx_cycles[MAX_CORE]={0L};
321unsigned long long pkt_tx_cycles[MAX_CORE]={0L};
322unsigned long long pkt_cb_cycles[MAX_CORE]={0L};
323unsigned long long idle_cycles[MAX_CORE]={0L};
324volatile unsigned long long start_time[MAX_CORE];
325unsigned long long end_time[MAX_CORE];
326unsigned long long pkt_stall[MAX_CORE]={0L};
327//*********************************
328// packet generator
329//*********************************
330void gen_pkts(int np, int out_port);
331
332/******************************************************
333 * stats callback
334 *******************************************************/
335void our_stats_cb_mt(NETAPI_T h, paSysStats_t* pPaStats)
336{
337 stats.n_stats_cb +=1;
338 if(pPaStats) memcpy(&netcp_stats,pPaStats, sizeof(paSysStats_t));
339}
340
341void our_stats_cb(NETAPI_T h, paSysStats_t* pPaStats)
342{
343 uint32_t numFreeDataPackets;
344 uint32_t numZeroBufferPackets;
345 uint32_t numPacketsinGarbage;
346 Pktlib_HeapStats pktLibHeapStats;
347 int i,j;
348 unsigned long long bcpp;
349 unsigned long long bcpp_noc;
350 unsigned long long bcpp_app;
351 unsigned long long bcpp_tx;
352 unsigned long long npL;
353 unsigned long long cyclesL;
354 unsigned long long ccyclesL; //cache cycles
355 unsigned long long tmp_npL[TUNE_NETAPI_NUM_CORES];
356 unsigned long long tmp_cyclesL[TUNE_NETAPI_NUM_CORES];
357 unsigned long long tmp_ccyclesL[TUNE_NETAPI_NUM_CORES]; //cache cycles
358 NETAPI_SA_STATS_T netapi_sa_stats;
359
360 printf(">*****stats @ %lld (#cbs%d) \n", hplib_mUtilGetTimestamp(),stats.n_stats_cb);
361 //printf("netcp_tx_handle check %x\n", netcp_tx_chan->back);
362 printf(">itx=%d rx=%d tx=%d bad=%d slow=%d \n>rx_class0=%d rx_class1=%d rx_class2=%d secRx=%d secPRX=%d sb_rx=%d sb_tx=%d auth_ok=%d sec_tx=%d min_rx=%d min_tx=%d ip=%d\n",
363 stats.itx, stats.rx, stats.tx, stats.n_bad, stats.n_new,
364 stats.n_class0_rx, stats.n_class1_rx,
365 stats.n_class2_rx, stats.sec_rx, stats.secp_rx, stats.sb_rx, stats.sb_tx, stats.n_auth_ok,
366 stats.sec_tx, stats.rx_min, stats.tx_min, stats.ip);
367 printf(">if rx stats: %d %d %d\n",stats.if_rx[0],stats.if_rx[1],stats.if_rx[2]);
368
369
370 printf(">core rx stats: %d %d %d\n",stats.core_rx[1],stats.core_rx[2],stats.core_rx[3]);
371
372
373 for (j= 1;j < NUM_PROCS;j++)
374 {
375 tmp_npL[j]=0LL; tmp_cyclesL[j]=0LL; tmp_ccyclesL[j]=0LL;
376 netapi_schedGetStats(scheduler[j],&tmp_npL[j],&tmp_cyclesL[j],&tmp_ccyclesL[j]);
377 npL += tmp_npL[j];
378 cyclesL += tmp_cyclesL[j];
379 ccyclesL += tmp_ccyclesL[j];
380 }
381
382 if (npL && stats.rx)
383 {
384 bcpp = cyclesL/npL;
385 bcpp_noc = (cyclesL-ccyclesL)/npL;
386 bcpp_app = (stats.app_cycles-stats.tx_cache_cycles)/stats.rx;
387 }
388 else {bcpp = bcpp_noc=bcpp_app=0L;}
389 if (stats.tx)
390 {
391 bcpp_tx = (stats.send_cycles-stats.tx_cache_cycles)/stats.tx;
392 }
393 else
394 {
395 bcpp_tx = 0L;
396 }
397 printf("> ++ busy cycles pp=%lld (%lld wo cache ops) (app+tx= %lld) (tx= %lld) ++\n",
398 bcpp,bcpp_noc,bcpp_app, bcpp_tx);
399
400
401#ifdef VDPI
402 navl_return_stats(
403 &pGlobDpiStats->n_ops,
404 &pGlobDpiStats->n_class,
405 &pGlobDpiStats->min_time,
406 &pGlobDpiStats->max_time,
407 &pGlobDpiStats->tot,
408 &pGlobDpiStats->m_op,
409 &pGlobDpiStats->m_bytes,
410 &pGlobDpiStats->n_err,
411 &pGlobDpiStats->f_op,
412 &pGlobDpiStats->m_cycles,
413 &pGlobDpiStats->f_cycles);
414
415 printf("dpi stats: nops=%d nclass=%d min cycle=%d max cycle=%d ave cycle=%lld #mallocs=%d #mbytes=%d n_err=%d fops=%d mCycles=%d fCycles=%d\n",
416 pGlobDpiStats->n_ops,
417 pGlobDpiStats->n_class,
418 pGlobDpiStats->min_time,
419 pGlobDpiStats->max_time,
420 pGlobDpiStats->n_ops? pGlobDpiStats->tot/pGlobDpiStats->n_ops : 0,
421 pGlobDpiStats->m_op,
422 pGlobDpiStats->m_bytes,
423 pGlobDpiStats->n_err,
424 pGlobDpiStats->f_op, pGlobDpiStats->m_cycles, pGlobDpiStats->f_cycles);
425 for(i=0; i< NUM_FP_PROCS;i++)
426 {
427 navl_results(i);
428 }
429#endif
430 if(pPaStats)
431 {
432 printf("C1 number of packets: %d\n", pPaStats->classify1.nPackets);
433 printf("C1 number IPv4 packets: %d\n", pPaStats->classify1.nIpv4Packets);
434 printf("C1 number IPv6 packets: %d\n", pPaStats->classify1.nIpv6Packets);
435 printf("C1 number Custom packets: %d\n", pPaStats->classify1.nCustomPackets);
436 printf("C1 number SRIO packets: %d\n", pPaStats->classify1.nSrioPackets);
437 printf("C1 number LLC/SNAP Fail packets: %d\n", pPaStats->classify1.nLlcSnapFail);
438 printf("C1 number table matched: %d\n", pPaStats->classify1.nTableMatch);
439 printf("C1 number failed table matched: %d\n", pPaStats->classify1.nNoTableMatch);
440 printf("C1 number IP Fragmented packets: %d\n", pPaStats->classify1.nIpFrag);
441 printf("C1 number IP Depth Overflow: %d\n", pPaStats->classify1.nIpDepthOverflow);
442 printf("C1 number VLAN Depth Overflow: %d\n", pPaStats->classify1.nVlanDepthOverflow);
443 printf("C1 number GRE Depth Overflow: %d\n", pPaStats->classify1.nGreDepthOverflow);
444 printf("C1 number MPLS Packets: %d\n", pPaStats->classify1.nMplsPackets);
445 printf("C1 number of parse fail: %d\n",pPaStats->classify1.nParseFail);
446 printf("C1 number of Invalid IPv6 Opt: %d\n", pPaStats->classify1.nInvalidIPv6Opt);
447 printf("C1 number of TX IP Fragments: %d\n", pPaStats->classify1.nTxIpFrag);
448 printf("C1 number of silent discard: %d\n",pPaStats->classify1.nSilentDiscard);
449 printf("C1 number of invalid control: %d\n", pPaStats->classify1.nInvalidControl);
450 printf("C1 number of invalid states: %d\n",pPaStats->classify1.nInvalidState);
451 printf("C1 number of system fails: %d\n",pPaStats->classify1.nSystemFail);
452 printf("C2 number Packets : %d\n",pPaStats->classify2.nPackets);
453 printf("C2 number udp : %d\n",pPaStats->classify2.nUdp);
454 printf("C2 number tcp : %d\n",pPaStats->classify2.nTcp);
455 printf("C2 number Custom : %d\n",pPaStats->classify2.nCustom);
456 printf("C2 number silent drop : %d\n",pPaStats->classify2.nSilentDiscard);
457 printf("C2 number invalid cntrl : %d\n\n",pPaStats->classify2.nInvalidControl);
458 printf("C2 number Modify Stats Cmd Fail : %d\n\n",pPaStats->modify.nCommandFail);
459 }
460 Pktlib_getHeapStats(OurHeap, &pktLibHeapStats);
461
462 printf("main heap stats> #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
463 pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
464 printf(" > #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
465 pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
466 pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
467}
468
469NETAPI_T worker_nh[MAX_NUM_CORES];
470
471void slow_path_thread(uint32_t index)
472{
473 int err, i;;
474 uint32_t thread_num;
475 cpu_set_t cpu_set;
476
477 /* index being passed in is the core we want to run the thread on */
478 thread_num = index;
479 printf("slow_path_thread, mypid: %d, core_id %d\n", gettid(), thread_num);
480
481 CPU_ZERO( &cpu_set);
482 for (i = 0; i < 1;i++)
483 {
484 CPU_SET( i, &cpu_set);
485 }
486 hplib_utilSetupThread(thread_num, &cpu_set, hplib_spinLock_Type_LOL);
487 worker_nh[thread_num] = netapi_init(NETAPI_CORE_MASTER,NULL);
488
489 if (worker_nh[thread_num] == NULL)
490 {
491 printf("slow_path_thread: netapi_init failure, exiting\n");
492 exit(1);
493 }
494 netapi_setCookie(worker_nh[thread_num],(void*)(thread_num | SP_THREAD_MASK));
495
496 scheduler[thread_num] =netapi_schedOpen(worker_nh[thread_num],&our_sched_cfg, &err);
497 if (!scheduler[thread_num])
498 {
499 printf("sched create failed for core%d\n",thread_num);
500 goto ERR_slow_path_thread;
501 }
502 scheduler[thread_num]->config.yield = TRUE;
503 scheduler[thread_num]->config.pollGarbageQ = TRUE;
504 scheduler[thread_num]->config.pollCtrlQ = TRUE;
505 printf("Slow Path thread: %d setup complete, running on ARM CORE: %d\n",
506 index,index);
507
508
509 netapi_schedRun(scheduler[thread_num], &err);
510
511ERR_slow_path_thread:
512 printf("slow_path_thread: calling netapi_shutdown\n");
513 netapi_shutdown(worker_nh[thread_num]);
514}
515
516
517void fast_path_thread(uint32_t index)
518{
519 int err, i;
520 PKTIO_HANDLE_T *rx_chan;
521 PKTIO_HANDLE_T *sb_rx_chan;
522 uint32_t thread_num;
523 int navlHandle;
524
525
526 cpu_set_t cpu_set;
527
528 CPU_ZERO( &cpu_set);
529 thread_num = index;
530 printf("fast_path_thread: core %d\n", index);
531
532
533 CPU_SET( thread_num, &cpu_set);
534 hplib_utilSetupThread(thread_num, &cpu_set, hplib_spinLock_Type_LOL);
535
536
537 hplib_mSpinLockLock(&dpi_demo_thread_lock);
538 worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,NULL);
539
540 if (worker_nh[thread_num] == NULL)
541 {
542 printf("fast_path_thread: netapi_init failure, exiting\n");
543 hplib_mSpinLockUnlock(&dpi_demo_thread_lock);
544 exit(1);
545 }
546 else
547 {
548#ifdef VDPI
549 navlHandle = navl_per_thread_init(thread_num);
550#endif
551 }
552 hplib_mSpinLockUnlock(&dpi_demo_thread_lock);
553
554
555 if (worker_nh[thread_num] == NULL)
556 {
557 printf("fast_path_thread: netapi_init failure, exiting\n");
558 exit(1);
559 }
560
561 /* open netcp default RX channels*/
562 rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_RX, (PKTIO_CB) recv_cb_bridge, &netcp_rx_cfg, &err);
563
564
565 netapi_setCookie(worker_nh[thread_num],(void*)thread_num);
566
567 scheduler[thread_num] =netapi_schedOpen(worker_nh[thread_num],
568 &our_sched_cfg,
569 &err);
570 if (!scheduler[thread_num])
571 {
572 printf("sched create failed for core%d\n",thread_num);
573 goto ERR_fast_path_thread;
574 //exit(1);
575 }
576
577
578 scheduler[thread_num]->config.yield = FALSE;
579 scheduler[thread_num]->config.pollGarbageQ = FALSE;
580 scheduler[thread_num]->config.pollCtrlQ = FALSE;
581 /* Entry point to scheduler */
582
583
584 printf("Fast Path thread: %d setup complete, running on ARM CORE: %d\n",
585 index,index);
586 netapi_schedRun(scheduler[thread_num], &err);
587
588ERR_fast_path_thread:
589#ifdef VDPI
590 navl_fini(navlHandle);
591#endif
592 netapi_pktioClose(rx_chan, &err);
593
594 printf("fast_path_thread: calling netapi_shutdown\n");
595 netapi_shutdown(worker_nh[thread_num]);
596}
597
598
599/******************************
600* main program
601*****************************/
602int main(int argc, char **argv)
603{
604 int err,i;
605 int j;
606 int32_t errCode;
607 Pktlib_HeapIfTable* pPktifTable;
608 Pktlib_HeapCfg heapCfg;
609 long t1, t2 ;
610 cpu_set_t cpu_set;
611 int c;
612 int statsQueryRequest = 0;
613 pthread_t *thrs;
614 int p;
615
616
617
618
619#if 1
620
621 if (argc == 2)
622 {
623 printf("main: argument %s\n", argv[1]);
624 if(!(strcmp(argv[1], "stats")))
625 {
626 statsQueryRequest =1;
627 printf("querying for stats\n");
628 }
629 }
630 printf("statsQueryReqeust: %d\n", statsQueryRequest);
631
632
633#endif
634
635
636 if (!statsQueryRequest)
637 {
638 if (initRm())
639 {
640 printf("main: initRm() returned error\n");
641 exit(1);
642 }
643
644 signal(SIGINT,netTest_utilMySig);
645 CPU_ZERO( &cpu_set);
646 CPU_SET( 0, &cpu_set);
647 hplib_utilSetupThread(HPLIB_THREADID, &cpu_set, hplib_spinLock_Type_LOL);
648
649 /* create netapi */
650 our_netapi_default_cfg.rmHandle = rmClientServiceHandle;
651 netapi_handle = netapi_init(NETAPI_SYS_MASTER,
652 &our_netapi_default_cfg);
653 if (netapi_handle == NULL)
654 {
655 printf("main: netapi_init failure, exiting\n");
656 exit(1);
657 }
658 /* allocate segment for shared memory for packet stats */
659 /* allocate packet statistics */
660 pShmBase = hplib_shmOpen();
661 if (pShmBase)
662 {
663 if (hplib_shmAddEntry(pShmBase,
664 sizeof(navl_wrapper_pkt_stat_t)
665 * MAX_PROTOCOLS *NUM_FP_PROCS + sizeof(navl_wrapper_cfg_info_t),
666 APP_ENTRY_1) != hplib_OK)
667 {
668 printf("main: hplib_shmAddEntry failure\n");
669 return -1;
670 }
671 else
672 {
673 pShmEntry = hplib_shmGetEntry(pShmBase, APP_ENTRY_1);
674 pNavlCfg = (navl_wrapper_cfg_info_t*)pShmEntry;
675 memset(pNavlCfg,
676 0,
677 sizeof(navl_wrapper_pkt_stat_t) * MAX_PROTOCOLS *NUM_FP_PROCS+ sizeof(navl_wrapper_cfg_info_t));
678 pNavlCfg = (navl_wrapper_cfg_info_t*)pShmEntry;
679 pNavlCfg->enable_dpi = 0; /* disable DPI by default */
680 }
681 if (hplib_shmAddEntry(pShmBase, sizeof(navl_global_dpi_stats), APP_ENTRY_2) != hplib_OK)
682 {
683 printf("main: hplib_shmAddEntry failure\n");
684 return -1;
685 }
686 else
687 {
688 pShmEntry = hplib_shmGetEntry(pShmBase, APP_ENTRY_2);
689 pGlobDpiStats = (navl_global_dpi_stats*) pShmEntry;
690 memset(pGlobDpiStats, 0, sizeof(navl_global_dpi_stats));
691 pGlobDpiStats->min_time=100000000;
692 }
693 if (hplib_shmAddEntry(pShmBase, sizeof(navl_wrapper_stat_t)* (NUM_FP_PROCS *NUM_MEM_CTX * NUM_MEM_OBJ),
694 APP_ENTRY_3) != hplib_OK)
695 {
696 printf("main: hplib_shmAddEntry failure\n");
697 return -1;
698 }
699 else
700 {
701 pShmEntry = hplib_shmGetEntry(pShmBase, APP_ENTRY_3);
702 pNavlMemStats = (navl_wrapper_mem_stats_t*) pShmEntry;
703 memset(pNavlMemStats, 0, sizeof(navl_wrapper_mem_stats_t));
704 }
705
706 }
707 else
708 {
709 printf("main: hplib_shmOpen failure, exiting\n");
710 exit(1);
711 }
712 /* open the main heap */
713 OurHeap = Pktlib_findHeapByName("netapi");
714 if (!OurHeap)
715 {
716 printf("findheapbyname fail\n");
717 exit(1);
718 }
719
720 //if we want to relay network packets, we create a handle to the
721 //default netcp receive queue here
722 netcp_rx_chan= netapi_pktioOpen(netapi_handle, NETCP_RX, (PKTIO_CB) recv_cb_bridge, &netcp_rx_cfg, &err);
723 if (!netcp_rx_chan)
724 {
725 printf("pktio open RX failed err=%d\n",err);
726 exit(1);
727 }
728
729 netcp_tx_chan= netapi_pktioOpen(netapi_handle, NETCP_TX, (PKTIO_CB) NULL, &netcp_tx_cfg, &err);
730 if (!netcp_tx_chan)
731 {
732 printf("pktio open TX failed err=%d\n",err);
733 exit(1);
734 }
735 else //install a fast path template into the NETCP TX channel
736 {
737 PKTIO_CONTROL_T control2;
738 control2.op = PKTIO_UPDATE_FAST_PATH;
739 PKTIO_CFG_T cfg2;
740 memset(&cfg2, 0, sizeof(PKTIO_CFG_T));
741 cfg2.fast_path_cfg.fp_send_option = PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT;
742 cfg2.fast_path_cfg.txPktInfo= &txPktInfoNoCrypto;
743 netapi_pktioControl(netcp_tx_chan, NULL, &cfg2, &control2, &err);
744 }
745
746
747 if (navl_setup() < 0)
748 {
749 printf("main: navl_setup failure, exiting\n");
750 exit(1);
751 }
752
753 /*********************************************/
754 /*****************end NETAPI STARTUP**********/
755 /*********************************************/
756
757 //now creaate a simple netcp rule
758 //to get a lot of packets
759 mac0 = netapi_netcpCfgCreateMacInterface(
760 netapi_handle,
761 &all_mac[0],
762 NULL,
763 0,
764 1,
765 (NETCP_CFG_ROUTE_HANDLE_T) NULL,
766 (NETCP_CFG_VLAN_T ) NULL , //future
767 0x0800,
768 1,
769 &err);
770 if (err) {printf("addmac0 failed %d\n",err); exit(1); }
771 else printf("addmac0 sucess\n");
772
773 mac1 = netapi_netcpCfgCreateMacInterface(
774 netapi_handle,
775 &all_mac[0],
776 NULL,
777 1,
778 2,
779 (NETCP_CFG_ROUTE_HANDLE_T) NULL,
780 (NETCP_CFG_VLAN_T ) NULL , //future
781 0x0800,
782 1,
783 &err);
784 if (err) {printf("addmac1 failed %d\n",err); exit(1); }
785 else printf("addmac1 sucess\n");
786
787 //calibrate idle
788 CALIB = calibrate_idle();
789
790 //**************************************
791 //Create a slow path thread
792 //***************************************
793 thrs = malloc( sizeof( pthread_t ) * NUM_PROCS );
794 if (thrs == NULL)
795 {
796 perror( "malloc" );
797 return -1;
798 }
799 printf( "dpi-demo: Starting slow_path_thread on core 0\n");
800
801 if (pthread_create( &thrs[0], NULL, (void*)slow_path_thread,
802 (void *)0 )) //start at core 0
803 {
804 perror( "pthread_create" );
805 exit(1);
806 }
807
808
809 for (j= 1;j < NUM_PROCS;j++)
810 {
811 printf( "dpi-demo: Starting fast_path_thread on core 1\n");
812 if (pthread_create( &thrs[j], NULL, (void*)fast_path_thread,
813 (void *)j )) //start at core 1
814 {
815 perror( "pthread_create" );
816 exit(1);
817 }
818 }
819 }
820 else
821 {
822
823 pShmBase = hplib_shmOpen();
824 if (pShmBase)
825 {
826 pTemp = hplib_shmGetEntry(pShmBase, APP_ENTRY_1);
827 pNavlCfg = (navl_wrapper_cfg_info_t*)pTemp;
828
829 pStats1 = pTemp + sizeof(navl_wrapper_cfg_info_t);
830
831
832 pStats2 = pTemp + sizeof(navl_wrapper_cfg_info_t) +
833 (sizeof(navl_wrapper_pkt_stat_t)*pNavlCfg->num_protocols);
834
835 pTemp = hplib_shmGetEntry(pShmBase, APP_ENTRY_2);
836 pGlobDpiStats = (struct dpi_stats*) pTemp;
837
838 printf("dpi stats: nops=%d nclass=%d min cycle=%d max cycle=%d ave cycle=%lld #mallocs=%d #mbytes=%d n_err=%d fops=%d mCycles=%d fCycles=%d\n",
839 pGlobDpiStats->n_ops,
840 pGlobDpiStats->n_class,
841 pGlobDpiStats->min_time,
842 pGlobDpiStats->max_time,
843 pGlobDpiStats->n_ops? pGlobDpiStats->tot/pGlobDpiStats->n_ops : 0,
844 pGlobDpiStats->m_op,
845 pGlobDpiStats->m_bytes,
846 pGlobDpiStats->n_err,
847 pGlobDpiStats->f_op, pGlobDpiStats->m_cycles, pGlobDpiStats->f_cycles);
848 for(i=0;i < NUM_FP_PROCS; i++)
849 {
850 navl_results2(i);
851 }
852 exit(1);
853 }
854 }
855
856
857 //this thread of execution (main) now just waits on user input
858 for(;;)
859 {
860 printf(">");
861 c=getchar();
862 if (c=='C')
863 {
864 CAP=!CAP;
865 printf("CAPTURE= %d\n", CAP);
866 }
867 else if (c=='q') {QUIT=1;break;}
868 else if (c=='s')
869 our_stats_cb(netapi_handle, &netcp_stats);
870 #ifdef VDPI
871 else if (c=='c')
872 {navl_clear_stats();printf("> Clearing DPI stats\n");}
873 else if (c=='v') navl_set_verbose();
874 else if (c=='p')
875 {DUMP_DPI_CONN = !DUMP_DPI_CONN;printf("> **DPI CONN DUMP is %s ** \n", DUMP_DPI_CONN ?"enabled":"disabled");}
876 else if (c=='d')
877 {
878 pNavlCfg->enable_dpi = !pNavlCfg->enable_dpi;
879 printf("enable_dpi flag: %d\n", pNavlCfg->enable_dpi);
880 printf("> **DPI is %s ** \n", pNavlCfg->enable_dpi?"enabled":"disabled");
881 }
882 #endif
883 else if (c=='!') {system("sh");}
884
885 else if ((c=='h')||(c=='?'))
886 {
887 printf("> 'q' to quit, 's' for stats,'d' to dump capture\n,> 'h' for help\n ");
888 }
889 #if 1
890 else if (c=='r')
891 {
892 netTest_utilDumpHeader(&last_header[0], 0,0,0);
893 netTest_utilDumpDescr(&last_desc[0], 0);
894 }
895 #endif
896 }
897
898
899
900#ifdef VDPI
901 navl_done();
902#endif
903
904 //wait for completion
905 printf("main task now pending on thread completion\n");
906 for (i = 0; i < NUM_PROCS; i++)
907 pthread_join( thrs[i], NULL );
908
909 free( thrs );
910
911 /*************************************************
912 ************CLEAN UP****************************
913 ************************************************/
914 //get rid of rule, in the case that we are relaying packets
915 //also close our netcp rx channel
916 netapi_netcpCfgDelMac(netapi_handle,0,&err);
917 netapi_netcpCfgDelMac(netapi_handle,1,&err);
918
919 netapi_pktioClose(netcp_rx_chan,&err);
920 netapi_pktioClose(netcp_tx_chan,&err);
921
922
923 //done
924 netapi_shutdown(netapi_handle);
925
926
927}
928#if 1
929static inline void send_it(Ti_Pkt *tip, int len, int out_port)
930{
931 int err=0;
932 PKTIO_METADATA_T meta2 = {PKTIO_META_TX,{0},0};
933 nwalTxPktInfo_t meta_tx2={0};
934 int coreid=Osal_nwalGetProcId();
935 if (len<60)
936 {
937 unsigned int templen;
938 char * p_pkt;
939 len=60;
940 Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);//ignore templen
941 Cppi_setData (Cppi_DescType_HOST, (Cppi_Desc *) tip, p_pkt,len);
942 }
943 Pktlib_setPacketLen(tip,len);
944 meta_tx2.txFlag1 = NWAL_TX_FLAG1_META_DATA_VALID;
945 meta_tx2.ploadLen = len ;
946 meta_tx2.enetPort=out_port;
947 meta2.u.tx_meta=&meta_tx2;
948 stats.tx+=1;
949 if(coreid<MAX_NUM_CORES)
950 pkt_tx[coreid]+=1;
951 netapi_pktioSend(netcp_tx_chan,tip,&meta2,&err);
952}
953#endif
954void recv_cb_bridge(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
955 PKTIO_METADATA_T meta[], int n_pkts,
956 uint64_t ts )
957{
958int i;
959int len;
960int p;
961Ti_Pkt * tip;
962unsigned int appid;
963unsigned int templen;
964char * p_pkt;
965unsigned long t1;
966unsigned long t2;
967unsigned long long ct1;
968unsigned long long ct2;
969unsigned short ip_pl;
970unsigned long long n_c_ops;
971int ifno;
972int out_port;
973
974int coreid=Osal_nwalGetProcId();
975
976
977pasahoLongInfo_t* protoInfo;
978
979t1=netapi_timing_start();
980ct1 =Osal_cache_op_measure(&n_c_ops);
981for(i=0;i<n_pkts;i++)
982{
983
984 tip = p_recv[i];
985 appid = ((unsigned int)meta[i].u.rx_meta->appId)&0xff000000;
986 if (appid == NETAPI_NETCP_MATCH_GENERIC_IP)
987 {
988 stats.ip+=1;
989 }
990
991 protoInfo=nwal_mGetProtoInfo(tip);
992 ifno = nwal_mGetRxEmacPort( protoInfo);
993 if (ifno ==1) out_port=2; else out_port=1;
994 if(coreid<MAX_NUM_CORES) stats.core_rx[coreid]+=1;
995 if (ifno < MAX_NUM_INTERFACES) stats.if_rx[ifno]+=1;
996 Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);//ignore templen
997 if (CAP==coreid)
998 {
999 memcpy((unsigned char *)&last_header[0],p_pkt,32);
1000 memcpy((unsigned char*)&last_desc[0],tip,64);
1001 }
1002 len = Pktlib_getPacketLen(tip);//real length, subtract mac trailer
1003 stats.rx+=1;
1004 //printf("recv_cb_bridge: appId: 0x%x, out_port: %d\n", appid, out_port);
1005 if (appid == NETAPI_NETCP_MATCH_GENERIC_MAC)
1006 {
1007#ifdef VDPI
1008 {
1009 if (pNavlCfg->enable_dpi)
1010 navl_process_pkt(p_pkt, len);
1011 }
1012#endif
1013 }
1014
1015
1016 //printf("recv_cb_bridge: coreId: %d, outPort %d\n", coreid, out_port);
1017 //Pktlib_freePacket(tip);
1018 send_it(tip,len,out_port);
1019}
1020t2=netapi_timing_start();
1021ct2 =Osal_cache_op_measure(&n_c_ops);
1022stats.app_cycles += (unsigned long long) (t2-t1);
1023stats.tx_cache_cycles += (unsigned long long) (ct2-ct1);
1024return;
1025}
1026
1027#define NTOPOP 150
1028volatile Ti_Pkt * pHd[NTOPOP];
1029
1030#define PKTGEN_PKT_LEN pkt_len
1031#define MAXP 4 //max ports
1032void gen_pkts(int np, int out_port)
1033{
1034 int i;
1035 int p=0;
1036 unsigned long * pI ;
1037 Ti_Pkt * tip;
1038 int len;
1039 unsigned char * pData;
1040 int cstall=0;
1041 int coreid = Osal_nwalGetProcId();
1042 for(i=0;i<np;)
1043 {
1044 //set out output port
1045 if (out_port)
1046 {
1047 p=out_port;
1048 }
1049 else //flip flop
1050 {
1051 p+=1;
1052 if(p>MAXP) p=1;
1053 }
1054 //get a packet
1055 tip=Pktlib_allocPacket(OurHeap,PKTGEN_PKT_LEN);
1056 pI = (unsigned long *) tip;
1057 if (!tip)
1058 {
1059 pkt_stall[coreid]+=1;
1060 cstall+=1;
1061 if (cstall >= 100000)
1062 {
1063 printf("worker core %d, max stall hit,, exiting.\n",coreid);
1064 return;
1065 }
1066 continue;
1067 }
1068 cstall=0;
1069 Pktlib_getDataBuffer(tip,&pData,&len);
1070 memcpy(pData,&dummy_mac,14);
1071 Cppi_setData (Cppi_DescType_HOST, (Cppi_Desc *) tip, pData,PKTGEN_PKT_LEN);
1072 Pktlib_setPacketLen(tip,PKTGEN_PKT_LEN);
1073 pI[1]=0x80000000;
1074 //pI[2] &= 0xfff0ffff ;move to pktio send function
1075
1076 //capture packet just in case
1077 if (CAP==coreid)
1078 {
1079 unsigned int templen;
1080 char * p_pkt;
1081 Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);//ignore templen
1082 memcpy((unsigned char *)&last_header[0],p_pkt,32);
1083 memcpy((unsigned char*)&last_desc[0],tip,64);
1084 }
1085
1086 //send packet
1087 send_it(tip, PKTGEN_PKT_LEN, p);
1088 pkt_tx[coreid]+=1;
1089 i+=1;
1090 }
1091
1092 return;
1093}
diff --git a/ti/runtime/netapi/demo/src/transport_dpi_demo.h b/ti/runtime/netapi/demo/src/transport_dpi_demo.h
new file mode 100755
index 0000000..98b7f82
--- /dev/null
+++ b/ti/runtime/netapi/demo/src/transport_dpi_demo.h
@@ -0,0 +1,52 @@
1#include <stdlib.h>
2
3#define MAC_HEADER_LEN 14
4#define IP_HEADER_LEN 20
5#define UDP_HEADER_LEN 8
6
7#define MAX_NUM_INTERFACES 64
8#define MAX_NUM_CORES 4
9
10#define SP_THREAD_MASK 0xF0000000
11#define THREAD_NUM_MASK 0x000000FF
12
13
14typedef struct stats_t
15{
16 long itx; //initially generated
17 long itx2;
18 long rx;
19 long tx;
20 long n_bad;
21 long n_new;
22 long n_class0_rx; //count of pkts classified
23 long n_class1_rx; //count of pkts classified
24 long n_class2_rx; //count of pkts classified
25 long n_t1;
26 long n_t2;
27 long n_t3;
28 long sec_tx;
29 long sec_rx;
30 long sb_tx;
31 long sb_rx;
32 long secp_rx;
33 long n_auth_ok;
34 unsigned long long app_cycles;
35 unsigned long long send_cycles;
36 unsigned long long tx_cache_cycles;
37 long rx_min;
38 long tx_min;
39 long if_rx[MAX_NUM_INTERFACES];
40 long core_rx[MAX_NUM_CORES];
41 long n_stats_cb;
42 long ip;
43} STATS_T;
44
45typedef struct head_t
46{
47 long ip[5];
48 long udp[2];
49} HEAD_T;
50
51
52
diff --git a/ti/runtime/netapi/device/k2e/src/netapi_device.c b/ti/runtime/netapi/device/k2e/src/netapi_device.c
new file mode 100755
index 0000000..d183d6f
--- /dev/null
+++ b/ti/runtime/netapi/device/k2e/src/netapi_device.c
@@ -0,0 +1,68 @@
1/******************************************************************************
2 * FILE PURPOSE: NETAPI Peripheral Device Configuration
3 ******************************************************************************
4 * FILE NAME: netapi_device.c
5 *
6 * DESCRIPTION: NETAPI Peripheral Device Configuration Mapping
7 *
8 * REVISION HISTORY:
9 *
10 * Copyright (c) Texas Instruments Incorporated 2013-2014
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
22 * distribution.
23 *
24 * Neither the name of Texas Instruments Incorporated nor the names of
25 * its contributors may be used to endorse or promote products derived
26 ******************************************************************************
27 * from this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 */
42
43#include <stdint.h>
44#include <stdio.h>
45#include <sys/types.h>
46#include <sys/stat.h>
47#include <fcntl.h>
48#include <sys/mman.h>
49#include <unistd.h>
50#include <sys/ioctl.h>
51
52#include "ti/runtime/netapi/netapi.h"
53
54#include "ti/csl/cslr_device.h"
55
56
57
58/* NETPAPI initialization parameters */
59NETCP_CFG_GLOB_DEVICE_PARAMS_T netapiDeviceGblCfgParam =
60{
61 1,
62 CSL_NETCP_CFG_REGS,
63 CSL_QMSS_CFG_BASE,
64 CSL_QMSS_DATA_BASE,
65 CSL_NETCP_CFG_SA_CFG_REGS
66};
67
68
diff --git a/ti/runtime/netapi/device/k2h/src/netapi_device.c b/ti/runtime/netapi/device/k2h/src/netapi_device.c
new file mode 100755
index 0000000..f06e653
--- /dev/null
+++ b/ti/runtime/netapi/device/k2h/src/netapi_device.c
@@ -0,0 +1,67 @@
1/******************************************************************************
2 * FILE PURPOSE: NETAPI Peripheral Device Configuration
3 ******************************************************************************
4 * FILE NAME: netapi_device.c
5 *
6 * DESCRIPTION: NETAPI Peripheral Device Configuration Mapping
7 *
8 * REVISION HISTORY:
9 *
10 * Copyright (c) Texas Instruments Incorporated 2013-2014
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
22 * distribution.
23 *
24 * Neither the name of Texas Instruments Incorporated nor the names of
25 * its contributors may be used to endorse or promote products derived
26 ******************************************************************************
27 * from this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 */
42
43#include <stdint.h>
44#include <stdio.h>
45#include <sys/types.h>
46#include <sys/stat.h>
47#include <fcntl.h>
48#include <sys/mman.h>
49#include <unistd.h>
50#include <sys/ioctl.h>
51
52#include "ti/runtime/netapi/netapi.h"
53
54#include "ti/csl/cslr_device.h"
55
56/* NETPAPI initialization parameters */
57NETCP_CFG_GLOB_DEVICE_PARAMS_T netapiDeviceGblCfgParam =
58{
59 0,
60 CSL_NETCP_CFG_REGS,
61 CSL_QMSS_CFG_BASE,
62 CSL_QMSS_DATA_BASE,
63 CSL_NETCP_CFG_SA_CFG_REGS
64
65};
66
67
diff --git a/ti/runtime/netapi/device/k2k/src/netapi_device.c b/ti/runtime/netapi/device/k2k/src/netapi_device.c
new file mode 100755
index 0000000..f06e653
--- /dev/null
+++ b/ti/runtime/netapi/device/k2k/src/netapi_device.c
@@ -0,0 +1,67 @@
1/******************************************************************************
2 * FILE PURPOSE: NETAPI Peripheral Device Configuration
3 ******************************************************************************
4 * FILE NAME: netapi_device.c
5 *
6 * DESCRIPTION: NETAPI Peripheral Device Configuration Mapping
7 *
8 * REVISION HISTORY:
9 *
10 * Copyright (c) Texas Instruments Incorporated 2013-2014
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
22 * distribution.
23 *
24 * Neither the name of Texas Instruments Incorporated nor the names of
25 * its contributors may be used to endorse or promote products derived
26 ******************************************************************************
27 * from this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 */
42
43#include <stdint.h>
44#include <stdio.h>
45#include <sys/types.h>
46#include <sys/stat.h>
47#include <fcntl.h>
48#include <sys/mman.h>
49#include <unistd.h>
50#include <sys/ioctl.h>
51
52#include "ti/runtime/netapi/netapi.h"
53
54#include "ti/csl/cslr_device.h"
55
56/* NETPAPI initialization parameters */
57NETCP_CFG_GLOB_DEVICE_PARAMS_T netapiDeviceGblCfgParam =
58{
59 0,
60 CSL_NETCP_CFG_REGS,
61 CSL_QMSS_CFG_BASE,
62 CSL_QMSS_DATA_BASE,
63 CSL_NETCP_CFG_SA_CFG_REGS
64
65};
66
67
diff --git a/ti/runtime/netapi/device/k2l/src/netapi_device.c b/ti/runtime/netapi/device/k2l/src/netapi_device.c
new file mode 100755
index 0000000..4acdabd
--- /dev/null
+++ b/ti/runtime/netapi/device/k2l/src/netapi_device.c
@@ -0,0 +1,66 @@
1/******************************************************************************
2 * FILE PURPOSE: NETAPI Peripheral Device Configuration
3 ******************************************************************************
4 * FILE NAME: netapi_device.c
5 *
6 * DESCRIPTION: NETAPI Peripheral Device Configuration Mapping
7 *
8 * REVISION HISTORY:
9 *
10 * Copyright (c) Texas Instruments Incorporated 2013-2014
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
22 * distribution.
23 *
24 * Neither the name of Texas Instruments Incorporated nor the names of
25 * its contributors may be used to endorse or promote products derived
26 ******************************************************************************
27 * from this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 */
42
43#include <stdint.h>
44#include <stdio.h>
45#include <sys/types.h>
46#include <sys/stat.h>
47#include <fcntl.h>
48#include <sys/mman.h>
49#include <unistd.h>
50#include <sys/ioctl.h>
51
52#include "ti/runtime/netapi/netapi.h"
53
54#include "ti/csl/cslr_device.h"
55
56/* NETPAPI initialization parameters */
57NETCP_CFG_GLOB_DEVICE_PARAMS_T netapiDeviceGblCfgParam =
58{
59 1,
60 CSL_NETCP_CFG_REGS,
61 CSL_QMSS_CFG_BASE,
62 CSL_QMSS_DATA_BASE,
63 CSL_NETCP_CFG_SA_CFG_REGS
64};
65
66
diff --git a/ti/runtime/netapi/docs/tifooter.htm b/ti/runtime/netapi/docs/tifooter.htm
new file mode 100755
index 0000000..4bdf9c9
--- /dev/null
+++ b/ti/runtime/netapi/docs/tifooter.htm
@@ -0,0 +1,4 @@
1<hr size="1"><small>
2Copyright $year, Texas Instruments Incorporated</small>
3</body>
4</html>
diff --git a/ti/runtime/netapi/docs/tiheader.htm b/ti/runtime/netapi/docs/tiheader.htm
new file mode 100755
index 0000000..57de9bb
--- /dev/null
+++ b/ti/runtime/netapi/docs/tiheader.htm
@@ -0,0 +1,12 @@
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3<title>$title</title>
4<link href="$relpath$doxygen.css" rel="stylesheet" type="text/css">
5<link href="$relpath$tabs.css" rel="stylesheet" type="text/css">
6</head><body>
7<table width=100%>
8<tr>
9 <td bgcolor="black" width="1"><a href="http://www.ti.com"><img border=0 src="../tilogo.gif"></a></td>
10 <td bgcolor="red"><img src="../titagline.gif"></td>
11</tr>
12</table>
diff --git a/ti/runtime/netapi/docs/tilogo.gif b/ti/runtime/netapi/docs/tilogo.gif
new file mode 100755
index 0000000..f2fab2d
--- /dev/null
+++ b/ti/runtime/netapi/docs/tilogo.gif
Binary files differ
diff --git a/ti/runtime/netapi/docs/titagline.gif b/ti/runtime/netapi/docs/titagline.gif
new file mode 100755
index 0000000..743a024
--- /dev/null
+++ b/ti/runtime/netapi/docs/titagline.gif
Binary files differ
diff --git a/ti/runtime/netapi/docs/user_space_apiv2.ppt b/ti/runtime/netapi/docs/user_space_apiv2.ppt
new file mode 100755
index 0000000..be24d81
--- /dev/null
+++ b/ti/runtime/netapi/docs/user_space_apiv2.ppt
Binary files differ
diff --git a/ti/runtime/netapi/makefile_armv7 b/ti/runtime/netapi/makefile_armv7
new file mode 100755
index 0000000..c380560
--- /dev/null
+++ b/ti/runtime/netapi/makefile_armv7
@@ -0,0 +1,157 @@
1#*******************************************************************************
2#* FILE PURPOSE: Top level makefile for Creating Component Libraries for ARM
3#* architectures
4#*******************************************************************************
5#* FILE NAME: makefile
6#*
7#* DESCRIPTION: Defines Compiler tools paths, libraries , Build Options
8#*
9#*
10#*******************************************************************************
11#*
12# (Mandatory) Specify where various tools are installed.
13
14# Output for prebuilt generated libraries
15export ARMV7LIBDIR ?= ./lib
16export ARMV7OBJDIR ?= ./obj
17export ARMV7OBJDIR_SO := $(ARMV7OBJDIR)/netapi/lib_so
18export ARMV7OBJDIR := $(ARMV7OBJDIR)/netapi/lib
19
20export ARMV7BINDIR ?= ./bin
21
22export DEVICE ?=k2l
23
24#Enable the following to build for tci6614
25#export CPU ?=cortex-a8
26
27
28# ROOT Directory
29export ROOTDIR := ../../..
30
31
32# INCLUDE Directory
33export INCDIR := ../;$(PDK_INSTALL_PATH);$(ROOTDIR)
34
35# Common Macros used in make
36
37ifndef RM
38export RM = rm -f
39endif
40
41ifndef CP
42export CP = cp -p
43endif
44
45export MKDIR = mkdir -p
46
47ifndef RMDIR
48export RMDIR = rm -rf
49endif
50
51ifndef SED
52export SED = sed
53endif
54
55ifndef MAKE
56export MAKE = make
57endif
58
59ifeq ($(DEVICE), k2h)
60export CSL_DEVICE = -DDEVICE_K2H
61endif
62ifeq ($(DEVICE), k2k)
63export CSL_DEVICE = -DDEVICE_K2K
64endif
65ifeq ($(DEVICE), k2l)
66export CSL_DEVICE = -DDEVICE_K2L -DNSS_GEN2
67endif
68ifeq ($(DEVICE), k2e)
69export CSL_DEVICE = -DDEVICE_K2E -DNSS_GEN2
70endif
71
72# PHONY Targets
73.PHONY: all clean lib tests examples install installbin demo installdemo
74
75# all rule
76all: .executables install installbin installdemo
77.executables: lib tests examples
78
79# Make rule to create $(ARMV7LIBDIR)/libnetapi.a library
80lib: $(ARMV7LIBDIR)/libnetapi_$(DEVICE).a libnetapi_$(DEVICE).so
81
82$(ARMV7LIBDIR)/libnetapi_$(DEVICE).a:
83 -@echo Building library...
84 -@echo ARMV7OBJDIR = $(ARMV7OBJDIR)
85 @$(MAKE) -f ./build/Makefile $@
86
87
88libnetapi_$(DEVICE).so:
89 -@echo Building library...
90 -@echo ARMV7OBJDIR = $(ARMV7OBJDIR_SO)
91 @$(MAKE) -f ./build/Makefile $@
92
93
94# Rule to clean $(ARMV7LIBDIR)/libnetapi.a library
95clean:
96 -@echo Cleaning netapi package... $@
97 @$(MAKE) -f ./build/Makefile $@
98 @$(MAKE) -f ./test/build/Makefile $@
99
100install:
101 install -d $(INSTALL_INC_BASE_DIR)/ti/runtime/netapi
102 install -d $(INSTALL_INC_BASE_DIR)/ti/runtime/netapi/src
103 install -d $(INSTALL_LIB_BASE_DIR)
104 $(CP) ./*.h $(INSTALL_INC_BASE_DIR)/ti/runtime/netapi
105 $(CP) -r ./device $(INSTALL_INC_BASE_DIR)/ti/runtime/netapi/
106 @$(CP) -r $(ARMV7LIBDIR)/libnetapi_$(DEVICE).a $(INSTALL_LIB_BASE_DIR)
107 @$(CP) -rp $(ARMV7LIBDIR)/libnetapi_$(DEVICE).so* $(INSTALL_LIB_BASE_DIR)
108 $(CP) src/*.h $(INSTALL_INC_BASE_DIR)/ti/runtime/netapi/src
109
110installbin:
111 install -d $(INSTALL_BIN_BASE_DIR)
112 install -c -m 755 $(ARMV7BINDIR)/netapi/test/net_test_loopback_$(DEVICE) $(INSTALL_BIN_BASE_DIR)/net_test_loopback_$(DEVICE)
113 install -c -m 755 $(ARMV7BINDIR)/netapi/test/net_test_router_$(DEVICE) $(INSTALL_BIN_BASE_DIR)/net_test_router_$(DEVICE)
114 install -c -m 755 $(ARMV7BINDIR)/netapi/test/net_test_bench_$(DEVICE) $(INSTALL_BIN_BASE_DIR)/net_test_bench_$(DEVICE)
115 install -c -m 755 $(ARMV7BINDIR)/netapi/test/nt_bridge_$(DEVICE) $(INSTALL_BIN_BASE_DIR)/nt_bridge_$(DEVICE)
116 install -c -m 755 tools/eqos/dumpqos.sh $(INSTALL_BIN_BASE_DIR)/dumpqos.sh
117 install -d $(SYSCONFDIR)/transportnetlib/test
118 $(CP) test/net_test_config.txt $(SYSCONFDIR)/transportnetlib/test
119 install -c -m 755 tools/net_test_loopback_setup.sh $(SYSCONFDIR)/transportnetlib/test
120 install -c -m 755 tools/net_test_router_setup.sh $(SYSCONFDIR)/transportnetlib/test
121 install -c -m 755 tools/nt_bridge_setup.sh $(SYSCONFDIR)/transportnetlib/test
122 install -c -m 755 tools/irqset.sh $(SYSCONFDIR)/transportnetlib/test
123 install -c -m 755 tools/dsp_core_setup.sh $(SYSCONFDIR)/transportnetlib/test
124 install -c -m 755 tools/eqos/parse_ale.sh $(SYSCONFDIR)/transportnetlib/test
125 install -c -m 755 tools/eqos/parse_ale.awk $(SYSCONFDIR)/transportnetlib/test
126 $(CP) test/eqos_config1.txt $(SYSCONFDIR)/transportnetlib/test
127 $(CP) test/eqos_config2.txt $(SYSCONFDIR)/transportnetlib/test
128 install -c -m 755 tools/ipsec_tools/sample_evm_ipsec.conf $(SYSCONFDIR)/transportnetlib/test
129
130installdemo:
131 install -d $(INSTALL_BIN_BASE_DIR)
132 install -c -m 755 $(ARMV7BINDIR)/netapi/demo/transport_dpi_demo $(INSTALL_BIN_BASE_DIR)/
133 install -d $(SYSCONFDIR)/transportnetlib/dpi_demo
134 install -c -m 755 demo/demo_setup_files/transport_dpi_demo_setup.sh $(SYSCONFDIR)/transportnetlib/dpi_demo
135 install -c -m 644 demo/demo_setup_files/index.html $(SYSCONFDIR)/transportnetlib/dpi_demo
136 install -c -m 755 demo/demo_setup_files/dpicgi1.sh $(SYSCONFDIR)/transportnetlib/dpi_demo
137 install -c -m 755 demo/demo_setup_files/dpicgi2.sh $(SYSCONFDIR)/transportnetlib/dpi_demo
138 install -c -m 755 demo/demo_setup_files/dpicgi3.sh $(SYSCONFDIR)/transportnetlib/dpi_demo
139 install -c -m 755 demo/demo_setup_files/dpicgi4.sh $(SYSCONFDIR)/transportnetlib/dpi_demo
140 install -c -m 755 demo/demo_setup_files/dpicgi5.sh $(SYSCONFDIR)/transportnetlib/dpi_demo
141 install -c demo/demo_setup_files/stats1.awk $(SYSCONFDIR)/transportnetlib/dpi_demo
142 install -c demo/demo_setup_files/stats2.awk $(SYSCONFDIR)/transportnetlib/dpi_demo
143 install -c demo/demo_setup_files/stats3.awk $(SYSCONFDIR)/transportnetlib/dpi_demo
144 install -c demo/demo_setup_files/stats4.awk $(SYSCONFDIR)/transportnetlib/dpi_demo
145 install -c demo/demo_setup_files/tilogo.gif $(SYSCONFDIR)/transportnetlib/dpi_demo
146 install -c demo/demo_setup_files/titagline.gif $(SYSCONFDIR)/transportnetlib/dpi_demo
147
148# Make rule to create tests
149tests:
150 -@echo compiling tests
151 @$(MAKE) -f ./test/build/Makefile $@
152
153# Make rule to create net_test_dpi_demo
154demo:
155 -@echo compiling tests
156 @$(MAKE) -f ./demo/build/Makefile $@
157examples:
diff --git a/ti/runtime/netapi/netapi.h b/ti/runtime/netapi/netapi.h
new file mode 100755
index 0000000..e1225c5
--- /dev/null
+++ b/ti/runtime/netapi/netapi.h
@@ -0,0 +1,319 @@
1/******************************************************************************
2 * FILE PURPOSE: User space access to transport resources on SOC
3 ******************************************************************************
4 * FILE NAME: netapi.h
5 *
6 * DESCRIPTION: NETAPI definitions and data structures
7 *
8 * REVISION HISTORY:
9 *
10 * Copyright (c) Texas Instruments Incorporated 2013
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
22 * distribution.
23 *
24 * Neither the name of Texas Instruments Incorporated nor the names of
25 * its contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 */
41/* ============================================================= */
42/**
43 * @file netapi.h
44 *
45 * path ti/runtime/netapi/netapi.h
46 *
47 * @brief Netapi main header file for user space transport library
48 *
49 */
50
51/** @mainpage Network API
52 *
53 * @section intro Introduction
54 *
55 * The network API provides a user space interface to TI SOC transport
56 * Resources. The library includes:
57 * - general startup and setup for user space operations
58 * - memory heap and packet buffer management
59 * - pktio either to/from network or internal queues
60 * - timers for network stacks
61 * - netcp (network co-processor) configuration and control
62 * - utilities including user space synchronization primitivies
63 * - sample scheduling event loop
64 *
65 * NETAPI allows user space transport to configure control the NETCP:
66 * - Classification of packets based on L2: MAC header fields
67 * - Classification of packets based on L3: IP header fields
68 * - Routing of packets to host based on L4 UDP or L5 GTPU ID
69 * - Unidirectional IPSec SA creation and deletion
70 * - Unidirectional IPSec Security Policy creation and deletion
71 *
72 * \par
73 * NOTE:
74 * (C) Copyright 2010-2012 Texas Instruments, Inc.
75 * \par
76 */
77
78#ifndef __NETAPI__H
79#define __NETAPI__H
80
81#ifdef __cplusplus
82extern "C" {
83#endif
84
85#include <stdio.h>
86#include <stdint.h>
87#include <stdlib.h>
88#include <stddef.h>
89#include <string.h>
90
91#include "ti/drv/nwal/nwal.h"
92#include "ti/runtime/hplib/hplib.h"
93#include "netapi_types.h"
94#include "netapi_tune.h"
95#include "pktio.h"
96#include "netcp_cfg.h"
97#include "netapi_sec.h"
98#include "netapi_sched.h"
99#include "netapi_util.h"
100
101
102/* Define NETAPI as a master group in Doxygen format and
103 * add all NETAPI
104 * definitions to this group.
105 */
106/** @defgroup netapi Network API
107 * @{
108 */
109/** @} */
110
111/** @defgroup netapi_gen_functions NETAPI General Functions
112 * @ingroup netapi
113 */
114
115
116/** @defgroup netapi_cfg NETAPI Configuration Interface
117 * @ingroup netapi
118 */
119/** @defgroup cfg_functions NETAPI Configuration Functions
120 * @ingroup netapi_cfg
121 */
122
123/** @defgroup cfg_structures NETAPI Configuration Structures used in API's
124 * @ingroup netapi_cfg
125 */
126
127/** @defgroup cfg_constants NETAPI Configuration Constants
128 * @ingroup netapi_cfg
129 */
130
131/** @defgroup netapi_security NETAPI Security Interface
132 * @ingroup netapi
133 */
134
135/** @defgroup cfg_security_functions NETAPI Security Configuration Functions
136 * @ingroup netapi_security
137 */
138
139/** @defgroup cfg_security_structures NETAPI Security Configuration Structures used in API's
140 * @ingroup netapi_security
141 */
142
143
144/** @defgroup security_constants NETAPI Security Constants
145 * @ingroup netapi_security
146 */
147
148/** @defgroup netapi_pktio NETAPI PKTIO Interface
149 * @ingroup netapi
150 */
151
152/** @defgroup pktio_functions NETAPI PKTIO Functions
153 * @ingroup netapi_pktio
154 */
155
156/** @defgroup pktio_structures NETAPI PKTIO Structures used in API's
157 * @ingroup netapi_pktio
158 */
159
160/** @defgroup pktio_constants NETAPI PKTIO Constants
161 * @ingroup netapi_pktio
162 */
163
164/** @defgroup netapi_scheduler NETAPI Scheduler Interface
165 * @ingroup netapi
166 */
167
168/** @defgroup sched_functions NETAPI Scheduler Functions
169 * @ingroup netapi_scheduler
170 */
171
172/** @defgroup sched_structures NETAPI Scheduler Structures used in API's
173 * @ingroup netapi_scheduler
174 */
175
176/** @defgroup sched_constants NETAPI Scheduler Constants
177 * @ingroup netapi_scheduler
178 */
179
180/** @defgroup netapi_cb_functions NETAPI Callback Functions
181 * @ingroup netapi
182 */
183
184/** @defgroup tune_parameters NETAPI Tune Parameters
185 * @ingroup netapi
186 */
187
188/**
189 * @def NETAPI_PROC_MASTER
190 * This defines the master core/thread for a process
191 */
192#define NETAPI_PROC_MASTER 3
193
194/**
195 * @def NETAPI_SYS_MASTER
196 * This defines the master core for the system
197 * also will be master core/thread of the process
198 */
199#define NETAPI_SYS_MASTER 2
200
201/**
202 * @def NETAPI_CORE_MASTER
203 * This defines the master thread for a particular core
204 */
205#define NETAPI_CORE_MASTER 1
206
207/**
208 * @def NETAPI_NO_MASTER
209 * This defines a non master thread which can be running on any core,, specifically for data only
210 */
211#define NETAPI_NO_MASTER 0 //data only
212
213
214
215
216/**
217 * @ingroup netapi_gen_functions
218 * @brief netapi_init API instantiates the NETAPI and allocated global resources.
219 *
220 * @details The API will allocate global resources valid per system level common
221 * across all ARM cores or per thread based on "master" argument.
222 * Intializes the following substems: pktio pklib qmss cppi nwal
223 *
224 * @param[in] master Can be either @ref NETAPI_SYS_MASTER or @ref NETAPI_NO_MASTER
225 * @param[in] p_cfg (master mode) pointer to @ref NETAPI_CFG_T or NULL to use netapi default configuration.
226 * @retval Handle to the instance or NULL on error, @ref NETAPI_T
227 * @pre none
228 */
229 NETAPI_T netapi_init(int master,
230 NETAPI_CFG_T * p_cfg);
231/**
232 * @ingroup netapi_gen_functions
233 * @brief netapi_shutdown API de-allocates all global resources allocated as part of @ref netapi_init
234 *
235 * @details De-allocates global resources valid per system level common across all ARM cores
236 * or per thread based on "master" argument passed in at init time.
237 * @param[in] p The NETAPI handle, @ref NETAPI_T
238 * @retval none
239 * @pre @ref netapi_init
240 */
241void netapi_shutdown(NETAPI_T p);
242
243/**
244 * @ingroup netapi_gen_functions
245 * @brief netapi_getPktlibIfTable API returns a Pktlib_HeapIfTable to use when creating
246 * pktlib heaps
247 *
248 * @details Application will need a Pktlib_HeapIfTable in order to create its own heaps. This
249 * function returns a table that can be passed in the call to Pktlib_CreateHeap
250 * The memory used for these heaps is special with the following characteristics:
251 * - Specific alignment.
252 * - Must be contguous.
253 * - Must have a physical to virtual mapping that is known by NETAPI.
254 * Thus it must be completely managed by NETAPI. This interface table provides a
255 * malloc function that the pktlib heap library uses to allocate data for the heap
256 * buffers.
257 * @retval Pktlib_HeapIfTable pointer
258 * @pre @ref netapi_init
259 */
260Pktlib_HeapIfTable *netapi_getPktlibIfTable(void) ;
261
262
263
264/**
265 * @ingroup netapi_gen_functions
266 * @brief netapi_getDescRemainder API is used to return the amount of free memory available
267 * for allocating descriptors for additonal Pktlib heaps.
268 *
269 * @details The application can use this API to determine how much free memory is
270 * available for heap descriptors if it decides to create its own heap.
271 * @retval Amount of memory available for heap descriptor storage (in bytes)
272 * @pre @ref netapi_init
273 */
274int netapi_getDescRemainder(void);
275
276/**
277 * @ingroup netapi_gen_functions
278 * @brief netapi_netcpPoll API is used to poll for NETCP configuration response messages.
279 *
280 * @details Application, if implementing the scheduler, will need to call this
281 * function periodically to check for NETCP configuration responses (eg
282 * statistics requests).
283 * @param[in] p The NETAPI handle, @ref NETAPI_T
284 * @retval none
285 * @pre @ref netapi_init
286 */
287void netapi_netcpPoll(NETAPI_T p);
288
289
290/**
291 * @ingroup netapi_gen_functions
292 * @brief netapi_pollHeapGarbage API is used to poll the garbage collection queue for
293 * the internal NETAPI heaps and any application created heaps.
294 *
295 * @details This API is used to poll the netapi internal heaps and any
296 * application-created heaps that have been registered with the netapi instance. The
297 * poll function checks the garbage collection queue associated with the heap and returns
298 * descriptors and buffers when appropriate to the main free queue.
299 * @param[in] p The NETAPI handle, @ref NETAPI_T
300 * @retval none
301 * @pre @ref netapi_init
302 */
303void netapi_pollHeapGarbage(NETAPI_T p);
304
305/**
306 * @ingroup netapi_gen_functions
307 * @brief netapi_getMemoryRegionId API is used to return configured descriptor
308 * memory region Id
309 *
310 * @details API is used to return configured descriptor memory region Id
311 * @param[in] p The NETAPI handle, @ref NETAPI_T
312 * @retval Memory Resgion Id, -1 on error
313 * @pre @ref netapi_init
314 */
315int netapi_getMemoryRegionId(NETAPI_T p);
316#ifdef __cplusplus
317}
318#endif
319#endif
diff --git a/ti/runtime/netapi/netapi_sched.h b/ti/runtime/netapi/netapi_sched.h
new file mode 100755
index 0000000..a42a09f
--- /dev/null
+++ b/ti/runtime/netapi/netapi_sched.h
@@ -0,0 +1,359 @@
1/**************************************************************************************
2 * FILE PURPOSE: Netapi scheduler module
3 ***************************************************************************************
4 * FILE NAME: netapi_sched.h
5 *
6 * DESCRIPTION: Netapi sample scheduler header file for user space transport library
7 *
8 * REVISION HISTORY:
9 *
10 * Copyright (c) Texas Instruments Incorporated 2013
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
22 * distribution.
23 *
24 * Neither the name of Texas Instruments Incorporated nor the names of
25 * its contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 */
41
42/**
43 * @file netapi_sched.h
44 * @brief netapi scheduler header file for user space transport library
45 */
46
47
48#ifndef __NETAPI_SCHED__
49#define __NETAPI_SCHED__
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54#include <stdio.h>
55#include <stdint.h>
56#include <stdlib.h>
57#include <stddef.h>
58#include <string.h>
59
60#include "ti/csl/tistdtypes.h"
61#include "netapi_types.h"
62#include "ti/runtime/netapi/src/netapi_loc.h"
63
64//#include "netapi.h"
65
66/**
67 * @brief This defines the handle to the NETAPI scheduling context.
68 * Each user space transport application thread/core should have its own
69 * scheduler context.
70 */
71struct NETAPI_SCHED_HANDLE_Tag;
72
73
74/**
75 * @ingroup netapi_cb_functions
76 * @brief NETAPI_SCHED_CB Callback function for scheduling context house keeping.
77 * This allows application to set a function to be periodically called by scheduler
78 * to perform house keeping operations. If NULL, then no callback will be invoked
79 *
80 * @details The application provides a callback function that the NETAPI scheduling context
81 * will call on a periodic/ low priority basis.
82 * @param[in] h The handle to the NETAPI scheduling context
83 * @retval none
84 * @pre @ref netapi_init
85 */
86typedef void (*NETAPI_SCHED_CB)(struct NETAPI_SCHED_HANDLE_Tag *h);
87
88/**
89 * @ingroup sched_structures
90 * @brief NETAPI scheduler configuration structure.
91 *
92 * @details Pointer to this structure is passed in the call to @ref netapi_schedOpen API.
93 */
94typedef struct NETAPI_SCHED_CONFIG_Tag
95{
96/**
97 * @def NETAPI_SCHED_DURATION
98 * @ingroup sched_constants
99 * Duration configuration flag for scheduler
100 */
101#define NETAPI_SCHED_DURATION 0x1
102
103/**
104 * @def NETAPI_SCHED_CBV
105 * @ingroup sched_constants
106 * This defines that the housekeeping call back option of scheduler context has been configured.
107 */
108#define NETAPI_SCHED_CBV 0x2
109
110/// @cond NOT_IMPLEMENTED
111/**
112 * @def NETAPI_SCHED_POWER
113 * @ingroup sched_constants
114 * This defines the power option of scheduler context being configured.
115 */
116#define NETAPI_SCHED_POWER 0x4
117
118/**
119 * @def NETAPI_SCHED_FINE
120 * @ingroup sched_constants
121 * This defines the fine tune option of scheduler context being configured.
122 */
123#define NETAPI_SCHED_FINE 0x8
124/// @endcond
125/**
126 * @def NETAPI_SCHED_FOREVER
127 * @ingroup sched_constants
128 * This defines is used to configure scheduler to run forever.
129 */
130#define NETAPI_SCHED_FOREVER 0L
131
132 int valid_flags; /**< Flags used to configure the scheduler, @ref NETAPI_SCHED_DURATION,
133 @ref NETAPI_SCHED_CBV. */
134 uint64_t duration; /**< Duration scheduler is configured to run, 0 == forever,
135 non-zero value is ticks for scheduler to run */
136 NETAPI_SCHED_CB house_cb; /**< House keeping callback */
137
138 uint32_t interval; /**< How many poll loop intervals after which to call the house keeping
139 callback function*/
140
141 int power_control; /**< Currently NOT_IMPLEMENTED */
142
143
144/**
145 * @def NETAPI_SCHED_POWER_ALWAYS_OFF
146 * @ingroup sched_constants
147 * This define is used to configure scheduler power_control option to be always off.
148 */
149#define NETAPI_SCHED_POWER_ALWAYS_OFF 0
150
151/**
152 * @def NETAPI_SCHED_POWER_ALWAYS_ON
153 * @ingroup sched_constants
154 * This define is used to configure scheduler power_control option to be always on.
155 */
156#define NETAPI_SCHED_POWER_ALWAYS_ON 1
157
158
159 int idle_time; /**< Currently NOT_IMPLEMENTED */
160 Bool yield; /**< Option to yield in scheduling loop if no packets received
161 from any NETAPI PKTIO channel associated with NETAPI instance.*/
162 Bool pollCtrlQ; /**< Option to poll the NETCP control queues associated with the NETAPI
163 intance in scheduling loop. */
164 Bool pollGarbageQ; /**< Option to poll the internal heaps and any application heaps that have
165 been registerd with NETAPI instance. in scheduling loop. */
166} NETAPI_SCHED_CONFIG_T;
167
168/**
169 * @ingroup sched_structures
170 * @brief NETAPI scheduler statisics.
171 *
172 * @details This structure is returned from call to @ref netapi_schedOpen API.
173 */
174typedef struct NETAPI_SCHED_STATS_Tag
175{
176 unsigned long long num_pkts; /**< Number of packets processed in sheduler context */
177 unsigned long long busy_cycles; /**< Number of CPU cyles scheduler was busy processing packets */
178 unsigned long long cache_cycles; /**< Number of CPU cyles scheduler was busy in cache operations */
179} NETAPI_SCHED_STATS_T;
180
181/**
182 * @ingroup sched_structures
183 * @brief NETAPI scheduler configuration structure.
184 *
185 * @details Pointer to this structure is passed in the call to @ref netapi_schedOpen API.
186 */
187typedef struct NETAPI_SCHED_HANDLE_Tag
188{
189/**
190 * @def NETAPI_SCHED_STATE_CLOSE
191 * @ingroup sched_constants
192 * This define indicates the state of the scheduler to be CLOSE state or idle
193 */
194#define NETAPI_SCHED_STATE_CLOSE 0x0
195
196/**
197 * @def NETAPI_SCHED_STATE_CLOSE_IN_PROGRESS
198 * @ingroup sched_constants
199 * This define indicates the state of the scheduler is being shutdown state
200 */
201#define NETAPI_SCHED_STATE_CLOSE_IN_PROGRESS 1
202
203/**
204 * @def NETAPI_SCHED_STATE_OPEN
205 * @ingroup sched_constants
206 * This define indicates the state of the scheduler is OPEN or running
207 */
208#define NETAPI_SCHED_STATE_OPEN 2
209
210
211 volatile int state; /**< @ref NETAPI_SCHED_STATE_CLOSE ,
212 @ref NETAPI_SCHED_STATE_CLOSE_IN_PROGRESS ,
213 @ref NETAPI_SCHED_STATE_OPEN */
214 void* back; /**< Pointer back to NETAPI handle */
215 NETAPI_SCHED_CONFIG_T config; /**< NETAPI scheduler configuration */
216 uint64_t start; /**< Start time of NETAPI scheduler context */
217 volatile int shutdown_reason; /**< Currently NOT_IMPLEMENTED */
218 volatile uint64_t shutdown_time; /**< Time till scheduler context will be shutdown/closed */
219 NETAPI_SCHED_STATS_T stats; /**< Per scheduler satistics */
220} NETAPI_SCHED_HANDLE_T;
221
222
223
224
225/// @cond NOT_IMPLEMENTED
226/* return codes for sched run */
227#define NETAPI_SCHED_RETURN_ERR 0 /**<unknown, err */
228#define NETAPI_SCHED_RETURN_TO 1 /**<returned after timeout */
229#define NETAPI_SCHED_RETURN_SHUTDOWN 2 /**<returned after shutdown */
230/// @endcond
231
232/**
233 * @ingroup sched_structures
234 * @brief NETAPI scheduler shutdown structure.
235 * @details This structure is passed an an argument for @ref netapi_schedClose.
236 */
237typedef struct NETAPI_SCHED_SHUTDOWN_Tag
238{
239/**
240 * @def NETAPI_SCHED_SHUTDOWN_NOW
241 * @ingroup sched_constants
242 * This define is used to shudown the scheduling context immediately
243 */
244#define NETAPI_SCHED_SHUTDOWN_NOW 0
245
246/// @cond NOT_IMPLEMENTED
247/**
248 * @def NETAPI_SCHED_SHUTDOWN_TO
249 * @ingroup sched_constants
250 * This define is used to shudown the scheduling context after a short while.
251 */
252#define NETAPI_SCHED_SHUTDOWN_TO 1
253
254/**
255 * @def NETAPI_SCHED_SHUTDOWN_NEXT_IDLE
256 * @ingroup sched_constants
257 * This define is used to shudown the scheduling context during next idle period
258 */
259#define NETAPI_SCHED_SHUTDOWN_NEXT_IDLE 2
260/// @endcond
261 int shutdown_type; /**< @ref NETAPI_SCHED_SHUTDOWN_NOW*/
262
263 int timeout; /**< Currently NOT_IMPLEMENTED */
264} NETAPI_SCHED_SHUTDOWN_T;
265
266/**
267 * @ingroup sched_functions
268 * @brief netapi_schedOpen: API to open a scheduling context.
269 *
270 * @details API to open a scheduling context.
271 * @param[in] n the NETAPI handle, @ref NETAPI_T
272 * @param[in] p_config :pointer to @ref NETAPI_SCHED_CONFIG_T
273 * @param[out] p_err Pointer to error code.
274 * @retval Handle associated with created scheduler context, @ref NETAPI_SCHED_HANDLE_T
275 * @pre @ref netapi_init
276 */
277NETAPI_SCHED_HANDLE_T * netapi_schedOpen(NETAPI_T n,
278 NETAPI_SCHED_CONFIG_T* p_config,
279 int* p_err);
280
281/// @cond NOT_IMPLEMENTED
282/**
283 * @ingroup sched_functions
284 * @brief netapi_schedControl: API to re-configure a scheduling context.
285 *
286 * @details API to re-configure a scheduling context.
287 * @param[in] s The NETAPI scheduling context handle, @ref NETAPI_SCHED_HANDLE_T
288 * @param[in] p_config Pointer to @ref NETAPI_SCHED_CONFIG_T
289 * @param[out] p_err Pointer to error code.
290 * @retval Handle associated with created scheduler context, @ref NETAPI_SCHED_HANDLE_T
291 * @pre @ref netapi_schedOpen
292 */
293int netapi_schedControl(NETAPI_SCHED_HANDLE_T* s,
294 NETAPI_SCHED_CONFIG_T* p_config,
295 int* p_err);
296/// @endcond
297
298/**
299 * @ingroup sched_functions
300 * @brief netapi_schedRun: API for main entry point to scheduler.
301 *
302 * @details API for main entry point to scheduler. User application gives up control to scheduler.
303 * @param[in] s The NETAPI scheduling context handle, @ref NETAPI_SCHED_HANDLE_T
304 * @param[out] p_err: error code, zero on sucess, non-zero on failure
305 * @retval always 1
306 * @pre @ref netapi_schedOpen
307 */
308int netapi_schedRun(NETAPI_SCHED_HANDLE_T* s,
309 int* p_err);
310
311/**
312 * @ingroup sched_functions
313 * @brief netapi_schedClose: API to close a scheduling context.
314 *
315 * @details API to close a scheduling context.
316 * @param[in] s The NETAPI scheduling context handle, @ref NETAPI_SCHED_HANDLE_T
317 * @param[in] p_close @ref NETAPI_SCHED_SHUTDOWN_T
318 * @param[out] p_err Pointer to error code.
319 * @retval NO USED, ALWAYS 1
320 * @pre @ref netapi_schedOpen
321 */
322int netapi_schedClose(NETAPI_SCHED_HANDLE_T* s,
323 NETAPI_SCHED_SHUTDOWN_T* p_close,
324 int* p_err);
325
326/**
327 * @ingroup sched_functions
328 * @brief netapi_schedGetHandle: API to get the NETAPI handle from scheduling context.
329 *
330 * @details API to get the NETAPI handle from scheduling context.
331 * @param[in] s The NETAPI scheduling context handle, @ref NETAPI_SCHED_HANDLE_T
332 * @retval Handle to NETAPI instance
333 */
334static NETAPI_T netapi_schedGetHandle(NETAPI_SCHED_HANDLE_T *s)
335{
336 return (NETAPI_T)s->back;
337}
338
339/**
340 * @ingroup sched_functions
341 * @brief netapi_schedGetStats: API to get scheduling context statistics.
342 *
343 * @details API to get scheduling context statistics.
344 * @param[in] s The NETAPI scheduling context handle, @ref NETAPI_SCHED_HANDLE_T
345 * @param[in] p_pkts total number of packets processed by scheduler poll loop
346 * @param[in] p_cycles total number cycles taken by scheduler poll loop
347 * @param[in] p_ccycles total number of cache control cycles taken by scheduler poll loop
348 * @retval none
349 */
350void netapi_schedGetStats(NETAPI_SCHED_HANDLE_T* s,
351 unsigned long long* p_pkts,
352 unsigned long long* p_cycles,
353 unsigned long long* p_ccycles);
354
355#ifdef __cplusplus
356}
357#endif
358
359#endif
diff --git a/ti/runtime/netapi/netapi_sec.h b/ti/runtime/netapi/netapi_sec.h
new file mode 100755
index 0000000..c4e8add
--- /dev/null
+++ b/ti/runtime/netapi/netapi_sec.h
@@ -0,0 +1,320 @@
1/******************************************************************************
2 * FILE PURPOSE: Netapi Security configuration header file
3 ******************************************************************************
4 * FILE NAME: netapi_sec.h
5 *
6 * DESCRIPTION: netapi security header file for user space transport library
7 *
8 * REVISION HISTORY:
9 *
10 * Copyright (c) Texas Instruments Incorporated 2013
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
22 * distribution.
23 *
24 * Neither the name of Texas Instruments Incorporated nor the names of
25 * its contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 */
41/* ============================================================= */
42
43
44/**
45 * @file netapi_sec.h
46 * @brief netapi security header file for user space transport library
47 */
48
49#ifndef __NETAPI_SEC__H
50#define __NETAPI_SEC__H
51
52#ifdef __cplusplus
53extern "C" {
54#endif
55
56
57#include "netcp_cfg.h"
58#include "ti/drv/nwal/nwal.h"
59#include <ti/drv/sa/salld.h>
60
61
62
63
64/**
65 * @ingroup cfg_security_structures
66 * @brief NETAPI SA Statistics
67 *
68 * @details Pointer to this structure is passed in the call to netapi_getSaStats API. It will be popluated with the requested statistics.
69 */
70typedef struct NETAPI_SA_STATS_Tag
71{
72/**
73 * Bit map indicating the IPSec SA Inflow/Side band data mode stats validity
74 * <br>
75 * The validParams field indicates to the caller which stats being returned by calling the @ref netapi_getSaStats are valid.
76 * @ref NETAPI_IPSEC_STAT_VALID, @ref NETAPI_SIDEBAND_DATA_MODE_STAT_VALID
77 */
78 uint16_t validParams; /**< Bit map indicating the IPSec SA Inflow/Side band data mode stats validity */
79
80/**
81 * @def NETAPI_IPSEC_STAT_VALID
82 * @ingroup security_constants
83 * Indicates to user application that IPSEC stats are valid for INFLOW mode
84 */
85#define NETAPI_IPSEC_STAT_VALID 0x0001
86
87/**
88 * @def NETAPI_SIDEBAND_DATA_MODE_STAT_VALID
89 * @ingroup security_constants
90 * Indicates to user application that IPSEC stats are valid for SIDEBAND mode
91 */
92#define NETAPI_SIDEBAND_DATA_MODE_STAT_VALID 0x0002
93
94 Sa_IpsecStats_t saIpsecStats; /**< Structure containing IPSEC stats for INFLOW MODE*/
95 Sa_DataModeStats_t dataModeStats; /**< Structure containing Data Mode stats for SIDEBAND MODE */
96} NETAPI_SA_STATS_T;
97
98
99/**
100 * @ingroup cfg_security_structures
101 * @brief NETAPI security SA information
102 *
103 * @details This structure contains the information necessary to create a security association (for either for inflow mode or sideband mode)
104 */
105typedef struct NETAPI_SEC_SA_INFO_tag
106{
107 nwal_SaDir dir; /**< Direction for the channel. Inbound or Outbound */
108 uint32_t spi; /**< IPSec Security Parameter index */
109 nwal_IpSecProto proto; /**< IpSec Proto (ESP/AH) */
110 nwal_saMode saMode; /**< Tunnel/ Transport mode (sideband RX/TX) */
111 nwal_IpType ipType; /**< IPV4 or V6 (sideband RX/TX) */
112 nwalIpAddr_t src; /**< Source IP Address (remote) (sideband RX) */
113 nwalIpAddr_t dst; /**< DST IP Address (local) (sideband RX) */
114 uint32_t replayWindow; /**< Replay Window Size (sideband RX) */
115 nwal_saAALG authMode; /**< Authentication Algorithm */
116 nwal_saEALG cipherMode; /**< Encryption Algorithm */
117 uint32_t esnLo; /**< Initial Value of Extended Sequence Number LSB (sideband TX) */
118 uint32_t esnHi; /**< Initial Value of Extended Sequence Number MSB (sideband TX) */
119} NETAPI_SEC_SA_INFO_T;
120
121
122
123/**
124 * @brief This defines the SA mode of operation to be INFLOW. This means that IPSEC will be applied
125 * as the packet is being received or just before it is transmitted. This is a more efficient
126 * way to use SA and saves host cycles.
127 * @ingroup security_constants
128 */
129#define NETAPI_SEC_SA_INFLOW 0x2
130
131/**
132 * @brief This defines the SA mode of operation to be SIDEBAND. This means that Security Acclerator is
133 * to be used a traditional accelerator where for RX, the packet will first be received on host
134 * and then sent back to SA for crypto. For TX the packet will first be sent to SA for crypto,
135 * returned to host and then sent to NETCP for transmit.
136 * @ingroup security_constants
137 */
138#define NETAPI_SEC_SA_SIDEBAND 0x1
139/**
140 * @ingroup cfg_security_functions
141 * @brief netapi_secAddSA API to add an IPSEC SA.
142 *
143 * @details API to add an IPSec SA. SAs are IPSec security contexts and define a uni-directional
144 * secure path (tunnel or transport). SAs are attached to MAC interfaces that have already
145 * been created. API allows SA to be configured as either inflow or sideband mode. This API is used for both receive and transmit SAs.
146 * @param[in] h The NETAPI handle, @ref NETAPI_T
147 * @param[in] iface_no Interface to attach SA to.
148 * @param[in] sa_info Information on the SA being added, @ref NETAPI_SEC_SA_INFO_T
149 * @param[in] key_params Security key information for the SA.
150 * @param[in] mode SA implementation mode @ref NETAPI_SEC_SA_SIDEBAND or @ref NETAPI_SEC_SA_INFLOW
151 * @param[in] route Optional: @ref NETCP_CFG_ROUTE_HANDLE_T
152 * @param[in] data_mode_handle Returned data mode handle for PKTIO (in the case of sideband SAs)
153 * @param[in] inflow_mode_handle Returned inflow mode handle for PKTIO (in the case of TX inflow SAs)
154 * @param[in] user_data Optional: pointer to user provided data associated with SA, optional
155 * @param[out] perr Pointer to error code.
156 * @retval Application id associated with created SA @ref NETCP_CFG_SA_T.
157 * This ID is used when referencing this SA in subsequent APIs (eg. to delete it).
158 * Also in the case of Receive Inflow, packets will be tagged with this ID so that s/w will know
159 * that the packet has already been decrypted, authenticated and window-replay checked.
160 * (note: if a RX policy is matched also then the ID associated with the policy will be tagged instead).
161 * @pre @ref netapi_init
162 */
163NETCP_CFG_SA_T netapi_secAddSA(NETAPI_T h,
164 int iface_no,
165 NETAPI_SEC_SA_INFO_T* sa_info,
166 nwalSecKeyParams_t* key_params,
167 int mode,
168 NETCP_CFG_ROUTE_HANDLE_T route,
169 void** data_mode_handle,
170 void** inflow_mode_handle,
171 void* user_data,
172 int* perr);
173
174/**
175 * @ingroup cfg_security_functions
176 * @brief netapi_secAddSAIP API to add an IPSEC SA with IP handle.
177 *
178 * @details API to add an IPSec SA. SAs are IPSec security contexts and define a uni-directional
179 * secure path (tunnel or transport). SAs are attached to MAC interfaces that have already
180 * been created. API allows SA to be configured as either inflow or sideband mode. This API is used for both receive and transmit SAs.
181 * @param[in] h The NETAPI handle, @ref NETAPI_T
182 * @param[in] iface_no Interface to attach SA to.
183 * @param[in] sa_info Information on the SA being added, @ref NETAPI_SEC_SA_INFO_T
184 * @param[in] key_params Security key information for the SA.
185 * @param[in] mode SA implementation mode @ref NETAPI_SEC_SA_SIDEBAND or @ref NETAPI_SEC_SA_INFLOW
186 * @param[in] route Optional: @ref NETCP_CFG_ROUTE_HANDLE_T
187 * @param[in] data_mode_handle Returned data mode handle for PKTIO (in the case of sideband SAs)
188 * @param[in] inflow_mode_handle Returned inflow mode handle for PKTIO (in the case of TX inflow SAs)
189 * @param[in] user_data Optional: pointer to user provided data associated with SA, optional
190 * @param[in] ip_rule IP rule @ref NETCP_CFG_IP_T
191 * @param[out] perr Pointer to error code.
192 * @retval Application id associated with created SA @ref NETCP_CFG_SA_T.
193 * This ID is used when referencing this SA in subsequent APIs (eg. to delete it).
194 * Also in the case of Receive Inflow, packets will be tagged with this ID so that s/w will know
195 * that the packet has already been decrypted, authenticated and window-replay checked.
196 * (note: if a RX policy is matched also then the ID associated with the policy will be tagged instead).
197 * @pre @ref netapi_init
198 */
199NETCP_CFG_SA_T netapi_secAddSAIP(NETAPI_T h,
200 int iface_no,
201 NETAPI_SEC_SA_INFO_T *sa_info,
202 nwalSecKeyParams_t * key_params,
203 int inflow_mode,
204 NETCP_CFG_ROUTE_HANDLE_T route,
205 void **p_data_mode_handle,
206 void **p_inflow_mode_handle,
207 void * p_user_data,
208 NETCP_CFG_IP_T ip_rule,
209 int * perr);
210
211/**
212 * @ingroup cfg_security_functions
213 * @brief netapi_secDelSA: API to delete an IPSEC SA.
214 *
215 * @details API to delete an IPSEC SA
216 * @param[in] h The NETAPI handle, @ref NETAPI_T
217 * @param[in] iface_no Interface to attach SA to.
218 * @param[in] sa_app_id Application id returned from call to @ref netapi_secAddSA
219 * @param[out] perr Pointer to error code.
220 * @retval none
221 * @pre @ref netapi_init @ref netapi_secAddSA
222*/
223void netapi_secDelSA(NETAPI_T h,
224 int iface_no,
225 NETCP_CFG_SA_T sa_app_id,
226 int* perr);
227
228/**
229 * @ingroup cfg_security_functions
230 * @brief netapi_secAddRxPolicy: API to add a receive security policy
231 *
232 * @details API to add a receive security policy
233 * @param[in] h The NETAPI handle @ref NETAPI_T
234 * @param[in] sa Application id returned from call to @ref netapi_secAddSA.
235 * This SA must have beeen configured for (a) RX and (b) Inflow mode.
236 * @param[in] ipType IPV4 or IPV6
237 * @param[in] src_ip_addr source IP for policy check
238 * @param[in] dst_ip_addr destination IP for policy check
239 * @param[in] ip_qualifiers IP qualifiers for policy check
240 * @param[in] route Optional: @ref NETCP_CFG_ROUTE_HANDLE_T
241 * @param[in] user_data Optional: pointer to user provided data associated with policy
242 * @param[out] perr Pointer to error code.
243 * @retval Aplication id associated with created receive security policy @ref NETCP_CFG_IPSEC_POLICY_T. This is used to refer to the policy in the @ref netapi_secDelRxPolicy call. Also, packets that match this policy but do not pass any further lookups in NETCP will be tagged with this ID
244 * @pre @ref netapi_init @ref netapi_secAddSA
245*/
246NETCP_CFG_IPSEC_POLICY_T netapi_secAddRxPolicy(NETAPI_T h,
247 NETCP_CFG_SA_T sa,
248 nwal_IpType ipType,
249 nwalIpAddr_t* src_ip_addr,
250 nwalIpAddr_t* dst_ip_addr,
251 nwalIpOpt_t* ip_qualifiers,
252 NETCP_CFG_ROUTE_HANDLE_T route,
253 void* user_data,
254 int* perr);
255
256/**
257 * @ingroup cfg_security_functions
258 * @brief netapi_secDelRxPolicy: API to add a receive security policy
259 *
260 * @details API to add a receive security policy
261 * @param[in] h The NETAPI handle, @ref NETAPI_T
262 * @param[in] policy_app_id Application id returned from call to @ref netapi_secAddRxPolicy
263 * @param[out] perr Pointer to error code.
264 * @retval none
265 * @pre @ref netapi_init, @ref netapi_secAddRxPolicy
266*/
267void netapi_secDelRxPolicy(NETAPI_T h,
268 NETCP_CFG_IPSEC_POLICY_T policy_app_id,
269 int* perr);
270
271
272/**
273 * @ingroup cfg_security_functions
274 * @brief netapi_getSaStats: API to retrieve SA statistics via NWAL.
275 *
276 * @details API to retrieve SA statistics via NWAL.
277 * @param[in] h The NETAPI handle, @ref NETAPI_T
278 * @param[in] handle @ref NETCP_CFG_SA_T
279 * @param[out] pSaStats Pointer to SA stats which will get populated by this API call @ref NETAPI_SA_STATS_T
280 * @retval none
281 * @pre @ref netapi_init, @ref netapi_secAddSA
282*/
283void netapi_getSaStats (NETAPI_T h,
284 NETCP_CFG_SA_T handle,
285 NETAPI_SA_STATS_T* pSaStats);
286
287
288
289/**
290 * @ingroup cfg_security_functions
291 * @brief API to retrieve internal context information from channel resources
292 * maintained by NWAL. Selective NetCP PA/SA channel handles are exposed
293 * to handle the case of multiple owner use case for PA/SA LLD
294 * @details API to retrieve internal context information from channel resources
295 * maintained by NWAL. Selective NetCP PA/SA channel handles are exposed
296 * to handle the case of multiple owner use case for PA/SA LLD
297 * @param[in] h The NETAPI handle, @ref NETAPI_T
298 * @param[in] appId Application Id returned from any config APIs
299 * @param[out] pInfo NWAL Channel context information
300 * @retval none
301 * @pre @ref netapi_init, @ref netapi_secAddSA
302 */
303void netapi_secGetChanCtxInfo(NETAPI_T h,
304 NETCP_CFG_APP_ID_T appId,
305 nwalChanCxtInfo_t* pInfo);
306
307typedef struct {
308 uint32_t spi; /**< IPSec Security Parameter index */
309 nwalIpAddr_t src; /**< Source IP Address */
310 nwalIpAddr_t dst; /**< Destination Address */
311 nwal_IpSecProto proto; /**< IpSec Proto */
312 uint8_t inUse;
313 uint8_t ref_count;
314 NETCP_CFG_SA_T app_id;
315} NETAPI_SA_INFO_LOCAL_T;
316
317#ifdef __cplusplus
318}
319#endif
320#endif
diff --git a/ti/runtime/netapi/netapi_tune.h b/ti/runtime/netapi/netapi_tune.h
new file mode 100755
index 0000000..8da5725
--- /dev/null
+++ b/ti/runtime/netapi/netapi_tune.h
@@ -0,0 +1,335 @@
1/******************************************************************************
2 * FILE PURPOSE: netapi tunable parameters (compile time)
3 ******************************************************************************
4 * FILE NAME: netapi_tune.h
5 *
6 * DESCRIPTION:Tuneable (compile time) parameters for user space transport library
7 *
8 * REVISION HISTORY:
9 *
10 * Copyright (c) Texas Instruments Incorporated 2013
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
22 * distribution.
23 *
24 * Neither the name of Texas Instruments Incorporated nor the names of
25 * its contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 */
41/* ============================================================= */
42
43/**
44 * @file netapi_tune.h
45 * @brief Netapi Tuneable (compile time) parameters for user space transport library
46 */
47
48
49#ifndef __NETAPI_TUNE__H
50#define __NETAPI_TUNE__H
51
52#ifdef __cplusplus
53extern "C" {
54#endif
55/**
56 * @ingroup tune_parameters
57 * @def NETAPI_ENABLE_SECURITY
58 * Define this to enable securtiy.
59 * @note Libraries using netapi need to be built with SA enabled
60*/
61#define NETAPI_ENABLE_SECURITY
62
63
64/**
65 * @ingroup tune_parameters
66 * @def NETAPI_USE_DDR
67 * Define this to enable use of cached DDR for buffers and descriptors.
68 * @note Do not define if USE_MSMC defined below
69*/
70#define NETAPI_USE_DDR
71
72
73#ifdef NETAPI_USE_DDR
74/**
75 * @ingroup tune_parameters
76 * @def NETAPI_TUNE_USE_CACHE_OPS
77 * Define this to enable use of cached DDR for buffers and descriptors.
78 * @note Do not define if USE_MSMC defined below
79*/
80#define NETAPI_TUNE_USE_CACHE_OPS //for appleton, no cache coherency with netcp & ARM
81#endif
82
83/**
84 * @ingroup tune_parameters
85 * @def NETAPI_USE_MSMC
86 * Define this to enable use of un-cached MSMC for buffers and descriptors
87 * @note Do not define if USE_DDR defined above
88*/
89//#define NETAPI_USE_MSMC
90
91#ifdef NETAPI_USE_MSMC
92#ifdef NETAPI_USE_DDR
93#error "only define NETAPO_USE_MSMC or NETAPI_USE_DDR"
94#endif
95#endif
96
97/**
98 * @ingroup tune_parameters
99* @def TUNE_NETAPI_NUM_CORES
100* This defines the number of cores (theads)
101 */
102#define TUNE_NETAPI_NUM_CORES 5
103
104/**
105 * @ingroup tune_parameters
106 * @def TUNE_NETAPI_PERM_MEM_SZ
107 * This defines how much contiguous memory to grab. This is used for
108 * descriptors and buffers in the case of uncached configuration only.
109 * descriptors and buffers. Can't be bigger than msmc if
110 * MSMC memory is being using uncached . This can be set at netapi_init via NETAPI_CFG_T
111 */
112#define TUNE_NETAPI_PERM_MEM_SZ (2*1024*1024)
113
114/**
115 * @ingroup tune_parameters
116 * @def TUNE_NETAPI_MAX_PKTIO
117 * This defines the number of GLOBAL pkt io channels
118 */
119#define TUNE_NETAPI_MAX_PKTIO 16
120
121/**
122 * @ingroup tune_parameters
123 * @def TUNE_NETAPI_DEFAULT_BUFFER_SIZE
124 * This defines the size of the netapi default pktlib heap buffers This can be set at @ref netapi_init
125 */
126#define TUNE_NETAPI_DEFAULT_BUFFER_SIZE 1600
127
128
129/**
130 * @ingroup tune_parameters
131 * @def TUNE_NETAPI_DEFAULT_NUM_BUFFERS
132 * This defines the number of netapi default pktlib heap buffers (and assoc descriptors)
133 * this can be set at @ref netapi_init
134 */
135#define TUNE_NETAPI_DEFAULT_NUM_BUFFERS 200
136
137/**
138 * @ingroup tune_parameters
139 * @def TUNE_NETAPI_DEFAULT_NUM_SOLO_DESCRIPTORS
140 * This defines the number of netapi default pkt lib heap solo descriptors
141 * this can be set at @ref netapi_init
142 */
143#define TUNE_NETAPI_DEFAULT_NUM_SOLO_DESCRIPTORS 100
144
145/**
146 * @ingroup tune_parameters
147 * @def NETAPI_INCLUDE_SCHED
148 * Define this to include the scheduler component
149 */
150#define NETAPI_INCLUDE_SCHED
151
152/**
153 * @ingroup tune_parameters
154 * @def TUNE_NETAPI_QM_CONFIG_MAX_DESC_NUM
155 * This defines the number of of QM descriptors (total). This can be set set in @ref netapi_init
156 * @note Must be a power or 2
157*/
158#define TUNE_NETAPI_QM_CONFIG_MAX_DESC_NUM 2048 /* 16384 is abs max */
159
160
161/**
162 * @ingroup tune_parameters
163 * @def TUNE_NETAPI_NUM_LOCAL_DESC
164 * This defines the number of of QM descriptors (total). This can be set set in @ref netapi_init
165*/
166#define TUNE_NETAPI_NUM_LOCAL_DESC 64
167
168
169/**
170 * @ingroup tune_parameters
171 * @def TUNE_NETAPI_NUM_GLOBAL_DESC
172 * This defines the number of global descriptors.
173 * @note Must be a power or 2
174*/
175#define TUNE_NETAPI_NUM_GLOBAL_DESC 1024
176
177/**
178 * @ingroup tune_parameters
179 * @def TUNE_NETAPI_DESC_SIZE
180 * This defines the descriptor size
181 * @note This define should NOT be changes
182 */
183#define TUNE_NETAPI_DESC_SIZE 128
184
185/**
186 * @ingroup tune_parameters
187 * @def TUNE_NETAPI_NWAL_ENABLE_PASS_LOOPBACK
188 * Define this to 1 for debutg mode where NETCP just loops pkts that tx back to rx
189 */
190#define TUNE_NETAPI_NWAL_ENABLE_PASS_LOOPBACK 0 /*1*/
191
192
193/// @cond INTERNAL
194//(10) NWAL (internal) config. Should not have to change
195#define TUNE_NETAPI_CONFIG_MAX_PA_TO_SA_DESC 32
196#define TUNE_NETAPI_CONFIG_MAX_SA_TO_PA_DESC 200
197/// @endcond
198
199/**
200 * @ingroup tune_parameters
201 * @def TUNE_NETAPI_MAX_NUM_MAC
202 * This defines the number of logical mac addresses
203 */
204#define TUNE_NETAPI_MAX_NUM_MAC 64
205
206/**
207 * @ingroup tune_parameters
208 * @def TUNE_NETAPI_MAX_NUM_IP
209 * This defines the number of ip addresses
210 */
211#define TUNE_NETAPI_MAX_NUM_IP 64
212
213/**
214 * @ingroup tune_parameters
215 * @def TUNE_NETAPI_MAX_NUM_PORTS_PER_CORE
216 * This defines the number of ports per core
217 */
218#define TUNE_NETAPI_MAX_NUM_PORTS_PER_CORE 4
219
220/**
221 * @ingroup tune_parameters
222 * @def TUNE_NETAPI_MAX_NUM_PORTS
223 * This defines the number maximum number of ports
224 */
225#define TUNE_NETAPI_MAX_NUM_PORTS (TUNE_NETAPI_MAX_NUM_PORTS_PER_CORE * (TUNE_NETAPI_NUM_CORES))
226
227#ifdef NETAPI_ENABLE_SECURITY
228/**
229 * @ingroup tune_parameters
230 * @def TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS
231 * This defines the number maximum number of ipsec channels
232 */
233#define TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS 128
234#else
235/**
236 * @ingroup tune_parameters
237 * @def TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS
238 * This defines the number maximum number of ipsec channels
239 */
240#define TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS 0
241#endif
242
243/**
244 * @ingroup tune_parameters
245 * @def TUNE_NETAPI_MAX_NUM_L2_L3_HDRS
246 * This defines the number maximum number of L2_L3 headers to reserve in the nwal layer. This should be kept small as transport lib does not expose this inwal feature by default
247 */
248#define TUNE_NETAPI_MAX_NUM_L2_L3_HDRS 3
249
250/**
251 * @ingroup tune_parameters
252 * @def TUNE_NETAPI_MAX_NUM_TRANS
253 * This defines the number maximum number of transactions with NETCP that can be outstanding at any one time
254 */
255#define TUNE_NETAPI_MAX_NUM_TRANS (TUNE_NETAPI_MAX_NUM_MAC + TUNE_NETAPI_MAX_NUM_IP + TUNE_NETAPI_MAX_NUM_PORTS + TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS)
256
257
258/// @cond INTERNAL
259/* PA control buffer pool (internal) */
260#define TUNE_NETAPI_CONFIG_MAX_CTL_RXTX_BUF_SIZE 2400
261#define TUNE_NETAPI_CONFIG_NUM_CTL_RX_BUF 16
262#define TUNE_NETAPI_CONFIG_NUM_CTL_TX_BUF 16
263/// @endcond
264
265/**
266 * @ingroup tune_parameters
267 * @def TUNE_NETAPI_MAX_BURST_RCV
268 * This defines the maximum number of packets to receive in one pktio poll.
269 */
270#define TUNE_NETAPI_MAX_BURST_RCV 32
271
272/**
273 * @ingroup tune_parameters
274 * @def TUNE_NETAPI_NUM_TIMER_CELLS
275 * This defines the number of hash bins in a timer group.
276 */
277#define TUNE_NETAPI_NUM_TIMER_CELLS 128
278/**
279 * @ingroup tune_parameters
280 * @def TUNE_NETAPI_NUM_GLOBAL_TIMERS
281 * This defines the number of global timer blocks
282 */
283#define TUNE_NETAPI_NUM_GLOBAL_TIMERS 4
284
285/**
286 * @ingroup tune_parameters
287 * @def TUNE_NETAPI_MAX_HEAPS
288 * This defines the maximum number of heaps one NETAPI instance can create
289 */
290#define TUNE_NETAPI_MAX_HEAPS 4
291
292/**
293 * @ingroup tune_parameters
294 * @def TUNE_NETAPI_MAX_CLASSIFIERS
295 * This defines the maximum number of classifiers
296 */
297#define TUNE_NETAPI_MAX_CLASSIFIERS 16
298
299/**
300 * @ingroup tune_parameters
301 * @def TUNE_NETAPI_MAX_BUF_POOLS_IN_FLOW
302 * This defines the maximum number of buffer pools in a flow - A flow is used by hardware
303 * when it needs a buffer for a receive packet. This define allows the maximum number
304 * of pools (free descriptor queues) to be defined for a flow, so that different sized packets
305 * can be allocated from different memory areas.
306 * @note This define should NOT be changed as HW assumes at most 4 now
307 */
308#define TUNE_NETAPI_MAX_BUF_POOLS_IN_FLOW 4
309
310
311/**
312 * @ingroup tune_parameters
313 * @def TUNE_NETAPI_MAX_FLOWS
314 * This defines the maximum number of flows
315 */
316#define TUNE_NETAPI_MAX_FLOWS 4 //app defined flows
317
318/**
319 * @ingroup tune_parameters
320* @def TUNE_NETAPI_MAX_SA
321* This defines the maximum number of security associations
322*/
323#define TUNE_NETAPI_MAX_SA 128 //rx&tx combined (so MAX_SA/4 tunnels typically)
324
325/**
326 * @ingroup tune_parameters
327 * @def TUNE_NETAPI_MAX_POLICY
328 * This defines the maximum number of security policies.
329*/
330#define TUNE_NETAPI_MAX_POLICY 128 //rx policies
331
332#ifdef __cplusplus
333}
334#endif
335#endif
diff --git a/ti/runtime/netapi/netapi_types.h b/ti/runtime/netapi/netapi_types.h
new file mode 100755
index 0000000..ca5c075
--- /dev/null
+++ b/ti/runtime/netapi/netapi_types.h
@@ -0,0 +1,159 @@
1/*******************************
2 * file: netapi_err.h
3 * purpose: netapi error codes
4 **************************************************************
5 * @file netapi.h
6 *
7 * @brief DESCRIPTION: netapi Error Definitions for user space transport
8 * library
9 *
10 * REVISION HISTORY: rev 0.0.1
11 *
12 * Copyright (c) Texas Instruments Incorporated 2013
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
42 ******************************/
43
44#ifndef __NETAPI_ERR__
45#define __NETAPI_ERR__
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51/**
52 * @ingroup cfg_constants
53 * @brief One per thread/core, used in most NETAPI function calls, returned from call to netapi_init().
54 */
55typedef void * NETAPI_T;
56
57
58
59/**
60 * @defgroup netapi_RetValue NETAPI API Return Values
61 * @ingroup netapi
62 */
63/** @ingroup nwal_RetValue */
64typedef int16_t netapi_RetValue;
65
66/** @defgroup netapi_errors NETAPI Error Return Values
67 * @ingroup netapi
68 */
69
70/**
71 * @def NETAPI_ERR_OK
72 * @ingroup netapi_errors
73 * No error
74 */
75#define NETAPI_ERR_OK 0
76
77/**
78 * @def NETAPI_ERR_NOMEM
79 * @ingroup netapi_errors
80 * @brief out of memory error
81 */
82#define NETAPI_ERR_NOMEM -1
83
84/**
85 * @def NETAPI_ERR_BAD_INPUT
86 * @ingroup netapi_errors
87 * @brief arguments or configuraiton is invalid
88 */
89#define NETAPI_ERR_BAD_INPUT -2
90
91/**
92 * @def NETAPI_ERR_QLLD
93 * @ingroup netapi_errors
94 * @brief QUEUE MANAGER Reports an error
95 */
96#define NETAPI_ERR_QLLD -3
97
98/**
99 * @def NETAPI_ERR_NOTFOUND
100 * @ingroup netapi_errors
101 * @brief the resource cannot be located
102 */
103#define NETAPI_ERR_NOTFOUND -4
104/**
105 * @def NETAPI_ERR_BUSY
106 * @ingroup netapi_errors
107 * @brief Temporarily out of resources or resource leak
108 */
109#define NETAPI_ERR_BUSY -5
110
111/**
112 * @def NETAPI_ERR_NWAL_ERR0
113 * @ingroup netapi_errors
114 * @brief NWAL subsytem reports error
115 */
116#define NETAPI_ERR_NWAL_ERR0 -6
117
118/**
119 * @def NETAPI_ERR_NOT_IMPLEMENTED
120 * @ingroup netapi_errors
121 * @brief Feature not implemented in this version
122 */
123#define NETAPI_ERR_NOT_IMPLEMENTED -7
124
125/**
126 * @def NETAPI_ERR_NORES
127 * @ingroup netapi_errors
128 * @brief no free (hw) resources available
129 */
130#define NETAPI_ERR_NORES -8
131
132/**
133 * @def NETAPI_ERR_NORES
134 * @ingroup netapi_errors
135 * @brief error returned by NETCP PA firmware
136 */
137#define NETAPI_ERR_PA_FW -9
138
139
140/**
141 * @def NETAPI_ERR_ALREADY_CANCELLED
142 * @ingroup netapi_errors
143 * @brief timer has already been cancelled
144 */
145#define NETAPI_ERR_ALREADY_CANCELLED -100
146
147/**
148 * @def NETAPI_ERR_NWAL_TX_ERR
149 * @ingroup netapi_errors
150 * @brief error trying to send to NWAL.
151 */
152#define NETAPI_ERR_NWAL_TX_ERR -65536
153
154#ifdef __cplusplus
155}
156#endif
157
158
159#endif
diff --git a/ti/runtime/netapi/netapi_util.h b/ti/runtime/netapi/netapi_util.h
new file mode 100644
index 0000000..a1cc0c7
--- /dev/null
+++ b/ti/runtime/netapi/netapi_util.h
@@ -0,0 +1,422 @@
1/******************************************************
2 * File: netapi_util.h
3 * Purpose: misc utilites
4 **************************************************************
5 * FILE: netapi_util.h
6 *
7 * DESCRIPTION: netapi utility header file for user space transport
8 * library
9 *
10 * REVISION HISTORY:
11 *
12 * Copyright (c) Texas Instruments Incorporated 2013
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
42 *****************************************************/
43#ifndef __NETAPI_UTIL__H
44#define __NETAPI_UTIL__H
45
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51#include <stdint.h>
52#include "./src/netapi_loc.h"
53
54
55//#define NETAPI_DEBUG
56#ifdef NETAPI_DEBUG
57#define netapi_Log printf
58#else
59#define netapi_Log
60#endif
61
62extern NETAPI_SHM_T* pnetapiShm;
63
64/* Wrapper functions around HPLIB APIs for QMSS , *utility to convert virt2phy, phy2virt */
65#define _Osal_qmssVirtToPhy hplib_mVMVirtToPhy
66
67#define _Osal_qmssPhyToVirt hplib_mVMPhyToVirt
68
69//static hplib_spinLock_T netapi_util_lock = hplib_spinLock_UNLOCKED_INITIALIZER;
70
71/**
72 * @ingroup netapi_gen_functions
73 * @brief netapi_registerHeap API is used to register a heap that is created by application so that
74 * it's garbage queue can be polled automatically by @ref netapi_pollHeapGarbage.
75 *
76 * @details This API registers an application-created heap with the netapi instance
77 * so that it can add that heap's garbage queue to the garbage poll function.
78 * NOTE: netapi internal heap is automatically registered
79 * @param[in] p The NETAPI handle, @ref NETAPI_T
80 * @param[in] h Handle of pklib heap to register
81 * @retval 1 if OK, <0 on error
82 * @pre @ref netapi_init
83 */
84static inline int netapi_registerHeap(NETAPI_T p,
85 Pktlib_HeapHandle h)
86{
87 NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
88 int i;
89 pp->spinLock.lock(&pnetapiShm->netapi_util_lock);
90 for(i=0;i<TUNE_NETAPI_MAX_HEAPS;i++)
91 {
92 if (!pp->createdHeaps[i])
93 {
94 pp->createdHeaps[i]=h;
95 pp->spinLock.unlock(&pnetapiShm->netapi_util_lock);
96 return 1;
97 }
98 }
99 pp->spinLock.unlock(&pnetapiShm->netapi_util_lock);
100 return -1;
101}
102
103/**
104 * @ingroup netapi_gen_functions
105 * @brief netapi_unregisterHeap API is used to un-register a heap that was created by application
106 * and previously registered so that it's garbage queue could be polled
107 * automatically by @ref netapi_pollHeapGarbage.
108 *
109 * @details This API un-registers an application-created heap with the netapi instance.
110 * NOTE: netapi internal heap is automatically registered
111 * @param[in] p The NETAPI handle, @ref NETAPI_T
112 * @param[in] h The pklib handle to heap
113 * @retval <0 if err, 1 if OK
114 * @pre @ref netapi_init
115 */
116static inline int netapi_unregisterHeap(NETAPI_T p,
117 Pktlib_HeapHandle h)
118{
119 NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
120 int i;
121 pp->spinLock.lock(&pnetapiShm->netapi_util_lock);
122 for(i=0;i<TUNE_NETAPI_MAX_HEAPS;i++)
123 {
124 if (pp->createdHeaps[i] == h)
125 {
126 pp->createdHeaps[i]=NULL;
127 pp->spinLock.unlock(&pnetapiShm->netapi_util_lock);
128 return 1;
129 }
130 }
131 pp->spinLock.unlock(&pnetapiShm->netapi_util_lock);
132 return -1;
133}
134
135/**
136 * @ingroup netapi_gen_functions
137 * @brief netapi_closeHeap API is used to remove a created pktlib heap
138 *
139 * @details This API removes an application-created heap with the netapi instance
140 * NOTE: descriptors are zapped and cannot be reused]
141 * @param[in] p The NETAPI handle, @ref NETAPI_T
142 * @param[in] h : handle to pklib heap
143 * @retval <0 if err, 1 if OK
144 * @pre @ref netapi_init @ref netapi_registerHeap
145 */
146static inline int netapi_closeHeap(NETAPI_T p,
147 Pktlib_HeapHandle h)
148{
149 int err = 0;
150
151 NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
152 Qmss_QueueHnd q;
153 Pktlib_garbageCollection(h);
154
155 Pktlib_deleteHeap(h, &err);
156
157 return 1;
158}
159/**
160 * @ingroup netapi_gen_functions
161 * @brief netapi_getCookie API is used to return a piece of application-provided opaque data that has been
162 * stored in the netapi instance.
163 *
164 * @details The application can save a pointer to opaque data in the @ref NETAPI_T instance.
165 * This APi lets this data be returned to the application.
166 * @param[in] p The NETAPI handle, @ref NETAPI_T
167 * @retval Data provided in @ref netapi_setCookie
168 * @pre @ref netapi_init, @ref netapi_setCookie
169 */
170
171static inline void * netapi_getCookie(NETAPI_T p)
172{
173 NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
174 return pp->cookie;
175}
176
177/**
178 * @ingroup netapi_gen_functions
179 * @brief netapi_setCookie API is used to set a piece of application-provided opaque data t in the netapi instance.
180 *
181 * @details The applicaiton can save a pointer to opaque data in the @ref NETAPI_T instance.
182 * Pointer to a opaque data can be returned later to the application via @ref netapi_getCookie
183 * @param[in] p The NETAPI handle, @ref NETAPI_T
184 * @param[in] cookie Opaque data to be saved
185 * @retval none
186 * @pre @ref netapi_init
187 */
188static inline void netapi_setCookie(NETAPI_T p,
189 void * cookie)
190{
191 NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
192 pp->cookie= cookie;
193}
194
195/**
196 * @ingroup netapi_gen_functions
197 * @brief netapi_getBufMemRemainder API is used to return the amount of free memory available for
198 * allocating buffers for additonal Pktlib heaps
199 *
200 * @details The application can use this API to determine how much free memory is
201 * available for heap buffers if it decides to create its own.
202 * @retval Amount of memory available for heap buffer storage (in bytes)
203 * @pre @ref netapi_init
204 */
205static inline int netapi_getBufMemRemainder(void)
206{
207 return hplib_vmGetMemPoolRemainder(0);
208}
209
210/**
211 * @ingroup netapi_gen_functions
212 * @brief netapi_getDefaultFlow: API is used to return the default NETCP flow that is to
213 * be used for incoming packets.
214 *
215 * @details The application can use this API to return the default NETCP flow that is used
216 * for received packets. A NETCP flow is a list of PacketLib Heaps that are to be
217 * used to supply free packets to the receive DMA function.
218 * @param[in] p The NETAPI handle, @ref NETAPI_T
219 * @retval NETCP_CFG_FLOW_HANDLE_T The handle to default flow
220 * @pre @ref netapi_init
221 */
222static inline NETCP_CFG_FLOW_HANDLE_T netapi_getDefaultFlow(NETAPI_T p)
223{
224 return NETCP_DEFAULT_FLOW;
225}
226
227/**
228 * @ingroup netapi_gen_functions
229 * @brief netapi_getDefaultRoute: API is used to return the default NETCP route handle.
230 *
231 * @details This API returns the default NETCP route created by @ref netapi_init.
232 * A netcp route consists of a NETCP flow plus a destination pktio channel
233 * @param[in] p The NETAPI handle, @ref NETAPI_T
234 * @retval The handle of the default route, NETCP_CFG_ROUTE_HANDLE_T
235 * @pre @ref netapi_init
236 */
237static inline NETCP_CFG_ROUTE_HANDLE_T netapi_getDefaultRoute(NETAPI_T p)
238{
239 return NETCP_DEFAULT_ROUTE;
240}
241
242/**
243 * @ingroup cfg_functions
244 * @brief netapi_netcpCfgGetPolicyUserData API to retrieve user mode data associated with
245 * Policy APPID.
246 *
247 * @details This api is used to retrieve user mode data associated with an Policy APPID
248 * @param[in] h NETAPI instance handle, @ref NETAPI_T
249 * @param[in] app_id application id whose user mode data is to be retrieved
250 * @retval void* pointer to user mode data.
251 * @pre @ref netapi_init
252 */
253static inline void* netapi_netcpCfgGetPolicyUserData(NETAPI_T h,
254 NETCP_CFG_SA_T app_id)
255{
256 NETAPI_NWAL_GLOBAL_CONTEXT_T *p = &netapi_get_global()->nwal_context;
257 int slot = netapi_cfgGetMatchId(app_id);
258 if ((slot <0 ) || (slot >= TUNE_NETAPI_MAX_POLICY))
259 {
260 return NULL;
261 }
262 return (p->policy[slot].user_data);
263}
264
265/**
266 * @ingroup cfg_functions
267 * @brief netapi_netcpCfgGetIpSecUserData API to retrieve user mode data associated with IPSEC APPID.
268 *
269 * @details This api is used to retrieve user mode data associated with an IPSEC APPID
270 * @param[in] h NETAPI instance handle, @ref NETAPI_T
271 * @param[in] app_id application id whose user mode data is to be retrieved
272 * @retval void* pointer to user mode data.
273 * @pre @ref netapi_init
274 */
275static inline void* netapi_netcpCfgGetIpSecUserData(NETAPI_T h,
276 NETCP_CFG_SA_T app_id)
277{
278 NETAPI_NWAL_GLOBAL_CONTEXT_T *p = &netapi_get_global()->nwal_context;
279 int slot = netapi_cfgGetMatchId(app_id);
280 if ((slot <0 ) || (slot >= TUNE_NETAPI_MAX_SA))
281 {
282 return NULL;
283 }
284 return (p->tunnel[slot].user_data);
285}
286
287
288/**
289 * @ingroup cfg_functions
290 * @brief netapi_netcpCfgGetIpUserData API to retrieve user mode data associated with Generic IP APPID.
291 *
292 * @details This api is used to retrieve user mode data associated with a Generic IP APPID
293 * @param[in] h NETAPI instance handle, @ref NETAPI_T
294 * @param[in] app_id application id whose user mode data is to be retrieved
295 * @retval void* pointer to user mode data.
296 * @pre @ref netapi_init
297 */
298static inline void* netapi_netcpCfgGetIpUserData(NETAPI_T h,
299 NETCP_CFG_SA_T app_id)
300{
301 NETAPI_NWAL_GLOBAL_CONTEXT_T *p = &netapi_get_global()->nwal_context;
302 int slot = netapi_cfgGetMatchId(app_id);
303 if ((slot <0 ) || (slot >= TUNE_NETAPI_MAX_NUM_IP))
304 {
305 return NULL;
306 }
307 return (p->ips[slot].user_data);
308}
309
310/**
311 * @ingroup cfg_functions
312 * @brief netapi_netcpCfgGetClassiferUserData API to retrieve user mode data associated with Classifer APPID.
313 *
314 * @details This api is used to retrieve user mode data associated with a flassifier APPID
315 * @param[in] h NETAPI instance handle, @ref NETAPI_T
316 * @param[in] app_id application id whose user mode data is to be retrieved
317 * @retval void* pointer to user mode data.
318 * @pre @ref netapi_init
319 */
320static inline void* netapi_netcpCfgGetClassiferUserData(NETAPI_T h,
321 NETCP_CFG_SA_T app_id)
322{
323 NETAPI_NWAL_GLOBAL_CONTEXT_T *p = &netapi_get_global()->nwal_context;
324 int slot = netapi_cfgGetMatchId(app_id);
325 if ((slot <0 ) || (slot >= TUNE_NETAPI_MAX_CLASSIFIERS))
326 {
327 return NULL;
328 }
329 return (p->classi[slot].user_data);
330}
331
332
333/**
334 * @ingroup cfg_functions
335 * @brief netapi_netcpCfgGetUserData API to retrieve user mode data associated with APPID.
336 *
337 * @details This api is used to retrieve user mode data associated with an APPID
338 * @param[in] h NETAPI instance handle, @ref NETAPI_T
339 * @param[in] app_id application id whose user mode data is to be retrieved
340 * @retval void* pointer to user mode data.
341 * @pre @ref netapi_init
342 */
343static inline void* netapi_netcpCfgGetUserData(NETAPI_T h,
344 NETCP_CFG_SA_T app_id)
345{
346 NETCP_CFG_SA_T appIdType;
347 NETAPI_NWAL_GLOBAL_CONTEXT_T *p = &netapi_get_global()->nwal_context;
348
349 appIdType = app_id & 0xff000000;
350 switch(appIdType)
351 {
352 case(NETAPI_NETCP_MATCH_IPSEC):
353 return (netapi_netcpCfgGetIpSecUserData(h, app_id));
354 break;
355 case(NETAPI_NETCP_MATCH_IPSEC_POLICY):
356 return (netapi_netcpCfgGetPolicyUserData(h, app_id));
357 break;
358 case(NETAPI_NETCP_MATCH_GENERIC_IP):
359 return (netapi_netcpCfgGetIpUserData(h, app_id));
360 break;
361 case(NETAPI_NETCP_MATCH_CLASS):
362 return (netapi_netcpCfgGetClassiferUserData(h, app_id));
363 break;
364 default:
365 return NULL;
366 break;
367 }
368}
369
370/**
371 * @ingroup cfg_functions
372 * @brief netapi_netcpCfgUpdateUserData API to update user mode data associated with APPID.
373 *
374 * @details This api is used to update user mode data associated with an APPID
375 * @param[in] h NETAPI instance handle, @ref NETAPI_T
376 * @param[in] app_id application id whose user mode data is to updated
377 * @retval void* pointer to user mode data.
378 * @pre @ref netapi_init
379 */
380static inline netapi_RetValue netapi_netcpCfgUpdateUserData(NETAPI_T h,
381 NETCP_CFG_SA_T app_id,
382 void * user_data)
383{
384 NETCP_CFG_SA_T appIdType;
385 NETAPI_NWAL_GLOBAL_CONTEXT_T *p = &netapi_get_global()->nwal_context;
386
387 int slot = netapi_cfgGetMatchId(app_id);
388 if ((slot <0 ) || (slot >= TUNE_NETAPI_MAX_CLASSIFIERS))
389 {
390 return NETAPI_ERR_BAD_INPUT;
391 }
392 appIdType = app_id & 0xff000000;
393 switch(appIdType)
394 {
395 case(NETAPI_NETCP_MATCH_IPSEC):
396 p->tunnel[slot].user_data = user_data;
397 return NETAPI_ERR_OK;
398 break;
399 case(NETAPI_NETCP_MATCH_IPSEC_POLICY):
400 p->policy[slot].user_data = user_data;
401 return NETAPI_ERR_OK;
402 break;
403 case(NETAPI_NETCP_MATCH_GENERIC_IP):
404 p->ips[slot].user_data = user_data;
405 return NETAPI_ERR_OK;
406 break;
407 case(NETAPI_NETCP_MATCH_CLASS):
408 p->classi[slot].user_data = user_data;
409 return NETAPI_ERR_OK;
410 break;
411 default:
412 return NETAPI_ERR_BAD_INPUT;
413 break;
414 }
415}
416
417#ifdef __cplusplus
418}
419#endif
420
421
422#endif
diff --git a/ti/runtime/netapi/netapi_ver.h b/ti/runtime/netapi/netapi_ver.h
new file mode 100755
index 0000000..43ab444
--- /dev/null
+++ b/ti/runtime/netapi/netapi_ver.h
@@ -0,0 +1,94 @@
1/*******************************
2 * file: netapi_ver.h
3 * purpose: netapi version information
4 **************************************************************
5 * @file netapi.h
6 *
7 * @brief DESCRIPTION: netapi version information for user space transport
8 * library
9 *
10 * REVISION HISTORY:
11 *
12 * Copyright (c) Texas Instruments Incorporated 2013
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
42 ******************************/
43
44#ifndef __NETAPI_ERR__
45#define __NETAPI_ERR__
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51/**
52 * @def NETAPI_VERSION_ID
53 * This is the NETAPI Version. Versions numbers are encoded in the following
54 * format:
55 * 0xAABBCCDD -> Arch (AA); API Changes (BB); Major (CC); Minor (DD)
56 */
57#define NETAPI_VERSION_ID (0x01010006)
58
59/**
60 * @def NETAPI_VERSION_STR
61 * This is the version string which describes the NETAPI along with the
62 * date and build information.
63 */
64#define NETAPI_VERSION_STR "NETAPI Revision: 01.01.00.06"
65
66/**
67 * @ingroup netapi_gen_functions
68 * @brief netapi_mGetVersion API used to get version of NETAPI
69 *
70 * @details This API used to get version of netapi
71 * @retval int version of netapi
72 * @pre @ref netapi_init
73 */
74static inline int netapi_getVersion(void)
75{
76return NETAPI_VERSION_ID;
77}
78
79/**
80 * @ingroup netapi_gen_functions
81 * @brief netapi_mGetVersionString API used to get version string of NETAPI
82 *
83 * @details This API used to get version string of netapi
84 * @retval char version string of netapi
85 * @pre @ref netapi_init
86 */
87static inline char * netapi_getVersionString(void) { return NETAPI_VERSION_STR;}
88
89
90
91#ifdef __cplusplus
92}
93#endif
94#endif
diff --git a/ti/runtime/netapi/netcp_cfg.h b/ti/runtime/netapi/netcp_cfg.h
new file mode 100755
index 0000000..1953a98
--- /dev/null
+++ b/ti/runtime/netapi/netcp_cfg.h
@@ -0,0 +1,911 @@
1/******************************************************************************
2 * FILE PURPOSE: netapi NETCP configuration API header file
3 ******************************************************************************
4 * FILE NAME: netcp_cfg.h
5 *
6 * DESCRIPTION:netapi NETCP configuration API header file for user space transport library
7 *
8 * REVISION HISTORY:
9 *
10 * Copyright (c) Texas Instruments Incorporated 2013
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
22 * distribution.
23 *
24 * Neither the name of Texas Instruments Incorporated nor the names of
25 * its contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 */
41/* ============================================================= */
42
43/**
44 * @file netcp_cfg.h
45 * @brief Netapi NETCP configuration API header file for user space transport library
46 */
47
48
49
50#ifndef __NETCP_CFG__H
51#define __NETCP_CFG__H
52
53#ifdef __cplusplus
54extern "C" {
55#endif
56
57//#include "netapi.h"
58
59/**
60 * @ingroup cfg_structures
61 * @brief NETCP Flow ID configuaration informaation
62 * @details A flow defines a set of free queues (pktlib heap) for hardware to use to get
63 * free packet descriptor(s) and buffer(s) to use when receiving a packet. CPPI flow ID for
64 * default case, use NETCP_DEFAULT_FLOW
65 */
66typedef struct NETCP_CFG_FLOW_Tag
67{
68 int flowid; /**< flow id*/
69 int dma_engine; /**< dma engine (QMSS, NETCP)*/
70} NETCP_CFG_FLOW_T;
71
72
73/**
74 * @ingroup cfg_structures
75 * @brief NETAPI configuration information
76 *
77 * @details The parameters in this structure are used to configure NETAPI.
78 */
79typedef struct NETAPI_CFG_Tag
80{
81 int def_mem_size; /**< Bytes of CMA memory we have allocated */
82 int def_flow_pkt_rx_offset; /**< Offset in pkt buffer for hw to start RX */
83 int def_max_descriptors; /**< Number of descriptors in system (must be power of 2), 2^14 max */
84 int def_tot_descriptors_for_us; /**< Number of descriptors to create in our region (must be power of 2)*/
85 int def_heap_n_descriptors; /**< Number of descriptor plus buffers in default heap*/
86 int def_heap_n_zdescriptors; /**< Number of zero len descriptors in defaut heap*/
87 int def_heap_buf_size; /**< Size of buffers in default heap, max amount of area for packet data */
88 int def_heap_tailroom_size; /**< Size of tailroom in reserve */
89 int def_heap_extra_size; /**< Size of extra space at end of buffer */
90 int def_multi_process; /**< Flag to indicate if NETAPI init is for multi-process environment */
91 void *rmHandle; /**< Optional: Resource Manager (RM) server handle to use RM for re souce allocations*/
92 int memoryRegion; /**< Optional: Specify the descriptor memory region to be used,
93 must be a valid memory region index
94 (0 to Maximum number of memory regions supported
95 Not used when using Resouce Manager(RM)as QMSS via RM will
96 return available Memory Region Id.
97 */
98 int start_index; /**< Optional: Used to leave holes by configuring dummy regions which
99 can be later configured with actual values. May either be
100 specified by the user (for example, to select "internal" or
101 "external" linking RAM, or set to QMSS_START_INDEX_NOT_SPECIFIED,
102 QMSS_PARAM_NOT_SPECIFIED to have LLD/RM select a compatible startIndex
103 from anywhere with free indicies, or QMSS_START_INDEX_INTERNAL.
104 for internal linking RAM, QMSS_START_INDEX_EXTERNAL for external linking RAM.
105 Not used when using Resouce Manager(RM)as QMSS via RM will
106 return available Memory Region Id and determine avialable start index.
107 */
108} NETAPI_CFG_T;
109
110/* @note:
111 each buffer will be allocated: def_heap_buf_size+def_heap_extra_size bytes
112 each descriptor attached to these buffers will have rigBufferLen of:
113 def_heap_buf_size.
114 for default RX flow, for rx packet, the bufptr will be def_flow_pkt_rx_offset.
115 for detault RX flow, threshold (ie max # of bytes in buffer) will be:
116 def_heap_buf_size - def_heap_tailroom_size-def_flow_pkt_rx_offset
117
118
119 RX Packet from NetCP
120
121Headroom [Application] Packet [HW] Tailroom [Application] Extra Space [Application]
122<-----------------------><--------------------------><------------------------><----------------------->
123
124Cppi_HostDesc->origBufferLen
125<----------------------------------------------------------------------------->
126Cppi_HostDesc->origBuffPtr
127|
128\/
129|------------def_heap_buf_size-------------------------------------------------|--def_heap_extra_size--|
130| def_flow_pkt_rx_offset| max Cppi_HostDesc->buffLen | def_heap_tailroom_size | Extra Size |
131 ^
132 |
133 Cppi_HostDesc->buffPtr
134*/
135
136
137/**
138 * @ingroup cfg_constants
139 * @brief This defines the handle to a NETCP configured Flow. A Flow is a set of pktlib heaps that h/w can use to obtain free packets.
140 */
141typedef NETCP_CFG_FLOW_T* NETCP_CFG_FLOW_HANDLE_T;
142
143/**
144 * @ingroup cfg_constants
145 * @def NETCP_DEFAULT_FLOW
146 * @brief This defines the default FLOW for NETCP to use.
147 * The default flow uses the default pktlib heap created by netapi_init; i.e.
148 * NETCP will allocate descriptors and buffers for received packets from this heap.
149 */
150#define NETCP_DEFAULT_FLOW (NETCP_CFG_FLOW_HANDLE_T) NULL
151
152
153
154/**
155 * @ingroup cfg_constants
156 * @def NETCP_DEFAULT_ROUTE
157 * @brief This defines the NETCP default route. This route has NETCP send received packets to the default NETCP
158 * pktio channel using descriptors and buffers from the default flow. The default route is created by netapi_init
159 */
160#define NETCP_DEFAULT_ROUTE (NETCP_CFG_ROUTE_HANDLE_T) NULL
161
162
163/**
164 * @ingroup cfg_constants
165 * @{
166 *
167 * @name Valid Parameter configuration for NETCP_CFG_ROUTE_T
168 * @brief Valid Parameter configuration
169 *
170 * @details Valid Parameter to configure optional parameters.
171 */
172/* @{ */
173/**
174 * @def NETCP_CFG_VALID_PARAM_ROUTE_TYPE
175 * Valid Route Type configuration
176 *
177 */
178
179#define NETCP_CFG_VALID_PARAM_ROUTE_TYPE 0x01
180/* @} */
181/* @{ */
182/**
183 * @def NETCP_CFG_VALID_PARAM_MATCH_ACTION_DEST
184 * Valid Match Destination configuration present,
185 * When set, NetCP to terminate packet at configured destination
186 * if classification matches as specified by match_destination of
187 * @NETCP_CFG_ROUTE_T
188 *
189 */
190#define NETCP_CFG_VALID_PARAM_MATCH_ACTION_DEST 0x02
191/* @} */
192/* @{ */
193/**
194 * @def NETCP_CFG_VALID_PARAM_FAIL_ACTION_DEST
195 * Valid Fail Destination configuration present,
196 * When set, NetCP to terminate packet at configured destination
197 * if next route classification fails as specified by fail_destination of
198 * @NETCP_CFG_ROUTE_T
199 *
200 */
201#define NETCP_CFG_VALID_PARAM_FAIL_ACTION_DEST 0x04
202/* @} */
203/** @} */
204
205
206
207/**
208 * @ingroup cfg_structures
209 * @brief NETCP application defined route information.
210 * @details This structure is used to define a packet receive route. A route consists of a
211 * flow where to get free descriptors and buffers to hold the packet, and a destination
212 * queue where to place the packet. Priority routing based on VLAN priority bits,
213 * DSCP/TOS, and received input port is supported. In the case
214 * of priority based routing, the PASS will forward the matchd packeed to the desired
215 * queue which is equal to the base queue plus an offset. This offset is sepcififed
216 * by the VLAN prioirty or DSCP/TOS value, or received input port.
217 *
218 */
219typedef struct NETCP_CFG_ROUTE_Tag
220{
221 uint32_t valid_params; /**< Specifies which route config params
222 are valid */
223 NETCP_CFG_FLOW_T *p_flow; /**< NULL or NETCP_DEFAULT_FLOW for default
224 *flow,@ref NETCP_CFG_FLOW_T
225 */
226 PKTIO_HANDLE_T *p_dest_q; /**< NULL for default destination queue */
227
228 nwalRouteType_t routeType; /**< Optional: Routing priority,
229 * @see nwal.h for nwalRouteType_t
230 */
231 uint16_t egress_swith_port; /* learned swithc port #, from ale_table */
232 uint16_t match_destination; /**< Optional: NetCP to terminate packet at specified destination
233 if classification matches
234 @see nwal.h for nwal_matchAction_t*/
235 uint16_t fail_destination; /**< Optional: NetCP to terminate packet at specified destination
236 if next route classification match fails
237 @see nwal.h for nwal_failAction_t*/
238
239} NETCP_CFG_ROUTE_T;
240
241
242/**
243 * @ingroup cfg_constants
244 * @brief Handle to a NETCP route.
245 * @details Application to use this handle to identify a NETCP route. A NETCP route defines the
246 * pktio channel for packets received by NETCP
247 * and the flow to use.
248 */
249typedef NETCP_CFG_ROUTE_T* NETCP_CFG_ROUTE_HANDLE_T;
250
251
252
253
254/**
255 * @ingroup cfg_constants
256 * @def NETCP_CFG_ACTION_DISCARD
257 * This defines the NETCP action to discard packet.
258 */
259#define NETCP_CFG_ACTION_DISCARD NWAL_MATCH_ACTION_DISCARD
260/**
261 * @ingroup cfg_constants
262 * @def NETCP_CFG_ACTION_CONTINUE
263 * This defines the NETCP action to pass packet ono the next classifier
264 */
265#define NETCP_CFG_ACTION_CONTINUE NWAL_MATCH_ACTION_CONTINUE_NEXT_ROUTE
266/**
267 * @ingroup cfg_constants
268 * @def NETCP_CFG_ACTION_TO_SW
269 * This defines the NETCP action to pass packet to User space application
270 */
271#define NETCP_CFG_ACTION_TO_SW NWAL_MATCH_ACTION_HOST
272
273/**
274 * @ingroup cfg_constants
275 * @def NETCP_CFG_ALL_EXCEPTIONS
276 * This defines NETCP configuration for all Exepction Packets.
277 */
278#define NETCP_CFG_ALL_EXCEPTIONS 0xff
279
280/**
281 * @ingroup cfg_constants
282 * @brief General APP_ID Type definition.
283 */
284typedef uint32_t NETCP_CFG_APP_ID_T;
285
286
287/**
288 * @ingroup cfg_constants
289 * @brief Handle to NETCP VLAN configuration (FUTURE).
290 * @details Application to use this handle to identify a VLAN configuration.
291 */
292typedef void * NETCP_CFG_VLAN_T;
293
294/**
295 * @ingroup cfg_constants
296 * @brief NETCP PA LLD handle associated with an SA
297 * @details Application to use this handle to identify a PA PLLD handle associated with an SA.
298 */
299typedef void * NETCP_CFG_PA_HANDLE_T;
300
301/**
302 * @ingroup cfg_constants
303 * @brief NETCP SA LLD handle associated with an SA
304 * @details Application to use this handle to identify a SA LLD handle associated with an SA.
305 */
306typedef void * NETCP_CFG_SA_HANDLE_T;
307
308/**
309 * @ingroup cfg_constants
310 * @brief AppID for packets matching a MAC interface rule
311 */
312typedef uint32_t NETCP_CFG_MACIF_T;
313
314/**
315 * @ingroup cfg_constants
316 * @brief AppID for packets matching an IP interface rule
317 */
318typedef uint32_t NETCP_CFG_IP_T;
319
320/**
321 * @ingroup cfg_constants
322 * @brief This define is used to identify the application id associated with a created SA (IPSEC security association) rule
323 */
324typedef uint32_t NETCP_CFG_SA_T;
325
326
327/**
328 * @ingroup cfg_constants
329 * @brief AppId for packets matching an NETCP IPSEC policy rule
330 */
331typedef uint32_t NETCP_CFG_IPSEC_POLICY_T;
332
333
334
335/**
336 * @ingroup cfg_constants
337 * @brief AppID for packets being classified as type exception.
338 */
339typedef uint32_t NETCP_CFG_EXCEPTION_PKT_T;
340
341/**
342 * @ingroup cfg_constants
343 *@brief This define is to be used in AddIp, AddClassifier, addSA, etc. to indicate that the rule can be bound to any MAC address.
344 */
345#define NETCP_CFG_NO_INTERFACE 0xff
346
347
348
349/**
350 * @note APPIDs are present in RX packet meta data and tell "how far" the packet got
351 * through the classification rules of NETCP.
352 * APPID is 32 bits:
353 * bits 31-24 = NETAPI_NETCP_MATCH_STAGE
354 * bits 23-8 = NETAPI_NETCP_MATCH_ID identifier
355 * bits 7-0 = NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE logical mac interface
356*/
357
358#define NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT 0
359#define NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK 0xFF
360
361#define NETAPI_NETCP_MATCH_ID_SHIFT 8
362#define NETAPI_NETCP_MATCH_ID_MASK 0xFFFF
363
364#define NETAPI_NETCP_MATCH_STAGE_SHIFT 24
365#define NETAPI_NETCP_MATCH_STAGE_MASK 0xFF
366
367
368/**
369 * @brief Helper function to get match stage associated with application ID.
370 */
371#define netapi_cfgGetMatchStage(appid) (((appid) >> NETAPI_NETCP_MATCH_STAGE_SHIFT) & NETAPI_NETCP_MATCH_STAGE_MASK)
372
373/**
374 * @brief Helper function to get match id associated with application ID.
375 */
376#define netapi_cfgGetMatchId(appid) (((appid) >> NETAPI_NETCP_MATCH_ID_SHIFT) & NETAPI_NETCP_MATCH_ID_MASK)
377
378/**
379 * @brief Helper function to get logical match interface associated with application ID.
380 */
381#define netapi_cfgGetMatchLogicalMacIface(appid) (((appid) >> NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT) & \
382 NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK)
383
384
385/**
386 * @ingroup cfg_constants
387 * @def NETAPI_NETCP_MATCH_GENERIC_MAC
388 * This define is used for an APPID that indicates that a packet matched a MAC entry.
389 * Logical MAC interface location:
390 * Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and
391 * NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
392 * Packet did not match any other rule.
393 */
394#define NETAPI_NETCP_MATCH_GENERIC_MAC 0x10000000
395
396/**
397 * @ingroup cfg_constants
398 * @def NETAPI_NETCP_MATCH_GENERIC_IP
399 * This define is used for an APPID that indicates that a packet matched a MAC entry.
400 * Logical MAC interface location:
401 * Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and
402 * NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
403 * IP rule number for this interface location:
404 * Refer to NETAPI_NETCP_MATCH_ID_SHIFT and
405 * NETAPI_NETCP_MATCH_ID_MASK.
406 * Packet also matched a generic IP rule attached to that interface.
407 * Packet did not match any other rule.
408 */
409#define NETAPI_NETCP_MATCH_GENERIC_IP 0x20000000
410
411/**
412 * @ingroup cfg_constants
413 * @def NETAPI_NETCP_MATCH_CLASS
414 * This define is used for an APPID that indicates that a packet matched a MAC entry.
415 * Logical MAC interface location:
416 * Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and
417 * NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
418 * Classifer ID location:
419 * Refer to NETAPI_NETCP_MATCH_ID_SHIFT and
420 * NETAPI_NETCP_MATCH_ID_MASK.
421 * Packet also matched a generic IP rule attached to
422 * that interface OR a general IP rule added as part of the classifier or it matched a combination
423 * of ISPEC SA rule and a policy check. In addition, packet matched a L4 port rule that was added
424 * as part of a classifer. Packet did not match any other rule.
425 */
426#define NETAPI_NETCP_MATCH_CLASS 0x80000000
427
428/**
429 * @ingroup cfg_constants
430 * @def NETAPI_NETCP_MATCH_CLASS_L3
431 * This define is used for an APPID that indicates that a packet matched a MAC entry.
432 * Logical MAC interface location:
433 * Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and
434 * NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
435 * Packet also matched a general IP rule added as part
436 * of a classifier. But it not match a L4 port or any other rule.
437 * We cannot determine what classifer partially matched so Bytes 3-2 are not applicable
438 */
439#define NETAPI_NETCP_MATCH_CLASS_L3 0x40000000
440
441/**
442 * @ingroup cfg_constants
443 * @def NETAPI_NETCP_MATCH_IPSEC
444 * This define is used for an APPID that indicates that a packet matched a MAC entry.
445 * Logical MAC interface location:
446 * Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and
447 * NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
448 * SA ID location:
449 * Refer to NETAPI_NETCP_MATCH_ID_SHIFT and
450 * NETAPI_NETCP_MATCH_ID_MASK.
451 * Packet also matched an IPSEC SA rule (matched proto, destination ip and SPI).
452 * Packet did not match any other rule (so may have failed a policy check)
453 */
454#define NETAPI_NETCP_MATCH_IPSEC 0x01000000
455
456
457/**
458 * @ingroup cfg_constants
459 * @def NETAPI_NETCP_MATCH_IPSEC_POLICY
460 * This define is used for an APPID that indicates that a packet matched a MAC entry
461 * Logical MAC interface location:
462 * Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and
463 * NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
464 * Packet also matched an IPSEC SA rule (matched proto,
465 * dest ip and SPI). Packet also matched a POLICY RULE (this is a check of the inner IP).
466 * IPSEC RX Policy ID location:
467 * Refer to NETAPI_NETCP_MATCH_ID_SHIFT and
468 * NETAPI_NETCP_MATCH_ID_MASK.
469 * Packet did not match any other rule
470 */
471#define NETAPI_NETCP_MATCH_IPSEC_POLICY 0x02000000 //lower byte==interface, Or' in SA id (16 bits)
472
473/**
474 * @ingroup cfg_constants
475 * @def NETAPI_NETCP_CFG_MATCH_EXCEPTION
476 * This define is used for an APPID that indicates that a packet is of type exception.
477 * Actual exception id is in byte 0 of APPID.
478 */
479#define NETAPI_NETCP_CFG_MATCH_EXCEPTION 0x08000000
480
481
482
483/**
484 * @ingroup cfg_structures
485 * @brief NETCP flow configuration information.
486 * @details This structure is used to define key parameters for the receive flow to be created.
487 * These include the flow index to use (or can be left un-specified), the dma_index
488 * (specifying out of which CPPI DMA engine the flow should be allocated),
489 * the receive offset (the byte offset into each buffer where received data should be placed),
490 * and the drop policy for the DMA channel to use if there is no free buffer available (drop or block)
491 *
492 */
493typedef struct NETCP_CFG_FLOW_CONFIG_Tag
494{
495 int flow_index; /**< flow index to use or NETAPI_NETCP_FLOW_INDEX_ANY */
496/**
497 * @def NETAPI_NETCP_FLOW_INDEX_ANY
498 * @ingroup cfg_constants
499 * This define is used to let NETAPI pick the flow index to use(for flow_index field)
500 */
501#define NETAPI_NETCP_FLOW_INDEX_ANY CPPI_PARAM_NOT_SPECIFIED
502
503 int dma_index; /**< allocate flow out of which DMA */
504/**
505 * @def NETAPI_DMA_INFRASTRUCTURE
506 * @ingroup cfg_constants
507 * This define is used specify a flow in the QMSS CPPI DMA (for dma_index field)
508 */
509#define NETAPI_DMA_INFRASTRUCTURE 0
510/**
511 * @def NETAPI_DMA_NETCP
512 * @ingroup cfg_constants
513 * This define us usee specify a flow in the NETCP CPPI DMA (for dma_index field)
514 */
515#define NETAPI_DMA_NETCP 1
516
517 int recv_offset; /**< start of packet offset */
518
519 int block; /**< TRUE => DMA will wait for free descriptor if heap(s) are empty.
520 FALSE => DMA will discard */
521/**
522 * @def NETAPI_FLOW_DROP
523 * @ingroup cfg_constants
524 * This define is used to indicate that the flow should institute a Block policy.
525 * This means that the DMA should wait for a free descriptor/buffer to come available if
526 * the free poll is empty (for the block field)
527 */
528#define NETAPI_FLOW_BLOCK 1
529/**
530 * @def NETAPI_FLOW_DROP
531 * @ingroup cfg_constants
532 * This define us used to indicate that the flow should institute a Drop policy.
533 * This means that the DMA should NOT wait for a free descriptor/buffer to come available
534 * if the free poll is empty. The transfer will be aborted and the data will dropped (for block field)
535 */
536#define NETAPI_FLOW_DROP 0
537
538 PKTIO_HANDLE_T * p_dest_q; /**<destination queue for this flow (may be overwrritten by source DMA) */
539} NETCP_CFG_FLOW_CONFIG_T;
540
541 /**
542 * @ingroup cfg_structures
543 * @brief
544 * The structure contains the NETAPI Physical Memory Address Device configuration for
545 * QMSS and PASS Perihperals.
546 *
547 * @details
548 * The structure contains the NETAPI Physical Memory Address Device configuration for
549 * QMSS and PASS Perihperals.
550 */
551typedef struct NETCP_CFG_GLOB_DEVICE_PARAMS_Tag
552{
553 int fNssGen2; /**< 1: NSS Gen2 device */
554 uint32_t cslNetCpCfgRegs; /**< Base address of NETCP configuration Registers */
555 uint32_t cslQmssCfgBase; /**< Base address of QMSS configuration Registers */
556 uint32_t cslQmssDataBase; /**< Base address of QMSS Data Registers */
557 uint32_t cslNetCpCfgSaCfgRegs;/**< Base address of SA configuration Registers */
558
559} NETCP_CFG_GLOB_DEVICE_PARAMS_T;
560
561
562
563
564/**
565 * @ingroup cfg_functions
566 * @brief netapi_netcpCfgAddFlow API to add a flow
567 *
568 * @details This api is used to add a flow
569 * @param[in] h NETAPI instance handle, @ref NETAPI_T
570 * @param[in] n number of Pktlib_HeapHandle
571 * @param[in] handles[] Handles to Pktlib_HeapHandle
572 * @param[in] sizes[] must be <= heap corresponding heap size-recv_offset-any desired tail room
573 * @param[in] p_cfg @ref NETCP_CFG_FLOW_CONFIG_T
574 * @param[out] err pointer to error return
575 * @retval NETCP flow handle, @ref NETCP_CFG_FLOW_HANDLE_T
576 * @pre @ref netapi_init
577 */
578NETCP_CFG_FLOW_HANDLE_T netapi_netcpCfgAddFlow(NETAPI_T h,
579 int n,
580 Pktlib_HeapHandle handles[],
581 int sizes[],
582 NETCP_CFG_FLOW_CONFIG_T * p_cfg,
583 int * err );
584
585/**
586 * @ingroup cfg_functions
587 * @brief netapi_netcpCfgDelFlow API to delete a flow
588 *
589 * @details This api is used to delete a flow.
590 * @param[in] h NETAPI instance handle, @ref NETAPI_T
591 * @param[in] p handle to NETCP flow
592 * @param[out] err pointer to error return
593 * @retval none
594 * @pre @ref netapi_init, netapi_netcpCfgAddFlow
595 */
596void netapi_netcpCfgDelFlow(NETAPI_T h ,
597 NETCP_CFG_FLOW_HANDLE_T p ,
598 int * err);
599
600/**
601 * @ingroup cfg_functions
602 * @brief API attaches an IP address and qualifier to a MAC interface
603 *
604 * @details This api is used to add an IP address to a MAC interface along
605 * with optional IP qualifier. A route, @ref NETCP_CFG_ROUTE_HANDLE_T,or NULL for default
606 * may be specified to indicate where to send packets matching the MAC interface MAC address, the
607 * supplied IP address and any qualifier. This API adds a rule to the NETCP level 1 lookup tables.
608 * Packets arriving that match this rule are identified in meta data with Appid= NETAPI_NETCP_MATCH_GENERIC_IP
609 * Note: An IP address must be attached to enable NETCP receive Checksum offload feature
610 * @param[in] h NETAPI instance handle, @ref NETAPI_T
611 * @param[in] iface_no interface number (0,1,..)
612 * @param[in] ipType type of IP address (V4 for V6)
613 * @param[in] ip_addr destination or local
614 * @param[in] ip_rem_addr source or remote
615 * @param[in] ip_qualifiers ip_qualifiers (all 0 for no qualifiers). This can be used to apply special handling for
616 * diffserv category for example.
617 * @param[in] route handle of a created route or NULL to use internal default route, @ref NETCP_CFG_ROUTE_HANDLE_T
618 * @param[in] user_data Optional: pointer to user provided data associated with IP
619 * @param[in] ip_addr remote
620 * @param[out] err pointer to error return
621
622 * @retval returned AppID for attached rule. This is returned in RX meta data for packets matching this rule and no other, @ref NETCP_CFG_IP_T
623 * @pre @ref netapi_init
624 */
625NETCP_CFG_IP_T netapi_netcpCfgAddIp(NETAPI_T h,
626 int iface_no,
627 nwal_IpType ipType,
628 nwalIpAddr_t* ip_addr,
629 nwalIpAddr_t* ip_rem_addr,
630 nwalIpOpt_t* ip_qualifiers,
631 NETCP_CFG_ROUTE_HANDLE_T route,
632 void* user_data,
633 int* err);
634
635/**
636 * @ingroup cfg_functions
637 * @brief netapi_netcpCfgDelIp API to delete IP interface
638 *
639 * @details This api is used to delete an IP interface
640 * @param[in] h NETAPI instance handle, @ref NETAPI_T
641 * @param[in] iface_no interface number (0,1,..)
642 * @param[in] ipType type of IP address (V4 for V6)
643 * @param[in] ip_addr ip_address
644 * @param[in] ip_qualifiers ip_qualifiers (all 0 for no qualifiers). This can be used to apply special handling for
645 * diffserv category for example.
646 * @param[in] ip_rule_id @ref NETCP_CFG_IP_T
647 * @param[out] err pointer to error return
648 * @retval returned AppID for attached rule. This is returned in RX meta data for packets matching this rule and no other, @ref NETCP_CFG_IP_T
649 * @pre @ref netapi_init , @ref netapi_netcpCfgAddIp
650 */
651void netapi_netcpCfgDelIp(NETAPI_T h,
652 int iface_no,
653 nwal_IpType ipType,
654 nwalIpAddr_t* ip_addr,
655 nwalIpOpt_t* ip_qualifiers,
656 NETCP_CFG_IP_T ip_rule_id,
657 int* err);
658
659/**
660 * @ingroup cfg_functions
661 * @brief netapi_netcpCfgCreateMacInterface API to insert a MAC interface rule in the NETCP hardware
662 * lookup engines.
663 *
664 * @details This api is used to insert a MAC interface in the NETCP hardware lookup engines.
665 * Once it is created, the MAC interface can be used to receive packets. The API
666 * adds a rule to the NETCP 1st level lookup tables to route all packets with destination
667 * MAC matching supplied argument and not matching any other lookup entry (see @ref netapi_netcpCfgAddIp) to
668 * the supplied route, @ref NETCP_CFG_ROUTE_T, (or default route).
669 * Packets arriving that match this rule are identified in meta data with Appid= NETAPI_NETCP_MATCH_GENERIC_MAC
670 * Note: The internal SOC switch (if operating in full swithc mode) may need to be "taught" that this mac
671 * address is present by transmitting a packet with destination mac = this interface mac address.
672 * @param[in] h NETAPI instance handle, @ref NETAPI_T
673 * @param[in] p_mac pointer to 6 byte MAC address for local interface
674 * @param[in] p_mac_remote pointer to 6 byte MAC address for remote interface
675 * @param[in] iface_no interface number (0,1,..)
676 * @param[in] switch_port (0 don't care, 1 switch port 1, 1 switch port 2) [only 0 supported currenly]
677 * @param[in] route handle of a created route or NULL to use internal default route, @ref NETCP_CFG_ROUTE_HANDLE_T
678 * @param[in] vlan [future[ vlan configuration . Set to NULL, @ref NETCP_CFG_VLAN_T
679 * @param[in] etherType Ethertype field.
680
681 * @param[in] state [future] interface state (0=down, 1= up)
682 * @param[out] err pointer to error return
683 * @retval returns AppID for interface (this is returned in meta data for received packets matching this rule an no others, @ref NETCP_CFG_MACIF_T
684 * @pre @ref netapi_init
685 */
686NETCP_CFG_MACIF_T netapi_netcpCfgCreateMacInterface(NETAPI_T h,
687 uint8_t* p_mac,
688 uint8_t* p_mac_remote,
689 int iface_no,
690 int switch_port,
691 NETCP_CFG_ROUTE_HANDLE_T route,
692 NETCP_CFG_VLAN_T vlan,
693 uint16_t etherType,
694 int state,
695 int * err);
696
697/**
698 * @ingroup cfg_functions
699 * @brief netapi_netcpCfgDelMac API to delete MAC interface
700 *
701 * @details This api is used to delete a MAC interface
702 * @param[in] h NETAPI instance handle, @ref NETAPI_T
703 * @param[in] iface_no interface number (0,1,..)
704 * @param[out] err pointer to error return
705 * @retval returned AppID for attached rule. This is returned in RX meta data for packets matching this rule and no other, @ref NETCP_CFG_IP_T
706 * @pre @ref netapi_init , @ref netapi_netcpCfgCreateMacInterface
707 */
708void netapi_netcpCfgDelMac(NETAPI_T h,
709 int iface_no,
710 int* err);
711
712
713/**
714 * @brief This defines handle to installed classifier returned by API. Pkts matching this classifier will have meta data with this tag.
715 * Also used to delete classifier
716 */
717typedef uint32_t NETCP_CFG_CLASS_T;
718
719
720/**
721 * @ingroup cfg_structures
722 * @brief NETAPI Class L4 Configuration
723 *
724 * @details This structure contains Classifier L4 Configuration. In this type of classifier, the L2 and L3 header match criteria are implied by the iface and ip entries. L4 packet match criteria are defined by the proto and appProto fields ( L4 protocol id and ports)
725 */
726typedef struct NETCP_CFG_CLASS_L4_Tag
727{
728 int iface; /**< Indicates which MAC interface packet should be received on*/
729 NETCP_CFG_IP_T ip; /**< IP rule to match: see @ref NETCP_CFG_IP_T */
730 nwal_appProtoType_t proto; /**< L4 proto (-1 for don't care)*/
731 nwalAppProto_t appProto; /**< L4 Ports or equivalent */
732
733} NETCP_CFG_CLASS_L4_T;
734
735
736/**
737 * @ingroup cfg_structures
738 * @brief NETAPI Classifier L4 plus IPSEC policy configuration
739 *
740 * @details This structure contains Classifier L4 plus IPSEC policy configuration. In this type of classifier, the L2,L3 header match criteria are implied by the iface and ip_policy fields. The L4 match criteria are implied by the proto and appProto fields.
741 */
742//classifier L4 + policy (L2, L3 (outer), tunnel, L3 (inner) implied by policy
743typedef struct NETCP_CFG_CLASS_L4_IPSEC_Tag
744{
745 int iface; /**< Indicates which MAC interface packet should be received from */
746 NETCP_CFG_IPSEC_POLICY_T ip_policy; /**< IPSEC policy configuration. see @ref NETCP_CFG_IPSEC_POLICY_T */
747 nwal_appProtoType_t proto; /**< L4 proto (-1 for don't care)*/
748 nwalAppProto_t appProto; /**< L4 Ports or equivalent */
749
750} NETCP_CFG_CLASS_L4_IPSEC_T;
751
752
753
754/**
755 * @ingroup cfg_structures
756 * @brief NETAPI Classifier L4/L3 configuration
757 *
758 * @details This structure contains Class L4 + L3 Classifier configuration. In this type of classifier the L2 header match criteria is implied by the iface field. The L3 header match criteria is implied by the ipType, ip_addr and ip_qulaifier fields. L4 match criteris is implied by the proto and appProto fields. A failed route can be optionally included to tell NETCP what to do if the L3 portion of the classifier matches but not the L4 portion.
759 */
760typedef struct NETCP_CFG_CLASS_L3_L4_Tag
761{
762 int iface; /**< Indicates which MAC interface packet is from */
763 nwal_IpType ipType; /**< IP address type, IPV4 or IPV6 */
764 nwalIpAddr_t* ip_addr; /**< IP address to match */
765 nwalIpOpt_t* ip_qualifiers; /**< IP address qualifiers */
766 NETCP_CFG_ROUTE_HANDLE_T p_fail_route; /**< What to do if L3 matches but L4 fails AND L3 is a
767 new rule.(if exisitng rule, then existing fail
768 route will be used). */
769 nwal_appProtoType_t proto; /**< L4 proto (-1 for don't care)*/
770 nwalAppProto_t appProto; /**< Ports or equivalent */
771} NETCP_CFG_CLASS_L3_L4_T;
772
773/**
774 * @ingroup cfg_structures
775 * @brief NETAPI Classifier configuration
776 *
777 * @details This structure contains the NETAPI classifer configuration. This is a union of the different classifier types above
778 */
779typedef struct NETCP_CFG_CLASSIFIER_Tag
780{
781
782/**
783 * Classifer type which can be set to one of the following defines:
784 * <br>
785 * @ref NETCP_CFG_CLASS_TYPE_L4 , @ref NETCP_CFG_CLASS_TYPE_L3_L4, _
786 */
787 int classType;
788
789/**
790 * @def NETCP_CFG_CLASS_TYPE_L4
791 * @ingroup cfg_constants
792 * This defines classifier type to be Class L4. Class L4 classifiers specifiy the L4 protocol information of the packets to matched; the L2,L3 portions of the classifier are implied by supplied handles from the mac interface create and IP Add APIs
793 */
794#define NETCP_CFG_CLASS_TYPE_L4 0
795
796/**
797 * @def NETCP_CFG_CLASS_TYPE_L3_L4
798 * @ingroup cfg_constants
799 * This defines classifier type to be Class L4/L3 . Class L3_L4 classifiers specify both the IP address (L3) and the L4 protocol information of the packets to be matched.
800 */
801#define NETCP_CFG_CLASS_TYPE_L3_L4 1
802
803 union
804 {
805 NETCP_CFG_CLASS_L3_L4_T c_l3_l4; /**< @ref NETCP_CFG_CLASS_L3_L4_T */
806 NETCP_CFG_CLASS_L4_T c_l4; /**< @ref NETCP_CFG_CLASS_L4_T */
807 NETCP_CFG_CLASS_L4_IPSEC_T c_l4_ipsec; /**< @ref NETCP_CFG_CLASS_L4_IPSEC_T */
808 } u; /**< union for classifier type configuration structure */
809} NETCP_CFG_CLASSIFIER_T;
810
811
812
813/**
814 * @ingroup cfg_functions
815 * @brief netapi_netcpCfgAddClass API to attach a classifier rule to NETCP.
816 * This can be used to route a particular packet flow to a specific PKTIO channel
817 *
818 * @details This api can be used to route a particular packet flow to a particular PktIO channel, using a specific
819 * pktLib heap, and/or have NetCP attach a tag (classifier id) to the incoming packet.
820 * @param[in] h NETAPI instance handle, @ref NETAPI_T
821 * @param[in] p_class definition of the classifier
822 * @param[in] p_route handle to NETCP route.
823 * @param[in] action what to do with packet: one of NETCP_CFG_ACTION_TO_SW, DISCARD or CONTINUE
824 * @param[in] user_data Optional: pointer to user provided data associated with SA
825 * @param[out] err pointer to error return
826 * @retval returned AppID for attached rule. This is returned in RX meta data for packets matching this rule and no other, @ref NETCP_CFG_IP_T
827 * @pre @ref netapi_init
828 */NETCP_CFG_CLASS_T netapi_netcpCfgAddClass(NETAPI_T h,
829 NETCP_CFG_CLASSIFIER_T* p_class,
830 NETCP_CFG_ROUTE_HANDLE_T p_route,
831 int action,
832 void* user_data,
833 int* err);
834
835
836
837/**
838 * @ingroup cfg_functions
839 * @brief netapi_netcpCfgDelClass API to delete a preconfigured classifier
840 *
841 * @details This API can be used to delete a preconfigured classifier
842 * @param[in] h NETAPI instance handle, @ref NETAPI_T
843 * @param[in] classId
844 * @param[out] err pointer to error return
845 * @retval none
846 * @pre @ref netapi_init, @ref netapi_netcpCfgAddClass
847 */
848void netapi_netcpCfgDelClass(NETAPI_T h,
849 NETCP_CFG_CLASS_T classId,
850 int* err);
851
852
853/**
854 * @ingroup netapi_cb_functions
855 * @brief NETCP_CFG_STATS_CB Callback function that is used to return statistics from NETCP
856 *
857 * @details The application provides a callback function that NETAPI uses to report statistics.
858 * The request for stats is generated from the @ref netapi_netcpCfgReqStats API.
859 * Note: to receive this stats callback, the @ref netapi_netcpPoll function must be called
860 * @param[in] h NETAPI instance handle, @ref NETAPI_T
861 * @param[out] pPaStats the PA (NETCP packet accelerator subsystem) statistics block
862 * @retval none
863 * @pre @ref netapi_init , @ref netapi_netcpCfgReqStats, @ref netapi_netcpPoll
864 */
865typedef void (*NETCP_CFG_STATS_CB)(NETAPI_T h,
866 paSysStats_t* pPaStats);
867
868/**
869 * @ingroup cfg_functions
870 * @brief netapi_netcpCfgReqStats API to request statistics from NETCP
871 *
872 * @details This api is used to request a statistics from NETCP. This will generate a stats request
873 * command to NETCP. Sometime later, the statistics result will arrive and will be passed to
874 * the caller via the asynchronus callback @ref NETCP_CFG_STATS_CB that is registered in this call.
875 * Note: to receive the stats callback, the @ref netapi_netcpPoll funcition must be called
876 * @param[in] h NETAPI instance handle, @ref NETAPI_T
877 * @param[in] cb the callback function to invoke with the resulting statistics block, @ref NETCP_CFG_STATS_CB
878 * @param[in] doClear clear the stats in NETCP after the report (0=no, 1=yes)
879 * @param[out] err pointer to error return
880 * @retval none
881 * @pre @ref netapi_init
882 */
883void netapi_netcpCfgReqStats(NETAPI_T h,
884 NETCP_CFG_STATS_CB cb,
885 int doClear,
886 int* err);
887
888
889/**
890 * @ingroup cfg_functions
891 * @brief netapi_netcpCfgExceptions API to configure NETCP with global rules for exception packet handling
892 *
893 * @details This api is used to configure NETCP with global rules of how to handle exception packets specified by exception_id.
894 * @param[in] h NETAPI instance handle, @ref NETAPI_T
895 * @param[in] exception_id id of the exception packet, refer to pa.h,.pa_EROUTE_XXX for list of exception packet id's
896 * @param[in] p_route handle to NETCP route.
897 * @param[in] action, action for NETCP to take upon classifying packet as type exception, refer to nwal. nwal_matchAction_t
898 * @retval returns app_id, @ref NETCP_CFG_EXCEPTION_PKT_T
899 * @pre @ref netapi_init
900 */
901NETCP_CFG_EXCEPTION_PKT_T netapi_netcpCfgExceptions(NETAPI_T h,
902 int exception_id ,
903 nwal_matchAction_t action,
904 NETCP_CFG_ROUTE_HANDLE_T p_route);
905
906
907#ifdef __cplusplus
908}
909#endif
910#endif
911
diff --git a/ti/runtime/netapi/netsync.h b/ti/runtime/netapi/netsync.h
new file mode 100755
index 0000000..133cf3c
--- /dev/null
+++ b/ti/runtime/netapi/netsync.h
@@ -0,0 +1,162 @@
1/*********************************************
2 * File: netsync.h
3 * Purpose: NETAPI Synchronization primitives
4 **************************************************************
5 * FILE: netsync.h
6 *
7 * DESCRIPTION: netapi synch utilities header file for user space transport
8 * library
9 *
10 * REVISION HISTORY:
11 *
12 * Copyright (c) Texas Instruments Incorporated 2013
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
42 **********************************************/
43#ifndef NETAPI_SYNC_H
44#define NETAPI_SYNCH_H
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49#include "hplib_sync.h"
50
51/*--------------------------*/
52/*----------spinLock--------*/
53/*--------------------------*/
54
55#define NETAPI_spinLock_T hplib_spinLock_T
56
57#define NETAPI_spinLock_LOCKVAL hplib_spinLock_LOCKVAL
58#define NETAPI_spinLock_UNLOCKVAL hplib_spinLock_UNLOCKVAL
59#define NETAPI_spinLock_UNLOCKED_INITIALIZER (NETAPI_spinLock_UNLOCKVAL)
60
61/* init a lock */
62#define netapi_spinLock_init hplib_mSpinLockInit
63
64/* lock a spinLock */
65#define netapi_spinLock_lock hplib_mSpinLockLock
66
67
68/* try to get lock 1 time. Return 1 if ok, 0 if un-successful */
69#define netapi_spinLock_try_lock hplib_mSpinLockTryLock
70
71/* unlock a spinLock. */
72#define netapi_spinLock_unlock hplib_mSpinLockUnlock
73
74/* poll a lock, return 0 if unlocked, NETAPI_spinLock_LOCKVAL if locked */
75#define netapi_spinLock_is_locked hplib_mSpinLockIsLocked
76
77
78/*--------------------------*/
79/*----------rwLock--------*/
80/*--------------------------*/
81
82/* a rw lock strucuture */
83#define NETAPI_rwLock_T hplib_rwLock_T
84
85//initialize a rw lock
86#define netapi_rwLock_init hplib_mRWLockInit
87
88// lock a write lock.
89#define netapi_rwLock_write_lock hplib_mRWLockWriteLock
90
91
92//unlock a writer part of rwLock */
93#define netapi_rwLock_write_unlock hplib_mRWLockWriteUnlock
94
95//grab a read lock
96//=> can be other readers, but no writer
97#define netapi_rwLock_read_lock hplib_mRWLockReadLock
98
99//rw_lock reader unlock
100#define netapi_rwLock_read_unlock hplib_mRWLockReadUnlock
101
102
103/*--------------------------*/
104/*----------atomic32--------*/
105/*--------------------------*/
106#define NETAPI_ATOMIC32_T hplib_atomic32_T
107
108
109
110#define NETAPI_ATOMIC_INIT32 hplib_mAtomic32Init
111
112#define netapi_atomic_read32 hplib_mAtomic32Read
113
114#define netapi_atomic_set32 hplib_mAtomic32Set
115
116#define netapi_atomic_add32 hplib_mAtomic32Add
117
118#define netapi_atomic_sub32 hplib_mAtomic32Sub
119
120#define NETAPI_atomic_inc32 hplib_mAtomic32Inc
121
122#define NETAPI_atomic_dec32(p) hplib_mAtomic32Dec
123
124#define netapi_atomic_add_return32 hplib_mAtomic32AddReturn
125
126#define netapi_atomic_sub_return32 hplib_mAtomic32SubReturn
127
128
129#define netapi_atomic_inc_and_test32 hplib_mAtomic32IncAndTest
130
131#define netapi_atomic_dec_and_test32 hplib_mAtomic32DecAndTest
132
133#define netapi_atomic_test_and_set32 hplib_mAtomic32TestSetReturn
134
135#define netapi_atomic_clear32(p) hplib_mAtomic32Clear
136
137/*--------------------------*/
138/*----------atomic64--------*/
139/*--------------------------*/
140#define NETAPI_ATOMIC64_T hplib_atomic64_T
141
142
143#define NETAPI_ATOMIC_INIT64(x) hplib_mAtomic64Init
144
145#define netapi_atomic_read64 hplib_mAtomic64Read
146
147#define netapi_atomic_set64 hplib_mAtomic64Set
148
149#define netapi_atomic_add64 hplib_mAtomic64Add
150
151/*******************************************************
152 ****************memory barrier************************
153******************************************************/
154#define netapi_mb hplib_mMemBarrier
155#define netapi_rmb hplib_mReadMemBarrier
156#define netapi_wmb hplib_mWriteMemBarrier
157
158
159#ifdef __cplusplus
160}
161#endif
162#endif
diff --git a/ti/runtime/netapi/pktio.h b/ti/runtime/netapi/pktio.h
new file mode 100755
index 0000000..81d50b4
--- /dev/null
+++ b/ti/runtime/netapi/pktio.h
@@ -0,0 +1,816 @@
1/******************************************************************************
2 * FILE PURPOSE: Top level interface file for NWAL Module
3 ******************************************************************************
4 * FILE NAME: pktio.h
5 *
6 * DESCRIPTION: netapi PKTIO module header file
7 *
8 * REVISION HISTORY:
9 *
10 * Copyright (c) Texas Instruments Incorporated 2013
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
22 * distribution.
23 *
24 * Neither the name of Texas Instruments Incorporated nor the names of
25 * its contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 */
41
42/**
43 * @file pktio.h
44 * @brief pktio module main header file for user space transport library
45 * @details: pktio provides an abstraction to H/W queues that are used to transmit and receive packets,
46 * IPC messages, etc. Pktio channels can be created by user but there are also several canned
47 * channels available for NETCP transmit, receive, SA sideband crypto transmit and receive
48 */
49
50
51
52#ifndef __PKTIO__H
53#define __PKTIO__H
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
59
60//#include "netapi.h"
61#include "ti/drv/nwal/nwal.h"
62#include "ti/drv/nwal/nwal_util.h"
63
64/**
65 * @def NETCP_TX
66 * @ingroup pktio_constants
67 * This defines the default PKTIO NETCP transmit channel name
68 */
69#define NETCP_TX "NETCP_TX"
70
71/**
72 * @def NETCP_RX
73 * @ingroup pktio_constants
74 * @brief This defines the default PKTIO NETCP receive channel name
75 */
76#define NETCP_RX "NETCP_RX"
77
78/**
79 * @def NETCP_SB_RX
80 * @ingroup pktio_constants
81 * @brief This defines the PKTIO NETCP-SA receive SIDEBAND channel name.
82 This channel is used to receive the results from sideband crypto operations
83 */
84#define NETCP_SB_RX "NETCP_SB_RX"
85
86/**
87 * @def NETCP_SB_TX
88 * @ingroup pktio_constants
89 * @brief This defines the PKTIO NETCP-SA transmit SIDEBAND channel name.
90 This channel is used to send packets for sideband crypto operations
91 */
92#define NETCP_SB_TX "NETCP_SB_TX"
93
94/**
95 * @def PKTIO_MAX_NAME
96 * @ingroup pktio_constants
97 * This defines the maximum length of a pktio channel name
98 */
99#define PKTIO_MAX_NAME 20
100
101/**
102 * @ingroup pktio_structures
103 * @brief PKTIO meta data information .
104 *
105 * @details PKTIO meta data information. meta data is used to convey the results of NETCP pre-processing on receive packets and to tell NETCP what functions to perform on transmitted packets. It is a union of sub-structures (one for TX, one for RX, one for sideband rx, one for sideband tx).
106 */
107typedef struct PKTIO_METADATA_Tag
108{
109
110 int flags1; /**< Configuration flags for PKTIO channel, @ref PKTIO_META_RX,
111 @ref PKTIO_META_TX,
112 @ref PKTIO_META_SB_RX,
113 @ref PKTIO_META_SB_TX*/
114
115/**
116 * @def PKTIO_META_RX
117 * @ingroup pktio_constants
118 * This defines the PKTIO NETCP receive INFLOW channel
119 */
120#define PKTIO_META_RX 0x01
121
122/**
123 * @def PKTIO_META_TX
124 * @ingroup pktio_constants
125 * This defines the PKTIO NETCP transmit INFLOW channel
126 */
127#define PKTIO_META_TX 0x02
128
129/**
130 * @def PKTIO_META_SB_RX
131 * @ingroup pktio_constants
132 * This defines the PKTIO NETCP SIDEBAND channel channel
133 */
134#define PKTIO_META_SB_RX 0x4
135
136/**
137 * @def PKTIO_META_SB_TX
138 * @ingroup pktio_constants
139 * This defines the PKTIO NETCP transmit SIDEBAND channel
140 */
141#define PKTIO_META_SB_TX 0x8
142
143
144/**
145 * @def PKTIO_META_IFDMA_TX
146 * @ingroup pktio_constants
147 * This defines the PKTIO NETCP infrastructure DMA transfer channel
148 */
149#define PKTIO_META_IFDMA_TX 0x10
150
151/**
152 * @def PKTIO_META_APP_DEF
153 * @ingroup pktio_constants
154 * This allows user space application to define custom packet types.
155 */
156#define PKTIO_META_APP_DEF 0x80000000
157
158/**
159 * @brief NWAL Packet meta data information
160 */
161 union
162 {
163 nwalRxPktInfo_t* rx_meta; /**< NWAL Packet meta data information for incoming packet */
164 nwalTxPktInfo_t* tx_meta; /**< NWAL Packet meta data information for outgoing packet */
165 nwalDmRxPayloadInfo_t* rx_sb_meta; /**<NWAL Data mode meta data payload information from NetCP */
166 nwalDmTxPayloadInfo_t* tx_sb_meta; /**< NWAL Data Mode Payload information for packet to SA */
167 unsigned int tx_ifdma_dest; /**< infrastructure dma destination flow */
168 } u; /**< union NWAL Packet meta data information */
169
170 void * sa_handle; /**< This contains the appplication id associated with created SA.
171 details This is used when crypto is to be performed on the
172 egress packet */
173} PKTIO_METADATA_T;
174
175/**
176 * @ingroup pktio_structures
177 * @brief PKTIO fast path configuration structure.
178 *
179 * @details This strucuture allows user space applications to specify the PKTIO packet send function.
180 *
181 * @note This configuration is not expected at time of @ref netapi_pktioOpen but can be updated via
182 * @ref netapi_pktioControl API.
183 */
184typedef struct PKTIO_FAST_PATH_CONFIG_Tag
185{
186 int fp_send_option; /**< PKTIO_FP_NONE, @ref PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT,
187 PKTIO_FP_L4CKSUM_PORT, @ref PKTIO_FP_ESP_L4CKSUM_PORT,
188 @ref PKTIO_FP_AH_L4CKSUM_PORT, @ref PKTIO_FP_ESP_PORT,
189 @ref PKTIO_FP_AH_PORT */
190
191/**
192 * @def PKTIO_FP_NONE
193 * @ingroup pktio_constants
194 * Use this define to reconfigure the PKTIO channel send function to not use any PKTIO fast path
195 send functions.
196 */
197#define PKTIO_FP_NONE 0
198
199/**
200 * @def PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT
201 * @ingroup pktio_constants
202 * Use this define to send packet with updates to ENET port, no crypto operation,
203 * no L4 checksum to be performed.
204 */
205#define PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT 1
206
207/**
208 * @def PKTIO_FP_L4CKSUM_PORT
209 * @ingroup pktio_constants
210 * Use this define to send packet with updates to L4 checksum, ENET port, no crypto operation
211 * to be performed.
212 */
213#define PKTIO_FP_L4CKSUM_PORT 2
214
215/**
216 * @def PKTIO_FP_ESP_L4CKSUM_PORT
217 * @ingroup pktio_constants
218 * Use this define to send packet with Crypto ESP, UDP checksum, updates to ENET port
219 */
220#define PKTIO_FP_ESP_L4CKSUM_PORT 3
221
222/**
223 * @def PKTIO_FP_AH_L4CKSUM_PORT
224 * @ingroup pktio_constants
225 * Use this define to send packet with Cypto AH, UDP checksum, updates to ENET port
226 */
227#define PKTIO_FP_AH_L4CKSUM_PORT 4
228
229/**
230 * @def PKTIO_FP_ESP_PORT
231 * @ingroup pktio_constants
232 * Use this define to send packet with Crypto ESP packet, updates to ENET port
233 */
234#define PKTIO_FP_ESP_PORT 5
235
236/**
237 * @def PKTIO_FP_AH_PORT
238 * @ingroup pktio_constants
239 * Use this define to send packet with AH packet
240 */
241#define PKTIO_FP_AH_PORT 6
242
243/**
244 * @def PKTIO_FP_AH_PORT
245 * @ingroup pktio_constants
246 * Use this define to send packet with Crypto ESP, IP checksum, updates to ENET port
247 */
248#define PKTIO_FP_ESP_L3CKSUM_PORT 7
249
250 nwalTxPktInfo_t *txPktInfo; /** <The parameters in this structure are used to
251 provide additional details for the outgoing packet*/
252} PKTIO_FAST_PATH_CONFIG_T;
253
254
255
256struct PKTIO_HANDLE_tag;
257/**
258 * @ingroup pktio_structures
259 * @brief PKTIO configuration information
260 *
261 * @details PKTIO :q information
262 */
263typedef struct PKTIO_CFG_Tag
264{
265/**
266 * @def PKTIO_RX
267 * @ingroup pktio_constants
268 * This defines the pktio channel as type read, i.e., for ingress
269 */
270#define PKTIO_RX 0x1
271
272/**
273 * @def PKTIO_TX
274 * @ingroup pktio_constants
275 * This defines the pktio channel as type write, i.e. for egress
276 */
277#define PKTIO_TX 0x2
278
279/**
280 * @def PKTIO_RX_TX
281 * @ingroup pktio_constants
282 * This defines the pktio channel as type read/write
283 */
284#define PKTIO_RX_TX (PKTIO_RX | PKTIO_TX)
285
286/**
287 * Flags for PKTIO channel configuration
288 * <br>
289 * The following are flags used to configure the pktio channel:
290 * @ref PKTIO_RX , @ref PKTIO_TX, @ref PKTIO_RX_TX
291 */
292 int flags1;
293
294/**
295 * @def PKTIO_GLOBAL
296 * @ingroup pktio_constants
297 * This defines the pktio channel as type global.
298 Type global means that this channel can be used by all worker threads/cores
299 */
300#define PKTIO_GLOBAL 0x1
301
302/**
303 * @def PKTIO_LOCAL
304 * @ingroup pktio_constants
305 * This defines the pktio channel as type local.
306 Type local means that thi s channel can only be used by the the thread/core that created it;
307 its name will not be visible to other threads/cores
308 */
309#define PKTIO_LOCAL 0x2
310
311/**
312 * @def PKTIO_PKT
313 * @ingroup pktio_constants
314 * This defines the pktio channel is for NETCP
315 */
316#define PKTIO_PKT 0x4
317
318/**
319 * @def PKTIO_SB
320 * @ingroup pktio_constants
321 * This defines the pktio channel is for sideband crypto
322 */
323#define PKTIO_SB 0x8
324#define PKTIO_IFDMA 0x10 //define this if this channel is for ifrastructure dma
325 int flags2; /**< Flags for PKTIO channel configuration, @ref PKTIO_LOCAL , @ref PKTIO_GLOBAL,
326 @ref PKTIO_PKT, @ref PKTIO_SB*/
327
328/**
329 * @def PKTIO_Q_ANY
330 * @ingroup pktio_constants
331 * This defines the pktio IO queue number to be specified by the transport library.
332 */
333#define PKTIO_Q_ANY QMSS_PARAM_NOT_SPECIFIED
334
335 int qnum; /**< PKTIO channel queue number */
336 int max_n; /**< Maximum number of packets read in 1 poll */
337 PKTIO_FAST_PATH_CONFIG_T fast_path_cfg; /** < @ref PKTIO_FAST_PATH_CONFIG_T */
338 int queueType ; /**<Queue Manager queue type,
339 refer to ti/csl/csl_qm_queue.h */
340} PKTIO_CFG_T;
341
342
343/**
344 * @ingroup pktio_structures
345 * @brief PKTIO polling control struct, currently NOT_IMPLEMENTED
346 *
347 * @details PKTIO polling control struct, currently NOT_IMPLEMENTED
348 */
349typedef struct PKTIO_POLL_Tag
350{
351} PKTIO_POLL_T;
352
353/**
354 * @ingroup netapi_cb_functions
355 * @brief PKTIO_CB Callback function to be issued on packet receive
356 *
357 * @details The application provides a callback function that gets invoked on packet receive
358 * @param[in] channel The PKTIO channel handle, @ref PKTIO_HANDLE_T
359 * @param[in] p_recv Pointer to the packets received.
360 * @param[in] p_meta Pointer to meta data associated with packet, @ref PKTIO_METADATA_T
361 * @param[in] n_pkts Number of packets received.
362 * @param[in] ts Timestamp associted with received packets.
363 * @retval none
364 * @pre @ref netapi_pktioOpen
365 */
366typedef void (*PKTIO_CB)(struct PKTIO_HANDLE_tag* channel,
367 Ti_Pkt* p_recv[],
368 PKTIO_METADATA_T p_meta[],
369 int n_pkts,
370 uint64_t ts);
371
372/**
373 * @ingroup pktio_functions
374 * @brief PKTIO_SEND PKTIO specific send function
375 *
376 * @details The application calls this PKTIO specific send function to transmit packet
377 * @param[in] channel The PKTIO channel handle, @ref PKTIO_HANDLE_T
378 * @param[in] p_send Pointer to the packet to send
379 * @param[in] p_meta Pointer to meta data associated with packet, @ref PKTIO_METADATA_T
380 * @param[out] p_err Pointer to error code.
381 * @retval none
382 * @pre @ref netapi_pktioOpen
383 */
384typedef int (*PKTIO_SEND)(struct PKTIO_HANDLE_tag * channel,
385 Ti_Pkt* p_send,
386 PKTIO_METADATA_T* p_meta,
387 int* p_err);
388
389
390/**
391 * @ingroup pktio_functions
392 * @brief PKTIO_POLL PKTIO specific poll function
393 *
394 * @details The application calls this PKTIO specific POLL function
395 * @param[in] channel The PKTIO channel handle, @ref PKTIO_HANDLE_T
396 * @param[in] p_poll_cfg @ref PKTIO_POLL_T, currently NOT_IMPLEMENTED
397 * @param[out] p_err Pointer to error code.
398 * @retval none
399 * @pre @ref netapi_pktioOpen
400 */
401typedef int (*PKTIO_POLL)(struct PKTIO_HANDLE_tag * channel,
402 PKTIO_POLL_T* p_poll_cfg,
403 int* p_err);
404
405
406/**
407 * @brief This defines an unused packet io channel slot
408 */
409#define PKTIO_NA 0
410
411
412struct NETAPI_tag;
413
414/**
415 * @ingroup pktio_structures
416 * @brief PKTIO handle structure definition.
417 *
418 * @details PKTIO handle strucutre which is returned from call to @ref netapi_pktioCreate
419 */
420typedef struct PKTIO_HANDLE_Tag
421{
422/**
423 * @def PKTIO_INUSE
424 * @ingroup pktio_constants
425 * This defines whether the pktio channel entry is valid.
426 */
427#define PKTIO_INUSE 0xfeedfeed
428
429 int inuse; /**<true is pktio channel is in use */
430
431/**
432 * Set the "use_nwal" field to one of the defines listed below.
433 * <br>
434 * The following defines are used to populate the use_nwal field:
435 * @ref PKTIO_4_IPC , @ref PKTIO_4_ADJ_NWAL, @ref PKTIO_DEF_NWAL. @ref PKTIO_4_ADJ_SB., @ref PKTIO_DEF_SB
436 */
437 int use_nwal;
438
439/**
440 * @def PKTIO_4_IPC
441 * @ingroup pktio_constants
442 * This define is for channels used for IPC between cores
443 */
444#define PKTIO_4_IPC 0
445
446/**
447 * @def PKTIO_4_ADJ_NWAL
448 * @ingroup pktio_constants
449 * This define is for NETCP (RX) channels whose associated queues are managed by NWAL
450 */
451#define PKTIO_4_ADJ_NWAL 1
452
453/**
454 * @def PKTIO_DEF_NWAL
455 * @ingroup pktio_constants
456 * This define is for NETCP channels that are tied to the default NWAL RX/TX queues
457 */
458#define PKTIO_DEF_NWAL 2
459
460/**
461 * @def PKTIO_4_ADJ_SB
462 * This define is for (RX) channels used to get crypto side band results via application managed queues
463 * @ingroup pktio_constants
464 */
465#define PKTIO_4_ADJ_SB 3
466
467/**
468 * @def PKTIO_DEF_SB
469 * @ingroup pktio_constants
470 * This define is for channels tied to the default crypto side band queues
471 */
472#define PKTIO_DEF_SB 4
473
474 struct NETAPI_tag * back; /**< back handle to NETPAI instance */
475 void * nwalInstanceHandle; /**<save here for conveninece this is the nwal handle set at init time*/
476 PKTIO_CB cb; /**< callback for channel (for Rx) */
477 PKTIO_CFG_T cfg; /**<configuration of channel */
478 Qmss_QueueHnd q; /**<the associated queue handle for channel */
479 Qmss_Queue qInfo; /**<and its qm#/q# */
480 int max_n; /**<max # of pkts to read in one poll */
481 void * cookie; /**<app specific */
482 PKTIO_SEND _send; /**<pktio type specific send function */
483 PKTIO_POLL _poll; /**<pktio type specific POLL function */
484 int poll_flags; /**< pktio flags to control polling options */
485 char name[PKTIO_MAX_NAME+1]; /**< Name of pktio channel */
486 Cppi_Handle cppiHnd; /* < cppi handle */
487 Cppi_ChHnd rxChHnd; /* < cppi receive channel handle */
488 Cppi_ChHnd txChHnd; /* < cppi transmit channe handle */
489 nwalTxPSCmdInfo_t tx_psCmdInfo; /**<Command Label to be sent to NetCP for the packet flow */
490} PKTIO_HANDLE_T;
491
492
493/**
494 * @ingroup pktio_structures
495 * @brief PKTIO control structure
496 *
497 * @details PKTIO control stucture for the control API. Allows operations on pktio channel such as CLEAR , DIVERT, etc
498 */
499typedef struct PKTIO_CONTROL_Tag
500{
501/**
502 * @def PKTIO_CLEAR
503 * This defines is used to clear out the pktio channel
504 */
505#define PKTIO_CLEAR 0x1
506
507// @cond NOT_IMPLEMENTED
508/**
509 * @def PKTIO_DIVERT
510 * This define is used to divert to a dest pktio channel
511 */
512#define PKTIO_DIVERT 0x2
513/// @endcond
514
515/**
516 * @def PKTIO_SET_POLL_FLAGS
517 * This define is used to set poll flags for a pktio channel
518 */
519#define PKTIO_SET_POLL_FLAGS 0x4 //control poll flags (netcp_rx only)
520/**
521 * @def PKTIO_UPDATE_FAST_PATH
522 * This define is used to update the command information template for
523 * INFLOW mode of operation of a ptktio channel (netcp_tx only)
524 */
525#define PKTIO_UPDATE_FAST_PATH 0x8
526
527/**<max # of pkts to read in one poll */
528/**
529 * @def PKTIO_UPDATE_MAX_PKTS_PER_POLL
530 * This define is used to update the maximum number of packets to read in 1 poll
531 * period for the pktio channel.
532 */
533#define PKTIO_UPDATE_MAX_PKTS_PER_POLL 0x10
534
535 int op; /**< Control operation (CLEAR, DIVERT, ..) */
536 PKTIO_HANDLE_T *dest; /**< Handle to PKTIO channel (for DIVERT) */
537 int poll_flags; /**< Flags to indicate polling options */
538} PKTIO_CONTROL_T;
539
540/**
541 * @ingroup pktio_functions
542 * @brief API creates a NETAPI PKTIO channel
543 *
544 * @details This assigns global resources to a NETAPI pktio channel.
545 * Once created, the channel can be used to send and/or receive
546 * a Ti_Pkt. This can be used for communication with the
547 * the Network co-processor (NETCP) or for internal inter-processor
548 * communication. The channel is saved under the assigned name
549 * and can be opened by other netapi threads instances.
550 * @param[in] netapi_handle The NETAPI handle, @ref NETAPI_T
551 * @param[in] name A pointer to the char string name for channel
552 * @param[in] cb Callback to be issued on packet receive, @ref PKTIO_CB
553 * @param[in] p_cfg Pointer to channel configuration, @ref PKTIO_CFG_T
554 * @param[out] err Pointer to error code.
555 * @retval Handle to the pktio instance or NULL on error, @ref PKTIO_HANDLE_T
556 * @pre @ref netapi_init
557 */
558PKTIO_HANDLE_T * netapi_pktioCreate(NETAPI_T netapi_handle,
559 char* name,
560 PKTIO_CB cb,
561 PKTIO_CFG_T* p_cfg,
562 int* err);
563
564/**
565 * @ingroup pktio_functions
566 * @brief API opens an existing NETAPI PKTIO channel
567 *
568 * @details This opens an NETAPI pktio channel for use. The channel
569 * must have already been created via @ref netapi_pktioCreate or may have
570 * been created internally during the netapi intialization.
571 * Once opened, the channel can be used to send and/or receive
572 * a Ti_Pkt. This can be used for communication with the
573 * the Network co-processor (NETCP) or for internal inter-processor
574 * communication.
575 *
576 * @param[in] netapi_handle The NETAPI handle, @ref NETAPI_T
577 * @param[in] name A pointer to the char string name for channel to open
578 * @param[in] cb Callback to be issued on packet receive, @ref PKTIO_CB
579 * @param[in] p_cfg Pointer to channel configuration, @ref PKTIO_CFG_T
580 * @param[out] err Pointer to error code.
581 * @retval Handle to the pktio instance or NULL on error, @ref PKTIO_HANDLE_T
582 * @pre @ref netapi_init, @ref netapi_pktioCreate
583 */
584PKTIO_HANDLE_T * netapi_pktioOpen(NETAPI_T netapi_handle,
585 char* name,
586 PKTIO_CB cb,
587 PKTIO_CFG_T* p_cfg,
588 int* err);
589
590/**
591 * @ingroup pktio_functions
592 * @brief API controls an existing NETAPI PKTIO channel
593 *
594 * @details This controls an opened pktio channel
595 *
596 * @param[in] handle The PKTIO channel handle, @ref PKTIO_HANDLE_T
597 * @param[in] cb Callback to be issued on packet receive, @ref PKTIO_CB
598 * @param[in] p_cfg Pointer to channel configuration which (optional), @ref PKTIO_CFG_T
599 * @param[in] p_control Pointer to PKTIO control information (optional), @ref PKTIO_CONTROL_T
600 * @param[out] err Pointer to error code.
601 * @retval none
602 * @pre @ref netapi_init, @ref netapi_pktioCreate, @ref netapi_pktioOpen
603 */
604void netapi_pktioControl(PKTIO_HANDLE_T* handle,
605 PKTIO_CB cb,
606 PKTIO_CFG_T* p_cfg,
607 PKTIO_CONTROL_T* p_control,
608 int* err);
609
610/**
611 * @ingroup pktio_functions
612 * @brief API closes a NETAPI PKTIO channel
613 *
614 * @details This closes a PKTIO channel
615 *
616 * @param[in] handle The PKTIO channel handle, @ref PKTIO_HANDLE_T
617 * @param[out] err Pointer to error code.
618 * @retval none
619 * @pre @ref netapi_init, @ref netapi_pktioCreate, @ref netapi_pktioOpen
620 */
621void netapi_pktioClose(PKTIO_HANDLE_T* handle,
622 int* err);
623
624/**
625 * @ingroup pktio_functions
626 * @brief API deletes a NETAPI PKTIO channel
627 *
628 * @details This deletes a PKTIO channel
629 *
630 * @param[in] handle The PKTIO handle, @ref PKTIO_HANDLE_T
631 * @param[out] err Pointer to error code.
632 * @retval none
633 * @pre @ref netapi_init, @ref netapi_pktioCreate, @ref netapi_pktioOpen
634 */
635void netapi_pktioDelete(PKTIO_HANDLE_T* handle,
636 int* err);
637
638/**
639 * @ingroup pktio_functions
640 * @brief API sends a packet to a NETAPI PKTIO channel
641 *
642 * @details This sends a Ti_Pkt and associated meta data,
643 * @ref PKTIO_METADATA_T to a channel. The channel
644 * must have already been created via @ref netapi_pktioCreate or opened
645 * via @ref netapi_pktioOpen. It may have
646 * been created internally during the netapi intialization.
647 * @param[in] handle The PKTIO channel handle, @ref PKTIO_HANDLE_T
648 * @param[in] pkt Pointer to the packet to send
649 * @param[in] m Pointer to meta data associated with packet, @ref PKTIO_METADATA_T
650 * @param[out] err Pointer to error code.
651 * @retval 1 if packet sent, 0 if error
652 * @pre @ref netapi_init, @ref netapi_pktioCreate, @ref netapi_pktioOpen
653 */
654static inline int netapi_pktioSend(PKTIO_HANDLE_T* handle,
655 Ti_Pkt* pkt,
656 PKTIO_METADATA_T* m,
657 int* err)
658{
659 return handle->_send((struct PKTIO_HANDLE_tag *)handle, pkt, m, err);
660}
661
662/**
663 * @ingroup pktio_functions
664 * @brief API sends multiple packets to a NETAPI PKTIO channel
665 *
666 * @details This sends an array of Ti_Pkt and associated meta data,
667 * @ref PKTIO_METADATA_T to a channel. The channel
668 * must have already been created via @ref netapi_pktioCreate or opened
669 * via @ref netapi_pktioOpen. It may have
670 * been created internally during the netapi intialization.
671 * @param[in] handle The PKTIO channel handle, @ref PKTIO_HANDLE_T
672 * @param[in] pkt Pointer to the packet to send
673 * @param[in] m Pointer to meta data associated with packet, @ref PKTIO_METADATA_T
674 * @param[in] np The number of packets in list to send
675 * @param[out] err Pointer to error code.
676 * @retval Number of packets sent, 0 if error
677 * @pre @ref netapi_init, @ref netapi_pktioCreate, @ref netapi_pktioOpen
678 */
679int netapi_pktioSendMulti(PKTIO_HANDLE_T* handle,
680 Ti_Pkt* pkt[],
681 PKTIO_METADATA_T* m[],
682 int np,
683 int* err);
684
685/**
686 * @ingroup pktio_functions
687 * @brief API polls a NETAPI PKTIO channel for received packets
688 *
689 * @details This api polls a pktio channel. Any pending data in the channel is
690 * passed to the @ref PKTIO_CB registered when the channel was
691 * created or opened. The channel must
692 * have already been created via @ref netapi_pktioCreate or opened
693 * via @ref netapi_pktioOpen. It may have
694 * been created internally during the netapi intialization.
695 * @param[in] handle The PKTIO channel handle, @ref PKTIO_HANDLE_T
696 * @param[in] p_poll_cfg Pointer to pktio poll configuration. @ref PKTIO_POLL_T
697 * @param[out] err Pointer to error code.
698 * @retval Number of packets received by poll
699 * @pre @ref netapi_init, @ref netapi_pktioCreate, @ref netapi_pktioOpen
700 */
701static inline int netapi_pktioPoll(PKTIO_HANDLE_T* handle,
702 PKTIO_POLL_T* p_poll_cfg,
703 int* err)
704{
705 return handle->_poll((struct PKTIO_HANDLE_tag *) handle, p_poll_cfg, err);
706}
707
708/**
709 * @ingroup pktio_functions
710 * @brief API polls all NETAPI PKTIO channels associated with @ref NETAPI_T instance
711 * for received packets
712 *
713 * @details This api polls all pktio channels attached to an instance.
714 * Any pending data in these channels are
715 * passed to the @ref PKTIO_CB registered when the channel was
716 * created or opened. The channels must
717 * have already been created via @ref netapi_pktioCreate or opened
718 * via @ref netapi_pktioOpen. They may have
719 * been created internally during the netapi intialization.
720 * @param[in] handle The PKTIO channel handle, @ref PKTIO_HANDLE_T
721 * @param[in] p_poll_cfg Pointer to pktio poll configuration. @ref PKTIO_POLL_T
722 * @param[out] err Pointer to error code.
723 * @retval Number of packets received by poll
724 * @pre @ref netapi_init, @ref netapi_pktioCreate, @ref netapi_pktioOpen
725 */
726int netapi_pktioPollAll(NETAPI_T handle,
727 PKTIO_POLL_T* p_poll_cfg,
728 int* err);
729
730
731/**
732 * @brief This define sets the max number of pkts to read in one poll in the @ref PKTIO_HANDLE_T
733 */
734#define netapi_pktioSetMaxN(handle,max_n) (handle)->max_n=max_n;
735
736/**
737 * @brief This define returns NETAPI handle stored in the @ref PKTIO_HANDLE_T
738 */
739#define netapi_pktioGetNetapiHandle(handle) (handle)->back
740
741
742/**
743 * @brief This define sets a user space application cookie in the @ref PKTIO_HANDLE_T
744 */
745#define netapi_pktioSetCookie(handle, cookie) (handle)->cookie = cookie
746
747/**
748 * @brief This define returns a previously set user space application cookie stored in the @ref PKTIO_HANDLE_T
749 */
750#define netapi_pktioGetCookie(handle) (handle)->cookie
751
752/**
753 * @brief This define returns a associate queue handle stored in the @ref PKTIO_HANDLE_T
754 */
755#define netapi_pktioGetQ(handle) (handle)->q
756
757/**
758 * @ingroup pktio_functions
759 * @brief API returns default packet queue to poll for netcp RX
760 * @note: these are expensive calls, so call once and save
761 */
762static inline Qmss_QueueHnd pktio_mGetDefaultNetCpQ(PKTIO_HANDLE_T *h)
763{
764 nwalGlobCxtInfo_t Info;
765 nwal_getGlobCxtInfo(h->nwalInstanceHandle,&Info);
766 return Info.rxDefPktQ;
767}
768
769
770/**
771 * @ingroup pktio_functions
772 * @brief API returns L4Queue to poll for netcp RX (L4 classifier queue).
773 * @note: these are expensive calls, so call once and save
774 */
775static inline Qmss_QueueHnd pktio_mGetDefaultNetCPL4Q(PKTIO_HANDLE_T *h)
776{
777 nwalLocCxtInfo_t Info;
778 nwal_getLocCxtInfo(h->nwalInstanceHandle,&Info);
779 return Info.rxL4PktQ;
780}
781
782
783/**
784 * @ingroup pktio_functions
785 * @brief API to perform descriptor push to QMSS Queue
786 */
787static inline void pktio_mQmssQueuePushDescSizeRaw(Qmss_QueueHnd hnd,
788 void* descAddr,
789 uint32_t descSize)
790{
791 return(Qmss_queuePushDescSizeRaw(hnd,descAddr,descSize));
792}
793
794/**
795 * @ingroup pktio_functions
796 * @brief API to perform descriptor pop from QMSS Queue
797 */
798static inline void* pktio_mQmssQueuePopRaw(Qmss_QueueHnd hnd)
799{
800 return(Qmss_queuePopRaw(hnd));
801}
802
803/**
804 * @ingroup pktio_functions
805 * @brief API to retrieve NWAL global instance handle.
806 */
807static inline nwal_Inst pktio_mGetNwalInstance(PKTIO_HANDLE_T *h)
808{
809 return h->nwalInstanceHandle;
810}
811
812#ifdef __cplusplus
813}
814#endif
815
816#endif
diff --git a/ti/runtime/netapi/src/netapi.c b/ti/runtime/netapi/src/netapi.c
new file mode 100755
index 0000000..db9301e
--- /dev/null
+++ b/ti/runtime/netapi/src/netapi.c
@@ -0,0 +1,462 @@
1/***********************************************************************
2 * FILE: netapi.c
3 * Purpose: Main initialization and shutdown routines of NETAPI
4 * user space transport library.
5 ***********************************************************************
6 * FILE: netapi.c
7 *
8 * DESCRIPTION: netapi main source file for user space transport
9 * library
10 *
11 * REVISION HISTORY:
12 *
13 * Copyright (c) Texas Instruments Incorporated 2013
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 *
19 * Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 *
22 * Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the
25 * distribution.
26 *
27 * Neither the name of Texas Instruments Incorporated nor the names of
28 * its contributors may be used to endorse or promote products derived
29 * from this software without specific prior written permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
36 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
37 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
38 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
39 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
41 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42
43 * *****************************/
44
45#include <unistd.h>
46#include "ti/runtime/netapi/netapi.h"
47#include "netapi_loc.h"
48
49void* pBase;
50NETAPI_SHM_T* pnetapiShm;
51void *pRmClientHandle = NULL;
52
53static NETAPI_CFG_T netapi_default_cfg=
54{
55 TUNE_NETAPI_PERM_MEM_SZ,
56 0, //start of packet offset for hw to place data on rx for default flow
57 TUNE_NETAPI_QM_CONFIG_MAX_DESC_NUM, //max number of descriptors in system
58 TUNE_NETAPI_NUM_GLOBAL_DESC, //total we will use
59 TUNE_NETAPI_DEFAULT_NUM_BUFFERS, //#descriptors+buffers in default heap
60 TUNE_NETAPI_DEFAULT_NUM_SOLO_DESCRIPTORS, //#descriptors w/o buffers in default heap
61 TUNE_NETAPI_DEFAULT_BUFFER_SIZE, //size of buffers in default heap
62 0,
63 0,
64 0,
65 NULL /* Resource manager handle to use RM server */
66};
67
68HPLIB_SPINLOCK_IF_T spinlock_lol =
69{
70 hplib_mSpinLockInit,
71 hplib_mSpinLockTryLock,
72 hplib_mSpinLockIsLocked,
73 hplib_mSpinLockLock,
74 hplib_mSpinLockUnlock,
75 hplib_mRWLockInit,
76 hplib_mRWLockWriteLock,
77 hplib_mRWLockWriteUnlock,
78 hplib_mRWLockReadLock,
79 hplib_mRWLockReadUnlock
80};
81
82
83HPLIB_SPINLOCK_IF_T spinlock_mp =
84{
85 hplib_mSpinLockInit,
86 hplib_mSpinLockTryLock,
87 hplib_mSpinLockIsLocked,
88 hplib_mSpinLockLockMP,
89 hplib_mSpinLockUnlockMP,
90 hplib_mRWLockInit,
91 hplib_mRWLockWriteLockMP,
92 hplib_mRWLockWriteUnlockMP,
93 hplib_mRWLockReadLockMP,
94 hplib_mRWLockReadUnlockMP
95};
96
97/* Global variablesto hold virtual address of various subsystems */
98hplib_virtualAddrInfo_T netapi_VM_VirtAddr[HPLIB_MAX_MEM_POOLS];
99
100/* Global variables which needs to be populated with memory pool attributes
101 which is passed to HPLIB for memory pool initialization*/
102hplib_memPoolAttr_T netapi_VM_MempoolAttr[HPLIB_MAX_MEM_POOLS];
103unsigned char *netapi_VM_QMemLocalDescRam;
104unsigned char *netapi_VM_QMemGlobalDescRam;
105unsigned char *netapi_VM_SaContextVaddr;
106
107//global for this process that points to the
108// master thread for this process (either the SYS_MASTER, or PROC_MASTER)
109//...
110NETAPI_HANDLE_T * netapi_proc_master = NULL;
111Pktlib_HeapIfTable netapi_pktlib_ifTable;
112NETAPI_PROC_GLOBAL_T netapi_proc_global;
113//NETAPI_GLOBAL_T * netapi_get_global(){ return &netapi_global;}
114NETAPI_GLOBAL_T * netapi_get_global(){ return &pnetapiShm->netapi_global;}
115NETAPI_PROC_GLOBAL_T * netapi_get_proc_global(){ return &netapi_proc_global;}
116
117/* utility API for NETAPI user to get pktlib if table to use if he creates his own heap */
118Pktlib_HeapIfTable *netapi_getPktlibIfTable(void) {return &netapi_pktlib_ifTable;}
119
120
121/********************************************************************
122* FUNCTION PURPOSE: API instantiates the NETAPI and allocated global resources.
123 ********************************************************************
124 * DESCRIPTION: API instantiates the NETAPI and allocated global resources.
125 ********************************************************************/
126NETAPI_T netapi_init(int master,
127 NETAPI_CFG_T * p_cfg)
128{
129 int i;
130 int err;
131 int exception_id = 7;
132 void* pBase = NULL;
133
134 hplib_shmInfo_T* pshmBase = NULL;
135 NETAPI_HANDLE_T * p = (NETAPI_HANDLE_T *) calloc(1,sizeof(NETAPI_HANDLE_T));
136 NETAPI_HANDLE_T * p_master;
137 if (!p) return NULL;
138 p->master = master;
139
140 /* SYS_MASTER: The following segment should be done 1 Time per system boot by global master process's main core/thread */
141 if (master == NETAPI_SYS_MASTER)
142 {
143 pBase = hplib_shmCreate(HPLIB_SHM_SIZE);
144
145 if (pBase == NULL)
146 {
147 free(p);
148 return NULL;
149 }
150
151 if (hplib_shmAddEntry(pBase, sizeof(NETAPI_SHM_T), NETAPI_ENTRY) !=
152 hplib_OK)
153 {
154 free(p);
155 return NULL;
156 }
157 hplib_utilOsalCreate();
158 }
159 /*ALL others: we are not the system master; assume SYS_MASTER has
160 created SHM area for us already, so just open it */
161 else
162 {
163 pBase = hplib_shmOpen();
164 if (pBase)
165 Osal_start(pBase);
166 }
167
168 /*ALL: create space for our local pktios */
169 for(i=0;i<TUNE_NETAPI_MAX_PKTIO; i++)
170 {
171 p->pktios[i] = calloc(1,sizeof(PKTIO_HANDLE_T));
172 if (!p->pktios[i])
173 {
174 free(p);
175 return NULL;
176 }
177 else
178 {
179 PKTIO_ENTRY_T *pe = (PKTIO_ENTRY_T*)p->pktios[i];
180 pe->qn.qNum = -1;
181 }
182 }
183
184#ifdef NETAPI_INCLUDE_SCHED
185 /* ALL: create space for scheduler */
186 p->p_sched = calloc(1,sizeof(NETAPI_SCHED_HANDLE_T));
187 if (!p->p_sched)
188 {
189 goto ERR_netapi_init;
190 }
191#endif
192
193 /* SYS_MASTER: The following segment should be done 1 Time per system boot by global master process */
194 if (master == NETAPI_SYS_MASTER)
195 {
196 pnetapiShm = (NETAPI_SHM_T*)hplib_shmGetEntry(pBase, NETAPI_ENTRY);
197 pnetapiShm->netapi_pktio_lock= hplib_spinLock_UNLOCKED_INITIALIZER;
198 pnetapiShm->netapi_netcp_cfg_lock = hplib_spinLock_UNLOCKED_INITIALIZER;
199 pnetapiShm->netapi_netcp_cfg_l3_classi_lock = hplib_spinLock_UNLOCKED_INITIALIZER;
200 pnetapiShm->netapi_util_lock = hplib_spinLock_UNLOCKED_INITIALIZER;
201
202 if (p_cfg)
203 {
204 memcpy(&pnetapiShm->netapi_global.cfg,p_cfg, sizeof(NETAPI_CFG_T));
205 }
206 else
207 {
208 memcpy(&pnetapiShm->netapi_global.cfg,&netapi_default_cfg, sizeof(NETAPI_CFG_T));
209 }
210 for(i=0;i<TUNE_NETAPI_MAX_PKTIO;i++)
211 {
212 pnetapiShm->netapi_global.pktios[i].qn.qNum=-1;
213 pnetapiShm->netapi_global.pktios[i].name[0]='\0';
214 }
215 }
216 else
217 {
218 /* other 'masters' will just get a pointer to the netapi SHM area*/
219 pnetapiShm = (NETAPI_SHM_T*)hplib_shmGetEntry(pBase, NETAPI_ENTRY);
220 }
221
222 /* all for convenience set a back pointer to the SOC global area
223 (in SHM) and process global in netapi_proc_global */
224 p->global = (void *) &pnetapiShm->netapi_global;
225 p->proc_global = (void *)&netapi_proc_global;
226 /* Update spinLock to point to either MP spinlock or fast spinlocks, this is
227 for all callers of netapi_init*/
228 if(p_cfg)
229 {
230 if(p_cfg->def_multi_process)
231 p->spinLock = spinlock_mp;
232 else
233 p->spinLock= spinlock_lol;
234 }
235 else
236 p->spinLock = spinlock_lol;
237
238 /* SYS_MASTER, PROC_MASTER: save a pointer to its netapi structure
239 globably for other threads/core of process to use */
240 if ((master == NETAPI_SYS_MASTER)||(master == NETAPI_PROC_MASTER))
241 {
242 p_master=netapi_proc_master = p;
243 if (p_cfg->rmHandle)
244 pRmClientHandle = p_cfg->rmHandle;
245 }
246 else
247 {
248 /* CORE_MASTER/NO_MASTER: get system master/proc master's handle */
249 p_master=(NETAPI_HANDLE_T *) netapi_proc_master;
250 }
251
252
253 /* SYS_MASTER: The following segment should be done 1 Time per system boot by global master process */
254 /* system init */
255 if(master == NETAPI_SYS_MASTER)
256 {
257 err = netapip_systemInit(p, NETAPI_TRUE);
258 if (err < 0)
259 {
260 goto ERR_netapi_init;
261 }
262 }
263 /* PROC_MASTER case */
264 else if (master==NETAPI_PROC_MASTER)
265 {
266 /* More limited initialization */
267 err = netapip_systemInit(p,
268 NETAPI_FALSE);
269 if (err<0)
270 {
271 goto ERR_netapi_init;
272 }
273 }
274 /* NO_MASTER: case */
275 else if (master == NETAPI_NO_MASTER)
276 {
277 /*Just copy master's pktio list for now */
278 p->n_pktios = p_master->n_pktios;
279 memcpy(&p->pktios[0],&p_master->pktios[0],TUNE_NETAPI_MAX_PKTIO*sizeof(PKTIO_HANDLE_T));
280 p->nwal_local=p_master->nwal_local;
281 }
282 /* this is the NETAPI_CORE_MASTER case */
283 else if (master == NETAPI_CORE_MASTER)
284 {
285 /* Start the QMSS. */
286 if (netapip_startQm(pRmClientHandle) != 1)
287 {
288 goto ERR_netapi_init;
289 }
290 netapip_startNwal(p_master->netcp_heap,
291 p_master->netcp_control_rx_heap,
292 p_master->netcp_control_tx_heap,
293 &p->nwal_local,
294 &pnetapiShm->netapi_global.cfg,
295 &pnetapiShm->netapi_global.nwal_context,
296 master);
297 }
298 else
299 {
300 goto ERR_netapi_init;
301 }
302
303 return (NETAPI_T) p;
304
305/* error handling */
306ERR_netapi_init:
307 for(i=0;i<TUNE_NETAPI_MAX_PKTIO; i++)
308 {
309 if (p->pktios[i])
310 {
311 free(p->pktios[i]);
312 }
313 }
314#ifdef NETAPI_INCLUDE_SCHED
315 if (p->p_sched)
316 {
317 free(p->p_sched);
318 }
319#endif
320 free(p);
321 return NULL;
322}
323
324/********************************************************************
325* FUNCTION PURPOSE: API de-allocates all global resources allocated as part
326* of ref netapi_init
327 ********************************************************************
328 * DESCRIPTION: API de-allocates all global resources allocated as part
329* of ref netapi_init
330 ********************************************************************/
331void netapi_shutdown(NETAPI_T h)
332{
333 int i;
334 hplib_shmInfo_T* pshmBase;
335 NETAPI_HANDLE_T * p = (NETAPI_HANDLE_T *) h;
336 if (!p) return;
337 void * map_base;
338 hplib_VirtMemPoolheader_T *poolHdr;
339
340 if (p->master == NETAPI_SYS_MASTER)
341 {
342
343 /* Un-configure rules for execption packet handling */
344
345 /* close nwal master (per soc) context */
346 nwal_delete(pnetapiShm->netapi_global.nwal_context.nwalInstHandle);
347
348 /* close heaps */
349 netapi_closeHeap(h, p->netcp_heap);
350 netapi_closeHeap(h, p->netcp_control_rx_heap);
351 netapi_closeHeap(h, p->netcp_control_tx_heap);
352 netapi_closeHeap(h, netapi_get_global()->nwal_context.pa2sa_heap);
353 netapi_closeHeap(h, netapi_get_global()->nwal_context.sa2pa_heap);
354
355 //loop over registered heaps
356 for(i=0;i<TUNE_NETAPI_MAX_HEAPS;i++)
357 {
358 if (p->createdHeaps[i])
359 {
360 netapi_closeHeap(h,p->createdHeaps[i]);
361 p->createdHeaps[i]=NULL;
362 }
363 }
364 netapip_cleanupAtStart(); //clear 1st 50 not-specified queues
365 //netapip_cleanupAtStart(); //clear 1st 50 not-specified queues
366 //reset DDR malloc area
367 hplib_resetMallocArea(0);
368 Qmss_removeMemoryRegion(p->memRegion,0);
369 hplib_vmTeardown();
370 hplib_shmDelete();
371 }
372 else if (p->master == NETAPI_PROC_MASTER)
373 {
374 //we can zap these because they are local to our process
375 netapi_closeHeap(h, p->netcp_control_rx_heap);
376 netapi_closeHeap(h, p->netcp_control_tx_heap);
377 //loop over registered heaps (again local to our process)
378 for(i=0;i<TUNE_NETAPI_MAX_HEAPS;i++)
379 {
380 if (p->createdHeaps[i])
381 {
382 netapi_closeHeap(h,p->createdHeaps[i]);
383 p->createdHeaps[i]=NULL;
384 }
385 }
386 Qmss_removeMemoryRegion(p->memRegion,0);
387 hplib_vmTeardown();
388 }
389 //TODO other master types
390 /* error handling */
391
392 for(i=0;i<TUNE_NETAPI_MAX_PKTIO; i++)
393 {
394 if (p->pktios[i])
395 {
396 free(p->pktios[i]);
397 p->pktios[i] = NULL;
398 }
399 }
400#ifdef NETAPI_INCLUDE_SCHED
401 if (p->p_sched)
402 {
403 free(p->p_sched);
404 p->p_sched = NULL;
405 }
406#endif
407
408 free(p);
409 return;
410}
411
412/***********************************************************************
413* FUNCTION PURPOSE: API is used to poll for NETCP configuration response messages.
414************************************************************************
415* DESCRIPTION: This API is used to poll the netapi internal heaps and any
416 * application-created heaps that have been registered with
417 * the netapi instance. The poll function checks the garbage collection
418 * queue associated with the heap and returns descriptors and buffers
419 * when appropriate to the main free queue.
420***********************************************************************/
421void netapi_pollHeapGarbage(NETAPI_T h)
422{
423 int i;
424 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
425 Pktlib_garbageCollection(n->netcp_heap);
426 //no need to do garbage collection on other internal heaps
427 for(i=0;i<TUNE_NETAPI_MAX_HEAPS;i++)
428 {
429 if (n->createdHeaps[i])
430 {
431 Pktlib_garbageCollection(n->createdHeaps[i]);
432 }
433 }
434}
435
436/****************************************************************************
437* FUNCTION PURPOSE: API is used to poll for NETCP configuration response messages.
438****************************************************************************
439* DESCRIPTION: This API is used to poll the netapi internal heaps and any
440 * application-created heaps that have been registered with the
441 * netapi instance. The poll function checks the garbage collection
442 * queue associated with the heap and returns descriptors and buffers
443 * when appropriate to the main free queue.
444***************************************************************************/
445void netapi_netcpPoll(NETAPI_T p)
446{
447 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) p;
448 nwal_pollCtl( ((NETAPI_GLOBAL_T *) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
449}
450/**************************************************************************************
451* FUNCTION PURPOSE: API is used to return configured descriptor memory region Id.
452***************************************************************************************
453* DESCRIPTION: This API is used to return the configured descriptor memory region Id.
454**************************************************************************************/
455int netapi_getMemoryRegionId(NETAPI_T p)
456{
457 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) p;
458 if(netapi_proc_master)
459 return (netapi_proc_master->memRegion);
460 else
461 return -1;
462}
diff --git a/ti/runtime/netapi/src/netapi_init.c b/ti/runtime/netapi/src/netapi_init.c
new file mode 100755
index 0000000..eb1cf41
--- /dev/null
+++ b/ti/runtime/netapi/src/netapi_init.c
@@ -0,0 +1,1106 @@
1/****************************************************************************
2* FILE: netapi_init.c
3* Global, Private initialization and cleanup routines and defines of NETAPI
4 *
5 * DESCRIPTION: Functions to initialize and cleanup framework resources
6 * for running NETAPI
7 *
8 * REVISION HISTORY:
9 *
10 * Copyright (c) Texas Instruments Incorporated 2013
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
22 * distribution.
23 *
24 * Neither the name of Texas Instruments Incorporated nor the names of
25 * its contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 ***************************************************************************/
41
42#include "netapi.h"
43#include "netapi_loc.h"
44#include <sys/types.h>
45#include <sys/stat.h>
46#include <fcntl.h>
47#include <sys/mman.h>
48#include <errno.h>
49#include <unistd.h>
50
51#include "ti/drv/nwal/nwal.h"
52
53/* CSL RL includes */
54#include <ti/csl/cslr_device.h>
55#include <ti/csl/cslr_qm_config.h>
56#include <ti/csl/cslr_qm_descriptor_region_config.h>
57#include <ti/csl/cslr_qm_queue_management.h>
58#include <ti/csl/cslr_qm_queue_status_config.h>
59#include <ti/csl/cslr_qm_intd.h>
60#include <ti/csl/cslr_pdsp.h>
61#include <ti/csl/csl_qm_queue.h>
62#include <ti/csl/cslr_cppidma_global_config.h>
63#include <ti/csl/cslr_cppidma_rx_channel_config.h>
64#include <ti/csl/cslr_cppidma_rx_flow_config.h>
65#include <ti/csl/cslr_cppidma_tx_channel_config.h>
66#include <ti/csl/cslr_cppidma_tx_scheduler_config.h>
67#include <ti/csl/csl_cppi.h>
68#include <ti/csl/csl_pscAux.h>
69#include <ti/csl/csl_semAux.h>
70#include <ti/csl/csl_cacheAux.h>
71#include <ti/csl/csl_xmcAux.h>
72#include <ti/drv/qmss/qmss_qm.h>
73
74
75/* pointer to NWAL local context memory block used by NWAL for local
76 context intance*/
77void* pNwalLocCtxMem = NULL;
78extern void *pRmClientHandle;
79
80nwal_Handle gPNwalInstHandle = NULL;
81
82
83extern NETAPI_SHM_T* pnetapiShm;
84/* Global variablesto hold virtual address of various subsystems */
85extern hplib_virtualAddrInfo_T netapi_VM_VirtAddr[];
86
87/* Global variables which needs to be populated with memory pool attributes
88 which is passed to HPLIB for memory pool initialization*/
89extern hplib_memPoolAttr_T netapi_VM_MempoolAttr[];
90extern unsigned char *netapi_VM_QMemLocalDescRam;
91extern unsigned char *netapi_VM_QMemGlobalDescRam;
92extern unsigned char *netapi_VM_SaContextVaddr;
93
94extern Pktlib_HeapIfTable netapi_pktlib_ifTable;
95extern NETAPI_PROC_GLOBAL_T netapi_proc_global;
96extern NETAPI_HANDLE_T * netapi_proc_master;
97
98
99/* TODO verify: */
100#define CACHE_LINESZ 64
101
102
103#define ALIGN(x) __attribute__((aligned (x)))
104
105/*****************************************************************************
106 * Global Resources shared by all Cores
107 *****************************************************************************/
108uint8_t *QMemGlobDescRam = 0;
109uint8_t *cppiMemPaSaLinkBuf = 0;
110uint8_t *cppiMemSaPaLinkBuf = 0;
111
112
113
114#if 0
115/*****************************************************************************
116 * Local Resource allocated at each Core
117 *****************************************************************************/
118/* Descriptors in global shared */
119uint8_t *QMemLocDescRam = NULL;
120uint8_t *cppiMemRxPktLinkBuf = NULL;
121uint8_t *cppiMemTxPktLinkBuf = NULL;
122uint8_t *cppiMemRxCtlLinkBuf = NULL;
123uint8_t *cppiMemTxCtlLinkBuf = NULL;
124
125#endif
126
127
128
129NETCP_CFG_GLOB_DEVICE_PARAMS_T *p_netapi_device_cfg_local;
130Qmss_MemRegInfo memInfo;
131
132
133/********************************************************************
134 * FUNCTION PURPOSE: Internal NETAPI function to setup the QM memory region
135 ********************************************************************
136 * DESCRIPTION: Internal NETAPI function to setup the QM memory region,
137 * once per SOC
138 ********************************************************************/
139int netapip_qmSetupMemRegion(
140 uint32_t numDesc,
141 uint32_t descSize,
142 uint32_t* pDescMemBase,
143 int memRegion,
144 int start_index)
145{
146 //Qmss_MemRegInfo memInfo;
147 int result;
148
149 memset(&memInfo,0,sizeof(Qmss_MemRegInfo));
150 memInfo.descBase = pDescMemBase;
151 memInfo.descSize = descSize;
152 memInfo.descNum = numDesc;
153 memInfo.manageDescFlag = Qmss_ManageDesc_MANAGE_DESCRIPTOR;
154
155 if (pRmClientHandle)
156 {
157 memInfo.memRegion = -1;
158 memInfo.startIndex = QMSS_START_INDEX_NOT_SPECIFIED;
159 }
160 else
161 {
162 memInfo.memRegion = memRegion;
163 memInfo.startIndex = start_index;
164 }
165
166 memset (pDescMemBase, 0, (descSize * numDesc));
167
168 result = Qmss_insertMemoryRegion (&memInfo);
169
170 if (result < QMSS_SOK)
171 {
172 return (-1);
173 }
174 netapi_proc_master->memRegion = memInfo.memRegion;
175 return 1;
176}
177
178/********************************************************************
179 * FUNCTION PURPOSE: Internal NETAPI function to start QM
180 ********************************************************************
181 * DESCRIPTION: Internal NETAPI function to start QM
182 * once per thread/core
183 ********************************************************************/
184int netapip_startQm(void* rmClientServiceHandle)
185{
186 int32_t result;
187 Qmss_StartCfg startCfg;
188
189 startCfg.rmServiceHandle = rmClientServiceHandle;
190 startCfg.pQmssGblCfgParams = NULL;
191 //result = Qmss_start();
192 result = Qmss_startCfg(&startCfg);
193 if (result != QMSS_SOK)
194 {
195 return (-1);
196 }
197 return 1;
198}
199
200
201/*** NWAL Memory Buffer Configuration ***/
202#define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_HANDLE 3400
203//uint8_t nwalInstMem[NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_HANDLE]ALIGN(CACHE_LINESZ);
204
205
206#define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_MAC 256
207#define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_IPSEC_HANDLE_PER_CHAN 256
208#define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_IP 128
209#define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_PORT 128
210#define NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_L2L3_HDR 128
211#define NWAL_CHAN_HANDLE_SIZE ((NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_MAC * TUNE_NETAPI_MAX_NUM_MAC) + \
212 (NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_IPSEC_HANDLE_PER_CHAN * TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2) + \
213 (NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_IP * TUNE_NETAPI_MAX_NUM_IP) + \
214 (NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_PORT * TUNE_NETAPI_MAX_NUM_PORTS)+ \
215 (NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_PER_L2L3_HDR * TUNE_NETAPI_MAX_NUM_L2_L3_HDRS))
216
217typedef struct NETAPI_NWAL_SHM_Tag
218{
219 uint8_t nwalInstMem[NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_HANDLE]ALIGN(CACHE_LINESZ);
220 uint8_t nwalHandleMem[NWAL_CHAN_HANDLE_SIZE]ALIGN(CACHE_LINESZ);
221} NETAPI_NWAL_SHM_T;
222
223
224typedef struct NETAPI_PA_SHM_Tag
225{
226/* todo: Check if below size information can be made available from pa interface file */
227#define NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF0 512
228/* PA instance */
229/* Memory used for the PA Instance. Needs to be assigned global uncached memory for chip */
230uint8_t paBuf0[NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF0]ALIGN(CACHE_LINESZ);
231
232/* Memory used for PA handles */
233#define NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1 128 * TUNE_NETAPI_MAX_NUM_MAC
234uint8_t paBuf1[NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1]ALIGN(CACHE_LINESZ);
235
236#define NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF2 14592
237
238
239uint8_t paBuf2[NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF2]ALIGN(CACHE_LINESZ);
240} NETAPI_PA_SHM_T;
241
242
243typedef struct NETAPI_SA_SHM_Tag
244{
245/* Memory used for SA LLD global Handle */
246#define NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE 512
247uint8_t salldHandle[NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE]ALIGN(CACHE_LINESZ);
248
249/* Memory used by SA LLD per Channel */
250#define NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE_PER_CHAN 512
251uint8_t salldChanHandle[NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE_PER_CHAN * TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2]ALIGN(CACHE_LINESZ);
252} NETAPI_SA_SHM_T;
253
254
255
256
257
258
259
260
261/********************************************************************
262* FUNCTION PURPOSE: NETAPI internal function to gracefully cleanup when startup
263* issue occurs.
264 ********************************************************************
265 * DESCRIPTION: NETAPI internal function to gracefully cleanup when startup
266* issue occurs.
267 ********************************************************************/
268void netapipErrTeardown() { netapip_cleanupAtStart(); exit(-99); }
269
270/********************************************************************
271 * FUNCTION PURPOSE: Internal NETAPI function to initialize NWAL subsystem
272 ********************************************************************
273 * DESCRIPTION: Internal NETAPI function to initialize NWAL subsytem
274 ********************************************************************/
275int netapip_initNwal(
276 int region2use,
277 Pktlib_HeapIfTable * p_table,
278 NETAPI_NWAL_GLOBAL_CONTEXT_T * p_nwal_context,
279 NETAPI_CFG_T*p_cfg)
280{
281 nwalSizeInfo_t nwalSizeInfo;
282 nwal_RetValue nwalRetVal;
283 nwalGlobCfg_t nwalGlobCfg;
284 nwalBaseAddrCfg_t nwalBaseAddrCfg;
285 uint8_t count;
286 int sizes[nwal_N_BUFS];
287 int aligns[nwal_N_BUFS];
288 void* bases[nwal_N_BUFS];
289 Pktlib_HeapCfg heapCfg;
290 int32_t errCode = 0;
291 void* pBase = NULL;
292 NETAPI_PA_SHM_T* paEntry = NULL;
293 NETAPI_SA_SHM_T* saEntry = NULL;
294 NETAPI_NWAL_SHM_T* nwalEntry = NULL;
295 uint32_t localCtxSize = 0;
296 memset(p_nwal_context,0,sizeof( NETAPI_NWAL_GLOBAL_CONTEXT_T) );
297 memset(&nwalGlobCfg,0,sizeof(nwalGlobCfg_t ) );
298 memset (&nwalBaseAddrCfg, 0, sizeof(nwalBaseAddrCfg_t));
299 pBase = hplib_shmOpen();
300 if (pBase)
301 {
302 if(hplib_shmAddEntry(pBase, sizeof(NETAPI_PA_SHM_T), PA_ENTRY) == hplib_OK)
303 {
304 paEntry = (NETAPI_PA_SHM_T*)hplib_shmGetEntry(pBase,PA_ENTRY);
305 nwalBaseAddrCfg.pInstPoolPaBaseAddr= (void *)paEntry;
306 }
307 else
308 {
309 return -1;
310 }
311 if(hplib_shmAddEntry(pBase, sizeof(NETAPI_SA_SHM_T), SA_ENTRY) == hplib_OK)
312 {
313 saEntry = (NETAPI_SA_SHM_T*)hplib_shmGetEntry(pBase,SA_ENTRY);
314 nwalBaseAddrCfg.pInstPoolSaBaseAddr= (void*) saEntry;
315 }
316 else
317 {
318 return -1;
319 }
320 if(hplib_shmAddEntry(pBase, sizeof(NETAPI_NWAL_SHM_T), NWAL_ENTRY) == hplib_OK)
321 {
322 nwalEntry = (NETAPI_NWAL_SHM_T*)hplib_shmGetEntry(pBase,NWAL_ENTRY);
323 }
324 else
325 {
326 return -1;
327 }
328
329 }
330 /* Initialize Buffer Pool for NetCP PA to SA packets */
331 nwalGlobCfg.pa2SaBufPool.numBufPools = 1;
332 nwalGlobCfg.pa2SaBufPool.bufPool[0].descSize = TUNE_NETAPI_DESC_SIZE;
333 nwalGlobCfg.pa2SaBufPool.bufPool[0].bufSize = p_cfg->def_heap_buf_size;
334
335 /* Initialize the heap configuration. */
336 memset ((void *)&heapCfg, 0, sizeof(Pktlib_HeapCfg));
337 /* Populate the heap configuration */
338 heapCfg.name = "nwal PA2SA";
339 heapCfg.memRegion = region2use;
340 heapCfg.sharedHeap = 0;
341 heapCfg.useStarvationQueue = 0;
342 heapCfg.dataBufferSize = p_cfg->def_heap_buf_size;
343 heapCfg.numPkts = TUNE_NETAPI_CONFIG_MAX_PA_TO_SA_DESC;
344 heapCfg.numZeroBufferPackets= 0;
345 heapCfg.heapInterfaceTable.data_malloc = p_table->data_malloc;
346 heapCfg.heapInterfaceTable.data_free = p_table->data_free;
347 heapCfg.dataBufferPktThreshold = 0;
348 heapCfg.zeroBufferPktThreshold = 0;
349
350
351 nwalGlobCfg.pa2SaBufPool.bufPool[0].heapHandle = p_nwal_context->pa2sa_heap=
352 Pktlib_createHeap(&heapCfg, &errCode);
353 if(nwalGlobCfg.pa2SaBufPool.bufPool[0].heapHandle == NULL)
354 {
355 netapipErrTeardown();
356 return -1;
357 }
358
359 /* Initialize Buffer Pool for NetCP SA to PA packets */
360 nwalGlobCfg.sa2PaBufPool.numBufPools = 1;
361 nwalGlobCfg.sa2PaBufPool.bufPool[0].descSize = TUNE_NETAPI_DESC_SIZE;
362 nwalGlobCfg.sa2PaBufPool.bufPool[0].bufSize = p_cfg->def_heap_buf_size;
363
364 /* Populate the heap configuration */
365 heapCfg.name = "nwal SA2PA";
366 heapCfg.numPkts = TUNE_NETAPI_CONFIG_MAX_SA_TO_PA_DESC;
367
368 nwalGlobCfg.sa2PaBufPool.bufPool[0].heapHandle =
369 p_nwal_context->sa2pa_heap = Pktlib_createHeap(&heapCfg, &errCode);
370 if(nwalGlobCfg.sa2PaBufPool.bufPool[0].heapHandle == NULL)
371 {
372 netapipErrTeardown();
373 return -1;
374 }
375
376 nwalGlobCfg.hopLimit = 5;/* Default TTL / Hop Limit */
377 nwalGlobCfg.paPowerOn = nwal_TRUE;
378 nwalGlobCfg.saPowerOn = nwal_TRUE;
379 nwalGlobCfg.paFwActive = nwal_TRUE;
380 nwalGlobCfg.saFwActive = nwal_FALSE;
381
382
383 /* Update nwal cfg with virtual PA and SA addresses */
384
385
386 nwalBaseAddrCfg.paVirtBaseAddr = (uint32_t) netapi_VM_VirtAddr->passCfgVaddr;
387
388
389 nwalBaseAddrCfg.pSaVirtBaseAddr = (uint32_t) netapi_VM_VirtAddr->passCfgVaddr +
390 CSL_NETCP_CFG_SA_CFG_REGS -
391 CSL_NETCP_CFG_REGS;
392 ;
393 nwalGlobCfg.rxDefPktQ = QMSS_PARAM_NOT_SPECIFIED;
394
395
396 /* Get the Buffer Requirement from NWAL */
397 memset(&nwalSizeInfo,0,sizeof(nwalSizeInfo));
398 nwalSizeInfo.nMaxMacAddress = TUNE_NETAPI_MAX_NUM_MAC;
399 nwalSizeInfo.nMaxIpAddress = TUNE_NETAPI_MAX_NUM_IP;
400 nwalSizeInfo.nMaxL4Ports = TUNE_NETAPI_MAX_NUM_PORTS;
401 nwalSizeInfo.nMaxIpSecChannels = TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS;//we allocate 2 per channel
402 nwalSizeInfo.nMaxDmSecChannels = TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS;//we allocate 2 per channel
403 nwalSizeInfo.nMaxL2L3Hdr = TUNE_NETAPI_MAX_NUM_L2_L3_HDRS;
404 nwalSizeInfo.nProc = TUNE_NETAPI_NUM_CORES;
405 nwalRetVal = nwal_getBufferReq(&nwalSizeInfo,
406 sizes,
407 aligns);
408 if(nwalRetVal != nwal_OK)
409 {
410 return nwal_FALSE;
411 }
412
413/* Check for memory size requirement and update the base */
414 count = 0;
415 //bases[nwal_BUF_INDEX_INST] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)nwalInstMem);
416 bases[nwal_BUF_INDEX_INST] =
417 (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)nwalEntry->nwalInstMem);
418
419 if(NETAPI_NWAL_CONFIG_BUFSIZE_NWAL_HANDLE < sizes[nwal_BUF_INDEX_INST])
420 {
421 /* Resize Memory */
422 return nwal_FALSE;
423 //while(1);
424 }
425 count++;
426
427 //bases[nwal_BUF_INDEX_INT_HANDLES] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)nwalHandleMem);
428 bases[nwal_BUF_INDEX_INT_HANDLES] =
429 (uint32_t *) Osal_nwalLocToGlobAddr((uint32_t)nwalEntry->nwalHandleMem);
430
431
432 if(NWAL_CHAN_HANDLE_SIZE < sizes[nwal_BUF_INDEX_INT_HANDLES])
433 {
434 /* Resize Memory */
435 return nwal_FALSE;
436 //while(1);
437
438 }
439 count++;
440 bases[nwal_BUF_INDEX_PA_LLD_BUF0] =
441 (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)paEntry->paBuf0);
442 if((NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF0) < sizes[nwal_BUF_INDEX_PA_LLD_BUF0])
443 {
444 /* Resize Memory */
445 return nwal_FALSE;
446 //while(1);
447
448 }
449 count++;
450
451 bases[nwal_BUF_INDEX_PA_LLD_BUF1] =
452 (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)paEntry->paBuf1);
453 if((NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1) < sizes[nwal_BUF_INDEX_PA_LLD_BUF1])
454 {
455 /* Resize Memory */
456 return nwal_FALSE;
457 //while(1);
458
459 }
460 count++;
461
462 bases[nwal_BUF_INDEX_PA_LLD_BUF2] =
463 (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)paEntry->paBuf2);
464 if((NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF2) < sizes[nwal_BUF_INDEX_PA_LLD_BUF2])
465 {
466 /* Resize Memory */
467 return nwal_FALSE;
468 //while(1);
469
470 }
471 count++;
472#ifdef NETAPI_ENABLE_SECURITY
473 bases[nwal_BUF_INDEX_SA_LLD_HANDLE] =
474 (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)saEntry->salldHandle);
475 if((NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE) < sizes[nwal_BUF_INDEX_SA_LLD_HANDLE])
476 {
477 /* Resize Memory */
478 return nwal_FALSE;
479 //while(1);
480
481 }
482 count++;
483
484 bases[nwal_BUF_INDEX_SA_CONTEXT] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)netapi_VM_SaContextVaddr);
485 /* also save this here for easy access to sa_start */
486 nwalBaseAddrCfg.pScPoolBaseAddr= bases[nwal_BUF_INDEX_SA_CONTEXT];
487 count++;
488
489 bases[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE] =
490 (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)saEntry->salldChanHandle);
491 if((NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE_PER_CHAN * TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2) <
492 sizes[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE])
493 {
494 /* Resize Memory */
495 return nwal_FALSE;
496 //while(1);
497
498 }
499 count++;
500#else
501 bases[nwal_BUF_INDEX_SA_LLD_HANDLE] = 0;
502 bases[nwal_BUF_INDEX_SA_CONTEXT] = 0;
503 bases[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE] = 0;
504 count = count+3;
505#endif
506
507 /* Initialize NWAL module */
508 nwal_getLocContextBufferReq(nwalSizeInfo.nProc, &localCtxSize);
509
510 pNwalLocCtxMem = malloc(localCtxSize);
511 nwal_createProc(bases[nwal_BUF_INDEX_INST],
512 pNwalLocCtxMem,
513 &nwalBaseAddrCfg);
514
515 nwalGlobCfg.pBaseAddrCfg = &nwalBaseAddrCfg;
516 nwalRetVal = nwal_create(&nwalGlobCfg,
517 &nwalSizeInfo,
518 sizes,
519 bases,
520 &gPNwalInstHandle);
521 if(nwalRetVal != nwal_OK)
522 {
523 return nwal_FALSE;
524 }
525
526 return 1;
527}
528
529/********************************************************************
530 * FUNCTION PURPOSE: Internal NETAPI function to start NWAL
531 ********************************************************************
532 * DESCRIPTION: Internal NETAPI function to start NWAL, per thread/core
533 ********************************************************************/
534int netapip_startNwal(Pktlib_HeapHandle pkt_heap,
535 Pktlib_HeapHandle cmd_rx_heap,
536 Pktlib_HeapHandle cmd_tx_heap,
537 NETAPI_NWAL_LOCAL_CONTEXT_T *p,
538 NETAPI_CFG_T *p_cfg,
539 NETAPI_NWAL_GLOBAL_CONTEXT_T * p_nwal_glob_context,
540 int master)
541{
542 nwalLocCfg_t nwalLocCfg;
543 nwalBaseAddrCfg_t nwalBaseAddrCfg;
544 int count=0;
545 static int first_time = 0;
546 nwal_RetValue nwalRetVal;
547 void* pBase = NULL;
548 NETAPI_NWAL_SHM_T* nwalEntry = NULL;
549 void* pNwalLocCtxMem = NULL;
550
551 NETAPI_SA_SHM_T* saEntry = NULL;
552 NETAPI_PA_SHM_T* paEntry = NULL;
553
554 uint32_t baseAddr;
555 void* instPoolSaBaseAddr;
556 void* pScPoolBaseAddr;
557 void* pInstPoolPaBaseAddr;
558 void* paVirtBaseAddr;
559 uint32_t localCtxSize;
560
561 memset(&nwalLocCfg,0,sizeof(nwalLocCfg));
562 memset(&nwalBaseAddrCfg, 0, sizeof(nwalBaseAddrCfg_t));
563
564 /* Update the Start of Packet Offset for the default flows created
565 * by NWAL
566 */
567 nwalLocCfg.rxSopPktOffset = p_cfg->def_flow_pkt_rx_offset;
568 nwalLocCfg.rxPktTailRoomSz = p_cfg->def_heap_tailroom_size;
569
570 /* Call back registration for the core */
571 nwalLocCfg.pRxPktCallBack = netapip_pktioNWALRxPktCallback;
572 nwalLocCfg.pCmdCallBack = netapip_netcpCfgNWALCmdCallBack;
573 nwalLocCfg.pPaStatsCallBack = netapip_netcpCfgNWALCmdPaStatsReply;
574
575 nwalLocCfg.pRxDmCallBack= netapip_pktioNWALSBPktCallback; //sideband mode callback
576
577 /* Initialize Buffer Pool for Control packets from NetCP to Host */
578 nwalLocCfg.rxCtlPool.numBufPools = 1;
579 nwalLocCfg.rxCtlPool.bufPool[0].descSize = TUNE_NETAPI_DESC_SIZE;
580 nwalLocCfg.rxCtlPool.bufPool[0].bufSize = TUNE_NETAPI_CONFIG_MAX_CTL_RXTX_BUF_SIZE;
581 nwalLocCfg.rxCtlPool.bufPool[0].heapHandle = cmd_rx_heap;
582
583 /* Initialize Buffer Pool for Control packets from Host to NetCP */
584 nwalLocCfg.txCtlPool.numBufPools = 1;
585 nwalLocCfg.txCtlPool.bufPool[0].descSize = TUNE_NETAPI_DESC_SIZE;
586 nwalLocCfg.txCtlPool.bufPool[0].bufSize = TUNE_NETAPI_CONFIG_MAX_CTL_RXTX_BUF_SIZE;
587 nwalLocCfg.txCtlPool.bufPool[0].heapHandle = cmd_tx_heap;
588
589/* Initialize Buffer Pool for L4 Packets from NetCP to Host */
590 nwalLocCfg.rxPktPool.numBufPools = 1;
591 nwalLocCfg.rxPktPool.bufPool[0].descSize = TUNE_NETAPI_DESC_SIZE;
592 nwalLocCfg.rxPktPool.bufPool[0].bufSize = p_cfg->def_heap_buf_size;
593 nwalLocCfg.rxPktPool.bufPool[0].heapHandle = pkt_heap;
594
595/* Initialize Buffer Pool for Packets from Host to NetCP */
596 nwalLocCfg.txPktPool.numBufPools = 1;
597 nwalLocCfg.txPktPool.bufPool[0].descSize = TUNE_NETAPI_DESC_SIZE;
598 nwalLocCfg.txPktPool.bufPool[0].bufSize = p_cfg->def_heap_buf_size;
599 nwalLocCfg.txPktPool.bufPool[0].heapHandle = pkt_heap;
600
601
602
603
604 memcpy(&p->nwalLocCfg,&nwalLocCfg,sizeof(nwalLocCfg_t));
605 while(1)
606 {
607 if(master == NETAPI_PROC_MASTER)
608 {
609 pBase = hplib_shmOpen();
610 nwalEntry = (NETAPI_NWAL_SHM_T*)hplib_shmGetEntry(pBase,NWAL_ENTRY);
611
612 baseAddr = (void*) netapi_VM_VirtAddr->passCfgVaddr +
613 CSL_NETCP_CFG_SA_CFG_REGS -
614 CSL_NETCP_CFG_REGS;
615 saEntry = (NETAPI_SA_SHM_T*)hplib_shmGetEntry(pBase,SA_ENTRY);
616 instPoolSaBaseAddr = (void*) saEntry;
617
618 pScPoolBaseAddr = Osal_nwalLocToGlobAddr((uint32_t)netapi_VM_SaContextVaddr);
619
620
621 paVirtBaseAddr = (void*) netapi_VM_VirtAddr->passCfgVaddr;
622 paEntry = (NETAPI_PA_SHM_T*)hplib_shmGetEntry(pBase,PA_ENTRY);
623 pInstPoolPaBaseAddr = (void *)paEntry;
624
625 nwal_getLocContextBufferReq(TUNE_NETAPI_NUM_CORES, &localCtxSize);
626 pNwalLocCtxMem = malloc(localCtxSize);
627 if (pNwalLocCtxMem == NULL)
628 {
629 return -1;
630 }
631 nwalBaseAddrCfg.pSaVirtBaseAddr = baseAddr;
632 nwalBaseAddrCfg.pInstPoolSaBaseAddr = instPoolSaBaseAddr;
633 nwalBaseAddrCfg.pScPoolBaseAddr = pScPoolBaseAddr;
634 nwalBaseAddrCfg.paVirtBaseAddr = paVirtBaseAddr;
635 nwalBaseAddrCfg.pInstPoolPaBaseAddr = pInstPoolPaBaseAddr;
636 /* this is 1 time per process */
637 nwal_createProc(nwalEntry,
638 pNwalLocCtxMem,
639 &nwalBaseAddrCfg);
640 }
641 /* this is for every thread including 1st thread of the process */
642 netapi_proc_master->spinLock.lock(&pnetapiShm->netapi_util_lock);
643 nwalRetVal = nwal_start(gPNwalInstHandle,&nwalLocCfg);
644 netapi_proc_master->spinLock.unlock(&pnetapiShm->netapi_util_lock);
645 if(nwalRetVal == nwal_ERR_INVALID_STATE)
646 {
647 continue;
648 }
649 break;
650 }
651
652 if(nwalRetVal != nwal_OK)
653 {
654 return -1;
655 }
656 p->state = NETAPI_NW_CXT_LOC_ACTIVE;
657 return 1;
658
659
660}
661/***********************************************************************
662 * FUNCTION PURPOSE: Internal NETAPI function to initialize the 64 bit timer.
663 ***********************************************************************
664 * DESCRIPTION: Internal NETAPI function to initialize the 64 bit timer. for tci6614 ONLY
665 **********************************************************************/
666int netapip_initTimer(void)
667{
668#ifdef CORTEX_A8
669 return t64_start();
670#else
671 return 0;
672#endif
673}
674
675
676
677
678/***************************************************************************
679* FUNCTION PURPOSE: NETAPI internal function for virtual memory allocation.
680 ***************************************************************************
681 * DESCRIPTION: NETAPI internal function for virtual memory allocation.
682 **************************************************************************/
683
684static uint8_t* netapip_sharedMemoryMalloc(uint32_t size)
685{
686 return (uint8_t *)hplib_vmMemAlloc(size +
687 pnetapiShm->netapi_global.cfg.def_heap_extra_size ,
688 128,
689 0);
690}
691
692/********************************************************************
693* FUNCTION PURPOSE: NETAPI internal function for virtual memory free.
694 ********************************************************************
695 * DESCRIPTION: NETAPI internal function for virtual memory free.
696 ********************************************************************/
697static void netapip_sharedMemoryFree(uint8_t* ptr, uint32_t size)
698{
699 /* Do Nothing. */
700 return;
701}
702
703//defensive: clean out stuff hanging around
704//
705// open a bunch of free queues and zap them
706#define NQUEUES2CLEAR 35
707static Qmss_QueueHnd tempQH[NQUEUES2CLEAR];
708void netapip_cleanupAtStart(void)
709{
710 int i;
711 uint8_t isAllocated;
712
713 for(i=0;i<NQUEUES2CLEAR;i++)
714 {
715 tempQH[i] = Qmss_queueOpen(Qmss_QueueType_GENERAL_PURPOSE_QUEUE,
716 QMSS_PARAM_NOT_SPECIFIED, &isAllocated);
717 netapip_zapQ(tempQH[i]);
718 }
719
720 for(i=0;i<NQUEUES2CLEAR;i++)
721 {
722 Qmss_queueClose(tempQH[i]);
723 }
724}
725
726
727
728/********************************************************************
729* FUNCTION PURPOSE: NETAPI internal function system initialization
730 ********************************************************************
731 * DESCRIPTION: NETAPI internal function system initialization
732 ********************************************************************/
733int netapip_systemInit(NETAPI_HANDLE_T * handle,
734 Bool global_master_process)
735{
736
737 int32_t result;
738 Pktlib_HeapHandle sharedHeapHandle;
739 Pktlib_HeapHandle controlRxHeapHandle,controlTxHeapHandle;
740 Pktlib_HeapCfg heapCfg;
741 int32_t errCode = 0;
742 int count=0;
743
744#ifdef NETAPI_USE_DDR
745 /* Init attributes for DDR */
746 netapi_VM_MempoolAttr[0].attr = HPLIB_ATTR_KM_CACHED0;
747 netapi_VM_MempoolAttr[0].phys_addr = 0;
748 netapi_VM_MempoolAttr[0].size = 0;
749
750#ifdef NETAPI_USE_DDR_AND_MSMC
751 /* Init attributes for un-cached MSMC */
752 netapi_VM_MempoolAttr[1].attr = HPLIB_ATTR_UN_CACHED;
753 netapi_VM_MempoolAttr[1].phys_addr = CSL_MSMC_SRAM_REGS;
754 netapi_VM_MempoolAttr[1].size = TUNE_NETAPI_PERM_MEM_SZ;
755#endif
756#else
757 /* Init attributes for un-cached MSMC */
758 netapi_VM_MempoolAttr[0].attr = HPLIB_ATTR_UN_CACHED;
759 netapi_VM_MempoolAttr[0].phys_addr = CSL_MSMC_SRAM_REGS;
760 netapi_VM_MempoolAttr[0].size = TUNE_NETAPI_PERM_MEM_SZ;
761#ifdef NETAPI_USE_DDR_AND_MSMC
762 netapi_VM_MempoolAttr[1].attr = HPLIB_ATTR_KM_CACHED0;
763 netapi_VM_MempoolAttr[1].phys_addr = 0;
764 netapi_VM_MempoolAttr[1].size = 0;
765#endif
766#endif
767 /* initialize all the memory we are going to use
768 - chunk for buffers, descriptors
769 - memory mapped peripherals we use, such as QMSS, PA, etc */
770#ifdef NETAPI_USE_DDR_AND_MSMC
771 result = hplib_vmInit(&netapi_VM_VirtAddr[0],
772 2,
773 &netapi_VM_MempoolAttr[0]);
774#else
775 result = hplib_vmInit(&netapi_VM_VirtAddr[0],
776 1,
777 &netapi_VM_MempoolAttr[0]);
778#endif
779
780 if (result != hplib_OK)
781 {
782 return -1;
783 }
784
785 if (global_master_process == NETAPI_TRUE)
786 {
787 hplib_initMallocArea(0);
788#ifdef NETAPI_USE_DDR_AND_MSMC
789 hplib_initMallocArea(1);
790#endif
791#ifdef NETAPI_ENABLE_SECURITY
792#define SEC_CONTEXT_SZ 384 //not tunable
793 /* allocate 2x number of tunnels since we need one for inflow and one for data mode */
794 netapi_VM_SaContextVaddr = hplib_vmMemAlloc((TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2 *
795 SEC_CONTEXT_SZ), 128, 0);
796 if (!netapi_VM_SaContextVaddr)
797 {
798 return (-1);
799 }
800#else
801 netapi_VM_SaContextVaddr= (char *) NULL;
802#endif
803
804 /* (3) Allocate 2 QM regions from continguous chunk above */
805 netapi_VM_QMemGlobalDescRam =
806 (void *)hplib_vmMemAlloc((TUNE_NETAPI_NUM_GLOBAL_DESC *
807 TUNE_NETAPI_DESC_SIZE),
808 128,
809 0);
810
811 netapi_VM_QMemLocalDescRam =
812 (void *)hplib_vmMemAlloc((TUNE_NETAPI_NUM_LOCAL_DESC *
813 TUNE_NETAPI_DESC_SIZE),
814 128,
815 0);
816 /* Initialize Queue Manager Sub System */
817 result = netapip_initQm (pnetapiShm->netapi_global.cfg.def_max_descriptors,
818 pRmClientHandle);
819
820 if (result != 1)
821 {
822 return -1;
823 }
824 /* Start the QMSS. */
825 if (netapip_startQm(pRmClientHandle) != 1)
826 {
827 return -1;
828 }
829
830 //clean our old junk in 1st bunch of queues that will be allocated to us
831 netapip_cleanupAtStart();
832 /* Initialize the global descriptor memory region. */
833 result= netapip_qmSetupMemRegion(
834 pnetapiShm->netapi_global.cfg.def_tot_descriptors_for_us,
835 TUNE_NETAPI_DESC_SIZE,
836 (unsigned int *) netapi_VM_QMemGlobalDescRam,
837 pnetapiShm->netapi_global.cfg.memoryRegion,
838 pnetapiShm->netapi_global.cfg.start_index);
839 if(result <0)
840 {
841 return -1;
842 }
843 /* Initialize CPPI CPDMA */
844 result = netapip_initCppi(pRmClientHandle);
845 if (result != 1)
846 {
847 return -1;
848 }
849 /* CPPI and Queue Manager are initialized. */
850
851 /* create main pkt heap */
852 /* Initialize the Shared Heaps. */
853 Pktlib_sharedHeapInit();
854 /* Populate the heap interface table. */
855 netapi_pktlib_ifTable.data_malloc = netapip_sharedMemoryMalloc;
856 netapi_pktlib_ifTable.data_free = netapip_sharedMemoryFree;
857 /* Initialize the heap configuration. */
858 memset ((void *)&heapCfg, 0, sizeof(Pktlib_HeapCfg));
859 /* Populate the heap configuration */
860 heapCfg.name = "netapi";
861 heapCfg.memRegion = memInfo.memRegion;
862 heapCfg.sharedHeap = 1;
863 heapCfg.useStarvationQueue = 0;
864 heapCfg.dataBufferSize = pnetapiShm->netapi_global.cfg.def_heap_buf_size;
865 heapCfg.numPkts = pnetapiShm->netapi_global.cfg.def_heap_n_descriptors;
866 heapCfg.numZeroBufferPackets= pnetapiShm->netapi_global.cfg.def_heap_n_zdescriptors;
867 heapCfg.heapInterfaceTable.data_malloc = netapi_pktlib_ifTable.data_malloc;
868 heapCfg.heapInterfaceTable.data_free = netapi_pktlib_ifTable.data_free;
869 heapCfg.dataBufferPktThreshold = 0;
870 heapCfg.zeroBufferPktThreshold = 0;
871
872 /* Create Shared Heap with specified configuration. */
873 sharedHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
874 if (!sharedHeapHandle) { return -1;}
875 handle->netcp_heap= sharedHeapHandle;
876 /* Update for Control */
877 heapCfg.name = "netapi_control_rx";
878 heapCfg.sharedHeap = 1;
879 heapCfg.dataBufferSize = TUNE_NETAPI_CONFIG_MAX_CTL_RXTX_BUF_SIZE;
880 heapCfg.numPkts = TUNE_NETAPI_CONFIG_NUM_CTL_RX_BUF;
881 heapCfg.numZeroBufferPackets= 0;
882
883 controlRxHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
884 //todo -> cleanup on failure
885 if (!controlRxHeapHandle) { return -1;}
886 handle->netcp_control_rx_heap= controlRxHeapHandle;
887
888
889 heapCfg.name = "netapi_control_tx";
890 heapCfg.numPkts = TUNE_NETAPI_CONFIG_NUM_CTL_TX_BUF;
891
892 controlTxHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
893 //todo -> cleanup on failure
894 if (!controlTxHeapHandle) { return -1;}
895 handle->netcp_control_tx_heap= controlTxHeapHandle;
896 /* now NWAL */
897 result = netapip_initNwal(memInfo.memRegion,
898 &netapi_pktlib_ifTable,
899 &pnetapiShm->netapi_global.nwal_context,
900 &pnetapiShm->netapi_global.cfg);
901 if (result<0) { return -1; }
902 /* Common Initialization for all cores */
903 while(count < TUNE_NETAPI_MAX_NUM_TRANS)
904 {
905 netapi_proc_global.nwal_context.transInfos[count].transId = count;
906 count++;
907 }
908 result = netapip_startNwal(sharedHeapHandle,
909 controlRxHeapHandle,
910 controlTxHeapHandle,
911 &handle->nwal_local,
912 &pnetapiShm->netapi_global.cfg,
913 &pnetapiShm->netapi_global.nwal_context,
914 handle->master);
915 if (result<0) { return -1; }
916 }
917 else
918 {
919 if (hplib_checkMallocArea(0) != hplib_OK)
920 return -1;
921 if (hplib_checkMallocArea(1) != hplib_OK)
922 return -1;
923
924#ifdef NETAPI_ENABLE_SECURITY
925 /* allocate 2x number of tunnels since we need one for inflow and one for data mode */
926 netapi_VM_SaContextVaddr = hplib_vmMemAlloc((TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2 *
927 SEC_CONTEXT_SZ), 128, 0);
928 if (!netapi_VM_SaContextVaddr)
929 {
930 return (-1);
931 }
932#else
933 netapi_VM_SaContextVaddr= (char *) NULL;
934#endif
935
936
937
938 /* (3) Allocate 2 QM regions from continguous chunk above */
939 netapi_VM_QMemGlobalDescRam =
940 (void *)hplib_vmMemAlloc((TUNE_NETAPI_NUM_GLOBAL_DESC *
941 TUNE_NETAPI_DESC_SIZE),
942 128,
943 0);
944
945 netapi_VM_QMemLocalDescRam =
946 (void *)hplib_vmMemAlloc((TUNE_NETAPI_NUM_LOCAL_DESC *
947 TUNE_NETAPI_DESC_SIZE),
948 128,
949 0);
950
951 /****************************************************
952 * partial initialization. For process, not for SOC
953 ***************************************************/
954 result = netapip_initQm (pnetapiShm->netapi_global.cfg.def_max_descriptors,
955 pRmClientHandle);
956 if (result != 1)
957 {
958 return -1;
959 }
960
961 /* Start the QMSS. */
962 if (netapip_startQm(pRmClientHandle) != 1)
963 {
964 return -1;
965 }
966
967 result= netapip_qmSetupMemRegion(
968 pnetapiShm->netapi_global.cfg.def_tot_descriptors_for_us,
969 TUNE_NETAPI_DESC_SIZE,
970 (unsigned int *) netapi_VM_QMemGlobalDescRam,
971 pnetapiShm->netapi_global.cfg.memoryRegion,
972 pnetapiShm->netapi_global.cfg.start_index);
973 if(result <0)
974 {
975 return -1;
976 }
977 /* Initialize CPPI CPDMA */
978 result = netapip_initCppi(pRmClientHandle);
979 if (result != 1)
980 {
981 return -1;
982 }
983 /* CPPI and Queue Manager are initialized. */
984
985 /* create main pkt heap for this process */
986 /* Initialize the Shared Heaps. */
987 Pktlib_sharedHeapInit();
988 /* Populate the heap interface table. */
989 netapi_pktlib_ifTable.data_malloc = netapip_sharedMemoryMalloc;
990 netapi_pktlib_ifTable.data_free = netapip_sharedMemoryFree;
991 /* Initialize the heap configuration. */
992 memset ((void *)&heapCfg, 0, sizeof(Pktlib_HeapCfg));
993 /* Populate the heap configuration */
994 heapCfg.name = "netapi";
995 //heapCfg.memRegion = TUNE_NETAPI_QM_GLOBAL_REGION;
996 heapCfg.memRegion = memInfo.memRegion;
997 heapCfg.sharedHeap = 1;
998 heapCfg.useStarvationQueue = 0;
999 heapCfg.dataBufferSize = pnetapiShm->netapi_global.cfg.def_heap_buf_size;
1000 heapCfg.numPkts = pnetapiShm->netapi_global.cfg.def_heap_n_descriptors;
1001 heapCfg.numZeroBufferPackets= pnetapiShm->netapi_global.cfg.def_heap_n_zdescriptors;
1002 heapCfg.heapInterfaceTable.data_malloc = netapi_pktlib_ifTable.data_malloc;
1003 heapCfg.heapInterfaceTable.data_free = netapi_pktlib_ifTable.data_free;
1004 heapCfg.dataBufferPktThreshold = 0;
1005 heapCfg.zeroBufferPktThreshold = 0;
1006
1007 /* Create Shared Heap with specified configuration. */
1008 sharedHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
1009 //todo -> cleanup on failure
1010 if (!sharedHeapHandle) { return -1;}
1011 handle->netcp_heap= sharedHeapHandle;
1012
1013 //open shared heap handle but create new controlRx & Tx heaps for this
1014 //process
1015 /* Update for Control */
1016 heapCfg.name = "netapi_control_rx";/*todo:add random#*/
1017 heapCfg.sharedHeap = 1;
1018 heapCfg.dataBufferSize = TUNE_NETAPI_CONFIG_MAX_CTL_RXTX_BUF_SIZE;
1019 heapCfg.numPkts = TUNE_NETAPI_CONFIG_NUM_CTL_RX_BUF;
1020 heapCfg.numZeroBufferPackets= 0;
1021 controlRxHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
1022 if (!controlRxHeapHandle) { return -1;}
1023
1024 handle->netcp_control_rx_heap= controlRxHeapHandle;
1025 heapCfg.name = "netapi_control_tx";
1026 heapCfg.numPkts = TUNE_NETAPI_CONFIG_NUM_CTL_TX_BUF;
1027 controlTxHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
1028 if (!controlTxHeapHandle) { return -1;}
1029 handle->netcp_control_tx_heap= controlTxHeapHandle;
1030
1031 /* Common Initialization for all threads in process */
1032 while(count < TUNE_NETAPI_MAX_NUM_TRANS)
1033 {
1034 netapi_proc_global.nwal_context.transInfos[count].transId = count;
1035 count++;
1036 }
1037 result = netapip_startNwal(sharedHeapHandle,
1038 controlRxHeapHandle,
1039 controlTxHeapHandle,
1040 &handle->nwal_local,
1041 &pnetapiShm->netapi_global.cfg,
1042 &pnetapiShm->netapi_global.nwal_context,
1043 handle->master);
1044 if (result<0)
1045 {
1046 return -1;
1047 }
1048 }
1049
1050 //get timer running
1051#ifdef CORTEX_A8
1052 netapip_initTimer();
1053#endif
1054
1055
1056
1057 return 0;
1058}
1059
1060
1061/****************************************************************************
1062* FUNCTION PURPOSE: NETAPI internal function which performs clean for linux user space
1063 ****************************************************************************
1064 * DESCRIPTION: NETAPI internal function which performs clean for linux user space
1065 ***************************************************************************/
1066void netapip_zapQ(int queueNum)
1067{
1068 int i;
1069 if (!queueNum)
1070 {
1071 return;
1072 }
1073 for (i=0;;i+=1 )
1074 {
1075 /* Pop descriptor from source queue */
1076 if (pktio_mQmssQueuePopRaw(queueNum) == NULL)
1077 {
1078 break;
1079 }
1080 }
1081}
1082
1083
1084/****************************************************************************
1085* FUNCTION PURPOSE: NETAPI internal function to display internal heap stats.
1086 ****************************************************************************
1087 * DESCRIPTION: NETAPI internal function to display internal heap stats.
1088 ***************************************************************************/
1089void netapi_dump_internal_heap_stats(void)
1090{
1091 Pktlib_HeapStats pktLibHeapStats;
1092 Pktlib_getHeapStats(netapi_get_global()->nwal_context.pa2sa_heap,&pktLibHeapStats);
1093 printf("PA2SA(ingress) stats> #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
1094 pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
1095 printf(" > #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
1096 pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
1097 pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
1098 Pktlib_getHeapStats(netapi_get_global()->nwal_context.sa2pa_heap,&pktLibHeapStats);
1099 printf("SA2PA stats> #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
1100 pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
1101 printf(" > #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
1102 pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
1103 pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
1104
1105}
1106
diff --git a/ti/runtime/netapi/src/netapi_loc.h b/ti/runtime/netapi/src/netapi_loc.h
new file mode 100755
index 0000000..3b047cf
--- /dev/null
+++ b/ti/runtime/netapi/src/netapi_loc.h
@@ -0,0 +1,454 @@
1/*****************************************
2 * file: netapi_loc.h
3 * purpose: internal netapi stuff
4 ****************************************/
5
6#ifndef __NETAPI_LOC__H
7#define __NETAPI_LOC__H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13#include "ti/drv/nwal/nwal_util.h"
14#include "ti/drv/nwal/nwal.h"
15#include "ti/runtime/hplib/hplib.h"
16#include "ti/runtime/netapi/pktio.h"
17#include "ti/runtime/netapi/netcp_cfg.h"
18#include "ti/runtime/netapi/netapi_tune.h"
19
20
21extern hplib_virtualAddrInfo_T netapi_VM_VirtAddr[HPLIB_MAX_MEM_POOLS];
22extern unsigned char *netapi_VM_SaContextVaddr;
23//extern NETAPI_SHM_T* pnetapiShm;
24
25#define NETAPI_FALSE 0
26#define NETAPI_TRUE 1
27/***********************************************
28 * GLOBAL AREA
29 * short term: this is global to process
30 * (multi-process not supported)
31 * long term: this structure gets put in shared memory
32 ***********************************************/
33
34/* list of global pktio channels that have been created
35 (NETCP_TX, RX are intrinsic so won't be here) */
36typedef struct PKTIO_ENTRY_tag
37{
38 char name[PKTIO_MAX_NAME+1];
39 Qmss_Queue qn; // -1 => slot is free
40} PKTIO_ENTRY_T;
41
42/* to hold an IP on an interface */
43typedef struct NETCP_INTERFACE_IP_Tag
44{
45 int in_use;
46 void * nwal_handle;
47 nwal_IpType ip_type;
48 nwalIpAddr_t ip_addr;
49 nwalIpOpt_t ip_qualifiers;
50 void * user_data;
51} NETCP_INTERFACE_IP_T;
52
53/* to hold a classifier */
54typedef struct NETCP_INTERFACE_CLASSIFIER_Tag
55{
56 int in_use;
57 int class_type; //see netcp_cfg.h
58 void * nwal_L2_handle;
59 void * nwal_L3_handle;
60 void * nwal_L4_handle;
61 void * user_data;
62} NETCP_INTERFACE_CLASSIFIER_T;
63
64/* to hold an ipsec rx policy */
65typedef struct NETCP_IPSEC_POLICY_Tag
66{
67 int in_use;
68 int tunnel; //associated tunnel
69 void * nwal_handle; //handle associated with this RX Policy
70 void * user_data; // user data associtaed with this RX Policy
71} NETCP_IPSEC_POLICY_T;
72
73/* to hold a tunnel */
74typedef struct NETCP_IPSEC_SA_Tag
75{
76 int in_use;
77 int inbound; //true if inbound
78
79 int sa_mode; //mode we are going to use
80#define NETCP_IPSEC_SA_MODE_INFLOW 0
81#define NETCP_IPSEC_SA_MODE_SIDEBAND 1
82
83 void * sa_handle_inflow; //for inflow mode
84 void * sa_handle_sideband; //for sideband mode
85 int iface; //associated interface
86 nwalTxDmPSCmdInfo_t dmPSCmdInfo;
87 uint32_t swInfo0;
88 uint32_t swInfo1;
89 void* user_data;
90} NETCP_IPSEC_SA_T;
91
92/* to hold a netcp 'interface' */
93typedef struct NETCP_INTERFACE_Tag
94{
95 int in_use; /* 1 for valid */
96 int state; /* 0=down, 1=up, future.. */
97 void * nwal_handle; //handle associated with this interface
98 unsigned char mac[6]; // mac address
99 unsigned int vlan; //future
100} NETCP_INTERFACE_T;
101
102/*to keep track of netcp config transactions */
103typedef struct {
104 nwal_Bool_t inUse;
105 uint16_t transType;
106#define NETAPI_NWAL_HANDLE_TRANS_NONE 0
107#define NETAPI_NWAL_HANDLE_TRANS_MAC 1
108#define NETAPI_NWAL_HANDLE_TRANS_IP 2
109#define NETAPI_NWAL_HANDLE_TRANS_PORT 3
110#define NETAPI_NWAL_HANDLE_TRANS_SA 4
111#define NETAPI_NWAL_HANDLE_TRANS_SA_POLICY 5
112#define NETAPI_NWAL_HANDLE_STAT_REQUEST 6
113
114 uint16_t state;
115#define NETAPI_NWAL_HANDLE_STATE_IDLE 0
116#define NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING 1
117#define NETAPI_NWAL_HANDLE_STATE_OPEN 2
118#define NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING 3
119#define NETAPI_NWAL_HANDLE_STATE_ERR 4
120 nwal_Handle handle;
121 uint64_t transId;
122 NETAPI_T netapi_handle; //the thread making the transaction
123} NetapiNwalTransInfo_t;
124
125/* to hold user defined flows */
126typedef struct NETCP_REGISTERED_FLOWS_Tag
127{
128 int in_use; //1=> in use
129 void* handle; //cppi handle to resource (internal)
130 NETCP_CFG_FLOW_T flow;
131} NETCP_REGISTERED_FLOWS_T;
132
133/******************************
134 * nwal global context : for SOC
135 * (shared over all process instances)
136 *******************************/
137typedef struct
138{
139 int state;
140#define NETAPI_NW_CXT_GLOB_INACTIVE 0x0
141#define NETAPI__CXT_GLOB_ACTIVE 0x1
142#define NETAPI_NW_CXT_GLOB_RES_ALLOC_COMPLETE 0x3
143
144 nwal_Handle nwalInstHandle; //created instance
145 //internal heaps used just by netcp (sa<->pa). SW doesn't touch these
146 Pktlib_HeapHandle sa2pa_heap;
147 Pktlib_HeapHandle pa2sa_heap;
148 //stats
149 paSysStats_t paStats;
150 NETCP_INTERFACE_T interfaces[TUNE_NETAPI_MAX_NUM_MAC]; //interfaces
151 NETCP_INTERFACE_CLASSIFIER_T classi[TUNE_NETAPI_MAX_CLASSIFIERS]; //classifiers
152 NETCP_REGISTERED_FLOWS_T flows[TUNE_NETAPI_MAX_FLOWS]; //flows
153 NETCP_IPSEC_SA_T tunnel[TUNE_NETAPI_MAX_SA]; //tunnels
154 NETCP_IPSEC_POLICY_T policy[TUNE_NETAPI_MAX_POLICY]; //policies
155 NETCP_INTERFACE_IP_T ips[TUNE_NETAPI_MAX_NUM_IP]; //ips
156} NETAPI_NWAL_GLOBAL_CONTEXT_T;
157/************************************/
158/* global instance for this process */
159/************************************/
160typedef struct
161{
162 int state; /* see above*/
163 int numCmdPass;
164 int numCmdFail;
165 int numBogusTransIds;
166 NetapiNwalTransInfo_t transInfos[TUNE_NETAPI_MAX_NUM_TRANS];
167} NETAPI_NWAL_GLOBAL_PROC_CONTEXT_T;
168
169/* NWAL Local context (per core/thread) */
170typedef struct
171{
172#define NETAPI_NW_CXT_LOC_INACTIVE 0x0
173#define NETAPI_NW_CXT_LOC_ACTIVE 0x2
174 int state;
175
176 int numPendingCfg;
177 NETCP_CFG_STATS_CB stats_cb;
178
179/* stats */
180 int numL2PktsRecvd;
181 int numL3PktsRecvd;
182 int numL4PktsRecvd;
183 int numL4PktsSent;
184 int TxErrDrop;
185
186 /* local config */
187 nwalLocCfg_t nwalLocCfg;
188} NETAPI_NWAL_LOCAL_CONTEXT_T;
189
190/* the global: for SOC, accross all processes */
191typedef struct NETAPI_GLOBAL_tag
192{
193#define NETAPI_MAX_PKTIO (TUNE_NETAPI_MAX_PKTIO)
194 PKTIO_ENTRY_T pktios[NETAPI_MAX_PKTIO];
195 /* configuration */
196 NETAPI_CFG_T cfg;
197 /* nwal context */
198 NETAPI_NWAL_GLOBAL_CONTEXT_T nwal_context;
199 //NETAPI_T p_master; // save p'masters handle
200} NETAPI_GLOBAL_T;
201
202/* the process global: one per process */
203typedef struct NETAPI_PROC_GLOBAL_tag
204{
205 /* nwal context */
206 NETAPI_NWAL_GLOBAL_PROC_CONTEXT_T nwal_context;
207
208 //NETAPI_T p_master; // save p'masters handle
209} NETAPI_PROC_GLOBAL_T;
210/************************************
211 * this is a per thread structure.
212 * It contains stuff local to thread
213 * and pointer to global stuff
214 * that is shared over all threads,
215 **************************************/
216typedef struct NETAPI_HANDLE_Tag
217{
218 int master; //master type
219
220 void* global; /* pointer to the soc global area */
221 void* proc_global; /* pointer to the proc global area */
222
223 /* heap handles */
224 Pktlib_HeapHandle netcp_heap; /* internal default */
225 Pktlib_HeapHandle netcp_control_rx_heap; /* for control messages */
226 Pktlib_HeapHandle netcp_control_tx_heap; /* for control messages */
227 Pktlib_HeapHandle createdHeaps[TUNE_NETAPI_MAX_HEAPS]; /* created by app and registered */
228
229 /* pktios defined */
230 int n_pktios; /* #of pktios that are active for this instance */
231 void* pktios[NETAPI_MAX_PKTIO]; /* the list of pktios */
232
233 /* scheduler stuff. unallocated if NETAPI_INCLUDE_SCHED not set */
234 void* p_sched;
235
236 /* nwal local context */
237 NETAPI_NWAL_LOCAL_CONTEXT_T nwal_local;
238
239 /* thread cookie */
240 void* cookie; /*set by calling thread */
241 HPLIB_SPINLOCK_IF_T spinLock;
242 int memRegion;
243} NETAPI_HANDLE_T;
244
245typedef struct NETAPI_SHM_Tag
246{
247 NETAPI_GLOBAL_T netapi_global;
248 hplib_spinLock_T netapi_pktio_lock;
249 hplib_spinLock_T netapi_netcp_cfg_lock;
250 hplib_spinLock_T netapi_util_lock;
251 hplib_spinLock_T netapi_netcp_cfg_l3_classi_lock;
252} NETAPI_SHM_T;
253
254//internal initialization routines */
255int netapip_initQm(int max_descriptors, void* rmClientServiceHandle);
256
257int netapip_initCppi(void* rmClientServiceHandle);
258
259int netapip_startQm(void* rmClientServiceHandle);
260int netapip_initNwal(int region2use,
261 Pktlib_HeapIfTable * p_table,
262 NETAPI_NWAL_GLOBAL_CONTEXT_T * p_nwal_context,
263 NETAPI_CFG_T *p_cfg);
264int netapip_startNwal(Pktlib_HeapHandle pkt_heap,
265 Pktlib_HeapHandle cmd_heapRx,
266 Pktlib_HeapHandle cmd_heapTx,
267 NETAPI_NWAL_LOCAL_CONTEXT_T* p,
268 NETAPI_CFG_T* p_cfg,
269 NETAPI_NWAL_GLOBAL_CONTEXT_T* p_nwal_glob_context,
270 int master);
271
272int netapip_initTimer(void);
273int netapip_qmSetupMemRegion(unsigned int numDesc,
274 unsigned int descSize,
275 unsigned int* pDescMemBase,
276 int memRegion,
277 int start_index);
278
279
280//nwal callbacks
281void netapip_pktioNWALRxPktCallback(uint32_t appCookie,
282 uint16_t numPkts,
283 nwalRxPktInfo_t* pPktInfo,
284 uint64_t timestamp,
285 nwal_Bool_t* pFreePkt);
286
287void netapip_netcpCfgNWALCmdCallBack (nwal_AppId appHandle,
288 uint16_t trans_id,
289 nwal_RetValue ret);
290
291void netapip_netcpCfgNWALCmdPaStatsReply (nwal_AppId appHandle,
292 nwal_TransID_t trans_id,
293 paSysStats_t *stats);
294
295void netapip_pktioNWALSBPktCallback (uint32_t appCookie,
296 uint16_t numPkts,
297 nwalDmRxPayloadInfo_t* pDmRxPktInfo,
298 nwal_Bool_t* pFreePkt);
299
300
301//***********************************
302//internal utilities
303//*************************************
304
305//return the list of pktios for this instance
306static inline void ** netapi_get_pktio_list(NETAPI_T p)
307{
308NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
309return &pp->pktios[0];
310}
311
312//get scheduler block handle
313static inline void * netapi_get_scheduler(NETAPI_T p)
314{
315 NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
316 return pp->p_sched;
317}
318
319/* return pointer to global area */
320NETAPI_GLOBAL_T * netapi_get_global(void);
321NETAPI_PROC_GLOBAL_T * netapi_get_proc_global(void);
322
323//add a pktio name (and queue) to global list
324static inline int netapip_addGlobalPktio(NETAPI_T p, char *name, Qmss_Queue * qn)
325{
326 NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
327 PKTIO_ENTRY_T *pe;
328 int i;
329 /* find a free slot */
330 pe = &((NETAPI_GLOBAL_T *)(pp->global))->pktios[0];
331
332 for(i=0;i<NETAPI_MAX_PKTIO; i++)
333 {
334 pe = &((NETAPI_GLOBAL_T *)(pp->global))->pktios[i];
335 if (pe->qn.qNum == -1)
336 {
337 pe->qn.qNum=qn->qNum;
338 pe->qn.qMgr=qn->qMgr;
339 strncpy(pe->name, name, PKTIO_MAX_NAME);
340 return 1;
341 }
342 }
343 return 0; //no room
344}
345
346//delete a pktio name (and queue) to global list
347static inline int netapi_del_global_pktio(NETAPI_T p, char *name)
348{
349 NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
350 PKTIO_ENTRY_T *pe;
351 int i;
352
353 /* find slot */
354
355
356 for(i=0;i<NETAPI_MAX_PKTIO; i++)
357 {
358 pe = &((NETAPI_GLOBAL_T *)(pp->global))->pktios[i];
359 if (pe->qn.qNum == -1)
360 continue;
361 if (!strncmp(name, pe->name, PKTIO_MAX_NAME))
362 {
363 pe->qn.qNum=-1;
364 pe->name[0]='\0';
365 return 1;
366 }
367 }
368 return 0; //no room
369}
370
371
372/* get list of global pktios that have been created */
373static inline Qmss_Queue* netapip_findGlobalPktio(NETAPI_T p, char *name)
374{
375 NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
376 PKTIO_ENTRY_T *pe;
377 int i;
378
379 /* find slot */
380 for(i=0;i<NETAPI_MAX_PKTIO; i++)
381 {
382 pe = &((NETAPI_GLOBAL_T *)(pp->global))->pktios[i];
383 if (pe->qn.qNum == -1) continue;
384 if (!strncmp(name, pe->name, PKTIO_MAX_NAME))
385 {
386 return &pe->qn;
387 }
388 }
389 return NULL; //not found
390}
391
392/* return the nwal global instance handle */
393static inline nwal_Handle netapip_returnNwalInstanceHandle(NETAPI_T p)
394{
395
396NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
397return ((NETAPI_GLOBAL_T *)(pp->global))->nwal_context.nwalInstHandle;
398}
399
400
401
402//utility to clear out a queue
403void netapip_zapQ(int queueNum);
404void netapip_netcpCfgBuildRoute(NETCP_CFG_ROUTE_T * p_route,
405 int16_t * p_flow,
406 Qmss_QueueHnd * p_q,
407 nwalRouteType_t *p_type);
408
409//database utilities
410void netapip_netcpCfgDeleteSa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int sa_slot);
411
412void netapip_netcpCfgInsertSa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
413 int sa_slot, //we 'reserved it already'
414 int dir,
415 int mode,
416 void * temp1,
417 void * temp2,
418 void * handle_inflow,
419 void * handle_sideband,
420 nwalTxDmPSCmdInfo_t *dmPSCmdInfo,
421 uint32_t swInfo0,
422 uint32_t swInfo1,
423 void* user_data);
424void *netapip_netcpCfgGetSaHandles( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
425 int sa_slot, void ** p_sideband);
426void* netapip_netcpCfgGetMacHandle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no);
427void *netapip_netcpCfgGetIpHandle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no,int ip_slot);
428NetapiNwalTransInfo_t * netapip_getFreeTransInfo(NETAPI_HANDLE_T *p_handle,
429 NETAPI_PROC_GLOBAL_T *p_global,
430 nwal_TransID_t *pTransId);
431void netapip_freeTransInfo(NetapiNwalTransInfo_t* pTransInfo);
432void *netapip_netcpCfgGetPolicy( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
433 int policy_slot);
434nwalTxDmPSCmdInfo_t* netapip_netcpCfgGetSaSBInfo(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
435 NETCP_CFG_SA_T sa_app_id);
436int netapip_netcpCfgGetSaInflowInfo(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
437 NETCP_CFG_SA_T sa_app_id,
438 uint32_t *swInfo0,
439 uint32_t *swInfo1);
440
441int netapip_systemInit(NETAPI_HANDLE_T *handle,
442 Bool global_master_process);
443
444
445void netapip_cleanupAtStart(void);
446
447
448
449
450#ifdef __cplusplus
451}
452#endif
453
454#endif
diff --git a/ti/runtime/netapi/src/netapi_sched.c b/ti/runtime/netapi/src/netapi_sched.c
new file mode 100755
index 0000000..6c079d5
--- /dev/null
+++ b/ti/runtime/netapi/src/netapi_sched.c
@@ -0,0 +1,221 @@
1/****************************************
2 * File: netapi_sched.c
3 * Purpose: netapi scheduling module
4 * NOTE: This sample right now.
5 **************************************************************
6 * FILE: netapi_sched.c
7 *
8 * DESCRIPTION: netapi sample scheduler source file for user space transport
9 * library
10 *
11 * REVISION HISTORY:
12 *
13 * Copyright (c) Texas Instruments Incorporated 2013
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 *
19 * Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 *
22 * Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the
25 * distribution.
26 *
27 * Neither the name of Texas Instruments Incorporated nor the names of
28 * its contributors may be used to endorse or promote products derived
29 * from this software without specific prior written permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
36 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
37 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
38 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
39 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
41 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42
43 ****************************************/
44
45#include "netapi_sched.h"
46
47#define NO_TIMER //turn off timer related scheduling
48
49
50/********************************************************************
51 * FUNCTION PURPOSE: API to get scheduling context statistics
52 ********************************************************************
53 * DESCRIPTION: API to get scheduling context statistics
54 ********************************************************************/
55void netapi_schedGetStats(NETAPI_SCHED_HANDLE_T *s,
56 unsigned long long * p_pkts,
57 unsigned long long * p_cycles,
58 unsigned long long * p_cache_cycles)
59{
60 *p_pkts= s->stats.num_pkts;
61 *p_cycles= s->stats.busy_cycles;
62 *p_cache_cycles= s->stats.cache_cycles;
63 return;
64}
65/****************************************/
66/************API************************/
67/**************************************/
68
69/********************************************************************
70 * FUNCTION PURPOSE: API to open a scheduling context
71 ********************************************************************
72 * DESCRIPTION: API to open a scheduling context
73 ********************************************************************/
74NETAPI_SCHED_HANDLE_T * netapi_schedOpen(NETAPI_T n,
75 NETAPI_SCHED_CONFIG_T * p_config,
76 int *p_err)
77{
78 *p_err=0;
79 NETAPI_SCHED_HANDLE_T * ph = (NETAPI_SCHED_HANDLE_T *) netapi_get_scheduler(n);
80 if(!ph)
81 {
82 *p_err= NETAPI_ERR_NOMEM;
83 return NULL;
84 }
85 if(!p_config)
86 {
87 *p_err= NETAPI_ERR_BAD_INPUT;
88 return NULL;
89 }
90 memcpy(&ph->config,p_config,sizeof(NETAPI_SCHED_CONFIG_T));
91 ph->start = hplib_mUtilGetTimestamp();
92 ph->back = (void *) n;
93 if (ph->config.valid_flags & NETAPI_SCHED_DURATION)
94 {
95 if (ph->config.duration == NETAPI_SCHED_FOREVER)
96 {
97 ph->shutdown_time=(uint64_t) -1;
98 }
99 else
100 {
101 ph->shutdown_time = ph->start + ph->config.duration;
102 }
103 }
104 else
105 {
106 ph->shutdown_time = (uint64_t) -1;
107 }
108 ph->state =NETAPI_SCHED_STATE_OPEN;
109 return(ph);
110}
111
112/********************************************************************
113 * FUNCTION PURPOSE: API to re-configure a scheduling context, FUTURE,
114 * not implemented
115 ********************************************************************
116 * DESCRIPTION: API to re-configure a scheduling context, FUTURE,
117 * not implemented
118 ********************************************************************/
119
120int netapi_schedControl(NETAPI_SCHED_HANDLE_T *s,
121 NETAPI_SCHED_CONFIG_T *p_config,
122 int *p_err)
123{
124 /* NOT_IMPLEMENTED */
125 return 0;
126}
127
128/********************************************************************
129 * FUNCTION PURPOSE: API for main entry point to scheduler
130 ********************************************************************
131 * DESCRIPTION: API to get NETAPI scheduling context statistics
132 ********************************************************************/
133/* main entry point. caller gives up control to scheduler */
134int netapi_schedRun(NETAPI_SCHED_HANDLE_T *s,
135 int *p_err)
136{
137 int err;
138 *p_err=0;
139 unsigned long long t = hplib_mUtilGetTimestamp();
140 int next_house;
141 volatile int pkts;
142 volatile unsigned long t1;
143 volatile unsigned long t2;
144 volatile unsigned long long cache_op_b2;
145 volatile unsigned long long n_c_ops;
146
147 next_house = s->config.interval;
148 /* loop for duration or until shutdown */
149 for(;t< s->shutdown_time;)
150 {
151#ifndef NO_TIMER
152 t = hplib_mUtilGetTimestamp();
153#endif
154 next_house -=1;
155
156 cache_op_b2= Osal_cache_op_measure(&n_c_ops);
157 t1=hplib_mUtilGetPmuCCNT();
158 /* poll all pktio channels we have open in RX mode */
159 pkts=netapi_pktioPollAll((NETAPI_T) s->back, NULL, &err);
160 if (!pkts && (s->config.yield == NETAPI_TRUE))
161 {
162 sched_yield();
163 }
164 t2=hplib_mUtilGetPmuCCNT();
165 if (pkts)
166 {
167 s->stats.num_pkts+= (unsigned long long) pkts;
168 s->stats.busy_cycles += (unsigned long long) (t2-t1);
169 cache_op_b2= Osal_cache_op_measure(&n_c_ops)- cache_op_b2;
170 s->stats.cache_cycles += (unsigned long long) cache_op_b2;
171 }
172
173 /* poll pktlib garbage collections for registered heaps */
174 if (NETAPI_TRUE == s->config.pollGarbageQ)
175 {
176 netapi_pollHeapGarbage((NETAPI_T) s->back);
177 }
178
179
180 /*poll NETCP/PA control channels */
181 if (NETAPI_TRUE == s->config.pollCtrlQ)
182 {
183 netapi_netcpPoll((NETAPI_T) s->back);
184 }
185
186 /* see if time to do a house keeping callback */
187 if ((s->config.valid_flags & NETAPI_SCHED_CBV) && s->config.house_cb)
188 if (next_house<=0)
189 {
190 s->config.house_cb(s);
191 next_house = s->config.interval;
192 }
193 /* see if we were closed and/or its time to close */
194 if (s->state!= NETAPI_SCHED_STATE_OPEN)
195 {
196 s->state=NETAPI_SCHED_STATE_CLOSE;
197 break;
198 }
199
200 }
201 return 1;
202}
203/********************************************************************
204 * FUNCTION PURPOSE: API to close a scheduling context
205 ********************************************************************
206 * DESCRIPTION: API to close a scheduling context
207 ********************************************************************/
208/* shutdown scheduler context */
209int netapi_schedClose(NETAPI_SCHED_HANDLE_T * s,
210 NETAPI_SCHED_SHUTDOWN_T * p_close,
211 int * p_err)
212{
213 *p_err=0;
214 if (p_close->shutdown_type == NETAPI_SCHED_SHUTDOWN_NOW)
215 {
216 s->state=NETAPI_SCHED_STATE_CLOSE_IN_PROGRESS;
217 }
218 return 1;
219}
220
221
diff --git a/ti/runtime/netapi/src/netapi_sec.c b/ti/runtime/netapi/src/netapi_sec.c
new file mode 100644
index 0000000..cd936be
--- /dev/null
+++ b/ti/runtime/netapi/src/netapi_sec.c
@@ -0,0 +1,900 @@
1/**************************************************************
2 * FILE PURPOSE : NETAPI SECURITY CONFIGURATION-
3 * user space access to security transport resources on SOC
4 **************************************************************
5 * @file netapi_sec.c
6 *
7 * @brief DESCRIPTION: netapi security cfg file for user space transport
8 * library
9 *
10 * REVISION HISTORY:
11 *
12 * Copyright (c) Texas Instruments Incorporated 2013
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41*****************************************************************************/
42
43#include "netapi.h"
44
45NETAPI_SA_INFO_LOCAL_T netapi_sa_db[TUNE_NETAPI_MAX_SA];
46/********************************************************************
47 * FUNCTION PURPOSE: API to add an IPSEC SA
48 ********************************************************************
49 * DESCRIPTION: API to add an IPSEC SA
50 ********************************************************************/
51NETCP_CFG_SA_T netapi_secAddSAInternal(NETAPI_T h,
52 int iface_no,
53 NETAPI_SEC_SA_INFO_T *sa_info,
54 nwalSecKeyParams_t * key_params,
55 int inflow_mode,
56 NETCP_CFG_ROUTE_HANDLE_T route,
57 void **p_data_mode_handle,
58 void **p_inflow_mode_handle,
59 void * p_user_data,
60 NETCP_CFG_IP_T ip_rule,
61 int * perr)
62{
63 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
64 nwal_RetValue retValue;
65 NetapiNwalTransInfo_t *pTransInfo;
66 nwal_TransID_t trans_id;
67 unsigned int appId = NETAPI_NETCP_MATCH_IPSEC | iface_no;
68 int tunnelId;
69 nwalSaIpSecId_t saInfo;
70 int have_to_wait=1;
71 nwalTxDmPSCmdInfo_t dmPSCmdInfo;
72 nwalSaIpSecId_t nwalSaIpSecId;
73 uint32_t swInfo0 = 0;
74 uint32_t swInfo1 = 0;
75 int sa_db_slot;
76 int free_sa_db_slot = 0;
77 int ip_slot = 0;
78 void * handle;
79 nwalCreateSAParams_t createParam =
80 {
81 /* mac handle */
82 NULL, //to be filled in
83 4,
84 /*nwalSaIpSecParam_t */
85 {
86 0,/* validParams */
87 nwal_SA_MODE_TUNNEL, //update from input
88 64,/* replayWindow */\
89 NWAL_SA_DIR_INBOUND,
90 0,
91 0,
92 NWAL_SA_AALG_HMAC_SHA1,/* update from input */
93 NWAL_SA_EALG_AES_CTR, /* update from input */
94 { 0x00}, /* remMacAddr: NA */
95 12, /* update from input, mac size */
96 NWAL_MATCH_ACTION_CONTINUE_NEXT_ROUTE,/* Continue parsing to next route for match */
97 NWAL_NEXT_ROUTE_FAIL_ACTION_HOST,/* For next route fail action by default is route to host */
98 CPPI_PARAM_NOT_SPECIFIED, /* Use default flow configured to NWAL if packet is routed to host */
99 QMSS_PARAM_NOT_SPECIFIED, /* Use default queue configured to NWAL if packet is routed to host */
100 0 /* route type */
101 },
102 /* nwalSaIpSecKeyParams_t */
103 {0}
104 };
105
106 /* Get IP slot for IP rule. */
107 if (ip_rule)
108 {
109 ip_slot = netapi_cfgGetMatchId(ip_rule);
110 handle = netapip_netcpCfgGetIpHandle(&netapi_get_global()->nwal_context,iface_no,ip_slot);
111 }
112 else
113 {
114 handle = netapip_netcpCfgGetMacHandle(&netapi_get_global()->nwal_context,iface_no);
115 }
116
117 *perr =NETAPI_ERR_OK;
118 if ((!n) || (!sa_info) || (!p_data_mode_handle))
119 {
120 *perr = NETAPI_ERR_BAD_INPUT;
121 return -1;
122 }
123
124 /* prior to building table, will need to store SA entry in local database,
125 * and make sure this SA has not been already offloaded, if already off-loaded,
126 * just return app_id associated with the SA */
127
128 for(sa_db_slot=0; sa_db_slot < TUNE_NETAPI_MAX_SA; sa_db_slot++)
129 {
130 if (netapi_sa_db[sa_db_slot].inUse)
131 {
132 if (sa_info->ipType == nwal_IPV4)
133 {
134 if (netapi_sa_db[sa_db_slot].spi != sa_info->spi)
135 continue;
136 if(memcmp(&netapi_sa_db[sa_db_slot].dst.ipv4,
137 &sa_info->dst.ipv4, sizeof(sa_info->dst.ipv4)))
138 continue;
139
140 netapi_sa_db[sa_db_slot].ref_count++;
141 return netapi_sa_db[sa_db_slot].app_id;
142 }
143 else if (sa_info->ipType == nwal_IPV6)
144 {
145 if (netapi_sa_db[sa_db_slot].spi != sa_info->spi)
146 continue;
147 if(memcmp(&netapi_sa_db[sa_db_slot].dst.ipv6,
148 &sa_info->dst.ipv6, sizeof(sa_info->dst.ipv6)))
149 continue;
150
151 netapi_sa_db[sa_db_slot].ref_count++;
152 return netapi_sa_db[sa_db_slot].app_id;
153 }
154 else
155 {
156 *perr = NETAPI_ERR_BAD_INPUT;
157 return -1;
158 }
159 }
160 else
161 {
162 /* found free slot */
163 free_sa_db_slot = sa_db_slot;
164 }
165 }
166 saInfo.spi = sa_info->spi;
167
168 memcpy(&saInfo.dst, &sa_info->dst, sizeof( nwalIpAddr_t));
169
170 /* reserve a slot */
171 tunnelId = netapip_netcpCfgFindSaSlot(n,
172 &netapi_get_global()->nwal_context,
173 iface_no);
174
175 if (tunnelId <0)
176 {
177 *perr= NETAPI_ERR_NOMEM;
178 return -1;
179 }
180 appId |= (tunnelId << NETAPI_NETCP_MATCH_ID_SHIFT);
181
182 *p_data_mode_handle= NULL;
183 *p_inflow_mode_handle= NULL;
184
185
186
187 if (inflow_mode & NETAPI_SEC_SA_INFLOW)
188 {
189 pTransInfo = netapip_getFreeTransInfo(n,
190 (NETAPI_PROC_GLOBAL_T *) n->proc_global,
191 &trans_id);
192 if (!pTransInfo)
193 {
194 *perr = NETAPI_ERR_BUSY;
195 netapip_netcpCfgDeleteSa(&netapi_get_global()->nwal_context,tunnelId);
196 return -1;
197 }
198 pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_SA;
199 pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING;
200 pTransInfo->inUse = nwal_TRUE;
201 pTransInfo->netapi_handle = h;
202
203 /* build SA parameters */
204 saInfo.spi = sa_info->spi;
205 memcpy(&saInfo.dst, &sa_info->dst, sizeof( nwalIpAddr_t));
206 memcpy(&saInfo.src, &sa_info->src, sizeof( nwalIpAddr_t));
207 saInfo.proto = sa_info->proto;
208 createParam.h.handle = handle;
209 createParam.ipType = sa_info->ipType;
210 createParam.saIpSecParam.dir = sa_info->dir;
211 createParam.saIpSecParam.saMode = sa_info->saMode;
212 createParam.saIpSecParam.replayWindow = sa_info->replayWindow;
213 createParam.saIpSecParam.authMode = sa_info->authMode;
214 createParam.saIpSecParam.cipherMode = sa_info->cipherMode;
215 createParam.saIpSecParam.esnLo = sa_info->esnLo;
216 createParam.saIpSecParam.esnHi = sa_info->esnHi;
217 if ((sa_info->cipherMode == NWAL_SA_EALG_AES_GCM) ||
218 (sa_info->cipherMode == NWAL_SA_EALG_AES_CCM) ||
219 (sa_info->authMode == NWAL_SA_AALG_GMAC) ||
220 (sa_info->authMode == NWAL_SA_AALG_HMAC_SHA2_256) ||
221 (sa_info->authMode == NWAL_SA_AALG_HMAC_SHA2_256_RFC4868))
222 {
223 createParam.saIpSecParam.macSize = 16;
224 }
225 if ((sa_info->authMode == NWAL_SA_AALG_NULL) &&
226 (!((sa_info->cipherMode == NWAL_SA_EALG_AES_GCM) ||
227 (sa_info->cipherMode == NWAL_SA_EALG_AES_CCM))))
228 {
229 createParam.saIpSecParam.replayWindow = 0;
230 createParam.saIpSecParam.macSize = 0;
231 }
232 memcpy(&createParam.keyParam,key_params,sizeof(nwalSecKeyParams_t));
233
234 if (route != NULL)
235 {
236 if((route->valid_params & NETCP_CFG_VALID_PARAM_ROUTE_TYPE) ==
237 NETCP_CFG_VALID_PARAM_ROUTE_TYPE)
238 {
239 createParam.saIpSecParam.validParams |=
240 NWAL_SA_INFO_VALID_PARAM_ROUTE_TYPE;
241 }
242 netapip_netcpCfgBuildRoute(route,
243 &createParam.saIpSecParam.appRxPktFlowId,
244 &createParam.saIpSecParam.appRxPktQueue,
245 &createParam.saIpSecParam.routeType);
246 }
247
248 /* fire off config message */
249 retValue = nwal_setSecAssoc (((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
250 trans_id,
251 (nwal_AppId) appId,
252 &saInfo,
253 &createParam,
254 &pTransInfo->handle);
255 if(retValue == nwal_TRANS_COMPLETE)
256 {
257 have_to_wait=0;
258 }
259 else if(retValue != nwal_OK)
260 {
261 *perr = NETAPI_ERR_NWAL_ERR0;
262 netapip_freeTransInfo(pTransInfo);
263 netapip_netcpCfgDeleteSa(&netapi_get_global()->nwal_context,tunnelId);
264 return -1;
265 }
266
267 if((trans_id != NWAL_TRANSID_SPIN_WAIT)&&(have_to_wait))
268 {
269 n->nwal_local.numPendingCfg++;
270 while ((pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_ERR) &&
271 (pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_OPEN))
272 {
273 nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
274 }
275 if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
276 {
277 pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
278 pTransInfo->inUse = nwal_FALSE;
279 *perr = NETAPI_ERR_PA_FW;
280 netapip_netcpCfgDeleteSa(&netapi_get_global()->nwal_context,tunnelId);
281 return -1;
282 }
283 }
284
285 *p_inflow_mode_handle=pTransInfo->handle;
286 netapip_freeTransInfo(pTransInfo);
287
288 if (sa_info->dir == NWAL_SA_DIR_OUTBOUND)
289 {
290 memset(&nwalSaIpSecId, 0, sizeof(nwalSaIpSecId_t));
291 nwalSaIpSecId.spi = sa_info->spi;
292 memcpy(&(nwalSaIpSecId.src), &sa_info->src,sizeof( nwalIpAddr_t));
293 memcpy(&(nwalSaIpSecId.dst), &sa_info->dst,sizeof( nwalIpAddr_t));
294 nwalSaIpSecId.proto = sa_info->proto;
295 if (nwal_getSecAssoc(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
296 &nwalSaIpSecId,
297 NWAL_SA_DIR_OUTBOUND,
298 p_inflow_mode_handle,
299 &swInfo0,
300 &swInfo1) != nwal_TRUE)
301 netapi_Log("netapisecAddSA: call to nwal_getSecAssoc() returned error\n");
302 }
303 }
304
305 /* sideband mode */
306 if (inflow_mode &NETAPI_SEC_SA_SIDEBAND)
307 {
308 nwalCreateDmSAParams_t dmSaParam;
309 void * dm_handle;
310 memset(&dmSaParam,0,sizeof(nwalCreateDmSAParams_t));
311 dmSaParam.dmSaParam.dmChnType= (sa_info->dir==NWAL_SA_DIR_INBOUND)? NWAL_DM_CHAN_DECRYPT: NWAL_DM_CHAN_ENCRYPT; /**direction*/
312 dmSaParam.dmSaParam.replayWindow=sa_info->replayWindow;
313 dmSaParam.dmSaParam.authMode=sa_info->authMode;
314 dmSaParam.dmSaParam.cipherMode=sa_info->cipherMode;
315 dmSaParam.dmSaParam.macSize=12;
316 dmSaParam.dmSaParam.aadSize=0;
317 dmSaParam.dmSaParam.enc1st = (sa_info->dir ==NWAL_SA_DIR_OUTBOUND) ? nwal_TRUE : nwal_FALSE; //encypt 1st for outbound
318 if ((sa_info->cipherMode == NWAL_SA_EALG_AES_GCM) ||
319 (sa_info->cipherMode == NWAL_SA_EALG_AES_CCM) ||
320 (sa_info->authMode == NWAL_SA_AALG_GMAC))
321 {
322 dmSaParam.dmSaParam.macSize = 16;
323 dmSaParam.dmSaParam.aadSize=8;
324 /* Enc1st needs to always be true for combined mode algorithms */
325 dmSaParam.dmSaParam.enc1st = nwal_TRUE;
326 }
327 else
328 {
329 dmSaParam.dmSaParam.macSize=12;
330 dmSaParam.dmSaParam.aadSize=0;
331 }
332
333 if (sa_info->authMode == NWAL_SA_AALG_NULL)
334 {
335 dmSaParam.dmSaParam.enc1st = nwal_TRUE;
336 }
337 /* todo; allow app q for Sideband return */
338 memcpy(&dmSaParam.keyParam,key_params,sizeof(nwalSecKeyParams_t));
339 retValue = nwal_setDMSecAssoc(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
340 (nwal_AppId)appId,
341 &dmSaParam,
342 &dm_handle);
343 if(retValue != nwal_OK)
344 {
345 *perr = NETAPI_ERR_NWAL_ERR0;
346 netapip_netcpCfgDeleteSa(&netapi_get_global()->nwal_context,tunnelId);
347 return -1;
348 }
349
350 *p_data_mode_handle = dm_handle;
351 memset(&dmPSCmdInfo, 0, sizeof(nwalTxDmPSCmdInfo_t));
352 retValue = nwal_initDMPSCmdInfo(netapip_returnNwalInstanceHandle(h),
353 *p_data_mode_handle,
354 &dmPSCmdInfo);
355 }
356
357 netapip_netcpCfgInsertSa(&netapi_get_global()->nwal_context,
358 tunnelId,
359 (sa_info->dir == NWAL_SA_DIR_INBOUND) ? NETAPI_TRUE: NETAPI_FALSE,
360 inflow_mode,
361 &saInfo,
362 &createParam,
363 *p_inflow_mode_handle,
364 *p_data_mode_handle,
365 &dmPSCmdInfo,
366 swInfo0,
367 swInfo1,
368 p_user_data);
369 netapi_sa_db[free_sa_db_slot].app_id = appId;
370 netapi_sa_db[free_sa_db_slot].inUse = 1;
371 netapi_sa_db[free_sa_db_slot].spi = sa_info->spi;
372 netapi_sa_db[free_sa_db_slot].ref_count++;
373 memcpy(&(netapi_sa_db[free_sa_db_slot].dst), &sa_info->dst,sizeof( nwalIpAddr_t));
374 return (appId);
375}
376
377/********************************************************************
378 * FUNCTION PURPOSE: API to add an IPSEC SA
379 ********************************************************************
380 * DESCRIPTION: API to add an IPSEC SA
381 ********************************************************************/
382NETCP_CFG_SA_T netapi_secAddSA(NETAPI_T h,
383 int iface_no,
384 NETAPI_SEC_SA_INFO_T *sa_info,
385 nwalSecKeyParams_t * key_params,
386 int inflow_mode,
387 NETCP_CFG_ROUTE_HANDLE_T route,
388 void **p_data_mode_handle,
389 void **p_inflow_mode_handle,
390 void * p_user_data,
391 int * perr)
392{
393 *perr = 0;
394 return netapi_secAddSAInternal(h,
395 iface_no,
396 sa_info,
397 key_params,
398 inflow_mode,
399 route,
400 p_data_mode_handle,
401 p_inflow_mode_handle,
402 p_user_data,
403 0,
404 perr);
405}
406
407/********************************************************************
408 * FUNCTION PURPOSE: API IP handle to add an IPSEC SA
409 ********************************************************************
410 * DESCRIPTION: API to add an IPSEC SA.
411 * Piggy back off perr for IP handle flag and IP slot.
412 ********************************************************************/
413NETCP_CFG_SA_T netapi_secAddSAIP(NETAPI_T h,
414 int iface_no,
415 NETAPI_SEC_SA_INFO_T *sa_info,
416 nwalSecKeyParams_t * key_params,
417 int inflow_mode,
418 NETCP_CFG_ROUTE_HANDLE_T route,
419 void **p_data_mode_handle,
420 void **p_inflow_mode_handle,
421 void * p_user_data,
422 NETCP_CFG_IP_T ip_rule,
423 int * perr)
424{
425 *perr = 0;
426 return netapi_secAddSAInternal(h,
427 iface_no,
428 sa_info,
429 key_params,
430 inflow_mode,
431 route,
432 p_data_mode_handle,
433 p_inflow_mode_handle,
434 p_user_data,
435 ip_rule,
436 perr);
437}
438
439/********************************************************************
440 * FUNCTION PURPOSE: Internal function to dynamically switch between inflow
441 * and sideband mode
442 ********************************************************************
443 * DESCRIPTION: Internal function to dynamically switch between inflow
444 * and sideband mode
445 ********************************************************************/
446void netapi_secInflowMode(int iface,
447 NETCP_CFG_SA_T sa,
448 int on)
449{
450 /* NOT_IMPLEMENTED */
451}
452
453/********************************************************************
454 * FUNCTION PURPOSE: Internal function to delete an IPSEC SA
455 ********************************************************************
456 * DESCRIPTION: Internal function to delete an IPSEC SA
457 ********************************************************************/
458static void netapi_secDelSA_internal(NETAPI_T h,
459 int iface_no,
460 NETCP_CFG_SA_T sa_app_id,
461 int flags,
462 int *perr)
463{
464 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
465 nwal_RetValue retValue;
466 NetapiNwalTransInfo_t *pTransInfo;
467 nwal_TransID_t trans_id;
468 int tunnelId = (sa_app_id >> NETAPI_NETCP_MATCH_ID_SHIFT) &NETAPI_NETCP_MATCH_ID_MASK;
469 void * handle_inflow;
470 void * handle_sideband;
471 int have_to_wait = 1;
472 int sa_db_slot;
473
474 *perr =0;
475 for(sa_db_slot=0; sa_db_slot < TUNE_NETAPI_MAX_SA; sa_db_slot++)
476 {
477 if((netapi_sa_db[sa_db_slot].inUse) &&
478 (netapi_sa_db[sa_db_slot].app_id == sa_app_id))
479 {
480 if(!netapi_sa_db[sa_db_slot].ref_count)
481 {
482 *perr = NETAPI_ERR_NOTFOUND;
483 return;
484 }
485 netapi_sa_db[sa_db_slot].ref_count--;
486 if(netapi_sa_db[sa_db_slot].ref_count)
487 {
488 return;
489 }
490 else
491 {
492 netapi_sa_db[sa_db_slot].inUse = 0;
493 break;
494 }
495 }
496 }
497 handle_inflow = netapip_netcpCfgGetSaHandles(&netapi_get_global()->nwal_context,
498 tunnelId, &handle_sideband);
499
500
501 if(handle_inflow)
502 {
503 /* get a transaction id */
504 pTransInfo = netapip_getFreeTransInfo(n,
505 (NETAPI_PROC_GLOBAL_T *) n->proc_global,
506 &trans_id);
507 if (!pTransInfo)
508 {
509 *perr = NETAPI_ERR_BUSY;
510 return;
511 }
512 pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_SA;
513 pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING;
514 pTransInfo->inUse = nwal_TRUE;
515 pTransInfo->netapi_handle = h;
516
517 retValue = nwal_delSecAssoc(
518 ((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
519 trans_id,
520 handle_inflow);
521 if(retValue == nwal_TRANS_COMPLETE)
522 {
523 have_to_wait=0;
524 }
525 else if(retValue != nwal_OK)
526 {
527 *perr = NETAPI_ERR_NWAL_ERR0;
528 netapip_freeTransInfo(pTransInfo);
529 netapip_netcpCfgDeleteSa(&netapi_get_global()->nwal_context,tunnelId);
530 }
531 if((trans_id != NWAL_TRANSID_SPIN_WAIT)&&(have_to_wait))
532 {
533 n->nwal_local.numPendingCfg++;
534
535 while ((pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_ERR) &&
536 (pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_IDLE))
537 {
538 nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
539 }
540 if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
541 {
542 netapip_freeTransInfo(pTransInfo);
543 *perr = NETAPI_ERR_PA_FW;
544 if (!flags)
545 netapip_netcpCfgDeleteSa(&netapi_get_global()->nwal_context, tunnelId);
546 return;
547 }
548 }
549 netapip_freeTransInfo(pTransInfo);
550 }
551 if (handle_sideband)
552 {
553 retValue=nwal_delDMSecAssoc( ((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
554 handle_sideband);
555 if(retValue != nwal_OK)
556 {
557 *perr = NETAPI_ERR_NWAL_ERR0;
558 }
559 }
560
561 /* zap the entry */
562 if (!flags)
563 netapip_netcpCfgDeleteSa(&netapi_get_global()->nwal_context, tunnelId);
564}
565
566/********************************************************************
567 * FUNCTION PURPOSE: API to delete an IPSEC SA
568 ********************************************************************
569 * DESCRIPTION: API to delete an IPSEC SA
570 ********************************************************************/
571void netapi_secDelSA(NETAPI_T h,
572 int iface_no,
573 NETCP_CFG_SA_T sa_app_id,
574 int *perr)
575{
576 netapi_secDelSA_internal( h, iface_no, sa_app_id, 0x00, perr);
577}
578
579
580/********************************************************************
581 * FUNCTION PURPOSE: API to add a receive security policy
582 ********************************************************************
583 * DESCRIPTION: API to add a receive security policy
584 ********************************************************************/
585NETCP_CFG_IPSEC_POLICY_T netapi_secAddRxPolicy(NETAPI_T h,
586 NETCP_CFG_SA_T sa,
587 nwal_IpType ipType,
588 nwalIpAddr_t * src_ip_addr,
589 nwalIpAddr_t * dst_ip_addr,
590 nwalIpOpt_t * ip_qualifiers,
591 NETCP_CFG_ROUTE_HANDLE_T route,
592 void * user_data,
593 int * perr)
594{
595 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
596 nwal_RetValue retValue;
597 NetapiNwalTransInfo_t *pTransInfo;
598 nwal_TransID_t trans_id;
599 unsigned int appId = NETAPI_NETCP_MATCH_IPSEC_POLICY;
600 int policyId;
601 int tunnelId= netapi_cfgGetMatchId(sa);
602 void * blah;
603 int iface_no = netapi_cfgGetMatchLogicalMacIface(sa);
604
605 nwalSecPolParams_t createParam =
606 {
607 0, /* handle */
608 0, /* valid params */
609 NWAL_SA_DIR_INBOUND,
610 4, /* IP Type */
611 {0}, /* dst */
612 {0}, /* src */
613 {0 },/* IP Options */
614 NWAL_MATCH_ACTION_CONTINUE_NEXT_ROUTE, /* Continue parsing to next route for match */
615 NWAL_NEXT_ROUTE_FAIL_ACTION_HOST, /* For next route fail action by default is route to host */
616 CPPI_PARAM_NOT_SPECIFIED, /* Use default flow configured to NWAL if packet is routed to host */
617 QMSS_PARAM_NOT_SPECIFIED, /* Use default queue configured to NWAL if packet is routed to host */
618 0 /* Optional: route type */
619 };
620
621 void * sa_handle = NULL;
622 *perr =0;
623
624 if ((!n) )
625 {
626 *perr = NETAPI_ERR_BAD_INPUT;
627 return -1;
628 }
629
630 sa_handle = netapip_netcpCfgGetSaHandles(&netapi_get_global()->nwal_context,tunnelId,&blah);
631 if (!sa_handle)
632 {
633 *perr = NETAPI_ERR_BAD_INPUT;
634 return -1;
635 }
636
637 /* get a transaction id */
638 pTransInfo = netapip_getFreeTransInfo(n,
639 (NETAPI_PROC_GLOBAL_T *) n->proc_global,
640 &trans_id);
641 if (!pTransInfo)
642 {
643 *perr = NETAPI_ERR_BUSY;
644 return -1;
645 }
646 pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_SA_POLICY;
647 pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING;
648 pTransInfo->inUse = nwal_TRUE;
649 pTransInfo->netapi_handle = h;
650 createParam.handle = sa_handle;
651 createParam.ipType = ipType;
652 if (dst_ip_addr) memcpy(&createParam.dst, dst_ip_addr, sizeof(nwalIpAddr_t));
653 if (src_ip_addr) memcpy(&createParam.src, src_ip_addr, sizeof(nwalIpAddr_t));
654 if (ip_qualifiers) memcpy(&createParam.ipOpt,ip_qualifiers ,sizeof(nwalIpOpt_t));
655 if (route != NULL)
656 {
657 if((route->valid_params & NETCP_CFG_VALID_PARAM_ROUTE_TYPE) ==
658 NETCP_CFG_VALID_PARAM_ROUTE_TYPE)
659 {
660 createParam.validParams |=
661 NWAL_SET_SEC_POLICY_VALID_PARAM_ROUTE_TYPE;
662 }
663 netapip_netcpCfgBuildRoute(route,
664 &createParam.appRxPktFlowId,
665 &createParam.appRxPktQueue,
666 &createParam.routeType);
667 }
668 /* reserve a slot */
669 policyId = netapip_netcpCfgFindPolicySlot(n,
670 &netapi_get_global()->nwal_context,
671 tunnelId);
672 if (policyId <0)
673 {
674 *perr= NETAPI_ERR_NOMEM;
675 netapip_freeTransInfo(pTransInfo);
676 return -1;
677 }
678 appId |= (policyId <<8);
679
680 /* fire off config message */
681 retValue = nwal_setSecPolicy (((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
682 trans_id,
683 (nwal_AppId) appId,
684 &createParam,
685 &pTransInfo->handle);
686 if(retValue != nwal_OK)
687 {
688 *perr = NETAPI_ERR_NWAL_ERR0;
689 netapip_freeTransInfo(pTransInfo);
690
691 netapip_netcpCfgDeletePolicy(&netapi_get_global()->nwal_context,policyId);
692 return -1;
693 }
694
695 if(trans_id != NWAL_TRANSID_SPIN_WAIT)
696 {
697 n->nwal_local.numPendingCfg++;
698 while ((pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_ERR) &&
699 (pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_OPEN))
700 {
701 nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
702 }
703 if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
704 {
705 netapip_freeTransInfo(pTransInfo);
706 *perr = NETAPI_ERR_PA_FW;
707 netapip_netcpCfgDeletePolicy(&netapi_get_global()->nwal_context,policyId);
708 return -1;
709 }
710 }
711
712 /* save stuff */
713 netapip_netcpCfgInsertPolicy(&netapi_get_global()->nwal_context,
714 policyId,
715 (void *) pTransInfo->handle,
716 user_data);
717 netapip_freeTransInfo(pTransInfo);
718 return (appId);
719}
720
721/********************************************************************
722 * FUNCTION PURPOSE: Internal function to delete a receive security policy
723 ********************************************************************
724 * DESCRIPTION: Internal function to delete a receive security policy
725 ********************************************************************/
726static void netapi_secDelRxPolicy_internal(NETAPI_T h,
727 NETCP_CFG_IPSEC_POLICY_T policy_app_id,
728 int flags,
729 int *perr)
730{
731 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
732 nwal_RetValue retValue;
733 NetapiNwalTransInfo_t *pTransInfo;
734 nwal_TransID_t trans_id;
735 int policyId = netapi_cfgGetMatchId(policy_app_id);
736 void * handle_policy=NULL;
737
738 handle_policy = netapip_netcpCfgGetPolicy(&netapi_get_global()->nwal_context,policyId);
739 ;
740 if (!handle_policy)
741 {
742 *perr = NETAPI_ERR_BAD_INPUT;
743 goto ERR_netapi_secDelRxPolicy_internal;
744 }
745 *perr =0;
746
747 /* get a transaction id */
748 pTransInfo = netapip_getFreeTransInfo(n,
749 (NETAPI_PROC_GLOBAL_T *) n->proc_global,
750 &trans_id);
751 if (!pTransInfo)
752 {
753 *perr = NETAPI_ERR_BUSY;
754 goto ERR_netapi_secDelRxPolicy_internal;
755 }
756 pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_SA_POLICY;
757 pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING;
758 pTransInfo->inUse = nwal_TRUE;
759 pTransInfo->netapi_handle = h;
760
761 /* issue request */
762 retValue = nwal_delSecPolicy(
763 ((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
764 trans_id,
765 handle_policy);
766 if(retValue != nwal_OK)
767 {
768 *perr = NETAPI_ERR_NWAL_ERR0;
769 netapip_freeTransInfo(pTransInfo);
770 goto ERR_netapi_secDelRxPolicy_internal;
771 }
772
773 if(trans_id != NWAL_TRANSID_SPIN_WAIT)
774 {
775 n->nwal_local.numPendingCfg++;
776 while ((pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_ERR) &&
777 (pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_IDLE))
778 {
779 nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
780 }
781 if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
782 {
783 netapip_freeTransInfo(pTransInfo);
784 *perr = NETAPI_ERR_PA_FW;
785 //zap the entry
786 if (!flags)
787 netapip_netcpCfgDeletePolicy(&netapi_get_global()->nwal_context, policyId);
788 goto ERR_netapi_secDelRxPolicy_internal;
789
790 }
791 }
792 netapip_freeTransInfo(pTransInfo);
793 /* zap the entry */
794 if (!flags)
795 {
796 netapip_netcpCfgDeletePolicy(&netapi_get_global()->nwal_context, policyId);
797 }
798ERR_netapi_secDelRxPolicy_internal:
799 return;
800}
801
802/********************************************************************
803 * FUNCTION PURPOSE: API to delete a receive security policy
804 ********************************************************************
805 * DESCRIPTION: API to delete a receive security policy
806 ********************************************************************/
807void netapi_secDelRxPolicy(NETAPI_T h,
808 NETCP_CFG_IPSEC_POLICY_T policy_app_id,
809 int *perr)
810{
811 netapi_secDelRxPolicy_internal(h, policy_app_id, 0, perr);
812}
813
814/********************************************************************
815 * FUNCTION PURPOSE: API to retrieve SA statistics via NWAL
816 ********************************************************************
817 * DESCRIPTION: API to retrieve SA statistics via NWAL
818 ********************************************************************/
819void netapi_getSaStats (NETAPI_T h,
820 NETCP_CFG_SA_T handle,
821 NETAPI_SA_STATS_T* pSaStats)
822{
823 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
824 void * handle_inflow;
825 void * handle_sideband;
826 int tunnelId = (handle >> NETAPI_NETCP_MATCH_ID_SHIFT) &0xffff;
827 int have_to_wait = 1;
828 handle_inflow = netapip_netcpCfgGetSaHandles(&netapi_get_global()->nwal_context,
829 tunnelId, &handle_sideband);
830 if(handle_inflow)
831 {
832 nwal_getSecAssocStats(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
833 handle_inflow, &(pSaStats->saIpsecStats));
834 pSaStats->validParams |= NETAPI_IPSEC_STAT_VALID;
835 }
836 if(handle_sideband)
837 {
838 nwal_getDataModeStats(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
839 handle_sideband, &(pSaStats->dataModeStats));
840 pSaStats->validParams |= NETAPI_SIDEBAND_DATA_MODE_STAT_VALID;
841 }
842}
843
844
845/**********************************************************************************
846 * FUNCTION PURPOSE: API to API to retrieve local channel context information
847 **********************************************************************************
848 * DESCRIPTION: API to retrieve API to retrieve local channel context information
849 *********************************************************************************/
850void netapi_secGetChanCtxInfo(NETAPI_T h,
851 NETCP_CFG_APP_ID_T appId,
852 nwalChanCxtInfo_t* pInfo)
853{
854
855 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
856 void * handle_inflow;
857 void * handle_sideband = NULL;
858 void * handle_policy=NULL;
859 nwalChanCxtInfo_t info;
860 uint32_t stage = 0;
861 int policyId;
862 int tunnelId;
863
864 if(!pInfo)
865 return;
866 memset(pInfo, 0, sizeof(nwalChanCxtInfo_t));
867
868 stage = netapi_cfgGetMatchStage(appId);
869
870 switch (stage)
871 {
872 case 1:
873 /* this is for SA, need SA and OUTER IP handle */
874 tunnelId = netapi_cfgGetMatchId(appId);
875 handle_inflow = netapip_netcpCfgGetSaHandles(&netapi_get_global()->nwal_context,
876 tunnelId, &handle_sideband);
877 if(handle_inflow)
878 {
879 nwal_getChanCxtInfo(&netapi_get_global()->nwal_context,
880 handle_inflow,
881 pInfo);
882 }
883 break;
884 case 2:
885 /* this is for policy, need SA inner IP */
886 policyId = netapi_cfgGetMatchId(appId);
887 handle_policy = netapip_netcpCfgGetPolicy(&netapi_get_global()->nwal_context,
888 policyId);
889 if (handle_policy)
890 {
891 nwal_getChanCxtInfo(&netapi_get_global()->nwal_context,
892 handle_policy,
893 pInfo);
894 }
895 break;
896 default:
897 break;
898 }
899 return;
900}
diff --git a/ti/runtime/netapi/src/netcp_cfg.c b/ti/runtime/netapi/src/netcp_cfg.c
new file mode 100755
index 0000000..3f04d1a
--- /dev/null
+++ b/ti/runtime/netapi/src/netcp_cfg.c
@@ -0,0 +1,2041 @@
1/**********************************************************
2 * file: netcp_cfg.c
3 * purpose: netcp configurations routines
4 **************************************************************
5 * FILE: netcp_cfg.c
6 *
7 * DESCRIPTION: netcp configuration main source file for user space transport
8 * library
9 *
10 * REVISION HISTORY:
11 *
12 * Copyright (c) Texas Instruments Incorporated 2013
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
42 ******************************************************/
43
44#include "netapi.h"
45
46extern NETAPI_SHM_T* pnetapiShm;
47
48/******************************************************************
49 ********************Netapi internal*************************************
50*******************************************************************/
51
52
53/********************************************************************
54 * FUNCTION PURPOSE: Netapi internal function to get a free transaction id
55 ********************************************************************
56 * DESCRIPTION: Netapi internal function to get a free transaction id.
57 ********************************************************************/
58NetapiNwalTransInfo_t * netapip_getFreeTransInfo(NETAPI_HANDLE_T *p_handle,
59 NETAPI_PROC_GLOBAL_T *p_proc_global,
60 nwal_TransID_t *pTransId)
61{
62 uint16_t count=0;
63
64 count=0;
65 p_handle->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_lock);
66 while(count < TUNE_NETAPI_MAX_NUM_TRANS)
67 {
68 if((p_proc_global->nwal_context.transInfos[count].inUse) != nwal_TRUE)
69 {
70 p_proc_global->nwal_context.transInfos[count].inUse = nwal_TRUE;
71 *pTransId = count;
72 p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
73 return(&p_proc_global->nwal_context.transInfos[count]);
74 }
75 count++;
76 }
77 p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
78 /* trouble. need to wait for one to free up*/
79 /* to do: handle this by forcing a poll of cntrl queue*/
80 return NULL;
81
82}
83
84/********************************************************************
85 * FUNCTION PURPOSE: Netapi internal function to free a transaction id
86 ********************************************************************
87 * DESCRIPTION: Netapi internal function to free a transaction id
88 ********************************************************************/
89void netapip_freeTransInfo(NetapiNwalTransInfo_t *pTransInfo)
90{
91 pTransInfo->inUse = nwal_FALSE;
92 pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
93 pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_NONE;
94}
95/********************************************************************
96 * FUNCTION PURPOSE: Netapi internal function to build a route
97 ********************************************************************
98 * DESCRIPTION: Netapi internal function to build a route
99 ********************************************************************/
100void netapip_netcpCfgBuildRoute(NETCP_CFG_ROUTE_T * p_route,
101 int16_t *p_flow,
102 Qmss_QueueHnd *p_q,
103 nwalRouteType_t *p_type)
104{
105 if (!p_route) return;
106 if (p_route->p_flow) *p_flow= p_route->p_flow->flowid;
107 else *p_flow = CPPI_PARAM_NOT_SPECIFIED;
108
109 if (p_route->p_dest_q) *p_q = netapi_pktioGetQ(p_route->p_dest_q);
110 else *p_q=QMSS_PARAM_NOT_SPECIFIED;
111
112 *p_type = p_route->routeType;
113}
114
115
116/******************************************************/
117/*----------------database management stuff */
118/******************************************************/
119
120/*=====================POLICIES=============================*/
121
122/********************************************************************
123 * FUNCTION PURPOSE: Netapi internal function to find a free slot for an SA
124 ********************************************************************
125 * DESCRIPTION: Netapi internal function to find a free slot for an SA
126 ********************************************************************/
127int netapip_netcpCfgFindPolicySlot(NETAPI_HANDLE_T *p_handle,
128 NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
129 int tunnel)
130{
131 int i;
132 if ((tunnel <0 ) || (tunnel >=TUNE_NETAPI_MAX_SA))
133 return -1;
134
135 p_handle->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_lock);
136 //find a free entry
137 for(i=0;i<TUNE_NETAPI_MAX_POLICY;i++)
138 {
139 if (!p->policy[i].in_use)
140 {
141 p->policy[i].in_use = 2; //pending
142 p->policy[i].tunnel= tunnel; //save tunnel this is linked to
143 p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
144 return i;
145 }
146 }
147 p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
148 return -1;
149}
150
151/********************************************************************
152 * FUNCTION PURPOSE: Netapi internal function to delete a policy from policy list
153 ********************************************************************
154 * DESCRIPTION: Netapi internal function to delete a policy from policy list
155 ********************************************************************/
156void netapip_netcpCfgDeletePolicy(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
157 int policy_slot)
158{
159 if ((policy_slot <0 ) || (policy_slot >= TUNE_NETAPI_MAX_POLICY))
160 {
161 return ;
162 }
163 p->policy[policy_slot].in_use=0;
164 return;
165}
166
167/********************************************************************
168 * FUNCTION PURPOSE: Netapi internal function to insert a policy to the policy list
169 ********************************************************************
170 * DESCRIPTION: Netapi internal function to insert a policy to the policy list
171 ********************************************************************/
172void netapip_netcpCfgInsertPolicy(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
173 int policy_slot,
174 void * handle,
175 void * user_data)
176{
177 p->policy[policy_slot].in_use=1;
178 p->policy[policy_slot].nwal_handle = handle;
179 p->policy[policy_slot].user_data = user_data;
180 return;
181}
182
183/************************************************************************
184 * FUNCTION PURPOSE: Netapi internal function which returns NWAL handle for a policy
185 ************************************************************************
186 * DESCRIPTION: Netapi internal function which returns NWAL handle for a policy
187 ************************************************************************/
188void *netapip_netcpCfgGetPolicy(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
189 int policy_slot)
190{
191 if ((policy_slot <0 ) || (policy_slot >= TUNE_NETAPI_MAX_POLICY))
192 return NULL;
193 if (!p->policy[policy_slot].in_use)
194 return NULL;
195 return p->policy[policy_slot].nwal_handle;
196}
197
198/********************************************************************
199 * FUNCTION PURPOSE: Netapi internal function to find a free slot in SA list for a SA
200 ********************************************************************
201 * DESCRIPTION: Netapi internal function to find a free slot in SA list for an SA
202 ********************************************************************/
203int netapip_netcpCfgFindSaSlot(NETAPI_HANDLE_T *p_handle,
204 NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
205 int iface)
206{
207 int i;
208 if (iface != NETCP_CFG_NO_INTERFACE)
209 {
210 if ((iface <0 ) || (iface >=TUNE_NETAPI_MAX_NUM_MAC)) return -1;
211 }
212 p_handle->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_lock);
213 //find a free entry
214 for(i=0;i<TUNE_NETAPI_MAX_SA;i++)
215 {
216 if (!p->tunnel[i].in_use)
217 {
218 p->tunnel[i].in_use = 2; //pending
219 p->tunnel[i].iface= iface; //save iface
220 p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
221 return i;
222 }
223 }
224 p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
225 return -1;
226}
227
228/********************************************************************
229 * FUNCTION PURPOSE: Netapi internal function to delete an SA from SA list
230 ********************************************************************
231 * DESCRIPTION: Netapi internal function to delete an SA from SA list
232 ********************************************************************/
233void netapip_netcpCfgDeleteSa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
234 int sa_slot)
235{
236 if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA))
237 {
238 return ;
239 }
240 p->tunnel[sa_slot].in_use=0;
241 return;
242}
243
244
245/****************************************************************************
246 * FUNCTION PURPOSE: Internal function to retrieve SB command info template
247 **************************************************************************
248 * DESCRIPTION: Internal function to retrieve SB command info template
249 ***************************************************************************/
250nwalTxDmPSCmdInfo_t* netapip_netcpCfgGetSaSBInfo(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
251 NETCP_CFG_SA_T sa_app_id)
252{
253 int sa_slot = netapi_cfgGetMatchId(sa_app_id);
254 if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA))
255 {
256 return NULL;
257 }
258 return (&p->tunnel[sa_slot].dmPSCmdInfo);
259}
260
261/****************************************************************************
262 * FUNCTION PURPOSE: Internal function to retrieve Inflow mode
263 * software information required to transmit packet
264 **************************************************************************
265 * DESCRIPTION: Internal function to retrieve Inflow mode
266 * software information required to transmit packet
267 ***************************************************************************/
268int netapip_netcpCfgGetSaInflowInfo(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
269 NETCP_CFG_SA_T sa_app_id,
270 uint32_t *swInfo0,
271 uint32_t *swInfo1)
272{
273 int sa_slot = netapi_cfgGetMatchId(sa_app_id);
274 if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA))
275 {
276 return 0;
277 }
278 *swInfo0 = p->tunnel[sa_slot].swInfo0;
279 *swInfo1 = p->tunnel[sa_slot].swInfo1;
280 return 1;
281}
282
283/********************************************************************
284 * FUNCTION PURPOSE: Netapi internal function to insert an SA to the SA list
285 ********************************************************************
286 * DESCRIPTION: Netapi internal function to insert an SA to the SA list
287 ********************************************************************/
288void netapip_netcpCfgInsertSa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
289 int sa_slot,
290 int dir,
291 int mode,
292 void * temp1,
293 void * temp2,
294 void * handle_inflow,
295 void * handle_sideband,
296 nwalTxDmPSCmdInfo_t *dmPSCmdInfo,
297 uint32_t swInfo0,
298 uint32_t swInfo1,
299 void* user_data)
300{
301 p->tunnel[sa_slot].in_use=1;
302 p->tunnel[sa_slot].inbound = dir;
303 p->tunnel[sa_slot].sa_mode = mode;
304 p->tunnel[sa_slot].sa_handle_inflow = handle_inflow;
305 p->tunnel[sa_slot].sa_handle_sideband = handle_sideband;
306 p->tunnel[sa_slot].swInfo0 = swInfo0;
307 p->tunnel[sa_slot].swInfo1 = swInfo1;
308 p->tunnel[sa_slot].user_data = user_data;
309
310 if (dmPSCmdInfo)
311 {
312 memcpy(&p->tunnel[sa_slot].dmPSCmdInfo, dmPSCmdInfo, sizeof(nwalTxDmPSCmdInfo_t));
313 }
314 return;
315}
316
317/********************************************************************
318 * FUNCTION PURPOSE: Netapi internal function to return NWAL handles for an SA
319 ********************************************************************
320 * DESCRIPTION: Netapi internal function to return NWAL handles for an SA
321 ********************************************************************/
322 void *netapip_netcpCfgGetSaHandles(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
323 int sa_slot,
324 void ** p_sideband)
325{
326 if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA))
327 return NULL;
328 if (!p->tunnel[sa_slot].in_use)
329 return NULL;
330 *p_sideband = p->tunnel[sa_slot].sa_handle_sideband;
331 return p->tunnel[sa_slot].sa_handle_inflow;
332}
333
334
335/*==============================FLOWS=============================*/
336
337/********************************************************************
338 * FUNCTION PURPOSE: Netapi internal function to find a free slot for a flow
339 ********************************************************************
340 * DESCRIPTION: Netapi internal function to find a free slot for a flow
341 ********************************************************************/
342static int netapip_netcpCfgFindFlowSlot(NETAPI_HANDLE_T *p_handle,
343 NETAPI_NWAL_GLOBAL_CONTEXT_T *p)
344{
345 int i;
346 //find a free entry
347 p_handle->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_lock);
348 for(i=0;i<TUNE_NETAPI_MAX_FLOWS;i++)
349 {
350 if (!p->flows[i].in_use)
351 {
352 p->flows[i].in_use = 2; /* pending */
353 p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
354 return i;
355 }
356 }
357 p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
358 return -1;
359}
360
361/********************************************************************
362 * FUNCTION PURPOSE: Netapi internal function to find delete a flow from flow list
363 ********************************************************************
364 * DESCRIPTION: Netapi internal function to find delete a flow from flow list
365 ********************************************************************/
366static void netapip_netcpCfgDeleteFlow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
367 int slot)
368{
369 if ((slot >=0 ) && (slot < TUNE_NETAPI_MAX_FLOWS))
370 {
371 p->flows[slot].in_use = 0;
372 }
373}
374
375/********************************************************************
376 * FUNCTION PURPOSE: Netapi internal function to insert a flow to the flow list
377 ********************************************************************
378 * DESCRIPTION: Netapi internal function to delete a flow from flow list
379 ********************************************************************/
380static NETCP_CFG_FLOW_HANDLE_T netapip_netcpCfgInsertFlow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
381 int slot,
382 int dma_engine,
383 void * handle)
384{
385 p->flows[slot].in_use=1;
386 p->flows[slot].handle = handle;
387 p->flows[slot].flow.flowid = Cppi_getFlowId(handle);
388 p->flows[slot].flow.dma_engine = dma_engine;
389 return (NETCP_CFG_FLOW_HANDLE_T) &p->flows[slot].flow;
390}
391
392/********************************************************************
393 * FUNCTION PURPOSE: Netapi internal function to find entry matching the flowid
394 ********************************************************************
395 * DESCRIPTION: Netapi internal function to find entry matching the flowid. Returns
396 * the slot number and the cPPI handle.
397 ********************************************************************/
398static int netapip_netcpCfgFindFlow(NETAPI_HANDLE_T *p_handle,
399 NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
400 int flowid,
401 int dma_engine,
402 void ** handle)
403{
404 int i;
405 *handle=NULL;
406 p_handle->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_lock);
407 for(i=0;i<TUNE_NETAPI_MAX_FLOWS;i++)
408 {
409 if ((p->flows[i].in_use)&&
410 (p->flows[i].flow.flowid == flowid)&&
411 (p->flows[i].flow.dma_engine == dma_engine))
412 {
413 *handle = p->flows[i].handle;
414 p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
415 return i;
416 }
417 }
418 p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
419 return -1;
420}
421
422
423
424/*============================IP ADDRESSES==========================*/
425
426/***************************************************************************
427 * FUNCTION PURPOSE: Netapi internal function to find a free slot for IP rule in IP slot list
428 ***************************************************************************
429 * DESCRIPTION: NNetapi internal function to find a free slot for IP rule in IP slot list
430 ***************************************************************************/
431static int netapip_netcpCfgFindIpSlot(NETAPI_HANDLE_T *p_handle,
432 NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
433 int iface_no)
434{
435 int i;
436
437 //find a free entry
438 p_handle->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_lock);
439 for(i=0;i<TUNE_NETAPI_MAX_NUM_IP;i++)
440 {
441 if (!p->ips[i].in_use)
442 {
443 p->ips[i].in_use = 2; //pending
444 p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
445 return i;
446 }
447 }
448 p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
449 return -1;
450}
451
452/***************************************************************************
453 * FUNCTION PURPOSE: Netapi internal function to insert an IP address into interface
454 ***************************************************************************
455 * DESCRIPTION: Netapi internal function to insert an IP address into interface
456 ***************************************************************************/
457static void netapip_netcpCfgInsertIp(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
458 nwal_IpType ipType,
459 nwalIpAddr_t *ip_addr,
460 nwalIpOpt_t *ip_qualifiers,
461 int iface_no,
462 int ip_slot,
463 void * handle,
464 void * user_data)
465{
466 p->ips[ip_slot].in_use=1;
467 memcpy(&p->ips[ip_slot].ip_addr, ip_addr, sizeof(nwalIpAddr_t));
468 if(ip_qualifiers)
469 {
470 memcpy(&p->ips[ip_slot].ip_qualifiers, ip_qualifiers, sizeof(nwalIpOpt_t));
471 }
472 else
473 {
474 memset(&p->ips[ip_slot].ip_qualifiers, 0, sizeof(nwalIpOpt_t));
475 }
476 p->ips[ip_slot].ip_type = ipType;
477 p->ips[ip_slot].nwal_handle = handle;
478 p->ips[ip_slot].user_data = user_data;
479}
480
481/***************************************************************************
482 * FUNCTION PURPOSE: Netapi internal function to free IP slot associated with IP address
483 ***************************************************************************
484 * DESCRIPTION: Netapi internal function to free IP slot associated with IP address
485 ***************************************************************************/
486static void netapip_netcpCfgDeleteIp(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
487 int iface_no,
488 int ip_slot)
489{
490 if ((ip_slot >=0) &&(ip_slot < TUNE_NETAPI_MAX_NUM_IP))
491 {
492 p->ips[ip_slot].in_use=0;
493 }
494}
495
496/***************************************************************************
497 * FUNCTION PURPOSE: Netapi internal function to get IP handle associated with IP address
498 ***************************************************************************
499 * DESCRIPTION: Netapi internal function to get IP handle associated with IP address
500 ***************************************************************************/
501void *netapip_netcpCfgGetIpHandle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
502 int iface_no,
503 int ip_slot)
504{
505 if ((ip_slot <0)||(ip_slot>=TUNE_NETAPI_MAX_NUM_IP))
506 return NULL;
507 if (!p->ips[ip_slot].in_use)
508 return NULL;
509 return (void *) p->ips[ip_slot].nwal_handle;
510}
511
512/*==========================MAC INTERFACES======================*/
513
514
515
516/*******************************************************************************
517 * FUNCTION PURPOSE: Netapi internal function to insert an interface to the interface list
518 *******************************************************************************
519 * DESCRIPTION: Netapi internal function to insert an interface to the interface list
520 *******************************************************************************/
521static void netapip_netcpCfgInsertMac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
522 unsigned char * p_mac,
523 int iface_no,
524 int state, NETCP_CFG_VLAN_T vlan,
525 void * handle)
526{
527 if ((iface_no >=0 ) && (iface_no < TUNE_NETAPI_MAX_NUM_MAC))
528 {
529 memset(&p->interfaces[iface_no],0,sizeof(NETCP_INTERFACE_T));
530 p->interfaces[iface_no].in_use = 1;
531 memcpy(&p->interfaces[iface_no].mac[0], p_mac,6);
532 p->interfaces[iface_no].state = state;
533 //todo p->interfaces[iface_no].vlan = vlan;
534 p->interfaces[iface_no].nwal_handle = handle; //save handle assoicated with this rule
535
536 }
537}
538
539/*******************************************************************************
540 * FUNCTION PURPOSE: Netapi internal function to get handle associated with interface
541 *******************************************************************************
542 * DESCRIPTION: Netapi internal function to get handle associated with interface
543 *******************************************************************************/
544void* netapip_netcpCfgGetMacHandle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
545 int iface_no)
546{
547 if (iface_no == NETCP_CFG_NO_INTERFACE)
548 {
549 return NULL;
550 }
551 if ((iface_no <0 ) || (iface_no >= TUNE_NETAPI_MAX_NUM_MAC))
552 {
553 return NULL;
554 }
555 else if ( p->interfaces[iface_no].in_use)
556 {
557 return (void *) p->interfaces[iface_no].nwal_handle;
558 }
559 //no valid entry in slot
560 return NULL;
561}
562/*******************************************************************************
563 * FUNCTION PURPOSE: Netapi internal function to delete interface from interface list
564 *******************************************************************************
565 * DESCRIPTION: Netapi internal function to delete interface from interface list
566 *******************************************************************************/
567static void netapip_netcpCfgDeleteMac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
568 int iface_no)
569{
570 if ((iface_no >=0 ) && (iface_no < TUNE_NETAPI_MAX_NUM_MAC))
571 {
572 p->interfaces[iface_no].in_use = 0;
573 }
574}
575
576/*========================CLASSIFIERS==========================*/
577
578/*******************************************************************************
579 * FUNCTION PURPOSE: Netapi internal function to find a free slot for classifier rule
580 *******************************************************************************
581 * DESCRIPTION: Netapi internal function to find a free slot for classifier rule
582 *******************************************************************************/
583static int netapip_netcpCfgFindClassSlot(NETAPI_HANDLE_T *p_handle,
584 NETAPI_NWAL_GLOBAL_CONTEXT_T *p)
585{
586 int i;
587 p_handle->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_lock);
588 for(i=0;i<TUNE_NETAPI_MAX_CLASSIFIERS;i++)
589 {
590 if (!p->classi[i].in_use)
591 {
592 p->classi[i].in_use = 2; //pending
593 p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
594 return i;
595 }
596 }
597 p_handle->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_lock);
598 return -1;
599}
600/*******************************************************************************
601 * FUNCTION PURPOSE: Netapi internal function to find a delete a classifer from classifer list
602 *******************************************************************************
603 * DESCRIPTION: Netapi internal function to find a delete a classifer from classifer list
604 *******************************************************************************/
605static void netapip_netcpCfgDeleteClass(
606 NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
607 int class_slot )
608{
609 if ((class_slot <0 ) || (class_slot >= TUNE_NETAPI_MAX_CLASSIFIERS))
610 {
611 return;
612 }
613 p->classi[class_slot].in_use=0;
614}
615
616/*******************************************************************************
617 * FUNCTION PURPOSE: Netapi internal function to find a insert a classifer to classifer list
618 *******************************************************************************
619 * DESCRIPTION: Netapi internal function to find a insert a classifer to classifer list
620 *******************************************************************************/
621static void netapip_netcpCfgInsertClass(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
622 int class_slot,
623 int class_type,
624 void * L2_handle,
625 void * L3_handle,
626 void * L4_handle,
627 void * user_data)
628{
629 if ((class_slot >=0 ) && (class_slot < TUNE_NETAPI_MAX_CLASSIFIERS))
630 {
631 p->classi[class_slot].in_use=1;
632 p->classi[class_slot].nwal_L2_handle = L2_handle;
633 p->classi[class_slot].nwal_L3_handle = L3_handle;
634 p->classi[class_slot].nwal_L4_handle = L4_handle;
635 p->classi[class_slot].class_type = class_type;
636 p->classi[class_slot].user_data = user_data;
637 }
638}
639
640/*******************************************************************************
641 * FUNCTION PURPOSE: Netapi internal function to get L4 nwal handle for classifier
642 *******************************************************************************
643 * DESCRIPTION: Netapi internal function to get L4 nwal handle for classifier
644 *******************************************************************************/
645static void *netapip_netcpCfgGetL4Handle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
646 int class_slot)
647{
648 if ((class_slot <0 ) || (class_slot >= TUNE_NETAPI_MAX_CLASSIFIERS))
649 {
650 return NULL;
651 }
652 if (!p->classi[class_slot].in_use)
653 {
654 return NULL;
655 }
656 return p->classi[class_slot].nwal_L4_handle;
657}
658
659
660
661/*******************************************************************************
662 * FUNCTION PURPOSE: Netapi internal function to get L3 nwal handle for classifier
663 *******************************************************************************
664 * DESCRIPTION: Netapi internal function to get L3 nwal handle for classifier
665 *******************************************************************************/
666static int cfgOkToDeleteL3ClassiHandle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
667 void* l3_handle)
668{
669 int i;
670 int count=0;
671
672 if(l3_handle == NULL)
673 return NETAPI_FALSE;
674 for(i=0; i< TUNE_NETAPI_MAX_CLASSIFIERS;i++)
675 {
676 if (!p->classi[i].in_use)
677 {
678 continue;
679 }
680 if (l3_handle == p->classi[i].nwal_L3_handle)
681 {
682 count++;
683 }
684 }
685 if (count > 0)
686 return NETAPI_FALSE;
687
688 return NETAPI_TRUE;
689}
690
691/*******************************************************************************
692 * FUNCTION PURPOSE: Netapi internal function to get L3 nwal handle for classifier
693 *******************************************************************************
694 * DESCRIPTION: Netapi internal function to get L3 nwal handle for classifier
695 *******************************************************************************/
696static void *netapip_netcpCfgGetL3Handle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
697 int class_slot)
698{
699 if ((class_slot <0 ) || (class_slot >= TUNE_NETAPI_MAX_CLASSIFIERS))
700 {
701 return NULL;
702 }
703 if (!p->classi[class_slot].in_use)
704 {
705 return NULL;
706 }
707 return p->classi[class_slot].nwal_L3_handle;
708}
709
710
711/***********************************************************************************/
712/****************************************API****************************************/
713/***********************************************************************************/
714
715
716/********************************************************************
717 * FUNCTION PURPOSE: API to request statistics from NETCP
718 ********************************************************************
719 * DESCRIPTION: API to request statistics from NETCP
720 ********************************************************************/
721void netapi_netcpCfgReqStats(NETAPI_T h,
722 NETCP_CFG_STATS_CB cb,
723 int doClear,
724 int *err)
725{
726 nwal_RetValue ret;
727 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
728 NetapiNwalTransInfo_t *pTransInfo;
729 nwal_TransID_t transId;
730
731 paSysStats_t netcp_stats;
732 if ((!n) || (!cb))
733 {
734 *err = NETAPI_ERR_BAD_INPUT;
735 return ;
736 }
737 *err =0;
738
739 pTransInfo = netapip_getFreeTransInfo(n,
740 (NETAPI_PROC_GLOBAL_T *) n->proc_global,
741 &transId);
742 if (!pTransInfo) { *err = NETAPI_ERR_BUSY; return ;}
743 pTransInfo->transType = NETAPI_NWAL_HANDLE_STAT_REQUEST;
744 pTransInfo->netapi_handle = h;
745 n->nwal_local.stats_cb = cb;
746
747 memset(&netcp_stats, 0, sizeof(paSysStats_t));
748 ret = nwal_getPAStats( ((NETAPI_GLOBAL_T *) n->global)->nwal_context.nwalInstHandle,
749 transId,
750 &netcp_stats,
751 doClear);
752 if(ret != nwal_OK)
753 {
754 *err = NETAPI_ERR_BUSY; //no resources??
755 netapip_freeTransInfo(pTransInfo);
756 return;
757 }
758#if defined(DEVICE_K2E) || defined(DEVICE_K2L)
759 if (cb)
760 {
761 cb(h, &netcp_stats);
762 }
763#endif
764 netapip_freeTransInfo(pTransInfo);
765}
766/********************************************************************
767 * FUNCTION PURPOSE: API to create a MAC interface
768 ********************************************************************
769 * DESCRIPTION: API to create a MAC interface
770 ********************************************************************/
771NETCP_CFG_MACIF_T netapi_netcpCfgCreateMacInterface(NETAPI_T h,
772 uint8_t *p_mac,
773 uint8_t *p_mac_remote,
774 int iface_no, /* index, from 0 to n */
775 int switch_port,
776 NETCP_CFG_ROUTE_HANDLE_T route,
777 NETCP_CFG_VLAN_T vlan, //future
778 uint16_t etherType,
779 int state, //0=down, 1=up //ignored
780 int * err)
781{
782 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
783 nwalMacParam_t macInfo=
784 {
785 0, /* validParams */
786 0, /* ifNum */
787 0, /* vlanId */
788 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* Local mac */
789 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* Remote mac */
790 NWAL_MATCH_ACTION_CONTINUE_NEXT_ROUTE, /* Continue parsing to next route for match */
791 NWAL_NEXT_ROUTE_FAIL_ACTION_HOST, /* For next route fail action by default is route to host */
792 CPPI_PARAM_NOT_SPECIFIED, /* Use default flow configured to NWAL if packet is routed to host */
793 QMSS_PARAM_NOT_SPECIFIED, /* Use default queue configured to NWAL if packet is routed to host */
794 0,
795 0,
796 0
797 };
798
799 nwal_RetValue retValue;
800 NetapiNwalTransInfo_t *pTransInfo;
801 nwal_TransID_t trans_id;
802 nwal_AppId appId;
803 if ((!n) || (!p_mac)) {*err = NETAPI_ERR_BAD_INPUT; return -1;}
804 *err =0;
805
806 pTransInfo = netapip_getFreeTransInfo(n,
807 (NETAPI_PROC_GLOBAL_T *) n->proc_global,
808 &trans_id);
809 if (!pTransInfo)
810 {
811 *err = NETAPI_ERR_BUSY;
812 return -1;
813 }
814 pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_MAC;
815 pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING;
816 pTransInfo->inUse = nwal_TRUE;
817 pTransInfo->netapi_handle = h;
818
819 /* set up MacInfo */
820 memcpy(&macInfo.macAddr,p_mac,6);
821
822 if(p_mac_remote)
823 {
824 macInfo.validParams |= NWAL_SET_MAC_VALID_PARAM_REMOTE_MAC;
825 memcpy(&macInfo.remMacAddr,p_mac_remote,6);
826 }
827 /* todo: vlan */
828 if (switch_port)
829 {
830 macInfo.validParams |= NWAL_SET_MAC_VALID_PARAM_IFNUM ;
831 macInfo.ifNum = switch_port;
832 }
833
834 if(etherType)
835 {
836 macInfo.validParams |= NWAL_SET_MAC_VALID_PARAM_ETHER_TYPE;
837 macInfo.etherType = etherType;
838 }
839
840 if (route != NULL)
841 {
842 if((route->valid_params & NETCP_CFG_VALID_PARAM_ROUTE_TYPE) ==
843 NETCP_CFG_VALID_PARAM_ROUTE_TYPE)
844 {
845 macInfo.validParams |=
846 NWAL_SET_MAC_VALID_PARAM_ROUTE_TYPE;
847
848 if(route->routeType == NWAL_ROUTE_PKTTYPE_EQOS)
849 {
850 macInfo.egress_switch_port = route->egress_swith_port;
851 macInfo.routeType = NWAL_ROUTE_PKTTYPE_EQOS;
852 macInfo.matchAction = NWAL_MATCH_ACTION_HOST;
853 }
854 }
855 if((route->valid_params & NETCP_CFG_VALID_PARAM_MATCH_ACTION_DEST) ==
856 NETCP_CFG_VALID_PARAM_MATCH_ACTION_DEST)
857 {
858 macInfo.matchAction = route->match_destination;
859 }
860 if((route->valid_params & NETCP_CFG_VALID_PARAM_FAIL_ACTION_DEST) ==
861 NETCP_CFG_VALID_PARAM_FAIL_ACTION_DEST)
862 {
863 macInfo.failAction = route->fail_destination;
864 }
865
866 netapip_netcpCfgBuildRoute(route,
867 &macInfo.appRxPktFlowId,
868 &macInfo.appRxPktQueue,
869 &macInfo.routeType);
870 }
871
872
873 appId = (nwal_AppId) (NETAPI_NETCP_MATCH_GENERIC_MAC | iface_no);
874
875 retValue = nwal_setMacIface( ((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
876 trans_id,
877 appId,
878 &macInfo,
879 &pTransInfo->handle);
880 if(retValue != nwal_OK)
881 {
882 *err = NETAPI_ERR_NWAL_ERR0;
883 netapip_freeTransInfo(pTransInfo);
884 return -1;
885 }
886
887 //wait here until its done since scheduler isn't running yet most likely..
888 // todo: make this handled by scheduler poll later ??
889 if(trans_id != NWAL_TRANSID_SPIN_WAIT)
890 {
891 n->nwal_local.numPendingCfg++;
892 while ((pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_ERR) &&
893 (pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_OPEN))
894 {
895 // if response is there, then this poll squirts out in the CTl poll callback,
896 // which handles the rest (including decrmenting #pending!!
897 nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
898 }
899 if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
900 {
901 netapip_freeTransInfo(pTransInfo);
902 *err = NETAPI_ERR_PA_FW;
903 return -1;
904 }
905
906 }
907 netapip_netcpCfgInsertMac(&netapi_get_global()->nwal_context,
908 p_mac, iface_no, state,vlan,
909 (void *) pTransInfo->handle);
910 netapip_freeTransInfo(pTransInfo);
911 return (NETCP_CFG_MACIF_T)appId;
912}
913
914/********************************************************************
915 * FUNCTION PURPOSE: API to delete MAC interface
916 ********************************************************************
917 * DESCRIPTION: API to delete MAC interface
918 ********************************************************************/
919void netapi_netcpCfgDelMac(NETAPI_T h,
920 int iface_no,
921 int *err)
922{
923 nwal_RetValue ret;
924 NetapiNwalTransInfo_t *pTransInfo;
925 nwal_TransID_t trans_id;
926 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
927 void * ifHandle;
928
929 //get the nwal handle assoicated with this iface
930 ifHandle = netapip_netcpCfgGetMacHandle(&netapi_get_global()->nwal_context, iface_no );
931 if(!ifHandle)
932 {
933 *err = NETAPI_ERR_BAD_INPUT; return ;
934 }
935 *err =0;
936
937 //get a transaction id
938 pTransInfo = netapip_getFreeTransInfo(n,
939 (NETAPI_PROC_GLOBAL_T *) n->proc_global,
940 &trans_id);
941 if (!pTransInfo)
942 {
943 *err = NETAPI_ERR_BUSY;
944 return ;
945 }
946 pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_MAC;
947 pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING;
948 pTransInfo->inUse = nwal_TRUE;
949 pTransInfo->netapi_handle = h;
950
951 //issue request
952 ret = nwal_delMacIface(
953 ((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
954 trans_id,
955 ifHandle);
956 if(ret != nwal_OK)
957 {
958 *err = NETAPI_ERR_NWAL_ERR0;
959 netapip_freeTransInfo(pTransInfo);
960 return;
961 }
962 //wait here until its done since scheduler isn't running yet most likely..
963 // todo: make this handled by scheduler poll later ??
964 if(trans_id != NWAL_TRANSID_SPIN_WAIT)
965 {
966 n->nwal_local.numPendingCfg++;
967 while ((pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_ERR) &&
968 (pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_IDLE))
969 {
970 // if response is there, then this poll squirts out in the CTl poll callback,
971 // which handles the rest (including decrmenting #pending!!
972 nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
973 }
974 if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
975 {
976 netapip_freeTransInfo(pTransInfo);
977 *err = NETAPI_ERR_PA_FW;
978 netapip_netcpCfgDeleteMac(&netapi_get_global()->nwal_context, iface_no);
979 return;
980 }
981 }
982 netapip_freeTransInfo(pTransInfo);
983 //zap the entry
984 netapip_netcpCfgDeleteMac(&netapi_get_global()->nwal_context, iface_no);
985 return ;
986}
987
988
989/********************************************************************
990 * FUNCTION PURPOSE: NETAPi internal function to Add IP to MAC interface
991 ********************************************************************
992 * DESCRIPTION: NETAPi internal function to Add IP to MAC interface
993 ********************************************************************/
994static NETCP_CFG_IP_T netapip_netcpCfgAddIpInternal(NETAPI_T h,
995 int iface_no,
996 nwal_IpType ipType,
997 nwalIpAddr_t * ip_addr,
998 nwalIpAddr_t *ip_rem_addr,
999 nwalIpOpt_t * ip_qualifiers,
1000 NETCP_CFG_ROUTE_HANDLE_T route,/*NULL for default*/
1001 void * user_data,
1002 int * err,
1003 int flag) /*TRUE: add IP to iface,
1004 FALSE: add IP as part of classifier */
1005{
1006 static unsigned char zeroIP6[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1007 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
1008 void * n_handle=NULL;
1009 nwalIpParam_t nwalIpParam= {
1010 0,
1011 pa_IPV4, /* IP Type */
1012 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Dest IP */
1013 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Source IP */
1014 { 0x0,0,0,0},/* IP Options */
1015 NWAL_MATCH_ACTION_CONTINUE_NEXT_ROUTE, /* Continue parsing to next route for match */
1016 NWAL_NEXT_ROUTE_FAIL_ACTION_HOST, /* For next route fail action by default is route to host */
1017 CPPI_PARAM_NOT_SPECIFIED, /* Use default flow configured to NWAL if packet is routed to host */
1018 QMSS_PARAM_NOT_SPECIFIED, /* Use default queue configured to NWAL if packet is routed to host */
1019 0
1020};
1021 nwal_RetValue retValue;
1022 NetapiNwalTransInfo_t *pTransInfo;
1023 nwal_TransID_t trans_id;
1024 int ip_slot=-1;
1025 NETCP_CFG_IP_T ip_rule_id;
1026 NETCP_CFG_IP_T temp;
1027
1028 //verify that iface has been configured
1029 if (iface_no != NETCP_CFG_NO_INTERFACE)
1030 {
1031 if ((iface_no<0) || (iface_no>= TUNE_NETAPI_MAX_NUM_MAC)) {*err = NETAPI_ERR_BAD_INPUT; return -1;}
1032 }
1033
1034 if (iface_no != NETCP_CFG_NO_INTERFACE)
1035 {
1036 if(netapi_get_global()->nwal_context.interfaces[iface_no].in_use)
1037 {
1038 n_handle = netapi_get_global()->nwal_context.interfaces[iface_no].nwal_handle;
1039 }
1040 else
1041 {
1042 *err = NETAPI_ERR_BAD_INPUT;
1043 return -1;
1044 }
1045 }
1046 if (flag) //if adding IP to MAC then reserve a slot to save info
1047 {
1048 //find free slot for IP & reserve
1049 ip_slot= netapip_netcpCfgFindIpSlot(n,
1050 &netapi_get_global()->nwal_context,
1051 iface_no);
1052 if (ip_slot <0)
1053 {
1054 *err= NETAPI_ERR_NOMEM; //no room
1055 return -1;
1056 }
1057 }
1058
1059 //get a transaction object for config action
1060 pTransInfo = netapip_getFreeTransInfo(n,
1061 (NETAPI_PROC_GLOBAL_T *) n->proc_global,
1062 &trans_id);
1063 if (!pTransInfo)
1064 {
1065 *err = NETAPI_ERR_BUSY;
1066 if (flag)
1067 {
1068 netapip_netcpCfgDeleteIp(&netapi_get_global()->nwal_context,
1069 iface_no,
1070 ip_slot);
1071 }
1072 return -1;
1073 }
1074 pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_IP;
1075 pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING;
1076 pTransInfo->inUse = nwal_TRUE;
1077 pTransInfo->netapi_handle = h;
1078
1079 //build nwalIpParam
1080 memcpy(&nwalIpParam.locIpAddr,ip_addr, sizeof(nwalIpAddr_t));
1081 if (ip_rem_addr)
1082 {
1083 if (ipType == nwal_IPV4)
1084 {
1085 if(memcmp(ip_rem_addr, zeroIP6, sizeof(nwalIpv4Addr_t)))
1086 {
1087 nwalIpParam.validParams |= NWAL_SET_IP_VALID_PARAM_REMOTE_IP;
1088 memcpy(&nwalIpParam.remIpAddr,ip_rem_addr, sizeof(nwalIpAddr_t));
1089 }
1090 }
1091 else
1092 {
1093 if(memcmp(ip_rem_addr, zeroIP6, sizeof(nwalIpv6Addr_t)))
1094 {
1095 nwalIpParam.validParams |= NWAL_SET_IP_VALID_PARAM_REMOTE_IP;
1096 memcpy(&nwalIpParam.remIpAddr,ip_rem_addr, sizeof(nwalIpAddr_t));
1097 }
1098 }
1099 }
1100 nwalIpParam.ipType=ipType;
1101 if(route)
1102 {
1103 if((route->valid_params & NETCP_CFG_VALID_PARAM_ROUTE_TYPE) ==
1104 NETCP_CFG_VALID_PARAM_ROUTE_TYPE)
1105 {
1106 nwalIpParam.validParams |=
1107 NWAL_SET_IP_VALID_PARAM_ROUTE_TYPE;
1108 }
1109 netapip_netcpCfgBuildRoute(route,
1110 &nwalIpParam.appRxPktFlowId,
1111 &nwalIpParam.appRxPktQueue,
1112 &nwalIpParam.routeType);
1113 }
1114 else{} //use nwal defaults
1115
1116 if (ip_qualifiers)
1117 memcpy(&nwalIpParam.ipOpt,ip_qualifiers, sizeof(nwalIpOpt_t));
1118 else
1119 memset(&nwalIpParam.ipOpt,0, sizeof(nwalIpOpt_t));
1120
1121 //build the rule id that will be returned when a packet matches
1122 if (flag)
1123 ip_rule_id = NETAPI_NETCP_MATCH_GENERIC_IP | iface_no | ((ip_slot&& NETAPI_NETCP_MATCH_ID_MASK) << NETAPI_NETCP_MATCH_ID_SHIFT);
1124 else
1125 ip_rule_id = (NETAPI_NETCP_MATCH_CLASS_L3 | iface_no);
1126
1127 retValue = nwal_setIPAddr( netapi_get_global()->nwal_context.nwalInstHandle,
1128 trans_id,
1129 (nwal_AppId) (ip_rule_id),
1130 n_handle,
1131 &nwalIpParam,
1132 &pTransInfo->handle);
1133
1134 if(retValue != nwal_OK)
1135 {
1136 *err = NETAPI_ERR_NWAL_ERR0;
1137 netapip_freeTransInfo(pTransInfo);
1138 //zap the entry
1139 if (flag)
1140 {
1141 netapip_netcpCfgDeleteIp(&netapi_get_global()->nwal_context,
1142 iface_no,
1143 ip_slot);
1144 }
1145 return -1;
1146 }
1147 //wait here until its done since scheduler isn't running yet most likely..
1148 // todo: make this handled by scheduler poll later ??
1149 if(trans_id != NWAL_TRANSID_SPIN_WAIT)
1150 {
1151 n->nwal_local.numPendingCfg++;
1152 while ((pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_ERR) &&
1153 (pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_OPEN))
1154 {
1155 // if response is there, then this poll squirts out in the CTl poll callback,
1156 // which handles the rest (including decrmenting #pending!!
1157 nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
1158 }
1159 if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
1160 {
1161 netapip_freeTransInfo(pTransInfo);
1162 *err = NETAPI_ERR_PA_FW;
1163 return -1;
1164 }
1165 }
1166 if (flag)
1167 {
1168 netapip_netcpCfgInsertIp(&netapi_get_global()->nwal_context,
1169 ipType,
1170 ip_addr,
1171 ip_qualifiers,
1172 iface_no,
1173 ip_slot,
1174 pTransInfo->handle,
1175 user_data);
1176 }
1177
1178 temp = (NETCP_CFG_IP_T) pTransInfo->handle;
1179 netapip_freeTransInfo(pTransInfo);
1180 return (flag ? ip_rule_id: temp);
1181}
1182
1183/********************************************************************
1184 * FUNCTION PURPOSE: API to Add IP to MAC interface
1185 ********************************************************************
1186 * DESCRIPTION: API to Add IP to MAC interface
1187 ********************************************************************/
1188NETCP_CFG_IP_T netapi_netcpCfgAddIp(NETAPI_T h,
1189 int iface_no,
1190 nwal_IpType ipType,
1191 nwalIpAddr_t* ip_addr,
1192 nwalIpAddr_t* ip_rem_addr,
1193 nwalIpOpt_t* ip_qualifiers,
1194 NETCP_CFG_ROUTE_HANDLE_T route, //NULL for default
1195 void* user_data,
1196 int* err)
1197{
1198 return netapip_netcpCfgAddIpInternal(h,
1199 iface_no,
1200 ipType,
1201 ip_addr,
1202 ip_rem_addr,
1203 ip_qualifiers,
1204 route,
1205 user_data,
1206 err,
1207 1);
1208}
1209
1210
1211/********************************************************************
1212 * FUNCTION PURPOSE: NETAPI internal function to detach IP from MAC interface
1213 ********************************************************************
1214 * DESCRIPTION: NETAPI internal function to detach IP from MAC interface
1215 ********************************************************************/
1216static void netapip_netcpCfgDelIpInternal(NETAPI_T h,
1217 int iface_no,
1218 nwal_IpType ipType,
1219 nwalIpAddr_t * ip_addr,
1220 nwalIpOpt_t * ip_qualifiers,
1221 NETCP_CFG_IP_T ip_rule_id,
1222 int *err,
1223 void * handle, /* if flag==0, handle must be valid */
1224 int flag) /* flag==0 => delete IP rule that was part of classifier, not interface */
1225{
1226 nwal_RetValue ret;
1227 NetapiNwalTransInfo_t *pTransInfo;
1228 nwal_TransID_t trans_id;
1229 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
1230 void * ifHandle;
1231 int ip_slot = netapi_cfgGetMatchId(ip_rule_id);
1232 /* get the nwal handle assoicated with this ip */
1233 if (flag)
1234 {
1235 ifHandle = netapip_netcpCfgGetIpHandle(&netapi_get_global()->nwal_context,
1236 iface_no,
1237 ip_slot);
1238 }
1239 else
1240 {
1241 ifHandle = handle;
1242 }
1243 if(!ifHandle)
1244 {
1245 *err = NETAPI_ERR_BAD_INPUT;
1246 return ;
1247 }
1248 *err =0;
1249
1250 //get a transaction id
1251 pTransInfo = netapip_getFreeTransInfo(n,
1252 (NETAPI_PROC_GLOBAL_T *) n->proc_global,
1253 &trans_id);
1254 if (!pTransInfo)
1255 {
1256 *err = NETAPI_ERR_BUSY;
1257 return;
1258 }
1259 pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_IP;
1260 pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING;
1261 pTransInfo->inUse = nwal_TRUE;
1262 pTransInfo->netapi_handle = h;
1263 //issue request
1264 ret = nwal_delIPAddr(
1265 ((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
1266 trans_id,
1267 ifHandle);
1268 if(ret != nwal_OK)
1269 {
1270 *err = NETAPI_ERR_NWAL_ERR0;
1271 netapip_freeTransInfo(pTransInfo);
1272 return ;
1273 }
1274 //wait here until its done since scheduler isn't running yet most likely..
1275 // todo: make this handled by scheduler poll later ??
1276 if(trans_id != NWAL_TRANSID_SPIN_WAIT)
1277 {
1278 n->nwal_local.numPendingCfg++;
1279 while ((pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_ERR) &&
1280 (pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_IDLE))
1281 {
1282 // if response is there, then this poll squirts out in the CTl poll callback,
1283 // which handles the rest (including decrmenting #pending!!
1284 nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
1285 }
1286 if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
1287 {
1288 netapip_freeTransInfo(pTransInfo);
1289 *err = NETAPI_ERR_PA_FW;
1290 return;
1291 }
1292 }
1293
1294 netapip_freeTransInfo(pTransInfo);
1295
1296 //zap the entry
1297 if (flag)
1298 netapip_netcpCfgDeleteIp(&netapi_get_global()->nwal_context,
1299 iface_no,
1300 ip_slot);
1301 return ;
1302}
1303
1304/********************************************************************
1305 * FUNCTION PURPOSE: API to detach IP from MAC interface
1306 ********************************************************************
1307 * DESCRIPTION: API to detach IP from MAC interface
1308 ********************************************************************/
1309void netapi_netcpCfgDelIp(NETAPI_T h,
1310 int iface_no,
1311 nwal_IpType ipType,
1312 nwalIpAddr_t* ip_addr,
1313 nwalIpOpt_t* ip_qualifiers,
1314 NETCP_CFG_IP_T ip_rule_id,
1315 int* err)
1316{
1317 netapip_netcpCfgDelIpInternal( h, iface_no, ipType,
1318 ip_addr, ip_qualifiers, ip_rule_id,
1319 err, NULL, 1);
1320 return;
1321}
1322
1323
1324/********************************************************************
1325 * FUNCTION PURPOSE: API to attach a classifier rule to NETCP
1326 ********************************************************************
1327 * DESCRIPTION: API to attach a classifier rule to NETCP
1328 ********************************************************************/
1329NETCP_CFG_CLASS_T netapi_netcpCfgAddClass(NETAPI_T h,
1330 NETCP_CFG_CLASSIFIER_T* p_class,
1331 NETCP_CFG_ROUTE_HANDLE_T route,
1332 int action,
1333 void* user_data,
1334 int* err)
1335{
1336 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
1337 void * l3_handle=NULL; //ip handle
1338 nwal_RetValue retValue;
1339 NetapiNwalTransInfo_t *pTransInfo;
1340 nwal_TransID_t trans_id;
1341 int class_slot=-1;
1342 int iface_no;
1343 int ip_slot=-1;
1344 NETCP_CFG_CLASS_T classHandle; //returned by us
1345 nwal_appProtoType_t proto;
1346 nwalRxConnCfg_t tempCfg=
1347 {
1348 0, //nwal_handle: to be filled in
1349 0, // l4 ports: to be filled in
1350 0, //core id (NA)
1351 0, //action
1352 CPPI_PARAM_NOT_SPECIFIED, //flow id
1353 QMSS_PARAM_NOT_SPECIFIED, //dest queue
1354 0,
1355 0, // l4 ports: to be filled in
1356 };
1357
1358 *err = NETAPI_ERR_OK;
1359
1360 if(!p_class)
1361 {
1362 *err=NETAPI_ERR_BAD_INPUT;
1363 return -1;
1364 }
1365 switch(p_class->classType)
1366 {
1367 default:
1368 break;
1369 case(NETCP_CFG_CLASS_TYPE_L3_L4):
1370 n->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_l3_classi_lock);
1371 case(NETCP_CFG_CLASS_TYPE_L4):
1372 //assume just type l4 only (L2, L3 defined by iface, l3 id )
1373 iface_no = p_class->u.c_l4.iface;
1374 if (p_class->classType== NETCP_CFG_CLASS_TYPE_L4)
1375 {
1376 ip_slot = netapi_cfgGetMatchId(p_class->u.c_l4.ip);
1377 }
1378
1379 //verify that iface has been configured
1380 if (iface_no != NETCP_CFG_NO_INTERFACE)
1381 {
1382 if(!netapi_get_global()->nwal_context.interfaces[iface_no].in_use)
1383 {
1384 *err = NETAPI_ERR_BAD_INPUT;
1385 if(p_class->classType== NETCP_CFG_CLASS_TYPE_L3_L4)
1386 n->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_l3_classi_lock);
1387 return -1;
1388 }
1389 }
1390
1391 if (p_class->classType== NETCP_CFG_CLASS_TYPE_L4)
1392 {
1393 //verify that ip has been configured and get its handle
1394 l3_handle = netapip_netcpCfgGetIpHandle(
1395 &netapi_get_global()->nwal_context, iface_no,
1396 ip_slot );
1397 }
1398 else
1399 {
1400 nwalIpParam_t tempParam=
1401 {
1402 0,
1403 pa_IPV4, /* IP Type */
1404 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Dest IP */
1405 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* Source IP */
1406 { 0x0,0,0,0},/* IP Options */
1407 NWAL_MATCH_ACTION_CONTINUE_NEXT_ROUTE, /* Continue parsing to next route for match */
1408 NWAL_NEXT_ROUTE_FAIL_ACTION_HOST, /* For next route fail action by default is route to host */
1409 CPPI_PARAM_NOT_SPECIFIED, /* Use default flow configured to NWAL if packet is routed to host */
1410 QMSS_PARAM_NOT_SPECIFIED, /* Use default queue configured to NWAL if packet is routed to host */
1411 0
1412 };
1413 //build nwalIpParam
1414 memcpy(&tempParam.locIpAddr,p_class->u.c_l3_l4.ip_addr, sizeof(nwalIpAddr_t));
1415 tempParam.ipType=p_class->u.c_l3_l4.ipType;
1416 //use nwal defauls for route
1417 if (p_class->u.c_l3_l4.ip_qualifiers)
1418 memcpy(&tempParam.ipOpt,p_class->u.c_l3_l4.ip_qualifiers, sizeof(nwalIpOpt_t));
1419 else
1420 memset(&tempParam.ipOpt,0, sizeof(nwalIpOpt_t));
1421
1422 //find if we have a matching L3 handle for IP classifier; if not create it
1423 retValue = nwal_getIPAddr (((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
1424 &tempParam,
1425 netapip_netcpCfgGetMacHandle(&netapi_get_global()->nwal_context, iface_no ),
1426 &l3_handle);
1427 if (retValue != nwal_TRUE)
1428 {
1429 int ret;
1430 //**NEW IP RULE
1431 //need to attach this IP RULE to the MAC
1432 l3_handle= (void *) netapip_netcpCfgAddIpInternal(
1433 h, iface_no,
1434 p_class->u.c_l3_l4.ipType,
1435 p_class->u.c_l3_l4.ip_addr,
1436 NULL,
1437 p_class->u.c_l3_l4.ip_qualifiers,
1438 p_class->u.c_l3_l4.p_fail_route,
1439 user_data,
1440 &ret,
1441 NETAPI_FALSE);
1442 if(!ret)
1443 {
1444 l3_handle=NULL;
1445 }
1446 }
1447 }
1448 if(!l3_handle)
1449 {
1450 *err = NETAPI_ERR_BAD_INPUT;
1451 if(p_class->classType == NETCP_CFG_CLASS_TYPE_L3_L4)
1452 n->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_l3_classi_lock);
1453 return -1 ;
1454 }
1455
1456 //find free slot for CLASS & reserve
1457 class_slot= netapip_netcpCfgFindClassSlot(n,
1458 &netapi_get_global()->nwal_context);
1459 if(class_slot<0)
1460 {
1461 *err = NETAPI_ERR_NOMEM;
1462 if(p_class->classType == NETCP_CFG_CLASS_TYPE_L3_L4)
1463 n->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_l3_classi_lock);
1464 return -1;
1465 }
1466 classHandle = NETAPI_NETCP_MATCH_CLASS |
1467 (class_slot << NETAPI_NETCP_MATCH_ID_SHIFT) |
1468 (iface_no & NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK);
1469 //build request from template
1470 tempCfg.inHandle=l3_handle;
1471 if (p_class->classType== NETCP_CFG_CLASS_TYPE_L4)
1472 {
1473 memcpy(&tempCfg.appProto,&p_class->u.c_l4.appProto,sizeof(nwalAppProto_t));
1474 proto = p_class->u.c_l4.proto;
1475 }
1476 else
1477 {
1478 memcpy(&tempCfg.appProto,&p_class->u.c_l3_l4.appProto,sizeof(nwalAppProto_t));
1479 proto = p_class->u.c_l3_l4.proto;
1480 }
1481
1482 tempCfg.matchAction = (action==NETCP_CFG_ACTION_TO_SW) ? NWAL_MATCH_ACTION_HOST : NWAL_MATCH_ACTION_DISCARD;
1483 if (route)
1484 {
1485 if((route->valid_params & NETCP_CFG_VALID_PARAM_ROUTE_TYPE) ==
1486 NETCP_CFG_VALID_PARAM_ROUTE_TYPE)
1487 {
1488 tempCfg.validParams |=
1489 NWAL_SET_CONN_VALID_PARAM_ROUTE_TYPE;
1490 }
1491 netapip_netcpCfgBuildRoute(route,
1492 &tempCfg.appRxPktFlowId,
1493 &tempCfg.appRxPktQueue,
1494 &tempCfg.routeType);
1495 }
1496
1497
1498 //get a transaction id
1499 pTransInfo = netapip_getFreeTransInfo(n,
1500 (NETAPI_PROC_GLOBAL_T *) n->proc_global,
1501 &trans_id);
1502 if (!pTransInfo)
1503 {
1504 *err = NETAPI_ERR_BUSY;
1505 if(p_class->classType == NETCP_CFG_CLASS_TYPE_L3_L4)
1506 n->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_l3_classi_lock);
1507 return -1;
1508 }
1509 pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_PORT;
1510 pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING;
1511 pTransInfo->inUse = nwal_TRUE;
1512 pTransInfo->netapi_handle = h;
1513 //issue request
1514 retValue = nwal_addConn(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
1515 trans_id,
1516 (nwal_AppId) classHandle,
1517 proto,
1518 &tempCfg,
1519 NULL,
1520 &pTransInfo->handle);
1521 if(retValue != nwal_OK)
1522 {
1523 *err = NETAPI_ERR_NWAL_ERR0;
1524 netapip_freeTransInfo(pTransInfo);
1525 netapip_netcpCfgDeleteClass(&netapi_get_global()->nwal_context, class_slot);
1526 if(p_class->classType== NETCP_CFG_CLASS_TYPE_L3_L4)
1527 n->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_l3_classi_lock);
1528 return -1;
1529 }
1530 //wait here until its done since scheduler isn't running yet most likely..
1531 // todo: make this handled by scheduler poll later ??
1532 if(trans_id != NWAL_TRANSID_SPIN_WAIT)
1533 {
1534 n->nwal_local.numPendingCfg++;
1535 while ((pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_ERR) &&
1536 (pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_OPEN))
1537 {
1538 // if response is there, then this poll squirts out in the CTl poll callback,
1539 // which handles the rest (including decrmenting #pending!!
1540 nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
1541 }
1542 if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
1543 {
1544 netapip_freeTransInfo(pTransInfo);
1545 *err = NETAPI_ERR_PA_FW;
1546 netapip_netcpCfgDeleteClass(&netapi_get_global()->nwal_context, class_slot);
1547 if(p_class->classType== NETCP_CFG_CLASS_TYPE_L3_L4)
1548 n->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_l3_classi_lock);
1549 return -1;
1550 }
1551 }
1552 netapip_netcpCfgInsertClass(&netapi_get_global()->nwal_context,
1553 class_slot,
1554 p_class->classType,
1555 NULL, //L2 we have
1556 (p_class->classType== NETCP_CFG_CLASS_TYPE_L3_L4? l3_handle : NULL),
1557 pTransInfo->handle,
1558 user_data);
1559
1560 netapip_freeTransInfo(pTransInfo);
1561 if(p_class->classType== NETCP_CFG_CLASS_TYPE_L3_L4)
1562 n->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_l3_classi_lock);
1563 return classHandle;
1564 } //end switch
1565
1566return -1;
1567}
1568
1569/********************************************************************
1570 * FUNCTION PURPOSE: API to delete a preconfigured classifier
1571 ********************************************************************
1572 * DESCRIPTION: API to delete a preconfigured classifier
1573 ********************************************************************/
1574void netapi_netcpCfgDelClass(NETAPI_T h,
1575 NETCP_CFG_CLASS_T classId,
1576 int* err)
1577{
1578 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
1579 void *L4_handle = NULL; //class handle -> L4
1580 void *L3_handle = NULL; //class handle -> L3
1581 nwal_RetValue retValue;
1582 NetapiNwalTransInfo_t *pTransInfo;
1583 nwal_TransID_t trans_id;
1584 int class_slot=-1;
1585
1586 class_slot = netapi_cfgGetMatchId(classId);
1587 L4_handle=netapip_netcpCfgGetL4Handle(&netapi_get_global()->nwal_context, class_slot);
1588 if(!L4_handle)
1589 {
1590 *err = NETAPI_ERR_BAD_INPUT;
1591 goto ERR_netapi_netcpCfgDelClass;
1592 }
1593 L3_handle = netapip_netcpCfgGetL3Handle( &netapi_get_global()->nwal_context,
1594 class_slot);
1595 /* l3 handle might be NULL, depending on type of classifier */
1596
1597 if(L3_handle)
1598 {
1599 // grab l3 lock
1600 n->spinLock.lock(&pnetapiShm->netapi_netcp_cfg_l3_classi_lock);
1601 }
1602 netapip_netcpCfgDeleteClass(
1603 &netapi_get_global()->nwal_context,
1604 class_slot );
1605 //get a transaction id
1606 pTransInfo = netapip_getFreeTransInfo(n,
1607 (NETAPI_PROC_GLOBAL_T *) n->proc_global,
1608 &trans_id);
1609 if (!pTransInfo)
1610 {
1611 *err = NETAPI_ERR_BUSY;
1612 goto ERR_netapi_netcpCfgDelClass;
1613 }
1614 pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_PORT;
1615 pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING;
1616 pTransInfo->inUse = nwal_TRUE;
1617 pTransInfo->netapi_handle = h;
1618 //issue request for L4
1619 retValue = nwal_delConn(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
1620 trans_id,
1621 L4_handle);
1622 if(retValue != nwal_OK)
1623 {
1624 *err = NETAPI_ERR_NWAL_ERR0;
1625 netapip_freeTransInfo(pTransInfo);
1626 goto ERR_netapi_netcpCfgDelClass; /* todo: what about the L3? */
1627 }
1628 //wait here until its done since scheduler isn't running yet most likely..
1629 // todo: make this handled by scheduler poll later ??
1630 if(trans_id != NWAL_TRANSID_SPIN_WAIT)
1631 {
1632 n->nwal_local.numPendingCfg++;
1633 while ((pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_ERR) &&
1634 (pTransInfo->state !=NETAPI_NWAL_HANDLE_STATE_IDLE))
1635 {
1636 // if response is there, then this poll squirts out in the CTl poll callback,
1637 // which handles the rest (including decrmenting #pending!!
1638 nwal_pollCtl(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
1639 }
1640 }
1641 if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
1642 {
1643 netapip_freeTransInfo(pTransInfo);
1644 *err = NETAPI_ERR_PA_FW;
1645 goto ERR_netapi_netcpCfgDelClass;
1646 }
1647 pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
1648 pTransInfo->inUse = nwal_FALSE;
1649
1650 /* delete L3 if we have to */
1651 if (cfgOkToDeleteL3ClassiHandle(h, L3_handle))
1652 {
1653 netapip_netcpCfgDelIpInternal(h,
1654 0,
1655 0,
1656 NULL,
1657 NULL,
1658 0,
1659 err,
1660 L3_handle,
1661 0);
1662 }
1663 netapip_freeTransInfo(pTransInfo);
1664
1665ERR_netapi_netcpCfgDelClass:
1666 if(L3_handle)
1667 n->spinLock.unlock(&pnetapiShm->netapi_netcp_cfg_l3_classi_lock);
1668
1669 return;
1670}
1671
1672/********************************************************************
1673 * FUNCTION PURPOSE: API to add a flow
1674 ********************************************************************
1675 * DESCRIPTION: API to add a flow
1676 ********************************************************************/
1677/*--------------flow management--------*/
1678// ADD A Flow
1679NETCP_CFG_FLOW_HANDLE_T netapi_netcpCfgAddFlow(NETAPI_T h,
1680 int n,
1681 Pktlib_HeapHandle handles[],
1682 int sizes[],
1683 NETCP_CFG_FLOW_CONFIG_T* p_cfg,
1684 int* err )
1685{
1686 Cppi_RxFlowCfg rxFlowCfg;
1687 Uint8 isAlloc;
1688 Qmss_QueueHnd rxBufQ[TUNE_NETAPI_MAX_BUF_POOLS_IN_FLOW];
1689 Uint32 rxBufSize[TUNE_NETAPI_MAX_BUF_POOLS_IN_FLOW];
1690 int i;
1691 Cppi_FlowHnd FlowHnd;
1692 int slot;
1693 NETCP_CFG_FLOW_HANDLE_T retVal;
1694 NETAPI_HANDLE_T * pHandle = (NETAPI_HANDLE_T *) h;
1695 *err= 0; /* ok */
1696 if (!p_cfg)
1697 {
1698 *err= NETAPI_ERR_BAD_INPUT;
1699 return NULL;
1700 }
1701 //get a slot to save new flow
1702 slot = netapip_netcpCfgFindFlowSlot(pHandle,
1703 &netapi_get_global()->nwal_context);
1704
1705 if (slot<0) { *err= NETAPI_ERR_NOMEM; return NULL; }
1706
1707 //configure flow
1708 memset(&rxFlowCfg,0,sizeof(Cppi_RxFlowCfg));
1709 for (i = 0; i < TUNE_NETAPI_MAX_BUF_POOLS_IN_FLOW; i++)
1710 {
1711 if (i >= n)
1712 {
1713 rxBufQ[i] = 0;
1714 rxBufSize[i] = 0;
1715 }
1716 else
1717 {
1718 rxBufQ[i] = Pktlib_getInternalHeapQueue(handles[i]);
1719 //todo: verity sizes< heapsize
1720 //todo: verify order
1721 rxBufSize[i]= sizes[i];
1722 }
1723 if (i && (rxBufQ[i] <= 0))
1724 {
1725 rxBufQ[i] = rxBufQ[i-1];
1726 rxBufSize[i] = 0;
1727 }
1728 }
1729
1730 /* Configure Rx flow */
1731 rxFlowCfg.flowIdNum = p_cfg->flow_index;/*CPPI_PARAM_NOT_SPECIFIED*/;
1732 rxFlowCfg.rx_dest_qnum = netapi_pktioGetQ(p_cfg->p_dest_q);
1733 rxFlowCfg.rx_dest_qmgr = Qmss_getQueueNumber(rxFlowCfg.rx_dest_qnum).qMgr;
1734 rxFlowCfg.rx_sop_offset = p_cfg->recv_offset;
1735 rxFlowCfg.rx_ps_location = Cppi_PSLoc_PS_IN_DESC;
1736 rxFlowCfg.rx_desc_type = Cppi_DescType_HOST;
1737 rxFlowCfg.rx_error_handling = p_cfg->block;
1738
1739 rxFlowCfg.rx_psinfo_present = 1;
1740 rxFlowCfg.rx_einfo_present = 1;
1741
1742 rxFlowCfg.rx_dest_tag_lo = 0;
1743 rxFlowCfg.rx_dest_tag_hi = 0;
1744 rxFlowCfg.rx_src_tag_lo = 0;
1745 rxFlowCfg.rx_src_tag_hi = 0;
1746
1747 rxFlowCfg.rx_size_thresh0_en = rxBufSize[1] ? 1 : 0;
1748 rxFlowCfg.rx_size_thresh1_en = rxBufSize[2] ? 1 : 0;
1749 rxFlowCfg.rx_size_thresh2_en = rxBufSize[3] ? 1 : 0;
1750
1751 if (p_cfg->dma_index==NETAPI_DMA_NETCP )
1752 rxFlowCfg.rx_dest_tag_lo_sel =0;
1753 else
1754 rxFlowCfg.rx_dest_tag_lo_sel = 0x4;
1755 rxFlowCfg.rx_dest_tag_hi_sel = 0;
1756 rxFlowCfg.rx_src_tag_lo_sel = 0;
1757 rxFlowCfg.rx_src_tag_hi_sel = 0;
1758
1759 rxFlowCfg.rx_fdq1_qnum = rxBufQ[1];
1760 rxFlowCfg.rx_fdq1_qmgr = (rxBufQ[1] ? Qmss_getQueueNumber(rxBufQ[1]).qMgr: 0);
1761 rxFlowCfg.rx_fdq2_qnum = rxBufQ[2];
1762 rxFlowCfg.rx_fdq2_qmgr = (rxBufQ[2] ? Qmss_getQueueNumber(rxBufQ[2]).qMgr: 0);
1763 rxFlowCfg.rx_fdq3_qnum = rxBufQ[3];
1764 rxFlowCfg.rx_fdq3_qmgr = (rxBufQ[3] ? Qmss_getQueueNumber(rxBufQ[3]).qMgr: 0);
1765
1766 rxFlowCfg.rx_size_thresh0 = rxBufSize[1] ? rxBufSize[0] : 0;
1767 rxFlowCfg.rx_size_thresh1 = rxBufSize[2] ? rxBufSize[1] : 0;
1768 rxFlowCfg.rx_size_thresh2 = rxBufSize[3] ? rxBufSize[2] : 0;
1769
1770 rxFlowCfg.rx_fdq0_sz0_qnum = rxBufQ[0];
1771 rxFlowCfg.rx_fdq0_sz0_qmgr = (rxBufQ[0] ? Qmss_getQueueNumber(rxBufQ[0]).qMgr: 0);
1772 rxFlowCfg.rx_fdq0_sz1_qnum = rxBufQ[1];
1773 rxFlowCfg.rx_fdq0_sz1_qmgr = (rxBufQ[1] ? Qmss_getQueueNumber(rxBufQ[1]).qMgr:0);
1774 rxFlowCfg.rx_fdq0_sz2_qnum = rxBufQ[2];
1775 rxFlowCfg.rx_fdq0_sz2_qmgr = (rxBufQ[2] ? Qmss_getQueueNumber(rxBufQ[2]).qMgr:0);
1776 rxFlowCfg.rx_fdq0_sz3_qnum = rxBufQ[3];
1777 rxFlowCfg.rx_fdq0_sz3_qmgr = (rxBufQ[3] ? Qmss_getQueueNumber(rxBufQ[3]).qMgr:0);
1778 {
1779 //todo: replace this with a nwal call to get global cntx info
1780 Cppi_CpDmaInitCfg cpdmaCfg;
1781 Cppi_Handle cppiHnd;
1782 memset(&cpdmaCfg,0,sizeof(Cppi_CpDmaInitCfg));
1783 cpdmaCfg.dmaNum = (p_cfg->dma_index==NETAPI_DMA_NETCP ) ?Cppi_CpDma_PASS_CPDMA: Cppi_CpDma_QMSS_CPDMA;
1784 cppiHnd= Cppi_open (&cpdmaCfg);
1785 if (cppiHnd == NULL)
1786 {
1787 netapip_netcpCfgDeleteFlow(&netapi_get_global()->nwal_context, slot);
1788 *err= NETAPI_ERR_NORES;
1789 return NULL;
1790 }
1791 FlowHnd = Cppi_configureRxFlow (cppiHnd, &rxFlowCfg, &isAlloc);
1792 }
1793 if (FlowHnd == NULL)
1794 {
1795 *err= NETAPI_ERR_NORES;
1796 netapip_netcpCfgDeleteFlow(&netapi_get_global()->nwal_context, slot);
1797 return (NULL);
1798 }
1799
1800 //update slot
1801 retVal = netapip_netcpCfgInsertFlow(&netapi_get_global()->nwal_context,
1802 slot,
1803 p_cfg->dma_index,
1804 (void*) FlowHnd);
1805 return (retVal);
1806}
1807
1808/********************************************************************
1809 * FUNCTION PURPOSE: API to delete a flow
1810 ********************************************************************
1811 * DESCRIPTION: API to delete a flow
1812 ********************************************************************/
1813void netapi_netcpCfgDelFlow(NETAPI_T h,
1814 NETCP_CFG_FLOW_HANDLE_T f,
1815 int* err)
1816{
1817 int slot;
1818 void * handle;
1819 *err=0;
1820 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
1821 /* find entry */
1822 slot = netapip_netcpCfgFindFlow(n,
1823 &netapi_get_global()->nwal_context,
1824 ((NETCP_CFG_FLOW_T *) f) ->flowid,
1825 ((NETCP_CFG_FLOW_T *) f) ->dma_engine,
1826 &handle);
1827 if (slot<0)
1828 {
1829 *err = NETAPI_ERR_BAD_INPUT;
1830 return;
1831 }
1832 if ((Cppi_closeRxFlow( (Cppi_FlowHnd) handle)) == 0)
1833 {
1834 netapip_netcpCfgDeleteFlow(&netapi_get_global()->nwal_context,
1835 slot);
1836 }
1837 return;
1838}
1839
1840/******************************************************************************
1841 * FUNCTION PURPOSE: API to configure NETCP with global rules for exception packet handling
1842 ******************************************************************************
1843 * DESCRIPTION: API to configure NETCP with global rules for exception packet handling
1844 *****************************************************************************/
1845NETCP_CFG_EXCEPTION_PKT_T netapi_netcpCfgExceptions(NETAPI_T h,
1846 int exception_id,
1847 nwal_matchAction_t action,
1848 NETCP_CFG_ROUTE_HANDLE_T p_route)
1849{
1850 nwalCtlInfo_t ctrl;
1851 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
1852 nwal_RetValue retVal = 0;
1853 memset(&ctrl, 0, sizeof(nwalCtlInfo_t));
1854
1855 if (p_route != NULL)
1856 {
1857 if((p_route->valid_params & NETCP_CFG_VALID_PARAM_ROUTE_TYPE) ==
1858 NETCP_CFG_VALID_PARAM_ROUTE_TYPE)
1859 {
1860 ctrl.validParams |=
1861 NWAL_CONTROL_VALID_PARAM_ROUTE_TYPE;
1862 ctrl.routeType = p_route->routeType;
1863 }
1864 netapip_netcpCfgBuildRoute(p_route,
1865 &ctrl.appRxPktFlowId,
1866 &ctrl.appRxPktQueue,
1867 &ctrl.routeType);
1868 }
1869 else
1870 {
1871 ctrl.appRxPktFlowId = NWAL_FLOW_NOT_SPECIFIED;
1872 ctrl.appRxPktQueue = NWAL_QUEUE_NOT_SPECIFIED;
1873 }
1874
1875 ctrl.appId = (void*)(NETAPI_NETCP_CFG_MATCH_EXCEPTION | exception_id);
1876
1877 ctrl.matchAction = action;
1878
1879 if (exception_id == NETCP_CFG_ALL_EXCEPTIONS)
1880 {
1881 ctrl.pktCtl = NWAL_CTRL_CFG_ALL_EXCEPTIONS;
1882 }
1883 else
1884 {
1885 ctrl.pa_EROUTE_Id = exception_id;
1886 ctrl.pktCtl = NWAL_CTRL_CFG_SINGLE_EXCEPTION;
1887 }
1888
1889 retVal = nwal_control(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle, &ctrl);
1890
1891
1892 return (NETCP_CFG_EXCEPTION_PKT_T) ctrl.appId;
1893}
1894
1895/*************************************************************************/
1896/*********************************INTERNAL*******************************/
1897/************************************************************************/
1898
1899/********************************************************************
1900 * FUNCTION PURPOSE: NETAPI internal function, NETCP command reply callback
1901 ********************************************************************
1902 * DESCRIPTION: NETAPI internal function, NETCP command reply callback
1903 ********************************************************************/
1904void netapip_netcpCfgNWALCmdCallBack(nwal_AppId appHandle,
1905 uint16_t trans_id,
1906 nwal_RetValue ret)
1907{
1908 NetapiNwalTransInfo_t * p_trans;
1909 NETAPI_NWAL_LOCAL_CONTEXT_T *p_local=NULL;
1910
1911 if(trans_id == NWAL_TRANSID_SPIN_WAIT)
1912 {
1913 netapi_get_proc_global()->nwal_context.numBogusTransIds++;
1914 return;
1915 }
1916
1917 p_trans= &netapi_get_proc_global()->nwal_context.transInfos[trans_id];
1918 p_local =&((NETAPI_HANDLE_T*) (p_trans->netapi_handle))->nwal_local;
1919
1920 if(ret != nwal_OK)
1921 {
1922 // update error code that is fialed in p_trans */
1923 //todo: atomic inc
1924 p_trans->state = NETAPI_NWAL_HANDLE_STATE_ERR;
1925 netapi_get_proc_global()->nwal_context.numCmdFail++;
1926 }
1927 else
1928 {
1929 //todo: atomic inc
1930 netapi_get_proc_global()->nwal_context.numCmdPass++;
1931 switch(p_trans->transType)
1932 {
1933 case NETAPI_NWAL_HANDLE_TRANS_MAC:
1934 {
1935 if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING)
1936 {
1937 p_trans->state =NETAPI_NWAL_HANDLE_STATE_OPEN;
1938 }
1939 else if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING)
1940 {
1941 p_trans->state =NETAPI_NWAL_HANDLE_STATE_IDLE;
1942 }
1943 break;
1944 }
1945 case NETAPI_NWAL_HANDLE_TRANS_IP:
1946 {
1947 if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING)
1948 {
1949 p_trans->state = NETAPI_NWAL_HANDLE_STATE_OPEN;
1950 }
1951 else if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING)
1952 {
1953 p_trans->state =NETAPI_NWAL_HANDLE_STATE_IDLE;
1954 }
1955 break;
1956 }
1957 case NETAPI_NWAL_HANDLE_TRANS_PORT:
1958 {
1959 if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING)
1960 {
1961 p_trans->state =NETAPI_NWAL_HANDLE_STATE_OPEN;
1962 }
1963 else if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING)
1964 {
1965 p_trans->state =NETAPI_NWAL_HANDLE_STATE_IDLE;
1966 }
1967 break;
1968 }
1969 case NETAPI_NWAL_HANDLE_TRANS_SA:
1970 {
1971 if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING)
1972 {
1973 p_trans->state =NETAPI_NWAL_HANDLE_STATE_OPEN;
1974 }
1975 else if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING)
1976 {
1977 p_trans->state =NETAPI_NWAL_HANDLE_STATE_IDLE;
1978 }
1979 break;
1980 }
1981 case NETAPI_NWAL_HANDLE_TRANS_SA_POLICY:
1982 {
1983 if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_OPEN_PENDING)
1984 {
1985 p_trans->state =NETAPI_NWAL_HANDLE_STATE_OPEN;
1986 }
1987 else if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING)
1988 {
1989 p_trans->state =NETAPI_NWAL_HANDLE_STATE_IDLE;
1990 }
1991 break;
1992 }
1993 default:
1994 {
1995 break;
1996 }
1997 }
1998 }
1999
2000 p_local->numPendingCfg--;
2001
2002 if(p_trans->state == NETAPI_NWAL_HANDLE_STATE_IDLE)
2003 {
2004 p_trans->inUse = nwal_FALSE;
2005 }
2006}
2007
2008
2009/********************************************************************
2010 * FUNCTION PURPOSE: NETAPI internal function, PA stats reply callback
2011 ********************************************************************
2012 * DESCRIPTION: NETAPI internal function, PA stats reply callback
2013 ********************************************************************/
2014void netapip_netcpCfgNWALCmdPaStatsReply(nwal_AppId appHandle,
2015 nwal_TransID_t trans_id,
2016 paSysStats_t *stats)
2017{
2018 NetapiNwalTransInfo_t * p_trans;
2019 NETAPI_NWAL_LOCAL_CONTEXT_T *p_local=NULL;
2020
2021 if(trans_id == NWAL_TRANSID_SPIN_WAIT)
2022 {
2023 netapi_get_proc_global()->nwal_context.numBogusTransIds++;
2024 return;
2025 }
2026
2027 p_trans= &netapi_get_proc_global()->nwal_context.transInfos[trans_id];
2028 p_trans->inUse = nwal_FALSE;
2029 p_local =&((NETAPI_HANDLE_T*) (p_trans->netapi_handle))->nwal_local;
2030
2031 //save a local copy of some stuff*/
2032 p_local->numL2PktsRecvd=stats->classify1.nPackets;
2033 p_local->numL3PktsRecvd=stats->classify1.nIpv4Packets;
2034
2035 //callout result to application !!
2036 if (p_local->stats_cb)
2037 {
2038 (*p_local->stats_cb)(p_trans->netapi_handle,stats);
2039 }
2040}
2041
diff --git a/ti/runtime/netapi/src/pdkv2/netapi_navig.c b/ti/runtime/netapi/src/pdkv2/netapi_navig.c
new file mode 100755
index 0000000..35069b5
--- /dev/null
+++ b/ti/runtime/netapi/src/pdkv2/netapi_navig.c
@@ -0,0 +1,303 @@
1/************************************************
2* FILE: netapi_device.c
3 * Device specific initialization for NETAPI
4 *
5 * DESCRIPTION: Functions to initialize multicore navigator related global
6 * resources
7 *
8 * REVISION HISTORY:
9 *
10 * Copyright (c) Texas Instruments Incorporated 2013
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
22 * distribution.
23 *
24 * Neither the name of Texas Instruments Incorporated nor the names of
25 * its contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 ***********************************************/
41
42#include "netapi.h"
43#include <sys/types.h>
44#include <sys/stat.h>
45#include <fcntl.h>
46#include <sys/mman.h>
47#include <errno.h>
48#include <unistd.h>
49
50#include <ti/csl/cslr_device.h>
51#include <ti/drv/qmss/qmss_qm.h>
52
53//pull in device config for qmss, cppi
54#include "qmss_device.c"
55#include "cppi_device.c"
56
57/********************************************************************
58 * FUNCTION PURPOSE: Internal NETAPI macro to convert to IP Register
59 * Virtual Address from a mapped base Virtual
60 * Address.
61 ********************************************************************
62 * DESCRIPTION: Arguments:
63 * virtBaseAddr: Virtual base address mapped using mmap for IP
64 * phyBaseAddr: Physical base address for the IP
65 * phyRegAddr: Physical register address
66 ********************************************************************/
67
68
69static inline void* NETAPI_GET_REG_VADDR (void * virtBaseAddr,
70 uint32_t phyBaseAddr,
71 uint32_t phyRegAddr)
72{
73 return((void *)((uint8_t *)virtBaseAddr + (phyRegAddr - phyBaseAddr)));
74}
75
76
77/********************************************************************
78 * FUNCTION PURPOSE: Internal NETAI function ti initialize CPPI.
79 ********************************************************************
80 * DESCRIPTION: Internal NETAI function ti initialize CPPI
81 ********************************************************************/
82int netapip_initCppi(void* rmClientServiceHandle)
83{
84 int32_t result, i;
85 Cppi_GlobalConfigParams netapi_cppiGblCfgParams[CPPI_MAX_CPDMA];
86 Cppi_StartCfg netapi_cppiStartCfg;
87
88 memset(&netapi_cppiStartCfg, 0, sizeof(Cppi_StartCfg));
89
90 for (i=0; i<CPPI_MAX_CPDMA; i++)
91 netapi_cppiGblCfgParams[i] = cppiGblCfgParams[i];
92
93 /* SRIO CPDMA regs */
94 netapi_cppiGblCfgParams[Cppi_CpDma_SRIO_CPDMA].gblCfgRegs =
95 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->srioCfgVaddr,
96 CSL_SRIO_CONFIG_REGS,
97 (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_SRIO_CPDMA].gblCfgRegs);
98
99 netapi_cppiGblCfgParams[Cppi_CpDma_SRIO_CPDMA].txChRegs =
100 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->srioCfgVaddr,
101 CSL_SRIO_CONFIG_REGS,
102 (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_SRIO_CPDMA].txChRegs);
103
104 netapi_cppiGblCfgParams[Cppi_CpDma_SRIO_CPDMA].rxChRegs =
105 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->srioCfgVaddr,
106 CSL_SRIO_CONFIG_REGS,
107 (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_SRIO_CPDMA].rxChRegs);
108
109 netapi_cppiGblCfgParams[Cppi_CpDma_SRIO_CPDMA].txSchedRegs =
110 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->srioCfgVaddr,
111 CSL_SRIO_CONFIG_REGS,
112 (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_SRIO_CPDMA].txSchedRegs);
113
114 netapi_cppiGblCfgParams[Cppi_CpDma_SRIO_CPDMA].rxFlowRegs =
115 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->srioCfgVaddr,
116 CSL_SRIO_CONFIG_REGS,
117 (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_SRIO_CPDMA].rxFlowRegs);
118
119 /* PASS CPDMA regs */
120 netapi_cppiGblCfgParams[Cppi_CpDma_PASS_CPDMA].gblCfgRegs =
121 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->passCfgVaddr,
122 CSL_PA_SS_CFG_REGS,
123 (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_PASS_CPDMA].gblCfgRegs);
124
125 netapi_cppiGblCfgParams[Cppi_CpDma_PASS_CPDMA].txChRegs =
126 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->passCfgVaddr,
127 CSL_PA_SS_CFG_REGS,
128 (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_PASS_CPDMA].txChRegs);
129
130 netapi_cppiGblCfgParams[Cppi_CpDma_PASS_CPDMA].rxChRegs =
131 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->passCfgVaddr,
132 CSL_PA_SS_CFG_REGS,
133 (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_PASS_CPDMA].rxChRegs);
134
135 netapi_cppiGblCfgParams[Cppi_CpDma_PASS_CPDMA].txSchedRegs =
136 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->passCfgVaddr,
137 CSL_PA_SS_CFG_REGS,
138 (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_PASS_CPDMA].txSchedRegs);
139
140 netapi_cppiGblCfgParams[Cppi_CpDma_PASS_CPDMA].rxFlowRegs =
141 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->passCfgVaddr,
142 CSL_PA_SS_CFG_REGS,
143 (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_PASS_CPDMA].rxFlowRegs);
144
145 /* QMSS CPDMA regs */
146 netapi_cppiGblCfgParams[Cppi_CpDma_QMSS_CPDMA].gblCfgRegs =
147 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
148 QMSS_CFG_BASE_ADDR,
149 (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_QMSS_CPDMA].gblCfgRegs);
150
151 netapi_cppiGblCfgParams[Cppi_CpDma_QMSS_CPDMA].txChRegs =
152 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
153 QMSS_CFG_BASE_ADDR,
154 (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_QMSS_CPDMA].txChRegs);
155
156 netapi_cppiGblCfgParams[Cppi_CpDma_QMSS_CPDMA].rxChRegs =
157 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
158 QMSS_CFG_BASE_ADDR,
159 (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_QMSS_CPDMA].rxChRegs);
160
161 netapi_cppiGblCfgParams[Cppi_CpDma_QMSS_CPDMA].txSchedRegs =
162 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
163 QMSS_CFG_BASE_ADDR,
164 (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_QMSS_CPDMA].txSchedRegs);
165
166 netapi_cppiGblCfgParams[Cppi_CpDma_QMSS_CPDMA].rxFlowRegs =
167 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
168 QMSS_CFG_BASE_ADDR,
169 (uint32_t)netapi_cppiGblCfgParams[Cppi_CpDma_QMSS_CPDMA].rxFlowRegs);
170
171 result = Cppi_init (netapi_cppiGblCfgParams);
172 if (result != CPPI_SOK)
173 {
174 return (-1);
175 }
176 if (rmClientServiceHandle)
177 {
178 netapi_cppiStartCfg.rmServiceHandle = rmClientServiceHandle;
179 Cppi_startCfg(&netapi_cppiStartCfg);
180 }
181 return 1;
182}
183
184/********************************************************************
185 * FUNCTION PURPOSE: Internal NETAI function ti initialize QM.
186 ********************************************************************
187 * DESCRIPTION: Internal NETAI function ti initialize QM (once per SOC)
188 ********************************************************************/
189int netapip_initQm(int max_descriptors, void* rmClientServiceHandle))
190{
191 Qmss_InitCfg qmssInitConfig;
192 int32_t result;
193 Qmss_GlobalConfigParams netapi_qmssGblCfgParams;
194
195 memset (&qmssInitConfig, 0, sizeof (Qmss_InitCfg));
196
197 /* Use Internal Linking RAM for optimal performance */
198 qmssInitConfig.linkingRAM0Base = 0;
199 qmssInitConfig.linkingRAM0Size = 0;
200 qmssInitConfig.linkingRAM1Base = 0;
201 qmssInitConfig.maxDescNum = max_descriptors;
202 qmssInitConfig.qmssHwStatus =QMSS_HW_INIT_COMPLETE; //bypass some of the hw init
203 netapi_qmssGblCfgParams = qmssGblCfgParams[0];
204
205 netapi_qmssGblCfgParams.qmConfigReg =
206 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
207 QMSS_CFG_BASE_ADDR,
208 (uint32_t)netapi_qmssGblCfgParams.qmConfigReg);
209
210 netapi_qmssGblCfgParams.qmDescReg =
211 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
212 QMSS_CFG_BASE_ADDR,
213 (uint32_t)netapi_qmssGblCfgParams.qmDescReg);
214
215 netapi_qmssGblCfgParams.qmQueMgmtReg =
216 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
217 QMSS_CFG_BASE_ADDR,
218 (uint32_t)netapi_qmssGblCfgParams.qmQueMgmtReg);
219
220 netapi_qmssGblCfgParams.qmQueMgmtProxyReg =
221 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
222 QMSS_CFG_BASE_ADDR,
223 (uint32_t)netapi_qmssGblCfgParams.qmQueMgmtProxyReg);
224
225 netapi_qmssGblCfgParams.qmQueStatReg =
226 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
227 QMSS_CFG_BASE_ADDR,
228 (uint32_t)netapi_qmssGblCfgParams.qmQueStatReg);
229
230 netapi_qmssGblCfgParams.qmQueIntdReg =
231 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
232 QMSS_CFG_BASE_ADDR,
233 (uint32_t)netapi_qmssGblCfgParams.qmQueIntdReg);
234
235 netapi_qmssGblCfgParams.qmPdspCmdReg[0] =
236 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
237 QMSS_CFG_BASE_ADDR,
238 (uint32_t)netapi_qmssGblCfgParams.qmPdspCmdReg[0]);
239
240 netapi_qmssGblCfgParams.qmPdspCmdReg[1] =
241 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
242 QMSS_CFG_BASE_ADDR,
243 (uint32_t)netapi_qmssGblCfgParams.qmPdspCmdReg[1]);
244
245 netapi_qmssGblCfgParams.qmPdspCtrlReg[0] =
246 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
247 QMSS_CFG_BASE_ADDR,
248 (uint32_t)netapi_qmssGblCfgParams.qmPdspCtrlReg[0]);
249
250 netapi_qmssGblCfgParams.qmPdspCtrlReg[1] =
251 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
252 QMSS_CFG_BASE_ADDR,
253 (uint32_t)netapi_qmssGblCfgParams.qmPdspCtrlReg[1]);
254
255 netapi_qmssGblCfgParams.qmPdspIRamReg[0] =
256 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
257 QMSS_CFG_BASE_ADDR,
258 (uint32_t)netapi_qmssGblCfgParams.qmPdspIRamReg[0]);
259
260 netapi_qmssGblCfgParams.qmPdspIRamReg[1] =
261 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
262 QMSS_CFG_BASE_ADDR,
263 (uint32_t)netapi_qmssGblCfgParams.qmPdspIRamReg[1]);
264
265 netapi_qmssGblCfgParams.qmStatusRAM =
266 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
267 QMSS_CFG_BASE_ADDR,
268 (uint32_t)netapi_qmssGblCfgParams.qmStatusRAM);
269
270 netapi_qmssGblCfgParams.qmLinkingRAMReg =
271 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
272 QMSS_CFG_BASE_ADDR,
273 (uint32_t)netapi_qmssGblCfgParams.qmLinkingRAMReg);
274
275 netapi_qmssGblCfgParams.qmMcDMAReg =
276 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
277 QMSS_CFG_BASE_ADDR,
278 (uint32_t)netapi_qmssGblCfgParams.qmMcDMAReg);
279
280 netapi_qmssGblCfgParams.qmTimer16Reg[0] =
281 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
282 QMSS_CFG_BASE_ADDR,
283 (uint32_t)netapi_qmssGblCfgParams.qmTimer16Reg[0]);
284
285 netapi_qmssGblCfgParams.qmTimer16Reg[1] =
286 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
287 QMSS_CFG_BASE_ADDR,
288 (uint32_t)netapi_qmssGblCfgParams.qmTimer16Reg[1]);
289
290 netapi_qmssGblCfgParams.qmQueMgmtDataReg =
291 (void *)((uint32_t)netapi_VM_VirtAddr->qmssDataVaddr);
292
293
294 if (rmClientServiceHandle)
295 netapi_qmssGblCfgParams.qmRmServiceHandle = rmClientServiceHandle;
296
297 netapi_qmssGblCfgParams.qmQueMgmtProxyDataReg = NULL;
298 result = Qmss_init (&qmssInitConfig, &netapi_qmssGblCfgParams);
299 if (result != QMSS_SOK) {
300 return (nwal_FALSE);
301 }
302 return 1;
303}
diff --git a/ti/runtime/netapi/src/pdkv3/netapi_navig.c b/ti/runtime/netapi/src/pdkv3/netapi_navig.c
new file mode 100755
index 0000000..11ed60e
--- /dev/null
+++ b/ti/runtime/netapi/src/pdkv3/netapi_navig.c
@@ -0,0 +1,267 @@
1/************************************************
2* FILE: netapi_device.c
3 * Device specific initialization for NETAPI
4 *
5 * DESCRIPTION: Functions to initialize multicore navigator related global
6 * resources
7 *
8 * REVISION HISTORY:
9 *
10 * Copyright (c) Texas Instruments Incorporated 2013
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
22 * distribution.
23 *
24 * Neither the name of Texas Instruments Incorporated nor the names of
25 * its contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 ***********************************************/
41
42#include "netapi.h"
43#include <sys/types.h>
44#include <sys/stat.h>
45#include <fcntl.h>
46#include <sys/mman.h>
47#include <errno.h>
48#include <unistd.h>
49
50#include <ti/csl/cslr_device.h>
51#include <ti/drv/qmss/qmss_qm.h>
52
53//pull in device config for qmss, cppi
54
55
56extern Qmss_GlobalConfigParams qmssGblCfgParams;
57extern Cppi_GlobalConfigParams cppiGblCfgParams;
58
59/********************************************************************
60 * FUNCTION PURPOSE: Internal NETAPI macro to convert to IP Register
61 * Virtual Address from a mapped base Virtual
62 * Address.
63 ********************************************************************
64 * DESCRIPTION: Arguments:
65 * virtBaseAddr: Virtual base address mapped using mmap for IP
66 * phyBaseAddr: Physical base address for the IP
67 * phyRegAddr: Physical register address
68 ********************************************************************/
69static inline void* NETAPI_GET_REG_VADDR (void * virtBaseAddr,
70 uint32_t phyBaseAddr,
71 uint32_t phyRegAddr)
72{
73 return((void *)((uint8_t *)virtBaseAddr + (phyRegAddr - phyBaseAddr)));
74}
75
76
77/*****************************************************************************
78 * FUNCTION PURPOSE: Global Initialization of CPPI. Once Per System
79 *****************************************************************************
80 * DESCRIPTION: The function will initialize the CPPI
81 *****************************************************************************/
82int netapip_initCppi(void* rmClientServiceHandle)
83{
84
85 int32_t result;
86 Cppi_GlobalConfigParams netapi_cppiGblCfgParams;
87 Cppi_StartCfg netapi_cppiStartCfg;
88
89 memset(&netapi_cppiStartCfg, 0, sizeof(Cppi_StartCfg));
90 netapi_cppiGblCfgParams = cppiGblCfgParams;
91
92 /* PASS CPDMA regs */
93 netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA].gblCfgRegs =
94 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->passCfgVaddr,
95 CSL_NETCP_CFG_REGS,
96 (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA].gblCfgRegs);
97
98 netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA].txChRegs =
99 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->passCfgVaddr,
100 CSL_NETCP_CFG_REGS,
101 (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA].txChRegs);
102
103 netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA].rxChRegs =
104 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->passCfgVaddr,
105 CSL_NETCP_CFG_REGS,
106 (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA].rxChRegs);
107
108 netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA].txSchedRegs =
109 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->passCfgVaddr,
110 CSL_NETCP_CFG_REGS,
111 (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA].txSchedRegs);
112
113 netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA].rxFlowRegs =
114 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->passCfgVaddr,
115 CSL_NETCP_CFG_REGS,
116 (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_PASS_CPDMA].rxFlowRegs);
117
118 /* QMSS CPDMA regs */
119 netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].gblCfgRegs =
120 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
121 CSL_QMSS_CFG_BASE,
122 (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].gblCfgRegs);
123
124 netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].txChRegs =
125 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
126 CSL_QMSS_CFG_BASE,
127 (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].txChRegs);
128
129 netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].rxChRegs =
130 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
131 CSL_QMSS_CFG_BASE,
132 (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].rxChRegs);
133
134 netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].txSchedRegs =
135 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
136 CSL_QMSS_CFG_BASE,
137 (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].txSchedRegs);
138
139 netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].rxFlowRegs =
140 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
141 CSL_QMSS_CFG_BASE,
142 (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].rxFlowRegs);
143
144 result = Cppi_init (&netapi_cppiGblCfgParams);
145 if (result != CPPI_SOK) {
146 return (-1);
147 }
148
149 if (rmClientServiceHandle)
150 {
151 netapi_cppiStartCfg.rmServiceHandle = rmClientServiceHandle;
152 Cppi_startCfg(&netapi_cppiStartCfg);
153 }
154
155 return (1);
156}
157
158/*****************************************************************************
159 * FUNCTION PURPOSE: Global Initialization of Queue Manager. Once Per System
160 *****************************************************************************
161 * DESCRIPTION: The function will initialize the Queue Manager
162 *****************************************************************************/
163int netapip_initQm(int max_descriptors, void* rmClientServiceHandle)
164{
165 Qmss_InitCfg qmssInitConfig;
166 int32_t result;
167 Qmss_GlobalConfigParams netapi_qmssGblCfgParams;
168 uint32_t count;
169
170 memset (&qmssInitConfig, 0, sizeof (Qmss_InitCfg));
171
172 /* Use Internal Linking RAM for optimal performance */
173 qmssInitConfig.linkingRAM0Base = 0;
174 qmssInitConfig.linkingRAM0Size = 0;
175 qmssInitConfig.linkingRAM1Base = 0;
176 qmssInitConfig.maxDescNum = max_descriptors;
177 qmssInitConfig.qmssHwStatus = QMSS_HW_INIT_COMPLETE;
178
179 netapi_qmssGblCfgParams = qmssGblCfgParams;
180
181 /* Convert address to Virtual address */
182 for(count=0;count < netapi_qmssGblCfgParams.maxQueMgrGroups;count++)
183 {
184 netapi_qmssGblCfgParams.groupRegs[count].qmConfigReg =
185 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
186 CSL_QMSS_CFG_BASE,
187 (uint32_t)netapi_qmssGblCfgParams.groupRegs[count].qmConfigReg);
188
189 netapi_qmssGblCfgParams.groupRegs[count].qmDescReg =
190 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
191 CSL_QMSS_CFG_BASE,
192 (uint32_t)netapi_qmssGblCfgParams.groupRegs[count].qmDescReg);
193
194 netapi_qmssGblCfgParams.groupRegs[count].qmQueMgmtReg =
195 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
196 CSL_QMSS_CFG_BASE,
197 (uint32_t)netapi_qmssGblCfgParams.groupRegs[count].qmQueMgmtReg);
198
199 netapi_qmssGblCfgParams.groupRegs[count].qmQueMgmtProxyReg =
200 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
201 CSL_QMSS_CFG_BASE,
202 (uint32_t)netapi_qmssGblCfgParams.groupRegs[count].qmQueMgmtProxyReg);
203
204 netapi_qmssGblCfgParams.groupRegs[count].qmQueStatReg =
205 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
206 CSL_QMSS_CFG_BASE,
207 (uint32_t)netapi_qmssGblCfgParams.groupRegs[count].qmQueStatReg);
208
209 netapi_qmssGblCfgParams.groupRegs[count].qmStatusRAM =
210 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
211 CSL_QMSS_CFG_BASE,
212 (uint32_t)netapi_qmssGblCfgParams.groupRegs[count].qmStatusRAM);
213
214 netapi_qmssGblCfgParams.groupRegs[count].qmQueMgmtDataReg =
215 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssDataVaddr,
216 CSL_QMSS_DATA_BASE,
217 (uint32_t)netapi_qmssGblCfgParams.groupRegs[count].qmQueMgmtDataReg);
218
219 netapi_qmssGblCfgParams.groupRegs[count].qmQueMgmtProxyDataReg = NULL;
220 }
221
222 for(count=0;count < QMSS_MAX_INTD;count++)
223 {
224 netapi_qmssGblCfgParams.regs.qmQueIntdReg[count] =
225 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
226 CSL_QMSS_CFG_BASE,
227 (uint32_t)netapi_qmssGblCfgParams.regs.qmQueIntdReg[count]);
228 }
229
230 for(count=0;count < QMSS_MAX_PDSP;count++)
231 {
232 netapi_qmssGblCfgParams.regs.qmPdspCmdReg[count] =
233 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
234 CSL_QMSS_CFG_BASE,
235 (uint32_t)netapi_qmssGblCfgParams.regs.qmPdspCmdReg[count]);
236
237 netapi_qmssGblCfgParams.regs.qmPdspCtrlReg[count] =
238 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
239 CSL_QMSS_CFG_BASE,
240 (uint32_t)netapi_qmssGblCfgParams.regs.qmPdspCtrlReg[count]);
241
242 netapi_qmssGblCfgParams.regs.qmPdspIRamReg[count] =
243 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
244 CSL_QMSS_CFG_BASE,
245 (uint32_t)netapi_qmssGblCfgParams.regs.qmPdspIRamReg[count]);
246 }
247
248 netapi_qmssGblCfgParams.regs.qmLinkingRAMReg =
249 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
250 CSL_QMSS_CFG_BASE,
251 (uint32_t)netapi_qmssGblCfgParams.regs.qmLinkingRAMReg);
252
253 netapi_qmssGblCfgParams.regs.qmBaseAddr =
254 NETAPI_GET_REG_VADDR(netapi_VM_VirtAddr->qmssCfgVaddr,
255 CSL_QMSS_CFG_BASE,
256 (uint32_t)netapi_qmssGblCfgParams.regs.qmBaseAddr);
257
258 if (rmClientServiceHandle)
259 netapi_qmssGblCfgParams.qmRmServiceHandle = rmClientServiceHandle;
260
261 result = Qmss_init (&qmssInitConfig, &netapi_qmssGblCfgParams);
262 if (result != QMSS_SOK)
263 {
264 return (nwal_FALSE);
265 }
266 return 1;
267}
diff --git a/ti/runtime/netapi/src/pktio.c b/ti/runtime/netapi/src/pktio.c
new file mode 100755
index 0000000..64e38e9
--- /dev/null
+++ b/ti/runtime/netapi/src/pktio.c
@@ -0,0 +1,1310 @@
1/*********************************
2 * FILE: pktio.c
3 * PURPOSE: pktio library for NETAPI
4 **************************************************************
5 * FILE: pktio.c
6 *
7 * DESCRIPTION: pktio source file for user space transport
8 * library
9 *
10 * REVISION HISTORY: rev 0.0.1
11 *
12 * Copyright (c) Texas Instruments Incorporated 2010-2011
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
42 ********************************/
43
44#include <unistd.h>
45#include "netapi.h"
46#include "pktio.h"
47#include <ti/csl/csl_qm_queue.h>
48
49
50
51/*This defines the maximum number of packets to receive in one pktio poll */
52#define PKTIO_MAX_RECV (TUNE_NETAPI_MAX_BURST_RCV)
53
54extern NETAPI_SHM_T* pnetapiShm;
55
56
57/* Utilites*/
58static PKTIO_HANDLE_T * netapip_pktioGetFreeChannelSlot(NETAPI_T n)
59{
60 NETAPI_HANDLE_T *p_handle;
61 PKTIO_HANDLE_T ** pp = (PKTIO_HANDLE_T **) netapi_get_pktio_list(n);
62 int i;
63 p_handle = (NETAPI_HANDLE_T*) n;
64 p_handle->spinLock.lock(&pnetapiShm->netapi_pktio_lock);
65 for(i=0;i<NETAPI_MAX_PKTIO;i++)
66 {
67 if (pp[i]->inuse != PKTIO_INUSE)
68 {
69 pp[i]->inuse = PKTIO_INUSE;
70 p_handle->spinLock.unlock(&pnetapiShm->netapi_pktio_lock);
71 return pp[i];
72 }
73 }
74 p_handle->spinLock.unlock(&pnetapiShm->netapi_pktio_lock);
75 return NULL;
76}
77
78
79/*Optimized send functions */
80
81
82/********************************************************************
83 * FUNCTION PURPOSE: Send packet via low level NWAL API's
84 * with updates for L4 checksum,ESP Crypto and outgoing EMAC port
85 * to NetCP command.
86 ********************************************************************
87 * DESCRIPTION: Send packet via low level NWAL API's
88 * with updates for L4 checksum,ESP Crypto and outgoing EMAC port
89 * to NetCP command.
90 ********************************************************************/
91static int netapip_pktioSendL4CkSumCryptPort(struct PKTIO_HANDLE_tag * pp,
92 Ti_Pkt *pkt,
93 PKTIO_METADATA_T *m,
94 int * err)
95{
96 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
97 nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
98 Cppi_HostDesc* pPloadDesc;
99 uint32_t swInfo0, swInfo1;
100
101 NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
102 if (netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
103 {
104 nwal_mCmdSetL4CkSumCrypPort(pkt,
105 &p->tx_psCmdInfo,
106 pTxPktInfo->l4OffBytes,
107 pTxPktInfo->ploadLen + pTxPktInfo->l4HdrLen,
108 pTxPktInfo->pseudoHdrChecksum,
109 pTxPktInfo->saOffBytes,
110 pTxPktInfo->saPayloadLen,
111 swInfo0,
112 swInfo1,
113 pTxPktInfo->enetPort);
114
115 pPloadDesc = Pktlib_getDescFromPacket(pkt);
116 pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
117 Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
118 pPloadDesc,
119 NWAL_DESC_SIZE);
120 }
121 else
122 {
123 *err=NETAPI_ERR_BAD_INPUT;
124 return -1;
125 }
126
127 return 1;
128}
129
130/********************************************************************
131 * FUNCTION PURPOSE: Send packet via low level NWAL API's
132 * with updates for ESP Crypto and outgoing EMAC port
133 * to NetCP command.
134 ********************************************************************
135 * DESCRIPTION: Send packet via low level NWAL API's
136 * with updates for ESP Crypto and outgoing EMAC port
137 * to NetCP command.
138 ********************************************************************/
139static int netapip_pktioSendCryptPort(struct PKTIO_HANDLE_tag * pp,
140 Ti_Pkt *pkt,
141 PKTIO_METADATA_T *m,
142 int * err)
143{
144 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
145 nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
146 Cppi_HostDesc* pPloadDesc;
147 uint32_t swInfo0, swInfo1;
148
149
150 NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
151
152 if (netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
153 {
154 nwal_mCmdSetCrypPort(pkt,
155 &p->tx_psCmdInfo,
156 pTxPktInfo->saOffBytes,
157 pTxPktInfo->saPayloadLen,
158 swInfo0,
159 swInfo1,
160 pTxPktInfo->enetPort);
161
162 pPloadDesc = Pktlib_getDescFromPacket(pkt);
163 pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
164 Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
165 pPloadDesc,
166 NWAL_DESC_SIZE);
167 }
168 else
169 {
170 *err=NETAPI_ERR_BAD_INPUT;
171 return -1;
172 }
173
174 return 1;
175}
176
177
178/********************************************************************
179 * FUNCTION PURPOSE: Send packet via low level NWAL API's
180 * with updates for L3 checksum, ESP Crypto and outgoing EMAC port
181 * to NetCP command.
182 ********************************************************************
183 * DESCRIPTION: Send packet via low level NWAL API's
184 * with updates for L3 checksum, ESP Crypto and outgoing EMAC port
185 * to NetCP command.
186 ********************************************************************/
187static int netapip_pktioSendL3CkSumCryptPort(struct PKTIO_HANDLE_tag * pp,
188 Ti_Pkt *pkt,
189 PKTIO_METADATA_T *m,
190 int * err)
191{
192 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
193 nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
194 Cppi_HostDesc* pPloadDesc;
195 uint32_t swInfo0, swInfo1;
196
197 NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
198
199
200 if (netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
201 {
202 nwal_mCmdSetL3CkSumCrypPort(pkt,
203 &p->tx_psCmdInfo,
204 pTxPktInfo->saOffBytes,
205 pTxPktInfo->saPayloadLen,
206 swInfo0,
207 swInfo1,
208 pTxPktInfo->enetPort);
209
210 pPloadDesc = Pktlib_getDescFromPacket(pkt);
211 pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
212
213 Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
214 pPloadDesc,
215 NWAL_DESC_SIZE);
216 }
217 else
218 {
219 *err=NETAPI_ERR_BAD_INPUT;
220 return -1;
221 }
222
223 return 1;
224}
225
226
227
228
229
230
231/********************************************************************
232 * FUNCTION PURPOSE: Send packet via low level NWAL API's
233 * with updates for L4 checksum,AH Crypto and outgoing EMAC port
234 * to NetCP command.
235 *******************************************************************
236 * DESCRIPTION: Send packet via low level NWAL API's
237 * with updates for L4 checksum,AH Crypto and outgoing EMAC port
238 * to NetCP command.
239 ********************************************************************/
240static int netapip_pktioSendL4CkSumAHCryptPort(struct PKTIO_HANDLE_tag * pp,
241 Ti_Pkt *pkt,
242 PKTIO_METADATA_T *m,
243 int * err)
244{
245 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
246 nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
247 Cppi_HostDesc* pPloadDesc;
248 uint32_t swInfo0, swInfo1;
249
250 NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
251
252 if (netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
253 {
254 nwal_mCmdSetL4CkSumAHCrypPort(pkt,
255 &p->tx_psCmdInfo,
256 pTxPktInfo->l4OffBytes,
257 pTxPktInfo->ploadLen + pTxPktInfo->l4HdrLen,
258 pTxPktInfo->pseudoHdrChecksum,
259 pTxPktInfo->saOffBytes,
260 pTxPktInfo->saPayloadLen,
261 swInfo0,
262 swInfo1,
263 pTxPktInfo->saAhIcvOffBytes,
264 pTxPktInfo->saAhMacSize,
265 pTxPktInfo->enetPort);
266
267 pPloadDesc = Pktlib_getDescFromPacket(pkt);
268 pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
269
270 Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
271 pPloadDesc,
272 NWAL_DESC_SIZE);
273 }
274 else
275 {
276 *err=NETAPI_ERR_BAD_INPUT;
277 return -1;
278 }
279
280 return 1;
281}
282
283/********************************************************************
284 * FUNCTION PURPOSE: Send packet via low level NWAL API's
285 * with updates for AH Crypto and outgoing EMAC port
286 * to NetCP command.
287 ********************************************************************
288 * DESCRIPTION: Send packet via low level NWAL API's
289 * with updates for AH Crypto and outgoing EMAC port
290 * to NetCP command.
291 ********************************************************************/
292static int netapip_pktioSendAHCryptPort(struct PKTIO_HANDLE_tag * pp,
293 Ti_Pkt *pkt,
294 PKTIO_METADATA_T *m,
295 int * err)
296{
297 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
298 nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
299 Cppi_HostDesc* pPloadDesc;
300 uint32_t swInfo0, swInfo1;
301
302
303 NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
304
305 if (netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
306 {
307 nwal_mCmdSetAHCrypPort(pkt,
308 &p->tx_psCmdInfo,
309 pTxPktInfo->saOffBytes,
310 pTxPktInfo->saPayloadLen,
311 swInfo0,
312 swInfo1,
313 pTxPktInfo->saAhIcvOffBytes,
314 pTxPktInfo->saAhMacSize,
315 pTxPktInfo->enetPort);
316
317 pPloadDesc = Pktlib_getDescFromPacket(pkt);
318 pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
319
320 Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
321 pPloadDesc,
322 NWAL_DESC_SIZE);
323 }
324 else
325 {
326 *err= NETAPI_ERR_BAD_INPUT;
327 return -1;
328 }
329 return 1;
330}
331
332
333
334/********************************************************************
335 * FUNCTION PURPOSE: Send packet via low level NWAL API's
336 * with updates for L4 checksum and outgoing EMAC port
337 * to NetCP command.
338 *******************************************************************
339 * DESCRIPTION: Send packet via low level NWAL API's
340 * with updates for L4 checksum and outgoing EMAC port
341 * to NetCP command.
342 ********************************************************************/
343static int netapip_pktioSendL4CkSumPort(struct PKTIO_HANDLE_tag * pp,
344 Ti_Pkt *pkt,
345 PKTIO_METADATA_T *m,
346 int * err)
347{
348
349 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
350 nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
351 Cppi_HostDesc* pPloadDesc;
352
353 nwal_mCmdSetL4CkSumPort(pkt,
354 &p->tx_psCmdInfo,
355 pTxPktInfo->l4OffBytes,
356 pTxPktInfo->l4HdrLen + pTxPktInfo->ploadLen,
357 pTxPktInfo->pseudoHdrChecksum,
358 pTxPktInfo->enetPort);
359
360 pPloadDesc = Pktlib_getDescFromPacket(pkt);
361 pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
362 Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
363 pPloadDesc,
364 NWAL_DESC_SIZE);
365 return 1;
366}
367
368
369/********************************************************************
370 * FUNCTION PURPOSE: Send packet via low level NWAL API's
371 * with updates for outgoing EMAC port to NetCP command.
372 ********************************************************************
373 * DESCRIPTION: Send packet via low level NWAL API's
374 * with updates for outgoing EMAC port to NetCP command.
375 ********************************************************************/
376static int netapip_pktioSendPort(struct PKTIO_HANDLE_tag * pp,
377 Ti_Pkt *pkt,
378 PKTIO_METADATA_T *m,
379 int * err)
380{
381 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
382 nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
383 Cppi_HostDesc* pPloadDesc;
384
385 nwal_mCmdSetPort(pkt,
386 &p->tx_psCmdInfo,
387 pTxPktInfo->enetPort);
388 pPloadDesc = Pktlib_getDescFromPacket(pkt);
389 pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
390
391 Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
392 pPloadDesc,
393 NWAL_DESC_SIZE);
394 *err = NETAPI_ERR_OK;
395 return 1;
396}
397
398/********************************************************************
399 * FUNCTION PURPOSE: Send packet via IPC queue
400 ********************************************************************
401 * DESCRIPTION: Send packet via IPC queue
402 ********************************************************************/
403static int netapip_pktioSendIpc(struct PKTIO_HANDLE_tag * pp,
404 Ti_Pkt *pkt,
405 PKTIO_METADATA_T *m,
406 int * err)
407{
408 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
409 Qmss_queuePushDesc (p->q, (void*)pkt);
410 *err = NETAPI_ERR_OK;
411 return 1;
412}
413/********************************************************************
414 * FUNCTION PURPOSE: Send packet to NETCP via NWAL
415 ********************************************************************
416 * DESCRIPTION: Send packet to NETCP via NWAL
417 ********************************************************************/
418static int netapip_pktioSendNwal(struct PKTIO_HANDLE_tag * pp,
419 Ti_Pkt *pkt,
420 PKTIO_METADATA_T *m,
421 int * err)
422{
423 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
424 nwalTxPktInfo_t * pPktInfo=m->u.tx_meta;
425 nwal_RetValue res;
426 pPktInfo->pPkt = pkt;
427 res=nwal_send(p->nwalInstanceHandle, m->sa_handle,pPktInfo);
428 if (res != nwal_OK)
429 {
430 *err = NETAPI_ERR_NWAL_TX_ERR -res;
431 return -1;
432 }
433 *err=NETAPI_ERR_OK;
434 return 1;
435}
436
437
438
439
440/********************************************************************
441 * FUNCTION PURPOSE: Send packet to SA via NWAL
442 ********************************************************************
443 * DESCRIPTION: Send packet to NETCP via NWAL for side band data mode
444 * channel via NWAL
445 ********************************************************************/
446static int netapip_pktioSendSb(struct PKTIO_HANDLE_tag * pp,
447 Ti_Pkt *pkt,
448 PKTIO_METADATA_T *m,
449 int * err)
450{
451
452 nwal_RetValue nwalRetVal;
453 nwalTxDmPSCmdInfo_t *dmPSCmdInfo;
454 nwalLocCxtInfo_t nwalLocCxt;
455 Cppi_HostDesc* pPloadDesc;
456 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
457 nwalLocCxtInfo_t info;
458 void* virtAddr = NULL;
459 nwalDmTxPayloadInfo_t *pPktInfoSB = m->u.tx_sb_meta;
460
461 NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
462
463 dmPSCmdInfo = netapip_netcpCfgGetSaSBInfo(&netapi_get_global()->nwal_context, tunnel_id);
464 if (dmPSCmdInfo)
465 {
466 nwalRetVal = nwal_getLocCxtInfo(pktio_mGetNwalInstance(p),&info);
467 if(nwalRetVal == nwal_OK)
468 {
469 dmPSCmdInfo->rxSbSaQ = info.rxSbSaQ;
470 }
471 else
472 {
473 *err=NETAPI_ERR_BAD_INPUT;
474 return -1;
475 }
476 nwal_mCmdDMUpdate(pkt,
477 dmPSCmdInfo,
478 pPktInfoSB->appCtxId,
479 pPktInfoSB->encOffset,
480 pPktInfoSB->encSize,
481 pPktInfoSB->pEncIV,
482 pPktInfoSB->authOffset,
483 pPktInfoSB->authSize,
484 pPktInfoSB->pAuthIV,
485 pPktInfoSB->aadSize,
486 pPktInfoSB->pAad);
487 pPloadDesc = Pktlib_getDescFromPacket(pkt);
488
489#if 0
490 printf("netapip_pktioSendSb: dumping descriptor begin\n");
491 PKTIO_dump_buf_32bit(pPloadDesc, 128);
492 printf("netapip_pktioSendSb: dumping descriptor end\n");
493
494 virtAddr= hplib_mVMPhyToVirt(pPloadDesc->softwareInfo1);
495
496 printf("phy Addr: 0x%x\n", pPloadDesc->softwareInfo1);
497 printf("virtAddr: 0x%x\n", virtAddr);
498
499 printf("netapip_pktioSendSb: dumping security context begin\n");
500 PKTIO_dump_buf((uint8_t*)virtAddr, 128);
501 PKTIO_dump_buf((uint8_t*)virtAddr+128, 128);
502 printf("netapip_pktioSendSb: dumping security context end\n");
503#endif
504
505
506 pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
507
508 Qmss_queuePushDescSizeRaw(dmPSCmdInfo->txQueue,
509 pPloadDesc,
510 NWAL_DESC_SIZE);
511 }
512 else
513 {
514 *err=NETAPI_ERR_BAD_INPUT;
515 return -1;
516 }
517
518 return 1;
519}
520
521/********************************************************************
522 * FUNCTION PURPOSE: Send packet via infrastructure DMA channel
523 ********************************************************************
524 * DESCRIPTION: Send packet via infrastructure DMA channel
525 ********************************************************************/
526static int netapip_pktioSendIfdma(struct PKTIO_HANDLE_tag * pp,
527 Ti_Pkt *pkt,
528 PKTIO_METADATA_T *m,
529 int * err)
530{
531 Cppi_DescTag tag={0};
532 Cppi_HostDesc* pPloadDesc;
533 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
534 *err=0;
535 tag.srcTagLo = m->u.tx_ifdma_dest;
536 Cppi_setTag (Cppi_DescType_HOST, (Cppi_Desc *)pkt, &tag);
537 pPloadDesc = Pktlib_getDescFromPacket(pkt);
538 pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
539
540 Qmss_queuePushDescSizeRaw(p->q,
541 pPloadDesc,
542 NWAL_DESC_SIZE);
543 return 1;
544}
545
546
547
548/********************************************************************
549 * FUNCTION PURPOSE: Stub function for send, do nothing.
550 ********************************************************************
551 * DESCRIPTION: Stub function for send, do nothing.
552 ********************************************************************/
553static int netapip_pktioSendDummy(struct PKTIO_HANDLE_tag * p,
554 Ti_Pkt *pkt,
555 PKTIO_METADATA_T *m,
556 int * err)
557{
558 *err = NETAPI_ERR_BAD_INPUT;
559 return -1;
560}
561
562/********************************************************************
563 * FUNCTION PURPOSE: Stub function for poll, do nothing.
564 ********************************************************************
565 * DESCRIPTION: Stub function for send, do nothing.
566 ********************************************************************/
567static int netapip_pktioPollDummy(struct PKTIO_HANDLE_tag * p,
568 PKTIO_POLL_T * p_poll_cfg,
569 int * err)
570{
571 *err= NETAPI_ERR_BAD_INPUT;
572 return 0;
573}
574
575/********************************************************************
576 * FUNCTION PURPOSE: Poll IPC queue
577 ********************************************************************
578 * DESCRIPTION: Poll IPC queue
579 ********************************************************************/
580static int netapip_pktioPollIpc(struct PKTIO_HANDLE_tag * pp,
581 PKTIO_POLL_T * p_poll_cfg,
582 int * err)
583{
584 Ti_Pkt * pkt_list[PKTIO_MAX_RECV];
585 PKTIO_METADATA_T meta_s[PKTIO_MAX_RECV];
586 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
587 int r=0;
588 int n;
589 Ti_Pkt * temp;
590 *err=0;
591 n= (p->max_n< PKTIO_MAX_RECV) ? p->max_n : PKTIO_MAX_RECV;
592 for(r=0;r<n;r++)
593 {
594
595 temp=(Ti_Pkt*)(Cppi_HostDesc*)QMSS_DESC_PTR(Qmss_queuePop(p->q));
596
597 if(!temp) break;
598 /* process meta data */
599 pkt_list[r]= temp;
600 meta_s[r].flags1=0x1;
601 }
602 if (r)
603 {
604 p->cb((struct PKTIO_HANDLE_tag *)p, pkt_list, &meta_s[0], r, 0LL);
605 }
606 return r;
607}
608
609/********************************************************************
610 * FUNCTION PURPOSE: Poll nwal data queues for pkts from netcp
611 ********************************************************************
612 * DESCRIPTION: Poll nwal data queues for pkts from netcp
613 ********************************************************************/
614static int netapip_pktioPollNwal(struct PKTIO_HANDLE_tag * pp,
615 PKTIO_POLL_T * p_poll_cfg,
616 int * err)
617{
618 int r=0;
619 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
620 *err=0;
621 /* Poll for common L2/L3 packets and L4 class pkts (todo-> only do L4 if classifiers are
622 set. optimizaion maybe? */
623 r=nwal_pollPkt(p->nwalInstanceHandle,
624 p->poll_flags,
625 (uint32_t) p,
626 p->max_n,
627 QMSS_PARAM_NOT_SPECIFIED,
628 (void*) NULL);
629 return r;
630}
631/********************************************************************
632 * FUNCTION PURPOSE: Poll nwal sideband queues for pkts from SA
633 ********************************************************************
634 * DESCRIPTION: Poll nwal sideband queues for pkts from SA
635 ********************************************************************/
636static int netapip_pktioPollSb(struct PKTIO_HANDLE_tag * pp,
637 PKTIO_POLL_T * p_poll_cfg,
638 int * err)
639{
640 int r=0;
641 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
642 *err=0;
643 r=nwal_pollDm(p->nwalInstanceHandle,
644 nwal_POLL_DM_DEF_SB_SA_Q,
645 (uint32_t) p,
646 p->max_n,
647 QMSS_PARAM_NOT_SPECIFIED,
648 (void *) NULL);
649 return r;
650}
651
652/********************************************************************
653 * FUNCTION PURPOSE: Poll application provided NETCP RX queue
654 ********************************************************************
655 * DESCRIPTION: Poll application provided NETCP RX queue
656 ********************************************************************/
657static int netapip_pktioPollNwalAdj(struct PKTIO_HANDLE_tag * pp,
658 PKTIO_POLL_T * p_poll_cfg,
659 int * err)
660{
661 int r=0;
662 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
663 *err=0;
664 /* Poll for common L2/L3 packets and L4 class pkts (todo-> only do L4 if classifiers are
665 set. optimizaion maybe? */
666 r=nwal_pollPkt(p->nwalInstanceHandle,
667 nwal_POLL_APP_MANAGED_PKT_Q,
668 (uint32_t) p,
669 p->max_n,
670 p->q,
671 (void *) NULL);
672
673 return r;
674}
675
676/*************************************************************************
677 * FUNCTION PURPOSE: Poll application defined sideband queues for packets
678 * from SA
679 ************************************************************************
680 * DESCRIPTION: Poll application defined sideband queues for packets
681 * from SA
682 *************************************************************************/
683static int netapip_pktioPollSbAdj(struct PKTIO_HANDLE_tag * pp,
684 PKTIO_POLL_T * p_poll_cfg,
685 int * err)
686{
687 int r=0;
688 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
689 *err=0;
690 r=nwal_pollDm(p->nwalInstanceHandle,
691 nwal_POLL_DM_APP_MANAGED_Q,
692 (uint32_t) p,
693 p->max_n,
694 p->q,
695 (void *) NULL);
696 return r;
697}
698
699/*-----------------------MAIN API----------------------*/
700/********************************************************************
701 * FUNCTION PURPOSE: API creates a NETAPI PKTIO channel
702 ********************************************************************
703 * DESCRIPTION: API creates a NETAPI PKTIO channel
704 ********************************************************************/
705PKTIO_HANDLE_T * netapi_pktioCreate(NETAPI_T n,
706 char * name,
707 PKTIO_CB cb,
708 PKTIO_CFG_T * p_cfg,
709 int * err)
710{
711 int r = 0;
712 PKTIO_HANDLE_T *p;
713 uint8_t isAllocated;
714
715 *err=0;
716 int q = QMSS_PARAM_NOT_SPECIFIED;
717
718 int qtype = Qmss_QueueType_GENERAL_PURPOSE_QUEUE;
719
720 if(p_cfg == NULL)
721 {
722 *err = NETAPI_ERR_BAD_INPUT;
723 return NULL;
724 }
725 /* over-ride only for Qmss_QueueType_GIC400_QUEUE */
726 if (p_cfg->queueType == Qmss_QueueType_GIC400_QUEUE)
727 qtype = p_cfg->queueType;
728
729 if ((!p_cfg)||(!name)) {*err=NETAPI_ERR_BAD_INPUT; return NULL;}
730 if ((p_cfg->flags2 & PKTIO_PKT) &&(p_cfg->flags1& PKTIO_TX)) { *err=NETAPI_ERR_BAD_INPUT; return NULL;};
731 if ((p_cfg->flags2 & PKTIO_SB) &&(p_cfg->flags1& PKTIO_TX)) { *err=NETAPI_ERR_BAD_INPUT; return NULL;};
732
733 /* get a free channel handle */
734 p=netapip_pktioGetFreeChannelSlot(n);
735
736 if (!p) {*err = NETAPI_ERR_NOMEM; return (p); }
737
738 p->back = n;
739 p->cb = cb;
740 p->max_n = p_cfg->max_n;
741 p->_poll=netapip_pktioPollDummy;
742 p->_send=netapip_pktioSendDummy;
743 memcpy((char *)&p->cfg, (char*) p_cfg, sizeof(PKTIO_CFG_T));
744
745 if (p_cfg->qnum!=PKTIO_Q_ANY)
746 {
747 q= p_cfg->qnum;
748 }
749 /* special case for infrastructure dma channels */
750 if (p_cfg->flags2 & PKTIO_IFDMA)
751 {
752 qtype=Qmss_QueueType_INFRASTRUCTURE_QUEUE;
753 }
754
755
756 /* create a general queue */
757 p->q = Qmss_queueOpen(qtype,
758 q,
759 &isAllocated);
760 if (p->q < 0)
761 {
762 p->inuse=0;
763 *err= NETAPI_ERR_QLLD; ///queue lld error
764 return NULL;
765 }
766
767 p->qInfo = Qmss_getQueueNumber(p->q);
768
769 if (p_cfg->flags2 & PKTIO_PKT)
770 {
771 p->use_nwal = PKTIO_4_ADJ_NWAL;
772 p->_poll=netapip_pktioPollNwalAdj;
773 p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
774 }
775 else if (p_cfg->flags2 & PKTIO_SB)
776 {
777 p->use_nwal = PKTIO_4_ADJ_SB;
778 p->_poll=netapip_pktioPollSbAdj;
779 p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
780 }
781 else if (p_cfg->flags2 & PKTIO_IFDMA)
782 {
783 p->use_nwal = 0;
784 p->_send = netapip_pktioSendIfdma;
785 p->cfg.flags1=PKTIO_TX;
786 r= netapip_pktioCreateIFDMA(p); //we create the IF DMA channel here
787 if (r<0)
788 {
789 //trouble -> couldn't set up DMA
790 //close queue and return failure
791 if (p->q)
792 {
793 Qmss_queueClose(p->q);
794 }
795 p->inuse=0;
796 *err= NETAPI_ERR_QLLD; ///queue lld error TODO: fix error code
797 return NULL;
798 }
799 }
800 else
801 {
802 p->use_nwal=0;
803 if (p_cfg->flags1& PKTIO_TX) p->_send=netapip_pktioSendIpc;
804 if (p_cfg->flags1& PKTIO_RX) p->_poll=netapip_pktioPollIpc;
805 }
806
807 /* save name */
808 strncpy(p->name,name,
809 strlen(name)<PKTIO_MAX_NAME ?
810 strlen(name):PKTIO_MAX_NAME);
811
812 /* add name, qnum to global name list */
813 if ((strcmp(name,NETCP_RX)) &&
814 (strcmp(name,NETCP_TX)) &&
815 (strcmp(name,NETCP_SB_RX)) &&
816 (strcmp(name,NETCP_SB_TX)) &&
817 (p_cfg->flags1 & PKTIO_GLOBAL))
818 {
819 //todo: make sure this succeeds..
820 hplib_mSpinLockLock(&pnetapiShm->netapi_pktio_lock);
821 r=netapip_addGlobalPktio(n, name, &p->qInfo);
822 hplib_mSpinLockUnlock(&pnetapiShm->netapi_pktio_lock);
823 }
824
825 ((NETAPI_HANDLE_T *)n )->n_pktios+=1;
826 return p;
827}
828
829/********************************************************************
830 * FUNCTION PURPOSE: API opens an existing NETAPI PKTIO channel
831 ********************************************************************
832 * DESCRIPTION: API opens an existing NETAPI PKTIO channel
833 ********************************************************************/
834PKTIO_HANDLE_T * netapi_pktioOpen(NETAPI_T n,
835 char *name,
836 PKTIO_CB cb,
837 PKTIO_CFG_T * p_cfg,
838 int * err)
839{
840 int r=0;
841 PKTIO_HANDLE_T *p, *p2;
842 uint8_t isAllocated;
843 *err=0;
844 Qmss_Queue *p_qnum;
845 int qtype=Qmss_QueueType_GENERAL_PURPOSE_QUEUE;
846
847
848 if ((!p_cfg)||(!name)) {*err=NETAPI_ERR_BAD_INPUT; return NULL;}
849
850 /* get a free channel handle */
851
852 p=netapip_pktioGetFreeChannelSlot(n);
853
854 if (!p) {*err = NETAPI_ERR_NOMEM; return (p); }
855 ((NETAPI_HANDLE_T *)n)->n_pktios+=1;
856
857 p->inuse= PKTIO_INUSE;
858 p->back = n;
859 p->cb = cb;
860 p->max_n = p_cfg->max_n;
861 p->_poll=netapip_pktioPollDummy;
862 p->_send=netapip_pktioSendDummy;
863 memcpy((char *)&p->cfg, (char*) p_cfg, sizeof(PKTIO_CFG_T));
864
865 /* special handling of NETCP_RX, NETCP_TX */
866 if( (!strcmp(name, NETCP_RX)) || (!strcmp(name,NETCP_TX)) )
867 {
868 /* these have already been opened internally, so don't search in global list */
869 p->use_nwal = PKTIO_DEF_NWAL;
870 p->q = 0;
871 p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
872 if (!strcmp(name,NETCP_RX))
873 {
874 p->_poll=netapip_pktioPollNwal;
875 p->poll_flags= nwal_POLL_DEFAULT_GLOB_PKT_Q|
876 nwal_POLL_DEFAULT_PER_PROC_PKT_Q;
877 }
878 if (!strcmp(name,NETCP_TX))
879 {
880 p->_send=netapip_pktioSendNwal;
881 }
882 }
883 else if( (!strcmp(name, NETCP_SB_RX)) || (!strcmp(name,NETCP_SB_TX)) )
884 {
885 /* these have already been opened internally, so don't search in global list */
886 p->use_nwal = PKTIO_DEF_SB;
887 p->q = 0;
888 p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
889 if (!strcmp(name,NETCP_SB_RX)) p->_poll=netapip_pktioPollSb;
890 if (!strcmp(name,NETCP_SB_TX)) p->_send=netapip_pktioSendSb;
891 }
892 else
893 {
894 hplib_mSpinLockLock(&pnetapiShm->netapi_pktio_lock);
895 /* Find queue in global list
896 Note names like "QUEUE:%d" or IFDMA:%d cause general purpose or
897 IFDMA queues of that number to be opened */
898 if (p_cfg->flags2 & PKTIO_IFDMA)
899 {
900 qtype= Qmss_QueueType_INFRASTRUCTURE_QUEUE;
901 }
902
903 hplib_mSpinLockUnlock(&pnetapiShm->netapi_pktio_lock);
904 p_qnum = netapip_findGlobalPktio(n, name);
905
906 if (!p_qnum )
907 {
908 p->inuse=0;
909 *err= NETAPI_ERR_NOTFOUND; ///queue lld error
910 return NULL;
911 }
912
913 /* open a general queue (for now). use qnum that was just found */
914 p->q = Qmss_queueOpen(qtype,
915 (p_qnum->qNum&0xfff)| (p_qnum->qMgr<<12),
916 &isAllocated);
917 if (p->q == (Qmss_QueueHnd) NULL)
918 {
919 p->inuse=0;
920 *err= NETAPI_ERR_QLLD; ///queue lld error
921 return NULL;
922 }
923 p->qInfo = Qmss_getQueueNumber(p->q);
924 if (p_cfg->flags2 & PKTIO_PKT)
925 {
926 p->use_nwal = PKTIO_4_ADJ_NWAL; //additonal RX q for nwal
927 p->_poll = netapip_pktioPollNwalAdj;
928 p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
929 }
930 else if (p_cfg->flags2 & PKTIO_SB)
931 {
932 p->use_nwal = PKTIO_4_ADJ_SB; //additional RX q for sideband with NWAL
933 p->_poll = netapip_pktioPollSbAdj;
934 p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
935 }
936 else if (p_cfg->flags2 & PKTIO_IFDMA)
937 {
938 p->_send= netapip_pktioSendIfdma;
939 p->use_nwal = 0;
940 }
941 else
942 {
943 p->use_nwal=0; //not handled by nwal
944 if (p_cfg->flags1& PKTIO_TX) p->_send=netapip_pktioSendIpc;
945 if (p_cfg->flags1& PKTIO_RX) p->_poll=netapip_pktioPollIpc;
946 }
947 }
948
949 /* save name */
950 strncpy(p->name,name,
951 strlen(name)<PKTIO_MAX_NAME ?
952 strlen(name):PKTIO_MAX_NAME);
953
954 return p;
955}
956
957/********************************************************************
958 * FUNCTION PURPOSE: API controls an existing NETAPI PKTIO channel
959 ********************************************************************
960 * DESCRIPTION: API controls an existing NETAPI PKTIO channel
961 ********************************************************************/
962void netapi_pktioControl(PKTIO_HANDLE_T * p,
963 PKTIO_CB cb,
964 PKTIO_CFG_T * p_cfg,
965 PKTIO_CONTROL_T * p_control,
966 int *err)
967{
968 nwal_RetValue nwalRetVal;
969 if (!p)
970 {
971 *err= NETAPI_ERR_BAD_INPUT;
972 return;
973 }
974 if (cb)
975 {
976 p->cb = cb;
977 }
978 if (p_control)
979 {
980 /* todo: check for validity, eg don't allow clear of NETCP TX queues */
981 /* todo: implement divert */
982 switch(p_control->op)
983 {
984 //clear the queue
985 case(PKTIO_SET_POLL_FLAGS):
986 p->poll_flags=p_control->poll_flags;
987 break;
988 case(PKTIO_CLEAR):
989 netapip_zapQ(p->q);
990 break;
991 case (PKTIO_UPDATE_FAST_PATH):
992 if (p_cfg)
993 {
994 nwalRetVal = nwal_initPSCmdInfo(p->nwalInstanceHandle,
995 p_cfg->fast_path_cfg.txPktInfo,
996 &p->tx_psCmdInfo);
997 if (nwalRetVal == nwal_OK)
998 {
999 switch (p_cfg->fast_path_cfg.fp_send_option)
1000 {
1001 case (PKTIO_FP_ESP_L4CKSUM_PORT):
1002 p->_send = netapip_pktioSendL4CkSumCryptPort;
1003 break;
1004 case (PKTIO_FP_AH_L4CKSUM_PORT):
1005 p->_send = netapip_pktioSendL4CkSumAHCryptPort;
1006 break;
1007 case (PKTIO_FP_ESP_PORT):
1008 p->_send = netapip_pktioSendCryptPort;
1009 break;
1010 case (PKTIO_FP_ESP_L3CKSUM_PORT):
1011 p->_send = netapip_pktioSendL3CkSumCryptPort;
1012 break;
1013 case (PKTIO_FP_AH_PORT):
1014 p->_send = netapip_pktioSendAHCryptPort;
1015 break;
1016 case (PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT):
1017 p->_send = netapip_pktioSendPort;
1018 break;
1019 case (PKTIO_FP_L4CKSUM_PORT):
1020 p->_send = netapip_pktioSendL4CkSumPort;
1021 break;
1022 default:
1023 break;
1024 }
1025 }
1026 else
1027 {
1028 *err = NETAPI_ERR_BAD_INPUT;
1029 }
1030 }
1031 else
1032 {
1033 *err = NETAPI_ERR_BAD_INPUT;
1034 }
1035 break;
1036 case (PKTIO_UPDATE_MAX_PKTS_PER_POLL):
1037 if (p_cfg)
1038 {
1039 p->max_n = p_cfg->max_n;
1040 }
1041 else
1042 {
1043 *err = NETAPI_ERR_BAD_INPUT;
1044 }
1045 break;
1046 case(PKTIO_DIVERT):
1047 default:
1048 *err= NETAPI_ERR_NOT_IMPLEMENTED;
1049 break;
1050 }
1051 }
1052
1053 *err = NETAPI_ERR_OK;
1054 return;
1055}
1056/********************************************************************
1057 * FUNCTION PURPOSE: API closes a NETAPI PKTIO channel
1058 ********************************************************************
1059 * DESCRIPTION: API closes a NETAPI PKTIO channel
1060 ********************************************************************/
1061void netapi_pktioClose(PKTIO_HANDLE_T * p,
1062 int * err)
1063{
1064 if(!p)
1065 {
1066 *err=1;
1067 return;
1068 }
1069 *err=0;
1070 if (p->q)
1071 {
1072 Qmss_queueClose(p->q);
1073 }
1074 p->q=-1;
1075 p->inuse=0;
1076 ((NETAPI_HANDLE_T *)p->back)->n_pktios-=1;
1077 return;
1078}
1079
1080/********************************************************************
1081 * FUNCTION PURPOSE: API deletes a NETAPI PKTIO channel
1082 ********************************************************************
1083 * DESCRIPTION: API deletes a NETAPI PKTIO channel
1084 ********************************************************************/
1085void netapi_pktioDelete(PKTIO_HANDLE_T * p,
1086 int * err)
1087{
1088 if(!p)
1089 {
1090 *err=1;
1091 return;
1092 }
1093 *err=0;
1094 if (p->cfg.flags2 & PKTIO_IFDMA)
1095 {
1096 netapip_pktioDeleteIFDMA(p);
1097 }
1098
1099 /* remove from name list */
1100 hplib_mSpinLockLock(&pnetapiShm->netapi_pktio_lock);
1101 netapi_del_global_pktio((NETAPI_HANDLE_T *)p->back, p->name);
1102 hplib_mSpinLockUnlock(&pnetapiShm->netapi_pktio_lock);
1103 if((p->use_nwal != PKTIO_DEF_NWAL) && (p->use_nwal != PKTIO_DEF_SB))
1104 {
1105 netapip_zapQ(p->q); //since we are deleting, zap the queue
1106 Qmss_queueClose(p->q);
1107 }
1108 p->q=-1;
1109 p->inuse=0;
1110 ((NETAPI_HANDLE_T *)p->back)->n_pktios-=1;
1111 return ;
1112}
1113
1114/********************************************************************
1115 * FUNCTION PURPOSE: API sends multiple packets to a NETAPI PKTIO channel
1116 ********************************************************************
1117 * DESCRIPTION: API sends multiple packets to a NETAPI PKTIO channel
1118 ********************************************************************/
1119int netapi_pktioSendMulti(PKTIO_HANDLE_T * p,
1120 Ti_Pkt * pkt[],
1121 PKTIO_METADATA_T * m[],
1122 int np,
1123 int* err)
1124{
1125 int r=0;
1126 for(r=0;r<np;r++)
1127 {
1128 p->_send((struct PKTIO_HANDLE_tag *)p, (Ti_Pkt *)pkt, (PKTIO_METADATA_T *)m, err);
1129 }
1130 return r;
1131}
1132
1133/********************************************************************
1134 * FUNCTION PURPOSE: API polls all NETAPI PKTIO channels associated with NETAPI_T
1135 * instance for received packets
1136 ********************************************************************
1137 * DESCRIPTION: API polls all NETAPI PKTIO channels associated with NETAPI_T
1138 * instance for received packets
1139 ********************************************************************/
1140int netapi_pktioPollAll(NETAPI_T handle,
1141 PKTIO_POLL_T * p_poll_cfg,
1142 int *err)
1143{
1144 int i=0;
1145 int r=0;
1146 int err2;
1147 int cnt=0;
1148 PKTIO_HANDLE_T **pp =( PKTIO_HANDLE_T **) netapi_get_pktio_list(handle);
1149
1150 *err=0;
1151 for(i=0;i<NETAPI_MAX_PKTIO && cnt < ((NETAPI_HANDLE_T *)handle)->n_pktios;i++)
1152 {
1153 if (pp[i]->inuse != PKTIO_INUSE) continue;
1154 if(!(pp[i]->cfg.flags1&PKTIO_RX)) continue;
1155 r+=netapi_pktioPoll(pp[i], p_poll_cfg, &err2); cnt+=1;
1156 if (err2) { *err = err2; break;}
1157 }
1158 return r;
1159
1160}
1161
1162/********************************************************************
1163 * FUNCTION PURPOSE: Internal function to delete a PKTIO infrastructure DMA channel
1164 ********************************************************************
1165 * DESCRIPTION: Internal function to delete a PKTIO infrastructure DMA channel
1166 ********************************************************************/
1167int netapip_pktioDeleteIFDMA(PKTIO_HANDLE_T *p)
1168{
1169 Cppi_channelDisable (p->txChHnd);
1170 Cppi_channelDisable (p->rxChHnd);
1171 Cppi_channelClose(p->txChHnd);
1172 Cppi_channelClose(p->rxChHnd);
1173 Cppi_close(p->cppiHnd);
1174 return 1;
1175}
1176
1177/********************************************************************
1178 * FUNCTION PURPOSE: Internal function to create a PKTIO infrastructure DMA channel
1179 ********************************************************************
1180 * DESCRIPTION: Internal function to create a PKTIO infrastructure DMA channel
1181 * for infrastructure DMQ queue
1182 ********************************************************************/
1183int netapip_pktioCreateIFDMA(PKTIO_HANDLE_T * p )
1184{
1185 int dmaChan = p->qInfo.qNum - QMSS_INFRASTRUCTURE_QUEUE_BASE;
1186 unsigned char isAllocated;
1187 Cppi_TxChInitCfg txChCfg;
1188 Cppi_RxChInitCfg rxChCfg;
1189 Cppi_CpDmaInitCfg cpdmaCfg;
1190
1191 /* Set up QMSS CPDMA configuration */
1192 memset ((void *) &cpdmaCfg, 0, sizeof (Cppi_CpDmaInitCfg));
1193 cpdmaCfg.dmaNum = Cppi_CpDma_QMSS_CPDMA;
1194
1195 /* Open QMSS CPDMA */
1196 p->cppiHnd = (Cppi_Handle) Cppi_open (&cpdmaCfg);
1197 if (p->cppiHnd == NULL)
1198 {
1199 return -1;
1200 }
1201
1202 /* Set up Tx Channel parameters */
1203 memset ((void *) &txChCfg, 0, sizeof (Cppi_TxChInitCfg));
1204 txChCfg.channelNum = dmaChan;
1205 txChCfg.priority = 0;
1206 txChCfg.filterEPIB = 0;
1207 txChCfg.filterPS = 0;
1208 txChCfg.aifMonoMode = 0;
1209 txChCfg.txEnable = Cppi_ChState_CHANNEL_DISABLE;
1210
1211 /* Open Tx Channel */
1212 p->txChHnd = (Cppi_ChHnd) Cppi_txChannelOpen (p->cppiHnd, &txChCfg, &isAllocated);
1213 if (p->txChHnd == NULL)
1214 {
1215 Cppi_close(p->cppiHnd);
1216 return -1;
1217 }
1218
1219 /* Set up Rx Channel parameters */
1220 memset ((void *) &rxChCfg, 0, sizeof (Cppi_RxChInitCfg));
1221 rxChCfg.channelNum = dmaChan;
1222 rxChCfg.rxEnable = Cppi_ChState_CHANNEL_DISABLE;
1223
1224 /* Open Rx Channel */
1225 p->rxChHnd = (Cppi_ChHnd) Cppi_rxChannelOpen (p->cppiHnd, &rxChCfg, &isAllocated);
1226 if (p->rxChHnd == NULL)
1227 {
1228 Cppi_channelClose(p->txChHnd);
1229 Cppi_close(p->cppiHnd);
1230 return -1;
1231 }
1232 if (Cppi_channelEnable (p->txChHnd) != CPPI_SOK)
1233 {
1234 Cppi_channelClose(p->txChHnd);
1235 Cppi_channelClose(p->rxChHnd);
1236 Cppi_close(p->cppiHnd);
1237 return -1;
1238 }
1239
1240 /* Enable receive channel */
1241 if (Cppi_channelEnable (p->rxChHnd) != CPPI_SOK)
1242 {
1243 Cppi_channelDisable (p->txChHnd);
1244 Cppi_channelClose(p->txChHnd);
1245 Cppi_channelClose(p->rxChHnd);
1246 Cppi_close(p->cppiHnd);
1247 return -1;
1248 }
1249 return 1;
1250}
1251
1252/**********************************************************************
1253 * FUNCTION PURPOSE: Internal Callback that gets registered with NWAL for packet reception
1254 **********************************************************************
1255 * DESCRIPTION: Callback that gets registered with NWAL for packet reception
1256 * appCookie is the pktio handle
1257 **********************************************************************/
1258void netapip_pktioNWALRxPktCallback(uint32_t appCookie,
1259 uint16_t numPkts,
1260 nwalRxPktInfo_t* pPktInfo,
1261 uint64_t timestamp,
1262 nwal_Bool_t* pFreePkt)
1263{
1264 PKTIO_HANDLE_T * p = (PKTIO_HANDLE_T *) appCookie;
1265 int r=0;
1266 int n;
1267 Ti_Pkt * pkt_list[PKTIO_MAX_RECV];
1268 PKTIO_METADATA_T meta_s[PKTIO_MAX_RECV];
1269
1270 for(r=0;r<numPkts;r++)
1271 {
1272 pkt_list[r] = pPktInfo[r].pPkt;
1273 meta_s[r].flags1 = PKTIO_META_RX;
1274 meta_s[r].u.rx_meta = &pPktInfo[r];
1275 }
1276 if (r)
1277 {
1278 p->cb((struct PKTIO_HANDLE_tag *)p, pkt_list, &meta_s[0], r, timestamp);
1279 }
1280}
1281
1282
1283/**********************************************************************
1284 * FUNCTION PURPOSE: Internal Callback that gets registered with NWAL for crypto reception
1285 **********************************************************************
1286 * DESCRIPTION: Callback that gets registered with NWAL for crypto reception,
1287 * appCookie is the pktio handle
1288 **********************************************************************/
1289void netapip_pktioNWALSBPktCallback(uint32_t appCookie,
1290 uint16_t numPkts,
1291 nwalDmRxPayloadInfo_t* pDmRxPktInfo,
1292 nwal_Bool_t* pFreePkt)
1293{
1294 PKTIO_HANDLE_T * p = (PKTIO_HANDLE_T *) appCookie;
1295 int r=0;
1296 int n;
1297 Ti_Pkt * pkt_list[PKTIO_MAX_RECV];
1298 PKTIO_METADATA_T meta_s[PKTIO_MAX_RECV];
1299 for(r=0;r<numPkts;r++)
1300 {
1301 pkt_list[r] = pDmRxPktInfo[r].pPkt;
1302 meta_s[r].flags1 = PKTIO_META_SB_RX;
1303 meta_s[r].u.rx_sb_meta = &pDmRxPktInfo[r];
1304 }
1305 if (r)
1306 {
1307 p->cb((struct PKTIO_HANDLE_tag *)p, pkt_list, &meta_s[0], r, 0LL);
1308 }
1309}
1310
diff --git a/ti/runtime/netapi/src/pktio.c~ b/ti/runtime/netapi/src/pktio.c~
new file mode 100755
index 0000000..6b69469
--- /dev/null
+++ b/ti/runtime/netapi/src/pktio.c~
@@ -0,0 +1,1323 @@
1/*********************************
2 * FILE: pktio.c
3 * PURPOSE: pktio library for NETAPI
4 **************************************************************
5 * FILE: pktio.c
6 *
7 * DESCRIPTION: pktio source file for user space transport
8 * library
9 *
10 * REVISION HISTORY: rev 0.0.1
11 *
12 * Copyright (c) Texas Instruments Incorporated 2010-2011
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
42 ********************************/
43
44#include <unistd.h>
45#include "netapi.h"
46#include "pktio.h"
47#include <ti/csl/csl_qm_queue.h>
48
49
50
51/*This defines the maximum number of packets to receive in one pktio poll */
52#define PKTIO_MAX_RECV (TUNE_NETAPI_MAX_BURST_RCV)
53
54extern NETAPI_SHM_T* pnetapiShm;
55
56
57/* Utilites*/
58static PKTIO_HANDLE_T * netapip_pktioGetFreeChannelSlot(NETAPI_T n)
59{
60 NETAPI_HANDLE_T *p_handle;
61 PKTIO_HANDLE_T ** pp = (PKTIO_HANDLE_T **) netapi_get_pktio_list(n);
62 int i;
63 p_handle = (NETAPI_HANDLE_T*) n;
64 p_handle->spinLock.lock(&pnetapiShm->netapi_pktio_lock);
65 for(i=0;i<NETAPI_MAX_PKTIO;i++)
66 {
67 if (pp[i]->inuse != PKTIO_INUSE)
68 {
69 pp[i]->inuse = PKTIO_INUSE;
70 p_handle->spinLock.unlock(&pnetapiShm->netapi_pktio_lock);
71 return pp[i];
72 }
73 }
74 p_handle->spinLock.unlock(&pnetapiShm->netapi_pktio_lock);
75 return NULL;
76}
77
78
79/*Optimized send functions */
80
81
82/********************************************************************
83 * FUNCTION PURPOSE: Send packet via low level NWAL API's
84 * with updates for L4 checksum,ESP Crypto and outgoing EMAC port
85 * to NetCP command.
86 ********************************************************************
87 * DESCRIPTION: Send packet via low level NWAL API's
88 * with updates for L4 checksum,ESP Crypto and outgoing EMAC port
89 * to NetCP command.
90 ********************************************************************/
91static int netapip_pktioSendL4CkSumCryptPort(struct PKTIO_HANDLE_tag * pp,
92 Ti_Pkt *pkt,
93 PKTIO_METADATA_T *m,
94 int * err)
95{
96 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
97 nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
98 Cppi_HostDesc* pPloadDesc;
99 uint32_t swInfo0, swInfo1;
100
101 NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
102 //printf("netapip_pktioSendL4CkSumCryptPort\n");
103 if (netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
104 {
105 nwal_mCmdSetL4CkSumCrypPort(pkt,
106 &p->tx_psCmdInfo,
107 pTxPktInfo->l4OffBytes,
108 pTxPktInfo->ploadLen + pTxPktInfo->l4HdrLen,
109 pTxPktInfo->pseudoHdrChecksum,
110 pTxPktInfo->saOffBytes,
111 pTxPktInfo->saPayloadLen,
112 swInfo0,
113 swInfo1,
114 pTxPktInfo->enetPort);
115
116 pPloadDesc = Pktlib_getDescFromPacket(pkt);
117 pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
118 Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
119 pPloadDesc,
120 NWAL_DESC_SIZE);
121 }
122 else
123 {
124 *err=NETAPI_ERR_BAD_INPUT;
125 return -1;
126 }
127
128 return 1;
129}
130
131/********************************************************************
132 * FUNCTION PURPOSE: Send packet via low level NWAL API's
133 * with updates for ESP Crypto and outgoing EMAC port
134 * to NetCP command.
135 ********************************************************************
136 * DESCRIPTION: Send packet via low level NWAL API's
137 * with updates for ESP Crypto and outgoing EMAC port
138 * to NetCP command.
139 ********************************************************************/
140static int netapip_pktioSendCryptPort(struct PKTIO_HANDLE_tag * pp,
141 Ti_Pkt *pkt,
142 PKTIO_METADATA_T *m,
143 int * err)
144{
145 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
146 nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
147 Cppi_HostDesc* pPloadDesc;
148 uint32_t swInfo0, swInfo1;
149
150 printf("netapip_pktioSendCryptPort\n");
151
152 NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
153
154 if (netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
155 {
156 nwal_mCmdSetCrypPort(pkt,
157 &p->tx_psCmdInfo,
158 pTxPktInfo->saOffBytes,
159 pTxPktInfo->saPayloadLen,
160 swInfo0,
161 swInfo1,
162 pTxPktInfo->enetPort);
163
164 pPloadDesc = Pktlib_getDescFromPacket(pkt);
165 pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
166 Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
167 pPloadDesc,
168 NWAL_DESC_SIZE);
169 }
170 else
171 {
172 *err=NETAPI_ERR_BAD_INPUT;
173 return -1;
174 }
175
176 return 1;
177}
178
179
180/********************************************************************
181 * FUNCTION PURPOSE: Send packet via low level NWAL API's
182 * with updates for L3 checksum, ESP Crypto and outgoing EMAC port
183 * to NetCP command.
184 ********************************************************************
185 * DESCRIPTION: Send packet via low level NWAL API's
186 * with updates for L3 checksum, ESP Crypto and outgoing EMAC port
187 * to NetCP command.
188 ********************************************************************/
189static int netapip_pktioSendL3CkSumCryptPort(struct PKTIO_HANDLE_tag * pp,
190 Ti_Pkt *pkt,
191 PKTIO_METADATA_T *m,
192 int * err)
193{
194 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
195 nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
196 Cppi_HostDesc* pPloadDesc;
197 uint32_t swInfo0, swInfo1;
198
199 NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
200
201 printf("netapip_pktioSendL3CkSumCryptPort\n");
202
203 if (netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
204 {
205 nwal_mCmdSetL3CkSumCrypPort(pkt,
206 &p->tx_psCmdInfo,
207 pTxPktInfo->saOffBytes,
208 pTxPktInfo->saPayloadLen,
209 swInfo0,
210 swInfo1,
211 pTxPktInfo->enetPort);
212
213 pPloadDesc = Pktlib_getDescFromPacket(pkt);
214 pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
215
216 Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
217 pPloadDesc,
218 NWAL_DESC_SIZE);
219 }
220 else
221 {
222 *err=NETAPI_ERR_BAD_INPUT;
223 return -1;
224 }
225
226 return 1;
227}
228
229
230
231
232
233
234/********************************************************************
235 * FUNCTION PURPOSE: Send packet via low level NWAL API's
236 * with updates for L4 checksum,AH Crypto and outgoing EMAC port
237 * to NetCP command.
238 *******************************************************************
239 * DESCRIPTION: Send packet via low level NWAL API's
240 * with updates for L4 checksum,AH Crypto and outgoing EMAC port
241 * to NetCP command.
242 ********************************************************************/
243static int netapip_pktioSendL4CkSumAHCryptPort(struct PKTIO_HANDLE_tag * pp,
244 Ti_Pkt *pkt,
245 PKTIO_METADATA_T *m,
246 int * err)
247{
248 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
249 nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
250 Cppi_HostDesc* pPloadDesc;
251 uint32_t swInfo0, swInfo1;
252
253 NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
254 printf("netapip_pktioSendL4CkSumAHCryptPort\n");
255
256 if (netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
257 {
258 nwal_mCmdSetL4CkSumAHCrypPort(pkt,
259 &p->tx_psCmdInfo,
260 pTxPktInfo->l4OffBytes,
261 pTxPktInfo->ploadLen + pTxPktInfo->l4HdrLen,
262 pTxPktInfo->pseudoHdrChecksum,
263 pTxPktInfo->saOffBytes,
264 pTxPktInfo->saPayloadLen,
265 swInfo0,
266 swInfo1,
267 pTxPktInfo->saAhIcvOffBytes,
268 pTxPktInfo->saAhMacSize,
269 pTxPktInfo->enetPort);
270
271 pPloadDesc = Pktlib_getDescFromPacket(pkt);
272 pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
273
274 Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
275 pPloadDesc,
276 NWAL_DESC_SIZE);
277 }
278 else
279 {
280 *err=NETAPI_ERR_BAD_INPUT;
281 return -1;
282 }
283
284 return 1;
285}
286
287/********************************************************************
288 * FUNCTION PURPOSE: Send packet via low level NWAL API's
289 * with updates for AH Crypto and outgoing EMAC port
290 * to NetCP command.
291 ********************************************************************
292 * DESCRIPTION: Send packet via low level NWAL API's
293 * with updates for AH Crypto and outgoing EMAC port
294 * to NetCP command.
295 ********************************************************************/
296static int netapip_pktioSendAHCryptPort(struct PKTIO_HANDLE_tag * pp,
297 Ti_Pkt *pkt,
298 PKTIO_METADATA_T *m,
299 int * err)
300{
301 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
302 nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
303 Cppi_HostDesc* pPloadDesc;
304 uint32_t swInfo0, swInfo1;
305
306 printf("netapip_pktioSendAHCryptPort\n");
307
308 NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
309
310 if (netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
311 {
312 nwal_mCmdSetAHCrypPort(pkt,
313 &p->tx_psCmdInfo,
314 pTxPktInfo->saOffBytes,
315 pTxPktInfo->saPayloadLen,
316 swInfo0,
317 swInfo1,
318 pTxPktInfo->saAhIcvOffBytes,
319 pTxPktInfo->saAhMacSize,
320 pTxPktInfo->enetPort);
321
322 pPloadDesc = Pktlib_getDescFromPacket(pkt);
323 pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
324
325 Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
326 pPloadDesc,
327 NWAL_DESC_SIZE);
328 }
329 else
330 {
331 *err= NETAPI_ERR_BAD_INPUT;
332 return -1;
333 }
334 return NETAPI_TRUE;
335}
336
337
338
339/********************************************************************
340 * FUNCTION PURPOSE: Send packet via low level NWAL API's
341 * with updates for L4 checksum and outgoing EMAC port
342 * to NetCP command.
343 *******************************************************************
344 * DESCRIPTION: Send packet via low level NWAL API's
345 * with updates for L4 checksum and outgoing EMAC port
346 * to NetCP command.
347 ********************************************************************/
348static int netapip_pktioSendL4CkSumPort(struct PKTIO_HANDLE_tag * pp,
349 Ti_Pkt *pkt,
350 PKTIO_METADATA_T *m,
351 int * err)
352{
353
354 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
355 nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
356 Cppi_HostDesc* pPloadDesc;
357
358 nwal_mCmdSetL4CkSumPort(pkt,
359 &p->tx_psCmdInfo,
360 pTxPktInfo->l4OffBytes,
361 pTxPktInfo->l4HdrLen + pTxPktInfo->ploadLen,
362 pTxPktInfo->pseudoHdrChecksum,
363 pTxPktInfo->enetPort);
364
365 pPloadDesc = Pktlib_getDescFromPacket(pkt);
366 pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
367 Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
368 pPloadDesc,
369 NWAL_DESC_SIZE);
370 return NETAPI_TRUE;
371}
372
373
374/********************************************************************
375 * FUNCTION PURPOSE: Send packet via low level NWAL API's
376 * with updates for outgoing EMAC port to NetCP command.
377 ********************************************************************
378 * DESCRIPTION: Send packet via low level NWAL API's
379 * with updates for outgoing EMAC port to NetCP command.
380 ********************************************************************/
381static int netapip_pktioSendPort(struct PKTIO_HANDLE_tag * pp,
382 Ti_Pkt *pkt,
383 PKTIO_METADATA_T *m,
384 int * err)
385{
386 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
387 nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
388 Cppi_HostDesc* pPloadDesc;
389
390 printf("netapip_pktioSendPort\n");
391
392
393 nwal_mCmdSetPort(pkt,
394 &p->tx_psCmdInfo,
395 pTxPktInfo->enetPort);
396 pPloadDesc = Pktlib_getDescFromPacket(pkt);
397 pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
398
399 Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
400 pPloadDesc,
401 NWAL_DESC_SIZE);
402 return NETAPI_TRUE;
403}
404
405/********************************************************************
406 * FUNCTION PURPOSE: Send packet via IPC queue
407 ********************************************************************
408 * DESCRIPTION: Send packet via IPC queue
409 ********************************************************************/
410static int netapip_pktioSendIpc(struct PKTIO_HANDLE_tag * pp,
411 Ti_Pkt *pkt,
412 PKTIO_METADATA_T *m,
413 int * err)
414{
415 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
416 err=0;
417 Qmss_queuePushDesc (p->q, (void*)pkt);
418 return 1;
419}
420/********************************************************************
421 * FUNCTION PURPOSE: Send packet to NETCP via NWAL
422 ********************************************************************
423 * DESCRIPTION: Send packet to NETCP via NWAL
424 ********************************************************************/
425static int netapip_pktioSendNwal(struct PKTIO_HANDLE_tag * pp,
426 Ti_Pkt *pkt,
427 PKTIO_METADATA_T *m,
428 int * err)
429{
430 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
431 nwalTxPktInfo_t * pPktInfo=m->u.tx_meta;
432 nwal_RetValue res;
433 *err=0;
434 pPktInfo->pPkt = pkt;
435 res=nwal_send(p->nwalInstanceHandle, m->sa_handle,pPktInfo);
436 if (res != nwal_OK)
437 {
438 *err = NETAPI_ERR_NWAL_TX_ERR -res;
439 return -1;
440 }
441 return 1;
442}
443
444
445
446
447/********************************************************************
448 * FUNCTION PURPOSE: Send packet to SA via NWAL
449 ********************************************************************
450 * DESCRIPTION: Send packet to NETCP via NWAL for side band data mode
451 * channel via NWAL
452 ********************************************************************/
453static int netapip_pktioSendSb(struct PKTIO_HANDLE_tag * pp,
454 Ti_Pkt *pkt,
455 PKTIO_METADATA_T *m,
456 int * err)
457{
458
459 nwal_RetValue nwalRetVal;
460 nwalTxDmPSCmdInfo_t *dmPSCmdInfo;
461 nwalLocCxtInfo_t nwalLocCxt;
462 Cppi_HostDesc* pPloadDesc;
463 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
464 nwalLocCxtInfo_t info;
465 void* virtAddr = NULL;
466 nwalDmTxPayloadInfo_t *pPktInfoSB = m->u.tx_sb_meta;
467
468 NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
469
470 dmPSCmdInfo = netapip_netcpCfgGetSaSBInfo(&netapi_get_global()->nwal_context, tunnel_id);
471 if (dmPSCmdInfo)
472 {
473 nwalRetVal = nwal_getLocCxtInfo(pktio_mGetNwalInstance(p),&info);
474 if(nwalRetVal == nwal_OK)
475 {
476 dmPSCmdInfo->rxSbSaQ = info.rxSbSaQ;
477 }
478 else
479 {
480 *err=NETAPI_ERR_BAD_INPUT;
481 return -1;
482 }
483 nwal_mCmdDMUpdate(pkt,
484 dmPSCmdInfo,
485 pPktInfoSB->appCtxId,
486 pPktInfoSB->encOffset,
487 pPktInfoSB->encSize,
488 pPktInfoSB->pEncIV,
489 pPktInfoSB->authOffset,
490 pPktInfoSB->authSize,
491 pPktInfoSB->pAuthIV,
492 pPktInfoSB->aadSize,
493 pPktInfoSB->pAad);
494 pPloadDesc = Pktlib_getDescFromPacket(pkt);
495
496#if 0
497 printf("netapip_pktioSendSb: dumping descriptor begin\n");
498 PKTIO_dump_buf_32bit(pPloadDesc, 128);
499 printf("netapip_pktioSendSb: dumping descriptor end\n");
500
501 virtAddr= hplib_mVMPhyToVirt(pPloadDesc->softwareInfo1);
502
503 printf("phy Addr: 0x%x\n", pPloadDesc->softwareInfo1);
504 printf("virtAddr: 0x%x\n", virtAddr);
505
506 printf("netapip_pktioSendSb: dumping security context begin\n");
507 PKTIO_dump_buf((uint8_t*)virtAddr, 128);
508 PKTIO_dump_buf((uint8_t*)virtAddr+128, 128);
509 printf("netapip_pktioSendSb: dumping security context end\n");
510#endif
511
512
513 pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
514
515 Qmss_queuePushDescSizeRaw(dmPSCmdInfo->txQueue,
516 pPloadDesc,
517 NWAL_DESC_SIZE);
518 }
519 else
520 {
521 *err=NETAPI_ERR_BAD_INPUT;
522 return -1;
523 }
524
525 return 1;
526}
527
528/********************************************************************
529 * FUNCTION PURPOSE: Send packet via infrastructure DMA channel
530 ********************************************************************
531 * DESCRIPTION: Send packet via infrastructure DMA channel
532 ********************************************************************/
533static int netapip_pktioSendIfdma(struct PKTIO_HANDLE_tag * pp,
534 Ti_Pkt *pkt,
535 PKTIO_METADATA_T *m,
536 int * err)
537{
538 Cppi_DescTag tag={0};
539 Cppi_HostDesc* pPloadDesc;
540 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
541 *err=0;
542 tag.srcTagLo = m->u.tx_ifdma_dest;
543 Cppi_setTag (Cppi_DescType_HOST, (Cppi_Desc *)pkt, &tag);
544 pPloadDesc = Pktlib_getDescFromPacket(pkt);
545 pPloadDesc = Osal_qmssConvertDescVirtToPhy(0, pPloadDesc);
546
547 Qmss_queuePushDescSizeRaw(p->q,
548 pPloadDesc,
549 NWAL_DESC_SIZE);
550 return 1;
551}
552
553
554
555/********************************************************************
556 * FUNCTION PURPOSE: Stub function for send, do nothing.
557 ********************************************************************
558 * DESCRIPTION: Stub function for send, do nothing.
559 ********************************************************************/
560static int netapip_pktioSendDummy(struct PKTIO_HANDLE_tag * p,
561 Ti_Pkt *pkt,
562 PKTIO_METADATA_T *m,
563 int * err)
564{
565 *err = NETAPI_ERR_BAD_INPUT;
566 return -1;
567}
568
569/********************************************************************
570 * FUNCTION PURPOSE: Stub function for poll, do nothing.
571 ********************************************************************
572 * DESCRIPTION: Stub function for send, do nothing.
573 ********************************************************************/
574static int netapip_pktioPollDummy(struct PKTIO_HANDLE_tag * p,
575 PKTIO_POLL_T * p_poll_cfg,
576 int * err)
577{
578 *err= NETAPI_ERR_BAD_INPUT;
579 return 0;
580}
581
582/********************************************************************
583 * FUNCTION PURPOSE: Poll IPC queue
584 ********************************************************************
585 * DESCRIPTION: Poll IPC queue
586 ********************************************************************/
587static int netapip_pktioPollIpc(struct PKTIO_HANDLE_tag * pp,
588 PKTIO_POLL_T * p_poll_cfg,
589 int * err)
590{
591 Ti_Pkt * pkt_list[PKTIO_MAX_RECV];
592 PKTIO_METADATA_T meta_s[PKTIO_MAX_RECV];
593 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
594 int r=0;
595 int n;
596 Ti_Pkt * temp;
597 *err=0;
598 n= (p->max_n< PKTIO_MAX_RECV) ? p->max_n : PKTIO_MAX_RECV;
599 for(r=0;r<n;r++)
600 {
601
602 temp=(Ti_Pkt*)(Cppi_HostDesc*)QMSS_DESC_PTR(Qmss_queuePop(p->q));
603
604 if(!temp) break;
605 /* process meta data */
606 pkt_list[r]= temp;
607 meta_s[r].flags1=0x1;
608 }
609 if (r)
610 {
611 p->cb((struct PKTIO_HANDLE_tag *)p, pkt_list, &meta_s[0], r, 0LL);
612 }
613 return r;
614}
615
616/********************************************************************
617 * FUNCTION PURPOSE: Poll nwal data queues for pkts from netcp
618 ********************************************************************
619 * DESCRIPTION: Poll nwal data queues for pkts from netcp
620 ********************************************************************/
621static int netapip_pktioPollNwal(struct PKTIO_HANDLE_tag * pp,
622 PKTIO_POLL_T * p_poll_cfg,
623 int * err)
624{
625 int r=0;
626 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
627 *err=0;
628 /* Poll for common L2/L3 packets and L4 class pkts (todo-> only do L4 if classifiers are
629 set. optimizaion maybe? */
630 r=nwal_pollPkt(p->nwalInstanceHandle,
631 p->poll_flags,
632 (uint32_t) p,
633 p->max_n,
634 QMSS_PARAM_NOT_SPECIFIED,
635 (void*) NULL);
636 return r;
637}
638/********************************************************************
639 * FUNCTION PURPOSE: Poll nwal sideband queues for pkts from SA
640 ********************************************************************
641 * DESCRIPTION: Poll nwal sideband queues for pkts from SA
642 ********************************************************************/
643static int netapip_pktioPollSb(struct PKTIO_HANDLE_tag * pp,
644 PKTIO_POLL_T * p_poll_cfg,
645 int * err)
646{
647 int r=0;
648 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
649 *err=0;
650 r=nwal_pollDm(p->nwalInstanceHandle,
651 nwal_POLL_DM_DEF_SB_SA_Q,
652 (uint32_t) p,
653 p->max_n,
654 QMSS_PARAM_NOT_SPECIFIED,
655 (void *) NULL);
656 return r;
657}
658
659/********************************************************************
660 * FUNCTION PURPOSE: Poll application provided NETCP RX queue
661 ********************************************************************
662 * DESCRIPTION: Poll application provided NETCP RX queue
663 ********************************************************************/
664static int netapip_pktioPollNwalAdj(struct PKTIO_HANDLE_tag * pp,
665 PKTIO_POLL_T * p_poll_cfg,
666 int * err)
667{
668 int r=0;
669 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
670 *err=0;
671 /* Poll for common L2/L3 packets and L4 class pkts (todo-> only do L4 if classifiers are
672 set. optimizaion maybe? */
673 r=nwal_pollPkt(p->nwalInstanceHandle,
674 nwal_POLL_APP_MANAGED_PKT_Q,
675 (uint32_t) p,
676 p->max_n,
677 p->q,
678 (void *) NULL);
679
680 return r;
681}
682
683/*************************************************************************
684 * FUNCTION PURPOSE: Poll application defined sideband queues for packets
685 * from SA
686 ************************************************************************
687 * DESCRIPTION: Poll application defined sideband queues for packets
688 * from SA
689 *************************************************************************/
690static int netapip_pktioPollSbAdj(struct PKTIO_HANDLE_tag * pp,
691 PKTIO_POLL_T * p_poll_cfg,
692 int * err)
693{
694 int r=0;
695 PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
696 *err=0;
697 r=nwal_pollDm(p->nwalInstanceHandle,
698 nwal_POLL_DM_APP_MANAGED_Q,
699 (uint32_t) p,
700 p->max_n,
701 p->q,
702 (void *) NULL);
703 return r;
704}
705
706/*-----------------------MAIN API----------------------*/
707/********************************************************************
708 * FUNCTION PURPOSE: API creates a NETAPI PKTIO channel
709 ********************************************************************
710 * DESCRIPTION: API creates a NETAPI PKTIO channel
711 ********************************************************************/
712PKTIO_HANDLE_T * netapi_pktioCreate(NETAPI_T n,
713 char * name,
714 PKTIO_CB cb,
715 PKTIO_CFG_T * p_cfg,
716 int * err)
717{
718 int r = 0;
719 PKTIO_HANDLE_T *p;
720 uint8_t isAllocated;
721
722 *err=0;
723 int q = QMSS_PARAM_NOT_SPECIFIED;
724
725 int qtype = Qmss_QueueType_GENERAL_PURPOSE_QUEUE;
726
727 if(p_cfg == NULL)
728 {
729 *err = NETAPI_ERR_BAD_INPUT;
730 return NULL;
731 }
732 /* over-ride only for Qmss_QueueType_GIC400_QUEUE */
733 if (p_cfg->queueType == Qmss_QueueType_GIC400_QUEUE)
734 qtype = p_cfg->queueType;
735
736 if ((!p_cfg)||(!name)) {*err=NETAPI_ERR_BAD_INPUT; return NULL;}
737 if ((p_cfg->flags2 & PKTIO_PKT) &&(p_cfg->flags1& PKTIO_TX)) { *err=NETAPI_ERR_BAD_INPUT; return NULL;};
738 if ((p_cfg->flags2 & PKTIO_SB) &&(p_cfg->flags1& PKTIO_TX)) { *err=NETAPI_ERR_BAD_INPUT; return NULL;};
739
740 /* get a free channel handle */
741 p=netapip_pktioGetFreeChannelSlot(n);
742
743 if (!p) {*err = NETAPI_ERR_NOMEM; return (p); }
744
745 p->back = n;
746 p->cb = cb;
747 p->max_n = p_cfg->max_n;
748 p->_poll=netapip_pktioPollDummy;
749 p->_send=netapip_pktioSendDummy;
750 memcpy((char *)&p->cfg, (char*) p_cfg, sizeof(PKTIO_CFG_T));
751
752 if (p_cfg->qnum!=PKTIO_Q_ANY)
753 {
754 q= p_cfg->qnum;
755 }
756 /* special case for infrastructure dma channels */
757 if (p_cfg->flags2 & PKTIO_IFDMA)
758 {
759 qtype=Qmss_QueueType_INFRASTRUCTURE_QUEUE;
760 }
761
762
763 /* create a general queue */
764 p->q = Qmss_queueOpen(qtype,
765 q,
766 &isAllocated);
767 if (p->q < 0)
768 {
769 netapi_Log("netapi_pktioCreate: queueOpen failed\n");
770 p->inuse=0;
771 *err= NETAPI_ERR_QLLD; ///queue lld error
772 return NULL;
773 }
774
775 p->qInfo = Qmss_getQueueNumber(p->q);
776
777 if (p_cfg->flags2 & PKTIO_PKT)
778 {
779 p->use_nwal = PKTIO_4_ADJ_NWAL;
780 p->_poll=netapip_pktioPollNwalAdj;
781 p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
782 }
783 else if (p_cfg->flags2 & PKTIO_SB)
784 {
785 p->use_nwal = PKTIO_4_ADJ_SB;
786 p->_poll=netapip_pktioPollSbAdj;
787 p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
788 }
789 else if (p_cfg->flags2 & PKTIO_IFDMA)
790 {
791 p->use_nwal = 0;
792 p->_send = netapip_pktioSendIfdma;
793 p->cfg.flags1=PKTIO_TX;
794 r= netapip_pktioCreateIFDMA(p); //we create the IF DMA channel here
795 if (r<0)
796 {
797 //trouble -> couldn't set up DMA
798 //close queue and return failure
799 if (p->q)
800 {
801 Qmss_queueClose(p->q);
802 }
803 p->inuse=0;
804 *err= NETAPI_ERR_QLLD; ///queue lld error TODO: fix error code
805 return NULL;
806 }
807 }
808 else
809 {
810 p->use_nwal=0;
811 if (p_cfg->flags1& PKTIO_TX) p->_send=netapip_pktioSendIpc;
812 if (p_cfg->flags1& PKTIO_RX) p->_poll=netapip_pktioPollIpc;
813 }
814
815 /* save name */
816 strncpy(p->name,name,
817 strlen(name)<PKTIO_MAX_NAME ?
818 strlen(name):PKTIO_MAX_NAME);
819
820 /* add name, qnum to global name list */
821 if ((strcmp(name,NETCP_RX)) &&
822 (strcmp(name,NETCP_TX)) &&
823 (strcmp(name,NETCP_SB_RX)) &&
824 (strcmp(name,NETCP_SB_TX)) &&
825 (p_cfg->flags1 & PKTIO_GLOBAL))
826 {
827 //todo: make sure this succeeds..
828 hplib_mSpinLockLock(&pnetapiShm->netapi_pktio_lock);
829 r=netapip_addGlobalPktio(n, name, &p->qInfo);
830 hplib_mSpinLockUnlock(&pnetapiShm->netapi_pktio_lock);
831 }
832
833 ((NETAPI_HANDLE_T *)n )->n_pktios+=1;
834 return p;
835}
836
837/********************************************************************
838 * FUNCTION PURPOSE: API opens an existing NETAPI PKTIO channel
839 ********************************************************************
840 * DESCRIPTION: API opens an existing NETAPI PKTIO channel
841 ********************************************************************/
842PKTIO_HANDLE_T * netapi_pktioOpen(NETAPI_T n,
843 char *name,
844 PKTIO_CB cb,
845 PKTIO_CFG_T * p_cfg,
846 int * err)
847{
848 int r=0;
849 PKTIO_HANDLE_T *p, *p2;
850 uint8_t isAllocated;
851 *err=0;
852 Qmss_Queue *p_qnum;
853 int qtype=Qmss_QueueType_GENERAL_PURPOSE_QUEUE;
854
855
856 if ((!p_cfg)||(!name)) {*err=NETAPI_ERR_BAD_INPUT; return NULL;}
857
858 /* get a free channel handle */
859
860 p=netapip_pktioGetFreeChannelSlot(n);
861
862 if (!p) {*err = NETAPI_ERR_NOMEM; return (p); }
863 ((NETAPI_HANDLE_T *)n)->n_pktios+=1;
864
865 p->inuse= PKTIO_INUSE;
866 p->back = n;
867 p->cb = cb;
868 p->max_n = p_cfg->max_n;
869 p->_poll=netapip_pktioPollDummy;
870 p->_send=netapip_pktioSendDummy;
871 memcpy((char *)&p->cfg, (char*) p_cfg, sizeof(PKTIO_CFG_T));
872
873 /* special handling of NETCP_RX, NETCP_TX */
874 if( (!strcmp(name, NETCP_RX)) || (!strcmp(name,NETCP_TX)) )
875 {
876 /* these have already been opened internally, so don't search in global list */
877 p->use_nwal = PKTIO_DEF_NWAL;
878 p->q = 0;
879 p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
880 if (!strcmp(name,NETCP_RX))
881 {
882 p->_poll=netapip_pktioPollNwal;
883 p->poll_flags= nwal_POLL_DEFAULT_GLOB_PKT_Q|
884 nwal_POLL_DEFAULT_PER_PROC_PKT_Q;
885 }
886 if (!strcmp(name,NETCP_TX))
887 {
888 p->_send=netapip_pktioSendNwal;
889 }
890 }
891 else if( (!strcmp(name, NETCP_SB_RX)) || (!strcmp(name,NETCP_SB_TX)) )
892 {
893 /* these have already been opened internally, so don't search in global list */
894 p->use_nwal = PKTIO_DEF_SB;
895 p->q = 0;
896 p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
897 if (!strcmp(name,NETCP_SB_RX)) p->_poll=netapip_pktioPollSb;
898 if (!strcmp(name,NETCP_SB_TX)) p->_send=netapip_pktioSendSb;
899 }
900 else
901 {
902 hplib_mSpinLockLock(&pnetapiShm->netapi_pktio_lock);
903 /* Find queue in global list
904 Note names like "QUEUE:%d" or IFDMA:%d cause general purpose or
905 IFDMA queues of that number to be opened */
906 if (p_cfg->flags2 & PKTIO_IFDMA)
907 {
908 qtype= Qmss_QueueType_INFRASTRUCTURE_QUEUE;
909 }
910
911 hplib_mSpinLockUnlock(&pnetapiShm->netapi_pktio_lock);
912 p_qnum = netapip_findGlobalPktio(n, name);
913
914 if (!p_qnum )
915 {
916 netapi_Log("netapi_pktioOpen: can't find %s\n",name);
917 p->inuse=0;
918 *err= NETAPI_ERR_NOTFOUND; ///queue lld error
919 return NULL;
920 }
921
922 /* open a general queue (for now). use qnum that was just found */
923 p->q = Qmss_queueOpen(qtype,
924 p_qnum->qNum , &isAllocated);
925 if (p->q == (Qmss_QueueHnd) NULL)
926 {
927 netapi_Log("netapi_pktioCreate: queueOpen failed\n");
928 p->inuse=0;
929 *err= NETAPI_ERR_QLLD; ///queue lld error
930 return NULL;
931 }
932 p->qInfo = Qmss_getQueueNumber(p->q);
933 netapi_Log("netapi_pktioOpen: queueMgr %d, queueNum; %d\n", p->qInfo.qMgr, p->qInfo.qNum);
934 if (p_cfg->flags2 & PKTIO_PKT)
935 {
936 p->use_nwal = PKTIO_4_ADJ_NWAL; //additonal RX q for nwal
937 p->_poll = netapip_pktioPollNwalAdj;
938 p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
939 netapi_Log("netapi_pktioOpen: nwalInstanceHandle 0x%x\n", p->nwalInstanceHandle);
940 }
941 else if (p_cfg->flags2 & PKTIO_SB)
942 {
943 p->use_nwal = PKTIO_4_ADJ_SB; //additional RX q for sideband with NWAL
944 p->_poll = netapip_pktioPollSbAdj;
945 p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
946 }
947 else if (p_cfg->flags2 & PKTIO_IFDMA)
948 {
949 p->_send= netapip_pktioSendIfdma;
950 p->use_nwal = 0;
951 }
952 else
953 {
954 p->use_nwal=0; //not handled by nwal
955 if (p_cfg->flags1& PKTIO_TX) p->_send=netapip_pktioSendIpc;
956 if (p_cfg->flags1& PKTIO_RX) p->_poll=netapip_pktioPollIpc;
957 }
958 }
959
960 /* save name */
961 strncpy(p->name,name,
962 strlen(name)<PKTIO_MAX_NAME ?
963 strlen(name):PKTIO_MAX_NAME);
964
965 netapi_Log("netapi_pktioOpen: returning with sucess for name %s\n", p->name);
966 return p;
967}
968
969/********************************************************************
970 * FUNCTION PURPOSE: API controls an existing NETAPI PKTIO channel
971 ********************************************************************
972 * DESCRIPTION: API controls an existing NETAPI PKTIO channel
973 ********************************************************************/
974void netapi_pktioControl(PKTIO_HANDLE_T * p,
975 PKTIO_CB cb,
976 PKTIO_CFG_T * p_cfg,
977 PKTIO_CONTROL_T * p_control,
978 int *err)
979{
980 nwal_RetValue nwalRetVal;
981 if (!p)
982 {
983 *err= NETAPI_ERR_BAD_INPUT;
984 return;
985 }
986 if (cb)
987 {
988 p->cb = cb;
989 }
990 if (p_control)
991 {
992 /* todo: check for validity, eg don't allow clear of NETCP TX queues */
993 /* todo: implement divert */
994 switch(p_control->op)
995 {
996 //clear the queue
997 case(PKTIO_SET_POLL_FLAGS):
998 p->poll_flags=p_control->poll_flags;
999 break;
1000 case(PKTIO_CLEAR):
1001 netapip_zapQ(p->q);
1002 break;
1003 case (PKTIO_UPDATE_FAST_PATH):
1004 if (p_cfg)
1005 {
1006 nwalRetVal = nwal_initPSCmdInfo(p->nwalInstanceHandle,
1007 p_cfg->fast_path_cfg.txPktInfo,
1008 &p->tx_psCmdInfo);
1009 if (nwalRetVal == nwal_OK)
1010 {
1011 switch (p_cfg->fast_path_cfg.fp_send_option)
1012 {
1013 case (PKTIO_FP_ESP_L4CKSUM_PORT):
1014 p->_send = netapip_pktioSendL4CkSumCryptPort;
1015 break;
1016 case (PKTIO_FP_AH_L4CKSUM_PORT):
1017 p->_send = netapip_pktioSendL4CkSumAHCryptPort;
1018 break;
1019 case (PKTIO_FP_ESP_PORT):
1020 p->_send = netapip_pktioSendCryptPort;
1021 break;
1022 case (PKTIO_FP_ESP_L3CKSUM_PORT):
1023 p->_send = netapip_pktioSendL3CkSumCryptPort;
1024 break;
1025 case (PKTIO_FP_AH_PORT):
1026 p->_send = netapip_pktioSendAHCryptPort;
1027 break;
1028 case (PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT):
1029 p->_send = netapip_pktioSendPort;
1030 break;
1031 case (PKTIO_FP_L4CKSUM_PORT):
1032 p->_send = netapip_pktioSendL4CkSumPort;
1033 break;
1034 default:
1035 break;
1036 }
1037 }
1038 else
1039 {
1040 *err = NETAPI_ERR_BAD_INPUT;
1041 }
1042 }
1043 else
1044 {
1045 *err = NETAPI_ERR_BAD_INPUT;
1046 }
1047 break;
1048 case (PKTIO_UPDATE_MAX_PKTS_PER_POLL):
1049 if (p_cfg)
1050 {
1051 p->max_n = p_cfg->max_n;
1052 }
1053 else
1054 {
1055 *err = NETAPI_ERR_BAD_INPUT;
1056 }
1057 break;
1058 case(PKTIO_DIVERT):
1059 default:
1060 netapi_Log("netapi_pktioControl: pktio_control op %d not implemented\n",p_control->op);
1061 *err= NETAPI_ERR_NOT_IMPLEMENTED;
1062 break;
1063 }
1064 }
1065
1066 *err = NETAPI_ERR_OK;
1067 return;
1068}
1069/********************************************************************
1070 * FUNCTION PURPOSE: API closes a NETAPI PKTIO channel
1071 ********************************************************************
1072 * DESCRIPTION: API closes a NETAPI PKTIO channel
1073 ********************************************************************/
1074void netapi_pktioClose(PKTIO_HANDLE_T * p,
1075 int * err)
1076{
1077 if(!p)
1078 {
1079 *err=1;
1080 return;
1081 }
1082 *err=0;
1083 if (p->q)
1084 {
1085 Qmss_queueClose(p->q);
1086 }
1087 p->q=-1;
1088 p->inuse=0;
1089 ((NETAPI_HANDLE_T *)p->back)->n_pktios-=1;
1090 return;
1091}
1092
1093/********************************************************************
1094 * FUNCTION PURPOSE: API deletes a NETAPI PKTIO channel
1095 ********************************************************************
1096 * DESCRIPTION: API deletes a NETAPI PKTIO channel
1097 ********************************************************************/
1098void netapi_pktioDelete(PKTIO_HANDLE_T * p,
1099 int * err)
1100{
1101 if(!p)
1102 {
1103 *err=1;
1104 return;
1105 }
1106 *err=0;
1107 if (p->cfg.flags2 & PKTIO_IFDMA)
1108 {
1109 netapip_pktioDeleteIFDMA(p);
1110 }
1111
1112 /* remove from name list */
1113 hplib_mSpinLockLock(&pnetapiShm->netapi_pktio_lock);
1114 netapi_del_global_pktio((NETAPI_HANDLE_T *)p->back, p->name);
1115 hplib_mSpinLockUnlock(&pnetapiShm->netapi_pktio_lock);
1116 if((p->use_nwal != PKTIO_DEF_NWAL) && (p->use_nwal != PKTIO_DEF_SB))
1117 {
1118 netapip_zapQ(p->q); //since we are deleting, zap the queue
1119 Qmss_queueClose(p->q);
1120 }
1121 p->q=-1;
1122 p->inuse=0;
1123 ((NETAPI_HANDLE_T *)p->back)->n_pktios-=1;
1124 return ;
1125}
1126
1127/********************************************************************
1128 * FUNCTION PURPOSE: API sends multiple packets to a NETAPI PKTIO channel
1129 ********************************************************************
1130 * DESCRIPTION: API sends multiple packets to a NETAPI PKTIO channel
1131 ********************************************************************/
1132int netapi_pktioSendMulti(PKTIO_HANDLE_T * p,
1133 Ti_Pkt * pkt[],
1134 PKTIO_METADATA_T * m[],
1135 int np,
1136 int* err)
1137{
1138 int r=0;
1139 for(r=0;r<np;r++)
1140 {
1141 p->_send((struct PKTIO_HANDLE_tag *)p, (Ti_Pkt *)pkt, (PKTIO_METADATA_T *)m, err);
1142 }
1143 return r;
1144}
1145
1146/********************************************************************
1147 * FUNCTION PURPOSE: API polls all NETAPI PKTIO channels associated with NETAPI_T
1148 * instance for received packets
1149 ********************************************************************
1150 * DESCRIPTION: API polls all NETAPI PKTIO channels associated with NETAPI_T
1151 * instance for received packets
1152 ********************************************************************/
1153int netapi_pktioPollAll(NETAPI_T handle,
1154 PKTIO_POLL_T * p_poll_cfg,
1155 int *err)
1156{
1157 int i=0;
1158 int r=0;
1159 int err2;
1160 int cnt=0;
1161 PKTIO_HANDLE_T **pp =( PKTIO_HANDLE_T **) netapi_get_pktio_list(handle);
1162
1163 *err=0;
1164 for(i=0;i<NETAPI_MAX_PKTIO && cnt < ((NETAPI_HANDLE_T *)handle)->n_pktios;i++)
1165 {
1166 if (pp[i]->inuse != PKTIO_INUSE) continue;
1167 if(!(pp[i]->cfg.flags1&PKTIO_RX)) continue;
1168 r+=netapi_pktioPoll(pp[i], p_poll_cfg, &err2); cnt+=1;
1169 if (err2) { *err = err2; break;}
1170 }
1171 return r;
1172
1173}
1174
1175/********************************************************************
1176 * FUNCTION PURPOSE: Internal function to delete a PKTIO infrastructure DMA channel
1177 ********************************************************************
1178 * DESCRIPTION: Internal function to delete a PKTIO infrastructure DMA channel
1179 ********************************************************************/
1180int netapip_pktioDeleteIFDMA(PKTIO_HANDLE_T *p)
1181{
1182 Cppi_channelDisable (p->txChHnd);
1183 Cppi_channelDisable (p->rxChHnd);
1184 Cppi_channelClose(p->txChHnd);
1185 Cppi_channelClose(p->rxChHnd);
1186 Cppi_close(p->cppiHnd);
1187 return 1;
1188}
1189
1190/********************************************************************
1191 * FUNCTION PURPOSE: Internal function to create a PKTIO infrastructure DMA channel
1192 ********************************************************************
1193 * DESCRIPTION: Internal function to create a PKTIO infrastructure DMA channel
1194 * for infrastructure DMQ queue
1195 ********************************************************************/
1196int netapip_pktioCreateIFDMA(PKTIO_HANDLE_T * p )
1197{
1198 int dmaChan = p->qInfo.qNum - QMSS_INFRASTRUCTURE_QUEUE_BASE;
1199 unsigned char isAllocated;
1200 Cppi_TxChInitCfg txChCfg;
1201 Cppi_RxChInitCfg rxChCfg;
1202 Cppi_CpDmaInitCfg cpdmaCfg;
1203
1204 /* Set up QMSS CPDMA configuration */
1205 memset ((void *) &cpdmaCfg, 0, sizeof (Cppi_CpDmaInitCfg));
1206 cpdmaCfg.dmaNum = Cppi_CpDma_QMSS_CPDMA;
1207
1208 /* Open QMSS CPDMA */
1209 p->cppiHnd = (Cppi_Handle) Cppi_open (&cpdmaCfg);
1210 if (p->cppiHnd == NULL)
1211 {
1212 return -1;
1213 }
1214
1215 /* Set up Tx Channel parameters */
1216 memset ((void *) &txChCfg, 0, sizeof (Cppi_TxChInitCfg));
1217 txChCfg.channelNum = dmaChan;
1218 txChCfg.priority = 0;
1219 txChCfg.filterEPIB = 0;
1220 txChCfg.filterPS = 0;
1221 txChCfg.aifMonoMode = 0;
1222 txChCfg.txEnable = Cppi_ChState_CHANNEL_DISABLE;
1223
1224 /* Open Tx Channel */
1225 p->txChHnd = (Cppi_ChHnd) Cppi_txChannelOpen (p->cppiHnd, &txChCfg, &isAllocated);
1226 if (p->txChHnd == NULL)
1227 {
1228 Cppi_close(p->cppiHnd);
1229 return -1;
1230 }
1231
1232 /* Set up Rx Channel parameters */
1233 memset ((void *) &rxChCfg, 0, sizeof (Cppi_RxChInitCfg));
1234 rxChCfg.channelNum = dmaChan;
1235 rxChCfg.rxEnable = Cppi_ChState_CHANNEL_DISABLE;
1236
1237 /* Open Rx Channel */
1238 p->rxChHnd = (Cppi_ChHnd) Cppi_rxChannelOpen (p->cppiHnd, &rxChCfg, &isAllocated);
1239 if (p->rxChHnd == NULL)
1240 {
1241 Cppi_channelClose(p->txChHnd);
1242 Cppi_close(p->cppiHnd);
1243 return -1;
1244 }
1245 if (Cppi_channelEnable (p->txChHnd) != CPPI_SOK)
1246 {
1247 Cppi_channelClose(p->txChHnd);
1248 Cppi_channelClose(p->rxChHnd);
1249 Cppi_close(p->cppiHnd);
1250 return -1;
1251 }
1252
1253 /* Enable receive channel */
1254 if (Cppi_channelEnable (p->rxChHnd) != CPPI_SOK)
1255 {
1256 Cppi_channelDisable (p->txChHnd);
1257 Cppi_channelClose(p->txChHnd);
1258 Cppi_channelClose(p->rxChHnd);
1259 Cppi_close(p->cppiHnd);
1260 return -1;
1261 }
1262 return 1;
1263}
1264
1265/**********************************************************************
1266 * FUNCTION PURPOSE: Internal Callback that gets registered with NWAL for packet reception
1267 **********************************************************************
1268 * DESCRIPTION: Callback that gets registered with NWAL for packet reception
1269 * appCookie is the pktio handle
1270 **********************************************************************/
1271void netapip_pktioNWALRxPktCallback(uint32_t appCookie,
1272 uint16_t numPkts,
1273 nwalRxPktInfo_t* pPktInfo,
1274 uint64_t timestamp,
1275 nwal_Bool_t* pFreePkt)
1276{
1277 PKTIO_HANDLE_T * p = (PKTIO_HANDLE_T *) appCookie;
1278 int r=0;
1279 int n;
1280 Ti_Pkt * pkt_list[PKTIO_MAX_RECV];
1281 PKTIO_METADATA_T meta_s[PKTIO_MAX_RECV];
1282
1283 for(r=0;r<numPkts;r++)
1284 {
1285 pkt_list[r] = pPktInfo[r].pPkt;
1286 meta_s[r].flags1 = PKTIO_META_RX;
1287 meta_s[r].u.rx_meta = &pPktInfo[r];
1288 }
1289 if (r)
1290 {
1291 p->cb((struct PKTIO_HANDLE_tag *)p, pkt_list, &meta_s[0], r, timestamp);
1292 }
1293}
1294
1295
1296/**********************************************************************
1297 * FUNCTION PURPOSE: Internal Callback that gets registered with NWAL for crypto reception
1298 **********************************************************************
1299 * DESCRIPTION: Callback that gets registered with NWAL for crypto reception,
1300 * appCookie is the pktio handle
1301 **********************************************************************/
1302void netapip_pktioNWALSBPktCallback(uint32_t appCookie,
1303 uint16_t numPkts,
1304 nwalDmRxPayloadInfo_t* pDmRxPktInfo,
1305 nwal_Bool_t* pFreePkt)
1306{
1307 PKTIO_HANDLE_T * p = (PKTIO_HANDLE_T *) appCookie;
1308 int r=0;
1309 int n;
1310 Ti_Pkt * pkt_list[PKTIO_MAX_RECV];
1311 PKTIO_METADATA_T meta_s[PKTIO_MAX_RECV];
1312 for(r=0;r<numPkts;r++)
1313 {
1314 pkt_list[r] = pDmRxPktInfo[r].pPkt;
1315 meta_s[r].flags1 = PKTIO_META_SB_RX;
1316 meta_s[r].u.rx_sb_meta = &pDmRxPktInfo[r];
1317 }
1318 if (r)
1319 {
1320 p->cb((struct PKTIO_HANDLE_tag *)p, pkt_list, &meta_s[0], r, 0LL);
1321 }
1322}
1323
diff --git a/ti/runtime/netapi/test/build/Makefile b/ti/runtime/netapi/test/build/Makefile
new file mode 100755
index 0000000..5d4287e
--- /dev/null
+++ b/ti/runtime/netapi/test/build/Makefile
@@ -0,0 +1,139 @@
1#
2empty =
3space =$(empty) $(empty)
4
5export ARMV7OBJDIR ?= ./obj
6export ARMV7BINDIR ?= ./bin
7export ARMV7LIBDIR ?= ./lib
8export ARMV7SALIBDIR ?= ./lib
9export ARMV7LIBDIRLOCAL ?= ../../lib
10# INCLUDE Directories
11#WORKDIR ?= $(TRANS_SDK_INSTALL_PATH)
12SA_INSTALL_PATH ?= $(PDK_INSTALL_PATH)/ti/drv/sa
13QMSS_INC_DIR ?= $(PDK_INSTALL_PATH)/ti/drv/qmss
14CPPI_INC_DIR ?= $(PDK_INSTALL_PATH)/ti/drv/cppi
15RM_INC_DIR ?= $(PDK_INSTALL_PATH)/ti/drv/rm
16HPLIB_INC_DIR ?= $(TRANS_SDK_INSTALL_PATH)
17NETAPI_SRC_DIR ?= $(TRANS_SDK_INSTALL_PATH)/ti/runtime/netapi
18NETAPI_INC_DIR ?= $(TRANS_SDK_INSTALL_PATH)
19NWAL_INSTALL_PATH ?= $(PDK_INSTALL_PATH)/ti/drv/nwal
20PKTLIB_INSTALL_PATH ?= $(PDK_INSTALL_PATH)/ti/runtime/pktlib
21
22# Set NETAPI INSTALL PATH to Transport SDK for default
23
24ifeq ($(CPU), cortex-a8)
25 CFLAGS += -DCORTEX_A8
26endif
27
28NT_RM_OBJS = $(ARMV7OBJDIR)/netapi/utils/sockutils.o $(ARMV7OBJDIR)/netapi/utils/netapi_util_rm.o
29
30TRIE_OBJS=$(ARMV7OBJDIR)/netapi/test/trie.o
31NT_OBJS= $(ARMV7OBJDIR)/netapi/test/net_test_loopback.o $(ARMV7OBJDIR)/netapi/test/stubs.o $(ARMV7OBJDIR)/netapi/test/net_test_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_sa_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_thread_utils.o
32#
33NT_ROUTER_OBJS= $(ARMV7OBJDIR)/netapi/test/net_test_router.o $(ARMV7OBJDIR)/netapi/test/stubs.o $(ARMV7OBJDIR)/netapi/test/net_test_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_sa_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_thread_utils.o
34#
35NT_MAX_PARAMS_OBJS= $(ARMV7OBJDIR)/netapi/test/net_test_max_params.o $(ARMV7OBJDIR)/netapi/test/stubs.o $(ARMV7OBJDIR)/netapi/test/net_test_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_sa_utils.o $(ARMV7OBJDIR)/netapi/test/net_test_thread_utils.o
36#
37
38IFDMA_OBJS= $(ARMV7OBJDIR)/netapi/test/ifdma_test.o
39
40NTB_OBJS= $(ARMV7OBJDIR)/netapi/test/nt_bridge.o $(ARMV7OBJDIR)/netapi/test/fdb.o $(ARMV7OBJDIR)/netapi/test/stubs.o
41
42NT_BENCH_OBJS= $(ARMV7OBJDIR)/netapi/test/net_test_bench.o $(ARMV7OBJDIR)/netapi/test/stubs.o
43
44# Support Libraries used by NETAPI
45QMSS_LIB = -lqmss
46CPPI_LIB = -lcppi
47PKTLIB_LIB = -lpktlib
48HP_LIB = -lhplib_$(DEVICE)
49NETAPI_LIB = -lnetapi_$(DEVICE)
50NWAL_LIB = -lnwalsa_$(DEVICE)
51SA_LIB = -lsa
52RM_LIB = -lrm
53#
54#with security enabled..
55
56
57ifeq ($(DEVICE), k2h)
58PA_LIB = -lpa
59endif
60ifeq ($(DEVICE), k2k)
61PA_LIB = -lpa
62endif
63ifeq ($(DEVICE), k2l)
64PA_LIB = -lpa2
65endif
66ifeq ($(DEVICE), k2e)
67PA_LIB = -lpa2
68endif
69
70#default if DEVICE not provided
71CSL_DEVICE ?= -DDEVICE_K2L -DNSS_GEN2
72PA_LIB ?= -lpa2
73NETAPI_LIB?=-lnetapi_k2l
74NWAL_LIB ?= -lnwalsa_k2l
75HP_LIB ?= -lhplib_k2l
76
77ifeq ($(USEDYNAMIC_LIB), yes)
78#presuming ARM executable would depend on dynamic library dependency
79EXE_EXTN = _so
80LIBS = $(QMSS_LIB) $(CPPI_LIB) $(PA_LIB) $(PKTLIB_LIB) $(NETAPI_LIB) $(HP_LIB) $(SA_LIB) $(NWAL_LIB) $(RM_LIB)
81else
82#forcing ARM executable to depend on static LLD libraries
83LIBS = -static $(QMSS_LIB) $(CPPI_LIB) $(PA_LIB) $(PKTLIB_LIB) $(NETAPI_LIB) $(HP_LIB) $(SA_LIB) $(NWAL_LIB) $(RM_LIB) -Wl,-Bdynamic
84EXE_EXTN =
85endif
86
87
88ifdef CROSS_TOOL_INSTALL_PATH
89## Support backwards compatibility with KeyStone1 approach
90 CC = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)gcc
91 AC = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)as
92 AR = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)ar
93 LD = $(CROSS_TOOL_INSTALL_PATH)/$(CROSS_TOOL_PRFX)gcc
94endif
95
96CFLAGS+= $(DEBUG_FLAG) -I../ -I. -I$(NETAPI_SRC_DIR) -I$(NETAPI_SRC_DIR)/src -I$(NETAPI_SRC_DIR)/util -I$(HPLIB_INC_DIR) -I$(NETAPI_INC_DIR)-I$(PDK_INSTALL_PATH) -I$(NWAL_INSTALL_PATH) -I$(PKTLIB_INSTALL_PATH) -I$(SA_INSTALL_PATH) -I$(QMSS_INC_DIR) -I$(CPPI_INC_DIR) -I$(RM_INC_DIR) $(CSL_DEVICE) -D__ARMv7 -D_VIRTUAL_ADDR_SUPPORT -D__LINUX_USER_SPACE -D_LITTLE_ENDIAN=1 -DNWAL_ENABLE_SA -DMAKEFILE_BUILD -D _GNU_SOURCE
97# Linker options
98INTERNALLINKDEFS = -Wl,--start-group $(LIBS) -Wl,--end-group -lrt -pthread -L$(ARMV7LIBDIR) -L$(ARMV7LIBDIRLOCAL) -L$(ARMV7SALIBDIR)
99
100
101all: tests
102
103tests: $(ARMV7BINDIR)/netapi/test/.created $(ARMV7BINDIR)/netapi/test/net_test_loopback_$(DEVICE) $(ARMV7BINDIR)/netapi/test/net_test_router_$(DEVICE) $(ARMV7BINDIR)/netapi/test/net_test_bench_$(DEVICE) $(ARMV7BINDIR)/netapi/test/nt_bridge_$(DEVICE)
104
105clean:
106 rm -f $(ARMV7OBJDIR)/netapi/test/*.o
107 rm -f $(ARMV7BINDIR)/netapi/test/*
108
109$(ARMV7OBJDIR)/netapi/utils/%.o: $(NETAPI_SRC_DIR)/utils/%.c $(ARMV7OBJDIR)/netapi/utils/.created
110 @echo compiling $<
111 $(CC) -c $(CFLAGS) $< -o $@
112
113$(ARMV7OBJDIR)/netapi/test/%.o: $(NETAPI_SRC_DIR)/test/%.c $(ARMV7OBJDIR)/netapi/test/.created
114 @echo compiling $<
115 $(CC) -c $(CFLAGS) $< -o $@
116
117$(ARMV7OBJDIR)/netapi/test/.created:
118 @mkdir -p $(ARMV7OBJDIR)/netapi/test/
119
120$(ARMV7BINDIR)/netapi/test/.created:
121 @mkdir -p $(ARMV7BINDIR)/netapi/test/
122
123$(ARMV7OBJDIR)/netapi/utils/.created:
124 @mkdir -p $(ARMV7OBJDIR)/netapi/utils/
125
126$(ARMV7BINDIR)/netapi/test/net_test_loopback_$(DEVICE): $(NT_OBJS) $(TRIE_OBJS) $(NT_RM_OBJS)
127 $(CC) $(LDFLAGS) $(NT_OBJS) $(TRIE_OBJS) $(NT_RM_OBJS) $(INTERNALLINKDEFS) -o $(ARMV7BINDIR)/netapi/test/net_test_loopback_$(DEVICE)$(EXE_EXTN)
128
129$(ARMV7BINDIR)/netapi/test/net_test_router_$(DEVICE): $(NT_ROUTER_OBJS) $(TRIE_OBJS) $(NT_RM_OBJS)
130 $(CC) $(LDFLAGS) $(NT_ROUTER_OBJS) $(TRIE_OBJS) $(NT_RM_OBJS) $(INTERNALLINKDEFS) -o $(ARMV7BINDIR)/netapi/test/net_test_router_$(DEVICE)$(EXE_EXTN)
131
132$(ARMV7BINDIR)/netapi/test/nt_bridge_$(DEVICE): $(NTB_OBJS) $(TRIE_OBJS) $(NT_RM_OBJS)
133 $(CC) $(LDFLAGS) $(NTB_OBJS) $(TRIE_OBJS) $(NT_RM_OBJS) $(INTERNALLINKDEFS) -o $(ARMV7BINDIR)/netapi/test/nt_bridge_$(DEVICE)$(EXE_EXTN)
134
135$(ARMV7BINDIR)/netapi/test/ifdma_test: $(IFDMA_OBJS)
136 $(CC) $(LDFLAGS) $(IFDMA_OBJS) $(INTERNALLINKDEFS) -o $(ARMV7BINDIR)/netapi/test/ifdma_test$(EXE_EXTN)
137
138$(ARMV7BINDIR)/netapi/test/net_test_bench_$(DEVICE): $(NT_BENCH_OBJS) $(NT_RM_OBJS)
139 $(CC) $(LDFLAGS) $(NT_BENCH_OBJS) $(NT_RM_OBJS) $(INTERNALLINKDEFS) -o $(ARMV7BINDIR)/netapi/test/net_test_bench_$(DEVICE)$(EXE_EXTN)
diff --git a/ti/runtime/netapi/test/eqos_config1.txt b/ti/runtime/netapi/test/eqos_config1.txt
new file mode 100644
index 0000000..226f7dc
--- /dev/null
+++ b/ti/runtime/netapi/test/eqos_config1.txt
@@ -0,0 +1,24 @@
1queueBase = 6400
2flowBase = 0
3vlanId = 0
4ingressDefPri = 0
5port = 1
6mode = dscp
7priority_override= 0
8pbit_map_default = 0 0
9pbit_map_0 = 0 0
10pbit_map_1 = 0 0
11pbit_map_2 = 0 0
12pbit_map_3 = 0 0
13pbit_map_4 = 0 0
14pbit_map_5 = 0 8
15pbit_map_6 = 0 0
16pbit_map_7 = 0 0
17#dscp_ma flow queue
18dscp_map_default = 0 0
19dscp_map_0 = 0 0
20dscp_map_1 = 0 0
21dscp_map_2 = 0 0
22dscp_map_3 = 0 0
23dscp_map_4 = 0 0
24
diff --git a/ti/runtime/netapi/test/eqos_config2.txt b/ti/runtime/netapi/test/eqos_config2.txt
new file mode 100644
index 0000000..b4931e4
--- /dev/null
+++ b/ti/runtime/netapi/test/eqos_config2.txt
@@ -0,0 +1,24 @@
1queueBase = 6440
2flowBase = 0
3vlanId = 0
4ingressDefPri = 0
5port = 2
6mode = dscp
7priority_override= 0
8pbit_map_default = 0 0
9pbit_map_0 = 0 0
10pbit_map_1 = 0 0
11pbit_map_2 = 0 0
12pbit_map_3 = 0 0
13pbit_map_4 = 0 0
14pbit_map_5 = 0 8
15pbit_map_6 = 0 0
16pbit_map_7 = 0 0
17#dscp_ma flow queue
18dscp_map_default = 0 0
19dscp_map_0 = 0 0
20dscp_map_1 = 0 0
21dscp_map_2 = 0 0
22dscp_map_3 = 0 0
23dscp_map_4 = 0 0
24
diff --git a/ti/runtime/netapi/test/fdb.c b/ti/runtime/netapi/test/fdb.c
new file mode 100755
index 0000000..97732e0
--- /dev/null
+++ b/ti/runtime/netapi/test/fdb.c
@@ -0,0 +1,425 @@
1/**********************************************************
2 * file: fdb.c
3 * purpose: netcp configurations routines
4 **************************************************************
5 * FILE: fdb.c
6 *
7 * DESCRIPTION: linux bridge forwarding data base processing for
8 * user space offload
9 *
10 * REVISION HISTORY:
11 *
12 * Copyright (c) Texas Instruments Incorporated 2013
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 ****************************************************************************/
42#include "stdlib.h"
43#include "stdio.h"
44#include "netapi.h"
45#include "fdb.h"
46
47
48extern FDB_ENTRY_T ale_cfg[];
49extern NETCP_CFG_ROUTE_T test_route[];
50extern uint16_t num_learned_macs;
51
52
53
54static OFFLOAD_DB_T our_fdb[2][OFFMAX]; //list offloaded, current and next
55static OFFLOAD_DB_T perm_do[PFDBMAX]; //white list
56static OFFLOAD_DB_T perm_dont[FDBMAX]; //black list`
57static OFFLOAD_DB_T learned[OFFMAX]; //filtered learned list`
58static int cur_off =-1; //which db has been loaded
59static int n_cur_off=0; //# of items offloaded
60
61//linux bridge fdb stuff
62//static struct our_fdb_entry linux_fdb[FDBMAX];
63
64//**********************************************************
65//Internal prototypes
66//**********************************************************
67
68//find a free slot
69int ntoff_find_free_slot(OFFLOAD_DB_T * pdb,int sz)
70{
71int s;
72for(s=0;s<sz;s++)
73{
74 if (pdb[s].flags==0x00000000)
75 {
76 return s;
77 }
78}
79return -1;
80}
81
82//find matching slot
83int ntoff_find_slot(OFFLOAD_DB_T * pdb,__u8 * p_mac, __u8 switch_port,int sz)
84{
85int s;
86for(s=0;s<sz;s++)
87{
88 if (pdb[s].flags==0x00000000) continue;
89 if (pdb[s].switch_port != switch_port) continue;
90 if (memcmp(p_mac, &pdb[s].mac_addr[0],6)) continue;
91 return s;
92}
93return -1;
94}
95
96//delete
97void ntoff_delete(OFFLOAD_DB_T pdb[], int sz)
98{
99}
100
101//startup
102int ntoff_start(void)
103{
104 return 0;
105}
106
107//shutdown
108int ntoff_stop(void)
109{
110 ntoff_delete(&our_fdb[cur_off][0], n_cur_off);
111 return 0;
112}
113
114//*************************************************
115//manipulate the permanent do & don't lists
116//************************************************
117int ntoff_add_do_perm(unsigned char *p_mac,int switch_port)
118{
119 int s = ntoff_find_free_slot(perm_do,PFDBMAX);
120 if (s<0) return -1; //no room
121 memcpy(perm_do[s].mac_addr,p_mac,6);
122 perm_do[s].switch_port=switch_port;
123 perm_do[s].flags=OUR_FSB_INUSE|OUR_FSB_PERM;
124 return 0;
125}
126int ntoff_del_do_perm(unsigned char *p_mac, int switch_port)
127{
128 int s = ntoff_find_slot(perm_do,p_mac,switch_port,PFDBMAX);
129 if (s<0) return -1; //not found
130 perm_do[s].flags=0x00000000; //mark it is as free
131 return 0;
132
133}
134int ntoff_add_dont_perm(unsigned char *p_mac, int switch_port)
135{
136 int s = ntoff_find_free_slot(perm_dont,FDBMAX);
137 if (s<0) return -1; //no room
138 memcpy(perm_dont[s].mac_addr,p_mac,6);
139 perm_dont[s].switch_port=switch_port;
140 perm_dont[s].flags=OUR_FSB_INUSE|OUR_FSB_PERM;
141 return 0;
142
143}
144int ntoff_del_dont_perm(unsigned char *p_mac, int switch_port)
145{
146 int s = ntoff_find_slot(perm_dont,p_mac,switch_port,FDBMAX);
147 if (s<0) return -1; //not found
148 perm_dont[s].flags=0x00000000; //mark it is as free
149 return 0;
150}
151//**************************
152//ADD macs
153//**************************
154int ntoff_add_macs(NETAPI_T h, NETCP_CFG_ROUTE_HANDLE_T r , int fast)
155{
156 int i;
157 int err;
158 NETCP_CFG_ROUTE_HANDLE_T route;
159 NETCP_CFG_FLOW_T flow;
160 nwalLocCxtInfo_t info;
161 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
162
163 memset(&route, 0, sizeof(NETCP_CFG_ROUTE_HANDLE_T));
164 memset(&flow, 0, sizeof(NETCP_CFG_FLOW_T));
165
166 memset(&info, 0, sizeof(nwalLocCxtInfo_t));
167
168 nwal_getLocCxtInfo(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle, &info);
169
170
171 n_cur_off=0;
172 //perm entries 1st
173 for(i=0;i<PFDBMAX;i++)
174 {
175 if (perm_do[i].flags & OUR_FSB_INUSE)
176 {
177 netapi_netcpCfgCreateMacInterface(
178 h,
179 &perm_do[i].mac_addr[0],
180 NULL,
181 n_cur_off,
182 0,
183 //perm_do[i].switch_port == 1 ? (NETCP_CFG_ROUTE_HANDLE_T)&test_route[0]:(NETCP_CFG_ROUTE_HANDLE_T)&test_route[1],
184 (NETCP_CFG_ROUTE_HANDLE_T)&test_route[perm_do[i].switch_port -1],
185 (NETCP_CFG_VLAN_T ) NULL,
186 0,
187 1,
188 &err);
189 perm_do[i].ifno = n_cur_off;
190 n_cur_off+=1;
191 }
192 }
193 printf("ntoff_add_mac: num_learned_macs: %d\n", num_learned_macs);
194 //learned list next
195 for(i=0; (i < num_learned_macs) && (i < 32) ;i++)
196
197 //for(i=0;(i<OFFMAX)&&(n_cur_off<OFFMAX);i++)
198 {
199 if (learned[i].flags & OUR_FSB_INUSE)
200 {
201 printf("ntoff_add_macs: index: %d\n", i);
202 netapi_netcpCfgCreateMacInterface(
203 h,
204 &learned[i].mac_addr[0],
205 NULL,
206 n_cur_off,
207 0,
208 //learned[i].switch_port == 1 ? (NETCP_CFG_ROUTE_HANDLE_T)&test_route[0]:(NETCP_CFG_ROUTE_HANDLE_T)&test_route[1],
209 (NETCP_CFG_ROUTE_HANDLE_T)&test_route[learned[i].switch_port-1],
210 (NETCP_CFG_VLAN_T ) NULL,
211 0,
212 1,
213 &err);
214 learned[i].ifno = n_cur_off;
215 n_cur_off+=1;
216 }
217 }
218 return n_cur_off;
219}
220//***************************
221//DEL MACS
222//***************************
223int ntoff_del_macs(NETAPI_T h)
224{
225int i;
226int err;
227
228 //perm entries
229 for(i=0;i<PFDBMAX;i++)
230 {
231 if (perm_do[i].flags & OUR_FSB_INUSE)
232 {
233 netapi_netcpCfgDelMac(h, perm_do[i].ifno ,&err);
234 perm_do[i].ifno = 0;
235 n_cur_off-=1;
236 }
237 }
238 //learned entries
239 for(i=0;(i<OFFMAX)&&(n_cur_off>=0);i++)
240 {
241 if (learned[i].flags & OUR_FSB_INUSE)
242 {
243 netapi_netcpCfgDelMac(h, learned[i].ifno ,&err);
244 learned[i].ifno = 0;
245 n_cur_off-=1;
246 }
247 }
248 return 0;
249
250}
251
252
253
254//*************************
255//do_offload
256// - read what linux is seeing
257// - build newoffload list:
258// -- perm do list +
259// -- newoffload (sorted by maxage)
260// -- oldoffload
261//*************************
262#if 0
263int ntoff_do_offload(NETAPI_T nh, int fast)
264{
265 int next_cur = !cur_off;
266 int i;
267 int new_count=0;
268 //read bridges DB
269 new = ntoff_read_fdb(linux_fdb,FDBMAX);
270 new = nt_sort_and_filter_fdb(linux_fdb,learned,new); //sort list, filter out ones that match perm_do[], perm_dont[];
271
272 //build the new offload db
273 //1st copy over permanent entries frin perm_do[] list
274 for(i=0; (new_count<OFFMAX)&&(i<PFDBMAX); )
275 {
276 if (perm_do[i].switch_port == 0xff)
277 {
278 i+=1;
279 }
280 else
281 {
282 our_fdb[next_cur][new_count].mac_addr= perm_do[i].mac_addr;
283 our_fdb[next_cur][new_count].switch_port = perm_do[i].switch_port;
284 our_fdb[next_cur][new_count].flags=OUR_FSB_INUSE|OUR_FSB_PERM;
285 i+=1;
286 new_count+=1;
287 }
288 }
289 //now copy over sorted & filtered new entries from linux's db
290 for (i=0;(new_count<OFFMAX) && (i<new))
291 {
292 our_fdb[next_cur][new_count].mac_addr= linux_fdb[i].mac_addr;
293 our_fdb[next_cur][new_count].switch_port= linux_fdb[i].switch_port;
294 our_fdb[next_cur][new_count].flags=OUR_FSB_INUSE;
295 i+=1;
296 new_count+=1;
297 }
298 //if we have room, now copy ones from the old list that we want to keep
299 for (i=0; (new_count<OFFMAX) && (i<OFFMAX); )
300 {
301
302 }
303
304 //mark the rest of the entries as not in use
305 for(i=new_count; i< OFFMAX; i++) our_fdb[next_cur][new_count].flags=0x00000000;
306
307
308 //delete old entries
309 ntoff_delete(&our_fdb[cur_off][0], n_cur_off);
310
311 //add new entries
312 ntoff_add(&our_fdb[next_cur][0], new_count);
313
314 //flip entries
315 cur_off= next_cur;
316 n_cur_off= new_count;
317
318}
319
320
321//******************
322// read the fdb
323// return #entries
324//******************
325int ntoff_read_fdb(struct our_fdb_entry fdb[], int max_fdb)
326{
327 FILE * f = fopen("/sys/class/net/br0/brforward", "r");
328 //FILE * f = fopen("blah.fdb", "r");
329 int n=0;
330 if (f) {
331 n = fread(fdb, sizeof(struct our_fdb_entry),max_fdb , f);
332 fclose(f);
333 }
334 return n;
335}
336#endif
337
338/********************************
339 * filter & sort learned list
340 *********************************/
341int ntoff_sort_and_filter(struct our_fdb_entry raw[],OFFLOAD_DB_T pl[] ,int sz)
342{
343 int i,j;
344 int s;
345
346 for(i=0,j=0; (i<sz)&&(j<OFFMAX);)
347 {
348 if(raw[i].is_local) {i+=1; continue;}
349 if(raw[i].ageing_timer_value > THRESH_OFF) { i+=1; continue;}
350 s = ntoff_find_slot(perm_dont,&raw[i].mac_addr[0], raw[i].switch_port,FDBMAX);
351 if (s>=0) {i+=1; continue;}
352 s = ntoff_find_slot(perm_do,&raw[i].mac_addr[0], raw[i].switch_port,PFDBMAX);
353 if (s>=0) {i+=1; continue;}
354 //OK to learn
355 pl[j].switch_port = raw[i].switch_port;
356 memcpy(&pl[j].mac_addr[0], &raw[i].mac_addr[0],6);
357 pl[j].flags = OUR_FSB_INUSE | OUR_FSB_LEARN;
358 j+=1;
359 i+=1;
360 }
361 //zap the rest of the table
362 for(i=j;i<OFFMAX;i++) pl[i].flags= 0x00;
363
364 return j;
365}
366
367/*******************************
368 * learn what the Linux bridge knows
369 ******************************************/
370int ntoff_learn(void)
371{
372 int new;
373 new = ntoff_sort_and_filter(&ale_cfg, learned,32);
374 return 0;
375
376}
377
378//*******************************
379//show stuff
380//*******************************
381void nt_print_fdb(char* title, OFFLOAD_DB_T *p, int sz)
382{
383 int i;
384 printf("%s \n", title);
385 printf("MAC switch_port FLAGS\n");
386
387 for (i=0;i<sz;i++)
388 {
389 if (p[i].flags & OUR_FSB_INUSE) printf("%x-%x-%x-%x-%x-%x %d %x\n",
390 p[i].mac_addr[0],
391 p[i].mac_addr[1],
392 p[i].mac_addr[2],
393 p[i].mac_addr[3],
394 p[i].mac_addr[4],
395 p[i].mac_addr[5],
396 p[i].switch_port, p[i].flags);
397}
398}
399
400void ntoff_show(void)
401{
402 nt_print_fdb("perm_dont:",perm_dont,FDBMAX);
403 nt_print_fdb("perm do:", perm_do,PFDBMAX);
404 nt_print_fdb("learned:", learned, OFFMAX);
405}
406
407//#define TEST
408#ifdef TEST
409unsigned char m1[6] = {0x00,0x01,0x2,0x3,0x4,0x5};
410unsigned char m2[6] = {0x00,0x01,0x2,0x3,0x4,0x6};
411
412void main()
413{
414 ntoff_start();
415 ntoff_add_do_perm(m1,1);
416 ntoff_add_do_perm(m2,2);
417 ntoff_learn();
418 ntoff_show();
419 ntoff_del_do_perm(m2,2);
420 ntoff_del_do_perm(m1,1);
421 ntoff_stop();
422
423}
424
425#endif
diff --git a/ti/runtime/netapi/test/fdb.h b/ti/runtime/netapi/test/fdb.h
new file mode 100755
index 0000000..952153b
--- /dev/null
+++ b/ti/runtime/netapi/test/fdb.h
@@ -0,0 +1,140 @@
1/**********************************************************
2 * file: fdb.h
3 * purpose: netcp configurations routines
4 **************************************************************
5 * FILE: fdb.c
6 *
7 * DESCRIPTION: linux bridge forwarding data base processing for
8 * user space offload
9 *
10 * REVISION HISTORY:
11 *
12 * Copyright (c) Texas Instruments Incorporated 2013
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 ****************************************************************************/
42#include "stdlib.h"
43#include "stdio.h"
44#include "netapi.h"
45//#include "fdb.h"
46
47#define __u8 unsigned char
48#define __u32 unsigned int
49#define FDBMAX 128
50#define PFDBMAX 8
51#define OFFMAX 32
52#define THRESH_OFF 50 //aging timer threshold: don't bother offloading entries < THRESH_OFF
53
54#define MAX_INTERFACES 2
55#define MAX_DSCP_ENTRIES 64
56#define MAX_PBIT_ENTRIES 8
57
58#define ntBridge_INIT_CONFIG_FLOW_BASE "flowBase"
59#define ntBridge_INIT_CONFIG_QUEUE_BASE "queueBase"
60#define ntBridge_INIT_CONFIG_VLAN_ID "vlanId"
61#define ntBridge_INIT_CONFIG_INGRESS_DEF_PRI "ingressDefPri"
62#define ntBridge_INIT_CONFIG_PORT "port"
63#define ntBridge_INIT_CONFIG_DSCP_MAP_DEFAULT "dscp_map_default"
64#define ntBridge_INIT_CONFIG_PBIT_MAP_DEFAULT "pbit_map_default"
65
66//#define ntBridge_INIT_CONFIG_DSCP_MAP "dscpMap"
67//#define ntBridge_INIT_CONFIG_PBIT_MAP "pbitMap"
68#define ntBridge_INIT_CONFIG_QOS_MODE "mode"
69
70
71typedef struct{
72 char flowBase[512];
73 char queueBase[512];
74 char vlanId[512];
75 char ingressDefPri[512];
76 char port[512];
77 char dscpMapQDefault[512];
78 char dscpMapFDefault[512];
79 char dscpMapQ[64][512];
80 char dscpMapF[64][512];
81 char pbitMapQDefault[512];
82 char pbitMapFDefault[512];
83 char pbitMapQ[8][512];
84 char pbitMapF[8][512];
85 char ctrlBitMap[512];
86} ntBridgeCfgFile_T;
87
88
89typedef struct{
90 char mac[32][512];
91 char switch_port[32][512];
92} ntBridgeAleCfgFile_T;
93
94typedef struct {
95unsigned char mac[32][6];
96uint8_t switch_port[32];
97} ntBridgeAleCfg_T;
98
99//the bridge fdb entry
100typedef struct our_fdb_entry
101{
102 uint8_t mac_addr[6];
103 uint8_t switch_port;
104 uint8_t is_local;
105 uint32_t ageing_timer_value; //jiffies
106 uint32_t unused;
107} FDB_ENTRY_T;
108
109//our offload db
110typedef struct offload_db_t
111{
112 __u8 mac_addr[6];
113 __u8 switch_port; //
114 __u8 ifno; //
115 __u32 spare0;
116 __u32 flags;
117#define OUR_FSB_INUSE 0x80000000
118#define OUR_FSB_PERM 0x40000000
119#define OUR_FSB_LEARN 0x20000000
120#define OUR_FSB_SKIP 0x00000001
121} OFFLOAD_DB_T;
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
diff --git a/ti/runtime/netapi/test/ifdma_test.c b/ti/runtime/netapi/test/ifdma_test.c
new file mode 100755
index 0000000..2f91761
--- /dev/null
+++ b/ti/runtime/netapi/test/ifdma_test.c
@@ -0,0 +1,566 @@
1/******************************************
2 * File: ifdma-test.c
3 * Purpose: test of infrastructure dma mode
4 **************************************************************
5 * FILE: ifdma-test.c
6 *
7 * DESCRIPTION: netapi user space transport
8 * library test application
9 *
10 * REVISION HISTORY: rev 0.0.1
11 *
12 * Copyright (c) Texas Instruments Incorporated 2010-2011
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
42 *****************************************/
43
44#include <stdio.h>
45#include <stdlib.h>
46#include <unistd.h>
47#include <string.h>
48#include <signal.h>
49#include <pthread.h>
50#include <sched.h>
51
52#include "trie.h"
53#include "string.h"
54#include "netapi.h"
55#include "pktio.h"
56#include "net_test.h"
57#include <ti/drv/sa/salld.h>
58
59
60void benchmarks(void);
61static inline unsigned long netapi_timing_start(void)
62{
63 volatile int vval;
64 //read clock
65 asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(vval));
66 return vval;
67}
68
69//turn this off to use packets received from Network instead of self generated ones
70#define INTERNAL_PACKETS
71static int scnt=0;
72static int QUIT=0;
73__thread int our_core;
74
75
76#define IFDMA_FLOW_INDEX 33
77#define IFMDA_HEAP_SIZE 200
78#define IFDMA_MAX_NUM_HEAPS 2
79#define IFDMA_MAX_HEAP_PKTS 128
80//sig handler
81void netTest_utilMySig(int x)
82{
83 QUIT=1;
84 scnt+=1;
85 printf(">ifdma-test: recv'd signal %d cnt=%d\n",x,scnt);
86 if (scnt > 10) {printf(">ifdma-test: WARNING EXITING WITH PROPER SHUTDOWN, LUTS LEFT ACTIVE\n");exit(1);}
87
88}
89void recv_cb_net(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
90 PKTIO_METADATA_T meta[], int n_pkts,
91 uint64_t ts );
92void recv_cb_consumer(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
93 PKTIO_METADATA_T meta[], int n_pkts,
94 uint64_t ts );
95
96
97/*************debug********************/
98void netTest_utilDumpDescr(unsigned long *p, int n)
99{
100 printf("--------dump of descriptor %d %x\n", n, (int) p);
101 printf("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
102 printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
103 printf("-----------------------------\n");
104}
105void netTest_utilDumpHeader(unsigned long *p, int n, int a, int r)
106{
107 printf("--------dump of header %d %x appID=%x flag1=%x\n", n, (int) p,a,r);
108 printf("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
109 printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
110 printf("> %x %x %x %x %x %x %x %x\n",p[16],p[17],p[18],p[19],p[20],p[21],p[22],p[23]);
111 printf("> %x %x %x %x %x %x %x %x\n",p[24],p[25],p[26],p[27],p[28],p[29],p[30],p[31]);
112 printf("-----------------------------\n");
113}
114/*****************************************/
115
116
117
118
119
120
121
122/*******************************************
123 *************NETAPI OBJECTS***************
124 *****************************************/
125static NETAPI_CFG_T our_netapi_default_cfg=
126{
127TUNE_NETAPI_PERM_MEM_SZ,
128128, //start of packet offset for hw to place data on rx for default flow
129TUNE_NETAPI_QM_CONFIG_MAX_DESC_NUM, //max number of descriptors in system
130TUNE_NETAPI_NUM_GLOBAL_DESC, //total we will use
131TUNE_NETAPI_DEFAULT_NUM_BUFFERS, //#descriptors+buffers in default heap
13264, //#descriptors w/o buffers in default heap
133TUNE_NETAPI_DEFAULT_BUFFER_SIZE+128+128, //size of buffers in default heap
134128 , //tail room
135256, //extra room
1360,
137NULL,
13818,
1390x2000
140};
141
142Pktlib_HeapHandle OurHeap; //default heap, used by producer
143Pktlib_HeapHandle consumerHeap; //for consumer
144PKTIO_HANDLE_T * rx_chan; //for consumer
145PKTIO_HANDLE_T * tx_chan; // for producer
146PKTIO_CFG_T rx_chan_cfg={PKTIO_RX|PKTIO_TX, PKTIO_GLOBAL, PKTIO_Q_ANY, 8};
147PKTIO_CFG_T tx_chan_cfg={PKTIO_TX, PKTIO_GLOBAL|PKTIO_IFDMA, /*PKTIO_Q_ANY*/ 820, 8};
148PKTIO_CFG_T netcp_rx_cfg={PKTIO_RX, PKTIO_NA, PKTIO_NA, 8};
149PKTIO_HANDLE_T * netcp_rx_chan;
150NETAPI_T netapi_handle;
151NETCP_CFG_FLOW_HANDLE_T specialFlow; //for consumer. Producer uses the "flowid" in this handle as meta data when he sends data
152
153PKTIO_CONTROL_T zap_channel_control={PKTIO_CLEAR, NULL};
154
155NETCP_CFG_ROUTE_T test_route=
156{
1570,
158NULL,
159NULL,
1600,
1610,
1620,
1631
164};
165
166
167/*************************END NETAPI OBJECTS***********************/
168
169static unsigned char all_mac[]={0,0,0,0,0,0};
170
171
172#define IFDMA_PKT_LEN 100
173
174//stats
175int pkt_rx=0;
176int pkt_tx=0;
177int pkt_stall=0;
178
179//***************************
180//consumer thread
181//**************************
182void consumer_thread(int coreid)
183{
184int err;
185int np;
186cpu_set_t cpu_set;
187
188 CPU_ZERO( &cpu_set);
189 CPU_SET( 1, &cpu_set);
190 hplib_utilSetupThread(1, &cpu_set,hplib_spinLock_Type_LOL);
191
192 for(;!((volatile int)QUIT);)
193 {
194 np = netapi_pktioPoll(rx_chan,NULL,&err);
195 pkt_rx+=np;
196 }
197 printf("IFDMA-TEST: CONSUMER DONE %d packets received\n", pkt_rx);
198}
199
200
201//**********************************
202//producer thread
203//*********************************
204void producer_thread(int coreid)
205{
206int err;
207int i;
208Ti_Pkt * tip;
209unsigned char * pData;
210int len;
211PKTIO_METADATA_T meta = {PKTIO_META_IFDMA_TX,{0},0};
212int np;
213cpu_set_t cpu_set;
214
215
216 CPU_ZERO( &cpu_set);
217 CPU_SET( 2, &cpu_set);
218 hplib_utilSetupThread(2, &cpu_set,hplib_spinLock_Type_LOL);
219
220#ifdef INTERNAL_PACKETS
221 //generate packets internally by allocating from OurHeap (the NETAPI
222 //default) and send to receiver via ifdma pktio channel
223 sleep(5);
224 for(i=0;!((volatile int) QUIT);i++)
225 {
226 tip=Pktlib_allocPacket(OurHeap,IFDMA_PKT_LEN);
227 if (!tip)
228 {
229 pkt_stall+=1;
230 sleep(1); //out of buffers, let consumer catch up
231 continue;
232 }
233 Pktlib_getDataBuffer(tip,&pData,&len);
234 sprintf(pData,"this is packet %d", pkt_tx);
235 Cppi_setData (Cppi_DescType_HOST, (Cppi_Desc *) tip, pData,IFDMA_PKT_LEN);
236 Pktlib_setPacketLen(tip,IFDMA_PKT_LEN);
237 meta.u.tx_ifdma_dest=((NETCP_CFG_FLOW_T*)specialFlow)->flowid;
238 netapi_pktioSend(tx_chan,tip,&meta,&err);
239 pkt_tx+=1;
240 if(!(pkt_tx % 64)) sched_yield(); //give consumer a chance
241 }
242#else
243 //relay packets from network. recv_cb registered when we created
244 //netcp_rx_chan will do this relay via the ifdma pktio channel
245 //so we poll the default pktio channel for pkts from net
246 for(i=0;!((volatile) QUIT);i++)
247 {
248 np = netapi_pktioPoll(netcp_rx_chan,NULL,&err);
249 if (!np) sched_yield();
250
251 }
252#endif
253 printf("IFDMA-TEST: PRODUCER DONE %d pkts sent (stalls=%d)\n", pkt_tx,pkt_stall);
254}
255
256
257//******************************
258// main program
259//*****************************
260int main(int argc, char **argv)
261{
262 int err,i;
263 int32_t errCode;
264 Pktlib_HeapIfTable* pPktifTable;
265 Pktlib_HeapCfg heapCfg;
266 long t1, t2 ;
267 cpu_set_t cpu_set;
268
269
270 //install signal handler for ^c
271 signal(SIGINT,netTest_utilMySig);
272 CPU_ZERO( &cpu_set);
273 CPU_SET( 0, &cpu_set);
274 hplib_utilSetupThread(0, &cpu_set, hplib_spinLock_Type_LOL);
275
276
277 /*******************************************/
278 /*************NETAPI STARTUP****************/
279 /*******************************************/
280
281 /* create netapi */
282 netapi_handle = netapi_init(NETAPI_SYS_MASTER, &our_netapi_default_cfg);
283 printf("main: returned from netapi_init\n");
284
285 /* Un-configure rules for execption packet handling */
286 /* open the main heap */
287 OurHeap = Pktlib_findHeapByName("netapi");
288 if (!OurHeap) {printf("findheapbyname fail\n"); exit(1);}
289
290 //create a receive queue for consumer
291 rx_chan=netapi_pktioCreate(netapi_handle,"ourrxq",(PKTIO_CB) recv_cb_consumer, &rx_chan_cfg,&err);
292 if (!rx_chan) {printf("pktio create failed err=%d\n",err); exit(1);}
293
294
295#ifndef INTERNAL_PACKETS
296 //if we want to relay network packets, we create a handle to the
297 //default netcp receive queue here
298 netcp_rx_chan= netapi_pktioOpen(netapi_handle, NETCP_RX, (PKTIO_CB) recv_cb_net, &netcp_rx_cfg, &err);
299 if (!netcp_rx_chan) {printf("pktio open RX failed err=%d\n",err); exit(1);}
300#endif
301
302//********************************
303//create a consumer heap
304//**********************************
305
306 /* Initialize the heap configuration. */
307 memset ((void *)&heapCfg, 0, sizeof(Pktlib_HeapCfg));
308
309 pPktifTable = netapi_getPktlibIfTable();
310
311 /* Populate the heap configuration */
312 heapCfg.name = "netapi-consumer";
313 heapCfg.memRegion = netapi_getMemoryRegionId(netapi_handle);
314 heapCfg.sharedHeap = 1;
315 heapCfg.useStarvationQueue = 0;
316 heapCfg.dataBufferSize = TUNE_NETAPI_DEFAULT_BUFFER_SIZE;
317 heapCfg.numPkts = IFDMA_MAX_HEAP_PKTS;
318 heapCfg.numZeroBufferPackets= 0;
319 heapCfg.heapInterfaceTable.data_malloc = pPktifTable->data_malloc;
320 heapCfg.heapInterfaceTable.data_free = pPktifTable->data_free;
321 heapCfg.dataBufferPktThreshold = 0;
322 heapCfg.zeroBufferPktThreshold = 0;
323 consumerHeap = Pktlib_createHeap(&heapCfg, &errCode);
324
325 //by registering the heap, netapi will take care of
326 //cleaning it up @ shutdown..
327 netapi_registerHeap(netapi_handle, consumerHeap); //register heap.
328
329 //**************************************************
330 //create a FLOW for consumer RX. Note this is created
331 //in the QMSS (INFRASTRUCTURE) CPPI DMA ENGINE
332 // todo: flowindex should be passed in or got
333 // from resource manager
334 //*************************************************
335 {
336 Pktlib_HeapHandle heaps[2];
337 int sizes[2];
338#define SPECIAL_SOP_OFF 0
339 NETCP_CFG_FLOW_CONFIG_T flow_config={IFDMA_FLOW_INDEX,
340 NETAPI_DMA_INFRASTRUCTURE,
341 SPECIAL_SOP_OFF,
342 NETAPI_FLOW_BLOCK };
343 heaps[0]= consumerHeap;
344 sizes[0]=IFMDA_HEAP_SIZE;
345 heaps[1]= consumerHeap;
346 sizes[1]=TUNE_NETAPI_DEFAULT_BUFFER_SIZE - SPECIAL_SOP_OFF;
347 flow_config.p_dest_q = rx_chan; // send pkts to rx_chan
348
349 //specialFlow handle will hold "magic" flowid that producer needs to
350 //include in his pkto_send meta data
351 specialFlow = netapi_netcpCfgAddFlow( netapi_handle,
352 IFDMA_MAX_NUM_HEAPS, //1 heap defined
353 heaps,
354 sizes,
355 &flow_config, //offset to start rx is 128
356 &err);
357 if (err) {printf("add flow failed\n", err); exit(1);}
358}
359
360//************************************************************
361//create the IDMA channel: this is used by producer to either
362//send generated packets or relay received packets from net
363//***************************************************************
364tx_chan=netapi_pktioCreate(netapi_handle,"ourtxq",NULL, &tx_chan_cfg,&err);
365if (!tx_chan) {printf("pktio create failed err=%d\n",err); exit(1);}
366
367#ifndef INTERNAL_PACKETS
368//if we want to relay packets, creaate a simple netcp rule
369//to get a lot of packets
370netapi_netcpCfgCreateMacInterface(
371 netapi_handle,
372 &all_mac[0],
373 NULL,
374 0,
375 0,
376 (NETCP_CFG_ROUTE_HANDLE_T) NULL,
377 (NETCP_CFG_VLAN_T ) NULL , //future
378 1,
379 &err);
380#endif
381
382/*********************************************/
383/*****************end NETAPI STARTUP**********/
384/*********************************************/
385
386#if 1
387//sonme benchmarks
388benchmarks();
389#endif
390//**************************************
391//Create a consumer and producer thread
392//***************************************
393{
394 pthread_t *thrs;
395 int procs =2;
396 int c;
397 thrs = malloc( sizeof( pthread_t ) * procs );
398 if (thrs == NULL)
399 {
400 perror( "malloc" );
401 return -1;
402 }
403 printf( "ifdma-test: Starting %d threads...\n", procs );
404
405 if (pthread_create( &thrs[0], NULL, (void*)consumer_thread,
406 (void *)0 ))
407 {
408 perror( "pthread_create" );
409 exit(1);
410 }
411 if (pthread_create( &thrs[1], NULL, (void*)producer_thread,
412 (void *)1 ))
413 {
414 perror( "pthread_create" );
415 exit(1);
416 }
417 //this thread of execution (main) now just waits on user input
418 for(;;)
419 {
420 printf(">");
421 c=getchar();
422 if (c=='q') {QUIT=1;break;}
423 else if (c=='s') printf(">IFDMA-TEST STATS: %d sent, %d received stall=%d \n",pkt_tx, pkt_rx,pkt_stall);
424 else if (c=='h') printf("> 'q' to quit, 's' for stats, 'h' for help\n");
425 }
426
427 //wait for completion
428 printf("main task now pending on thread completion\n");
429 for (i = 0; i < procs; i++)
430 pthread_join( thrs[i], NULL );
431
432 free( thrs );
433
434}
435
436/*************************************************
437 ************CLEAN UP****************************
438 ************************************************/
439#ifndef INTERNAL_PACKETS
440//get rid of rule, in the case that we are relaying packets
441//also close our netcp rx channel
442netapi_netcpCfgDelMac(netapi_handle,0,&err);
443netapi_pktioClose(netcp_rx_chan,&err);
444#endif
445
446//close pktio channels we opened
447netapi_pktioDelete(tx_chan ,&err);
448netapi_pktioDelete(rx_chan ,&err);
449
450//close flow
451netapi_netcpCfgDelFlow(netapi_handle, specialFlow, &err);
452
453//done
454netapi_shutdown(netapi_handle);
455
456
457//!finished!
458}
459
460
461//receive callback for packets from net (for consumer)
462// this is used for case where we want to relay packets from
463// network, instead of internally generating them
464void recv_cb_net(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
465 PKTIO_METADATA_T meta[], int n_pkts,
466 uint64_t ts )
467{
468int i;
469PKTIO_METADATA_T meta2 = {PKTIO_META_TX,{0},0};
470Ti_Pkt * tip;
471int err;
472
473for(i=0;i<n_pkts;i++)
474{
475 tip = p_recv[i];
476 meta2.u.tx_ifdma_dest=((NETCP_CFG_FLOW_T*)specialFlow)->flowid;
477 netapi_pktioSend(tx_chan,tip,&meta2,&err);
478 pkt_tx+=1;
479 if(!(pkt_tx % 128)) sched_yield(); //give consumer a chance
480}
481
482
483}
484
485
486//receive callback for consumer (registered when we create pktio channel)
487void recv_cb_consumer(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
488 PKTIO_METADATA_T meta[], int n_pkts,
489 uint64_t ts )
490{
491int i;
492int len;
493Ti_Pkt * tip;
494unsigned int templen;
495char * p_pkt;
496
497for(i=0;i<n_pkts;i++)
498{
499 tip = p_recv[i];
500 Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);//ignore templen
501 len = Pktlib_getPacketLen(tip);
502 Pktlib_freePacket((Ti_Pkt*)tip);
503}
504return;
505}
506
507
508
509
510//SOME BENCHMARKS
511//sonme benchmarks
512void benchmarks(void)
513{
514int i,j;
515unsigned long v1pop;
516unsigned long v2pop;
517unsigned long v1push;
518unsigned long v2push;
519unsigned long v1read;
520unsigned long v2read;
521unsigned long v1write;
522unsigned long v2write;
523unsigned long v1read2;
524unsigned long v2read2;
525#define N 100
526Ti_Pkt pkts[N];
527unsigned char * p_pkt;
528int len;
529int sum=0;
530int sum2=0;
531char *p=(char *) malloc(1000);
532
533//queue pop
534v1pop=netapi_timing_start();
535for(i=0;i<N;i++) pkts[i]= Pktlib_allocPacket(OurHeap,1000);
536v2pop = netapi_timing_start();
537
538//write access
539Pktlib_getDataBuffer(pkts[0],(uint8_t**)&p_pkt,&len);
540v1write=netapi_timing_start();
541for(i=0;i<1000;i++) p_pkt[i]=i;
542v2write=netapi_timing_start();
543
544// access
545
546v1read=netapi_timing_start();
547for(j=0;j<10;j++)
548for(i=0;i<1000;i++) sum+=p_pkt[i];
549v2read=netapi_timing_start();
550
551// access (from malloc)
552v1read2=netapi_timing_start();
553for(i=0;i<1000;i++) sum2+=p[i];
554v2read2=netapi_timing_start();
555
556//queue push
557v1push=netapi_timing_start();
558for(i=0;i<N;i++) Pktlib_freePacket(pkts[i]);
559v2push = netapi_timing_start();
560
561//resutls
562printf("allocs= %d free=%d write=%d read=%d read-malloc=%d (sum=%d %d)\n",
563 (v2pop-v1pop)/N, (v2push-v1push)/N, (v2write-v1write)/1000, (v2read-v1read)/10000,
564 (v2read2-v1read2)/1000,sum,sum2);
565
566}
diff --git a/ti/runtime/netapi/test/net_test.h b/ti/runtime/netapi/test/net_test.h
new file mode 100755
index 0000000..9caae3f
--- /dev/null
+++ b/ti/runtime/netapi/test/net_test.h
@@ -0,0 +1,61 @@
1/******************************************************************************
2 * FILE PURPOSE: local defines for net_test application.
3 ******************************************************************************
4 * FILE NAME: net_test.h
5 *
6 * DESCRIPTION: NET TEST definitions and defines
7 *
8 * REVISION HISTORY:
9 *
10 * Copyright (c) Texas Instruments Incorporated 2010-2011
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 *
19 * Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the
22 * distribution.
23 *
24 * Neither the name of Texas Instruments Incorporated nor the names of
25 * its contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 */
41/* ============================================================= */
42
43#ifndef __NET_TEST_H__
44#define __NET_TEST_H__
45
46#include "netapi.h"
47#include "trie.h"
48
49//#include "net_test_sa_utils.h"
50//#include "net_test_utils.h"
51//#include "net_test_thread_utils.h"
52
53//#include "net_test_sa_utils.h"
54//define this for multi-thread
55#define netTest_MULTI_THREAD
56
57
58#define netTest_DSP_FASTPATH
59
60
61#endif
diff --git a/ti/runtime/netapi/test/net_test_bench.c b/ti/runtime/netapi/test/net_test_bench.c
new file mode 100755
index 0000000..80fbc54
--- /dev/null
+++ b/ti/runtime/netapi/test/net_test_bench.c
@@ -0,0 +1,743 @@
1/******************************************
2 * File: nt_bench.c
3 * Purpose: benchmarks for NT.
4 **************************************************************
5 * FILE: nt_bench.c
6 *
7 * DESCRIPTION: netapi user space transport
8 * library test application : benchmarks
9 *
10 * REVISION HISTORY: rev 0.0.1
11 *
12 * Copyright (c) Texas Instruments Incorporated 2010-2011
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
42 *****************************************/
43
44#include <stdio.h>
45#include <stdlib.h>
46#include <unistd.h>
47#include <string.h>
48#include <signal.h>
49#include <pthread.h>
50#include <sched.h>
51
52//#include "trie.h"
53#include "string.h"
54#include "netapi.h"
55//#include "pktio.h"
56#include "net_test.h"
57#include "net_test_sa_utils.h"
58#include "net_test_utils.h"
59#include "net_test_thread_utils.h"
60#include <ti/drv/sa/salld.h>
61
62#if defined(DEVICE_K2H)
63#include <ti/drv/qmss/device/k2h/src/qmss_device.c>
64#include <ti/drv/cppi/device/k2h/src/cppi_device.c>
65#elif defined (DEVICE_K2K)
66#include <ti/drv/qmss/device/k2k/src/qmss_device.c>
67#include <ti/drv/cppi/device/k2k/src/cppi_device.c>
68#elif defined (DEVICE_K2L)
69#include <ti/drv/qmss/device/k2l/src/qmss_device.c>
70#include <ti/drv/cppi/device/k2l/src/cppi_device.c>
71#elif defined (DEVICE_K2E)
72#include <ti/drv/qmss/device/k2e/src/qmss_device.c>
73#include <ti/drv/cppi/device/k2e/src/cppi_device.c>
74#else /*Default */
75#include <ti/drv/qmss/device/k2h/src/qmss_device.c>
76#include <ti/drv/cppi/device/k2h/src/cppi_device.c>
77#endif /* Device */
78extern Rm_ServiceHandle *rmClientServiceHandle;
79
80extern Rm_ServiceHandle *rmClientServiceHandle;
81#define netapi_timing_start hplib_mUtilGetPmuCCNT
82
83static int scnt=0;
84static int QUIT=0;
85static int XMIT=0;
86static int CAP=0;
87volatile int RESET=0; //to reset stats
88
89__thread int our_core;
90
91void benchmarks1(void);
92void benchmarks2(Pktlib_HeapHandle h , int n_trials);
93void benchmarks3(Pktlib_HeapHandle h , int n_trials);
94
95//sig handler
96void netTest_utilMySig(int x)
97{
98 QUIT=1;
99 scnt+=1;
100 printf(">ifdma-test: recv'd signal %d cnt=%d\n",x,scnt);
101 if (scnt > 10) {printf(">ifdma-test: WARNING EXITING WITH PROPER SHUTDOWN, LUTS LEFT ACTIVE\n");exit(1);}
102
103}
104void recv_cb_net(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
105 PKTIO_METADATA_T meta[], int n_pkts,
106 uint64_t ts );
107
108
109/*************debug********************/
110void netTest_utilDumpDescr(unsigned long *p, int n)
111{
112 printf("--------dump of descriptor %d %x\n", n, (int) p);
113 printf("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
114 printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
115 printf("-----------------------------\n");
116}
117void netTest_utilDumpHeader(unsigned long *p, int n, int a, int r)
118{
119 printf("--------dump of header %d %x appID=%x flag1=%x\n", n, (int) p,a,r);
120 printf("> %0x %0x %0x %0x %0x %0x %0x %0x\n",
121 ntohl(p[0]),ntohl(p[1]),ntohl(p[2]),ntohl(p[3]),
122 ntohl(p[4]),ntohl(p[5]),ntohl(p[6]),ntohl(p[7]) );
123#if 0
124 printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
125 printf("> %x %x %x %x %x %x %x %x\n",p[16],p[17],p[18],p[19],p[20],p[21],p[22],p[23]);
126 printf("> %x %x %x %x %x %x %x %x\n",p[24],p[25],p[26],p[27],p[28],p[29],p[30],p[31]);
127#endif
128 printf("-----------------------------\n");
129}
130/*****************************************/
131
132
133unsigned long long CALIB=0;
134unsigned long long calibrate_idle(void)
135{
136volatile unsigned long long at1;
137volatile unsigned long long at2;
138volatile unsigned long pt1;
139volatile unsigned long pt2;
140unsigned long long calib;
141at1 = hplib_mUtilGetTimestamp();
142pt1=netapi_timing_start();
143for(;;)
144{
145 pt2=netapi_timing_start() ;
146 if ((pt2-pt1) >= 100000) break;
147}
148at2 = hplib_mUtilGetTimestamp();
149
150calib = ((unsigned long long) (pt2-pt1))/(at2-at1);
151printf("calibrate: arm time=%lld -> arm cycles=%d calib=%lld\n", at2-at1, pt2-pt1, calib);
152
153return calib;
154}
155
156/*******************************************
157 *************NETAPI OBJECTS***************
158 *****************************************/
159static NETAPI_CFG_T our_netapi_default_cfg=
160{
161TUNE_NETAPI_PERM_MEM_SZ,
162128, //start of packet offset for hw to place data on rx for default flow
163TUNE_NETAPI_QM_CONFIG_MAX_DESC_NUM, //max number of descriptors in system
164TUNE_NETAPI_NUM_GLOBAL_DESC, //total we will use
165TUNE_NETAPI_DEFAULT_NUM_BUFFERS, //#descriptors+buffers in default heap
16664, //#descriptors w/o buffers in default heap
167TUNE_NETAPI_DEFAULT_BUFFER_SIZE+128+128, //size of buffers in default heap
168128, //tail room
169256, //extra room
1700,
171NULL,
172-1,
173-1
174};
175
176Pktlib_HeapHandle OurHeap; //default heap, used by producer
177PKTIO_CFG_T netcp_rx_cfg={PKTIO_RX, PKTIO_NA, PKTIO_NA, 8};
178PKTIO_CFG_T netcp_tx_cfg={PKTIO_TX, PKTIO_NA, PKTIO_NA, 12};
179PKTIO_HANDLE_T * netcp_rx_chan;
180PKTIO_HANDLE_T * netcp_tx_chan;
181NETAPI_T netapi_handle;
182
183PKTIO_CONTROL_T zap_channel_control={PKTIO_CLEAR, NULL};
184PKTIO_CONTROL_T poll_cannel_control={PKTIO_SET_POLL_FLAGS, NULL, nwal_POLL_DEFAULT_GLOB_PKT_Q};
185
186//template for fast path
187nwalTxPktInfo_t txPktInfoNoCrypto =
188{
189 NULL, /* p_pkt */
190 NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
191 0, /* lpbackPass */
192 0, /* enetport */
193 0, /* msuSize */
194 0, /* startOffset */
195 0, /* saOffBytes */
196 0, /* saPayLoadLen */
197 0 , /* saAhIcvOffBytes */
198 0, /* saAhMacSize */
199 0,
200 /* etherLenOffBytes */
201 netTest_MAC_HEADER_LEN, /* ipOffBytes */
202 netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN, /* l4OffBytes */
203 netTest_UDP_HEADER_LEN, /* l4HdrLen */
204 0, /* pseudoHdrChecksum */
205 0 /* pLoadLen */
206};
207
208
209NETCP_CFG_ROUTE_T test_route=
210{
2110,
212NULL,
213NULL,
2140,
2150,
2160,
2171
218};
219
220
221/*************************END NETAPI OBJECTS***********************/
222
223static unsigned char all_mac[]={0,0,0,0,0,0};
224
225static unsigned long last_header[32/sizeof(unsigned long)];
226
227
228//stats
229int pkt_rx=0;
230int pkt_tx=0;
231unsigned long long pkt_rx_cycles=0L;
232unsigned long long pkt_tx_cycles=0L;
233unsigned long long pkt_cb_cycles=0L;
234unsigned long long idle_cycles=0L;
235volatile unsigned long long start_time;
236unsigned long long end_time;
237
238//**********************************
239//producer thread
240//*********************************
241void producer_thread(int coreid)
242{
243int err;
244int i;
245Ti_Pkt * tip;
246unsigned char * pData;
247int len;
248PKTIO_METADATA_T meta = {PKTIO_META_IFDMA_TX,{0},0};
249int np;
250cpu_set_t cpu_set;
251unsigned long t1;
252unsigned long t2;
253
254 CPU_ZERO( &cpu_set);
255 CPU_SET( 2, &cpu_set);
256 hplib_utilSetupThread(0, &cpu_set, hplib_spinLock_Type_LOL);
257 start_time = hplib_mUtilGetTimestamp();
258
259 //DAL we poll the default pktio channel for pkts from net
260 for(i=0;!((volatile int) QUIT);i++)
261 {
262 t1 = netapi_timing_start();
263 np = netapi_pktioPoll(netcp_rx_chan,NULL,&err);
264 t2 = netapi_timing_start();
265 pkt_rx+=np;
266 if (np)
267 {
268 pkt_rx_cycles += (t2-t1);
269 }
270 else
271 {
272 idle_cycles += (t2-t1);
273 }
274 if (RESET)
275 {
276 idle_cycles=0LL;
277 start_time = hplib_mUtilGetTimestamp();
278 pkt_rx=pkt_tx=0;
279 pkt_rx_cycles=pkt_tx_cycles=0LL;
280 pkt_cb_cycles=0LL;
281 RESET=0;
282 }
283 }
284 end_time = hplib_mUtilGetTimestamp();
285 printf("nt-bench: receiver DONE %d pkts rx, pkt poll cycles=% u; pkt rx cycle=%u pkt tx cycles=%u idle cycles=%lld duration=%lld ticks idle pct= %lld\n",
286 pkt_rx,
287 (unsigned) (pkt_rx ? (pkt_rx_cycles - pkt_cb_cycles)/pkt_rx : 0),
288 (unsigned) (pkt_rx ? (pkt_rx_cycles) /pkt_rx : 0),
289 (unsigned) (pkt_tx ? (pkt_tx_cycles) /pkt_tx : 0),
290 idle_cycles, (end_time-start_time),
291 (idle_cycles*100) /( CALIB* (end_time-start_time))
292
293 );
294 printf("Leaving producer_thread\n");
295}
296
297
298//******************************
299// main program
300//*****************************
301int main(int argc, char **argv)
302{
303 int err,i;
304 int32_t errCode;
305 Pktlib_HeapIfTable* pPktifTable;
306 Pktlib_HeapCfg heapCfg;
307 long t1, t2 ;
308 cpu_set_t cpu_set;
309 NETCP_CFG_ROUTE_T test_route;
310
311
312 //install signal handler for ^c
313 signal(SIGINT,netTest_utilMySig);
314
315 if (initRm())
316 {
317 printf("main: initRm() returned error\n");
318 exit(1);
319 }
320
321 CPU_ZERO( &cpu_set);
322 CPU_SET( 0, &cpu_set);
323 hplib_utilSetupThread(0, &cpu_set, hplib_spinLock_Type_LOL);
324
325
326 /*******************************************/
327 /*************NETAPI STARTUP****************/
328 /*******************************************/
329
330 /* create netapi */
331 our_netapi_default_cfg.rmHandle = rmClientServiceHandle;
332 netapi_handle = netapi_init(NETAPI_SYS_MASTER,
333 &our_netapi_default_cfg);
334 if (netapi_handle == NULL)
335 {
336 printf("main: netapi_init failure, exiting\n");
337 exit(1);
338 }
339
340 /* open the main heap */
341 OurHeap = Pktlib_findHeapByName("netapi");
342 if (!OurHeap) {printf("findheapbyname fail\n"); exit(1);}
343
344 //if we want to relay network packets, we create a handle to the
345 //default netcp receive queue here
346 netcp_rx_chan= netapi_pktioOpen(netapi_handle, NETCP_RX, (PKTIO_CB) recv_cb_net, &netcp_rx_cfg, &err);
347 if (!netcp_rx_chan) {printf("pktio open RX failed err=%d\n",err); exit(1);}
348
349 netcp_tx_chan= netapi_pktioOpen(netapi_handle, NETCP_TX, (PKTIO_CB) NULL, &netcp_tx_cfg, &err);
350 if (!netcp_tx_chan) {printf("pktio open TX failed err=%d\n",err); exit(1);}
351 else //install a fast path template into the NETCP TX channel
352 {
353 PKTIO_CONTROL_T control2;
354 control2.op = PKTIO_UPDATE_FAST_PATH;
355 PKTIO_CFG_T cfg2;
356 cfg2.fast_path_cfg.fp_send_option = PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT;
357 cfg2.fast_path_cfg.txPktInfo= &txPktInfoNoCrypto;
358 netapi_pktioControl(netcp_tx_chan, NULL, &cfg2, &control2, &err);
359 }
360
361
362/*********************************************/
363/*****************end NETAPI STARTUP**********/
364/*********************************************/
365
366/*************************************************
367********************some basic benchmarks*********
368**************************************************/
369printf("\n\n*******STARTING MEM ACCESS BENCHMARK*********\n\n");
370benchmarks1();
371printf("\n\n*******STARTING RAW BENCHMARK2*********\n\n");
372benchmarks2(OurHeap, 20);
373printf("\n\n*******STARTING RAW BENCHMARK3*********\n\n");
374benchmarks3(OurHeap, 20);
375printf("\n\n******STARTING RECV BENCHMARK (q to quit)*****\n\n");
376
377
378//now creaate a simple netcp rule
379//to get a lot of packets
380memset(&test_route, 0, sizeof(NETCP_CFG_ROUTE_T));
381test_route.valid_params = NETCP_CFG_VALID_PARAM_MATCH_ACTION_DEST;
382test_route.match_destination = NETCP_CFG_ACTION_TO_SW;
383test_route.routeType = 0;
384test_route.p_flow = NULL;
385test_route.p_dest_q = NULL;
386
387netapi_netcpCfgCreateMacInterface(
388 netapi_handle,
389 &all_mac[0],
390 NULL,
391 0,0,
392 (NETCP_CFG_ROUTE_HANDLE_T) &test_route,
393 (NETCP_CFG_VLAN_T ) NULL , //future
394 0,
395 1,
396 &err);
397
398//calibrate idle
399 CALIB = calibrate_idle();
400
401//**************************************
402//Create a worked thread
403//***************************************
404{
405 pthread_t *thrs;
406 int procs =1;
407 int c;
408 thrs = malloc( sizeof( pthread_t ) * procs );
409 if (thrs == NULL)
410 {
411 perror( "malloc" );
412 return -1;
413 }
414 printf( "benchmark-test: Starting %d threads...\n", procs );
415
416 if (pthread_create( &thrs[0], NULL, (void*)producer_thread,
417 (void *)0 ))
418 {
419 perror( "pthread_create" );
420 exit(1);
421 }
422 //this thread of execution (main) now just waits on user input
423 for(;;)
424 {
425 printf(">");
426 c=getchar();
427 if (c=='c') {CAP=!CAP; printf("CAPTURE= %d\n", CAP); }
428 else if (c=='q') {QUIT=1;break;}
429 else if (c=='t') {XMIT=!XMIT; printf("XMIT= %d\n", XMIT); }
430 else if (c=='s')
431 {
432 unsigned long long et= hplib_mUtilGetTimestamp();
433 printf(">NT_BENCH STATS: %d received %d xmitted, %lld idle cycles, %lld duration ticks idle=%lld\n",
434 pkt_rx,pkt_tx,
435 idle_cycles,
436 (et-start_time),
437 (idle_cycles*100)/(CALIB*(et-start_time)));
438 Pktlib_HeapStats pktLibHeapStats;
439 Pktlib_getHeapStats(OurHeap, &pktLibHeapStats);
440 printf("main heap stats> #free=%d #zb=%d #garbage=%d\n",
441 pktLibHeapStats.numFreeDataPackets,
442 pktLibHeapStats.numZeroBufferPackets,
443 pktLibHeapStats.numPacketsinGarbage);
444 }
445 else if (c=='r')
446 {
447 RESET=1;
448 }
449 else if (c=='h')
450 {
451 printf("> 'q' to quit, 's' for stats, 't' to toggle transmit 'c' to toggle capture, 'd' to dump capture, 'r' to reset idle counters, 'h' for help\n");
452 }
453 else if (c=='d')
454 {
455 netTest_utilDumpHeader(&last_header[0], 0,0,0);
456 }
457 }
458
459 //wait for completion
460 printf("main task now pending on thread completion\n");
461 for (i = 0; i < procs; i++)
462 pthread_join( thrs[i], NULL );
463
464 free( thrs );
465
466}
467
468/*************************************************
469 ************CLEAN UP****************************
470 ************************************************/
471//get rid of rule, in the case that we are relaying packets
472//also close our netcp rx channel
473netapi_netcpCfgDelMac(netapi_handle,0,&err);
474netapi_pktioClose(netcp_rx_chan,&err);
475netapi_pktioClose(netcp_tx_chan,&err);
476
477
478//done
479netapi_shutdown(netapi_handle);
480
481
482//!finished!
483}
484static inline void sendit(Ti_Pkt *tip, int len, int out_port)
485{
486 int err=0;
487 PKTIO_METADATA_T meta2 = {PKTIO_META_TX,{0},0};
488 nwalTxPktInfo_t meta_tx2={0};
489 if (len<60)
490 {
491 unsigned int templen;
492 char * p_pkt;
493 len=60;
494 Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);//ignore templen
495 Cppi_setData (Cppi_DescType_HOST, (Cppi_Desc *) tip, p_pkt,len);
496 }
497 Pktlib_setPacketLen(tip,len);
498 meta_tx2.txFlag1 = NWAL_TX_FLAG1_META_DATA_VALID ;
499 meta_tx2.ploadLen = len ;
500 meta_tx2.enetPort=out_port;
501 meta2.u.tx_meta=&meta_tx2;
502 netapi_pktioSend(netcp_tx_chan,tip,&meta2,&err);
503}
504
505//receive callback for packets from net (for consumer)
506void recv_cb_net(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
507 PKTIO_METADATA_T meta[], int n_pkts,
508 uint64_t ts )
509{
510int i;
511Ti_Pkt * tip;
512int len;
513unsigned long t1;
514unsigned long t2;
515unsigned long t3;
516unsigned long t4;
517pasahoLongInfo_t* protoInfo;
518int ifno;
519int out_port;
520
521t1= netapi_timing_start();
522for(i=0;i<n_pkts;i++)
523{
524 tip = p_recv[i];
525 len = Pktlib_getPacketLen(tip);
526
527 if (CAP)
528 {
529 unsigned int templen;
530 char * p_pkt;
531 Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);//ignore templen
532 memcpy(last_header,p_pkt,32);
533 }
534
535 if (XMIT)
536 {
537 protoInfo=nwal_mGetProtoInfo(tip);
538 ifno = nwal_mGetRxEmacPort( protoInfo);
539 //----------------------------------------------------
540 //very trivial bridging -> just output to other port!
541 //----------------------------------------------------
542 if (ifno ==1) out_port=2; else out_port=1;
543 t3= netapi_timing_start();
544 sendit(tip,len,out_port);
545 pkt_tx+=1;
546 t4= netapi_timing_start();
547 pkt_tx_cycles += (t4-t3);
548 }
549 else
550 {
551 Pktlib_freePacket((Ti_Pkt*)tip);
552 }
553}
554t2 = netapi_timing_start();
555pkt_cb_cycles += (t2-t1);
556}
557
558
559
560
561//SOME BENCHMARKS
562//sonme benchmarks
563void benchmarks1(void)
564{
565 int i,j;
566 unsigned long v1pop;
567 unsigned long v2pop;
568 unsigned long v1push;
569 unsigned long v2push;
570 unsigned long v1read;
571 unsigned long v2read;
572 unsigned long v1write;
573 unsigned long v2write;
574 unsigned long v1read2;
575 unsigned long v2read2;
576#define N 100
577 Ti_Pkt pkts[N];
578 unsigned char * p_pkt;
579 int len;
580 int sum=0;
581 int sum2=0;
582 char *p=(char *) malloc(1000);
583
584 if(p)
585 {
586 for(i=0;i<1000;i++)
587 p[i] = i;
588 //alloc
589 v1pop=netapi_timing_start();
590 for(i=0;i<N;i++) pkts[i]= Pktlib_allocPacket(OurHeap,1000);
591 v2pop = netapi_timing_start();
592
593 //write access
594 Pktlib_getDataBuffer(pkts[0],(uint8_t**)&p_pkt,&len);
595 v1write=netapi_timing_start();
596 for(i=0;i<1000;i++) p_pkt[i]=i;
597 v2write=netapi_timing_start();
598
599 //read access
600 v1read=netapi_timing_start();
601 for(j=0;j<10;j++)
602 for(i=0;i<1000;i++) sum+=p_pkt[i];
603 v2read=netapi_timing_start();
604
605 // access (from malloc)
606 v1read2=netapi_timing_start();
607 for(i=0;i<1000;i++) sum2+=p[i];
608 v2read2=netapi_timing_start();
609
610 //free packet
611 v1push=netapi_timing_start();
612 for(i=0;i<N;i++) Pktlib_freePacket(pkts[i]);
613 v2push = netapi_timing_start();
614
615 //resutls
616 printf("allocs= %d free=%d write=%d read=%d read-malloc=%d (sum=%d %d)\n",
617 (v2pop-v1pop)/N, (v2push-v1push)/N, (v2write-v1write)/1000, (v2read-v1read)/10000,
618 (v2read2-v1read2)/1000,sum,sum2);
619 free(p);
620 }
621
622};
623
624
625//raw queue benchmark
626#include "ti/drv/nwal/nwal_util.h"
627
628#define NTOPOP 150
629volatile unsigned long t1;
630volatile unsigned long t2;
631volatile unsigned long t3;
632volatile unsigned long t4;
633volatile unsigned long t5;
634volatile unsigned long t6;
635volatile unsigned long sum1=0;
636volatile unsigned long sum2=0;
637volatile unsigned long sum3=0;
638volatile unsigned long sum4=0;
639volatile Ti_Pkt * pHd[NTOPOP];
640
641
642void benchmarks2(Pktlib_HeapHandle h , int ntrials)
643{
644int i,j;
645int k;
646int abort=0;
647Qmss_QueueHnd freeQ=Pktlib_getInternalHeapQueue(h);
648
649//n_trials of NTOPOP actions
650for(i=0;i<ntrials;i++)
651{
652 abort=0;
653 sum1=sum2=sum3=sum4=0;
654 //raw pop
655 t1= netapi_timing_start();
656 for(j=0;j<NTOPOP;j++)
657 {
658 pHd[j] = (Ti_Pkt *)QMSS_DESC_PTR(pktio_mQmssQueuePopRaw (freeQ));
659 if (!pHd[j])
660 {
661 printf("abort test. out of descriptors\n"); abort=1;
662 break;
663 }
664 }
665 t2= netapi_timing_start();
666 k=j;
667 for(j=0;j<k;j++)
668 {
669 pHd[j] = Osal_qmssConvertDescPhyToVirt(0,pHd[j]);
670 }
671 t3= netapi_timing_start();
672 sum1 += (t2-t1);
673 sum2 += (t3-t2);
674 //raw push
675 t4= netapi_timing_start();
676 for(j=0;j<k;j++)
677 {
678 if (!pHd[j]) continue;
679 pHd[j]= Osal_qmssConvertDescVirtToPhy(0,pHd[j]);
680 }
681 t5= netapi_timing_start();
682 for(j=0;j<k;j++)
683 {
684 pktio_mQmssQueuePushDescSizeRaw(freeQ,
685 (void *) pHd[j],
686 128);
687 }
688 t6= netapi_timing_start();
689 sum3 += (t5-t4);
690 sum4 += (t6-t5);
691
692 if (!abort)
693 printf("nt=%d raw pop=%d p2v=%d v2p=%d raw push=%d\n", i,
694 sum1/k, sum2/k, sum3/k, sum4/k);
695 sleep(1);
696}
697return;
698}
699
700//full queue push/pops
701void benchmarks3(Pktlib_HeapHandle h , int ntrials)
702{
703int i,j;
704int k;
705int abort=0;
706Qmss_QueueHnd freeQ=Pktlib_getInternalHeapQueue(h);
707
708//n_trials of NTOPOP actions
709for(i=0;i<ntrials;i++)
710{
711 abort=0;
712 sum2=sum4=0;
713 //raw pop
714 t1= netapi_timing_start();
715 for(j=0;j<NTOPOP;j++)
716 {
717 pHd[j] = (Ti_Pkt *)QMSS_DESC_PTR(Qmss_queuePop(freeQ));
718 if (!pHd[j])
719 {
720 printf("abort test. out of descriptors\n"); abort=1;
721 break;
722 }
723 }
724 t3= netapi_timing_start();
725 sum2 += (t3-t1);
726 k=j;
727 //raw push
728 t5= netapi_timing_start();
729 for(j=0;j<k;j++)
730 {
731 if (!pHd[j]) continue;
732 Qmss_queuePushDescSize(freeQ, pHd[j], 128);
733 }
734 t6= netapi_timing_start();
735 sum4 += (t6-t5);
736 if (!abort)
737 printf("nt=%d pop=%d push=%d\n", i,
738 sum2/k, sum4/k);
739 sleep(1);
740}
741return;
742}
743
diff --git a/ti/runtime/netapi/test/net_test_config.txt b/ti/runtime/netapi/test/net_test_config.txt
new file mode 100755
index 0000000..b38ccdd
--- /dev/null
+++ b/ti/runtime/netapi/test/net_test_config.txt
@@ -0,0 +1,68 @@
1#sp0 thread-number start-core end-core
2sp0 = 1 0-0
3fp0 = 2 1-1
4fp1 = 3 2-2
5fp2 = 4 3-3
6#mac0 = mac-address switch-port
7mac0 = 00-01-02-03-05-05 swp0
8mac1 = 00-01-02-03-06-07 swp0
9
10#ip0 = ip-address mac-interface
11ip0 = 10.0.0.100 mac0
12ip1 = 10.0.1.100 mac1
13ip2 = 10.0.2.100 mac0
14
15local_ipsec_ip = 192.168.1.100
16remote_ipsec_ip = 192.168.1.10
17ipsec_if = 0
18#
19dsp_ip = ip0
20#
21#ipsec_mode_rx = SIDEBAND
22#ipsec_mode_tx = SIDEBAND
23ipsec_mode_rx = INFLOW
24ipsec_mode_tx = INFLOW
25route0 = MAC00-00-00-00-00-0f 1
26route1 = MAC00-00-00-00-00-ff 2
27
28dstip0 = 172.0.0.2 route1
29dstip1 = 172.1.0.2 route0
30
31# _dest_udp port config, if set to ZERO, net_test will use eceived src port as destination port when packet
32# is transmitted to network, if non-ZERO, net test will use this the the destination port when packet
33# is tranmitted to network.
34dest_udp_port_config = 30000
35
36#sa0 = dir spi prot saMode iptype srcip destip window auth cipher esnlo esphi encrkeysize authkeysize encrkey pauthkey tunnel_id
37
38sa0 = INBOUND 0x11111111 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA1 AES_CBC 0 0 16 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
39
40sa1 = OUTBOUND 0x11111111 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA1 AES_CBC 0 0 16 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
41
42sa2 = INBOUND 0x44444444 AH TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_MD5 NULL 0 0 0 16 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x1
43
44sa3 = OUTBOUND 0x44444444 AH TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_MD5 NULL 0 0 0 16 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x1
45
46sa4 = INBOUND 0x22222222 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA2_256 AES_CTR 0 0 20 32 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x3
47
48sa5 = OUTBOUND 0x22222222 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA2_256 AES_CTR 0 0 20 32 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x3
49
50sa6 = INBOUND 0x55555555 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 NULL AES_GCM 0 0 20 0 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x4
51
52sa7 = OUTBOUND 0x55555555 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 NULL AES_GCM 0 0 20 0 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x4
53
54sa8 = INBOUND 0x66666666 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 NULL AES_CCM 0 0 19 0 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x5
55
56sa9 = OUTBOUND 0x66666666 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 NULL AES_CCM 0 0 19 0 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x5
57
58sa10 = INBOUND 0x33333333 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA2_256 3DES_CBC 0 0 24 32 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x6
59
60sa11 = OUTBOUND 0x33333333 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA2_256 3DES_CBC 0 0 24 32 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x6
61
62sa12 = INBOUND 0x77777777 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 AES_XCBC NULL 0 0 0 16 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x7
63
64sa13 = OUTBOUND 0x77777777 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 AES_XCBC NULL 0 0 0 16 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x7
65
66#sa14 = INBOUND 0x88888888 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 GMAC NULL 0 0 0 20 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x8
67
68#sa15 = OUTBOUND 0x88888888 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 GMAC NULL 0 0 0 20 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x8
diff --git a/ti/runtime/netapi/test/net_test_config_max_iface.txt b/ti/runtime/netapi/test/net_test_config_max_iface.txt
new file mode 100644
index 0000000..fa90322
--- /dev/null
+++ b/ti/runtime/netapi/test/net_test_config_max_iface.txt
@@ -0,0 +1,143 @@
1#sp0 thread-number start-core end-core
2sp0 = 1 0-0
3fp0 = 2 0-0
4fp1 = 3 0-0
5#mac0 = mac-address switch-port
6mac0 = 00-01-02-03-05-01 sp0
7mac1 = 00-01-02-03-05-02 sp1
8mac2 = 00-01-02-03-05-03 sp0
9mac3 = 00-01-02-03-05-04 sp1
10mac4 = 00-01-02-03-05-05 sp0
11mac5 = 00-01-02-03-05-06 sp1
12mac6 = 00-01-02-03-05-07 sp0
13mac7 = 00-01-02-03-05-08 sp0
14mac8 = 00-01-02-03-05-09 sp0
15mac9 = 00-01-02-03-05-0a sp0
16mac10 = 00-01-02-03-05-15 sp0
17mac11 = 00-01-02-03-05-25 sp0
18mac12 = 00-01-02-03-05-35 sp0
19mac13 = 00-01-02-03-05-45 sp0
20mac14 = 00-01-02-03-05-55 sp0
21mac15 = 00-01-02-03-05-65 sp0
22mac16 = 00-01-02-03-05-75 sp0
23mac17 = 00-01-02-03-05-85 sp0
24mac18 = 00-01-02-03-05-95 sp0
25mac19 = 00-01-02-03-01-05 sp0
26mac20 = 00-01-02-03-02-05 sp0
27mac21 = 00-01-02-03-03-06 sp1
28mac22 = 00-01-02-03-04-05 sp0
29mac23 = 00-01-02-33-05-06 sp1
30mac24 = 00-01-02-03-06-05 sp0
31mac25 = 00-01-02-03-07-06 sp1
32mac26 = 00-01-02-03-08-06 sp1
33mac27 = 00-01-02-03-09-05 sp0
34mac28 = 00-01-02-01-05-06 sp1
35mac29 = 00-01-02-02-05-05 sp0
36mac30 = 00-01-02-63-05-06 sp1
37mac31 = 00-01-02-04-05-06 sp1
38mac32 = 00-01-02-05-05-05 sp0
39mac33 = 00-01-02-06-05-06 sp1
40mac34 = 00-01-02-07-05-05 sp0
41mac35 = 00-01-02-08-05-06 sp1
42mac36 = 00-01-02-09-05-06 sp1
43mac37 = 00-01-01-03-05-05 sp0
44mac38 = 00-01-22-03-05-06 sp1
45mac39 = 00-01-03-03-05-05 sp0
46mac40 = 00-01-04-03-05-06 sp1
47mac41 = 00-01-05-03-05-06 sp1
48mac42 = 00-01-05-03-05-05 sp0
49mac43 = 00-01-06-03-05-06 sp1
50mac44 = 00-01-07-03-05-05 sp0
51mac45 = 00-01-08-03-05-06 sp1
52mac46 = 00-01-09-03-05-06 sp1
53mac47 = 00-01-12-03-05-05 sp0
54mac48 = 00-01-22-33-05-06 sp1
55mac49 = 00-01-32-03-05-05 sp0
56mac50 = 00-01-42-03-05-06 sp1
57mac51 = 00-01-52-03-05-06 sp1
58mac52 = 00-01-62-03-05-05 sp0
59mac53 = 00-01-72-03-05-06 sp1
60mac54 = 00-01-82-03-05-05 sp0
61mac55 = 00-01-92-03-05-06 sp1
62mac56 = 00-01-02-83-05-06 sp1
63mac57 = 00-02-02-03-05-05 sp0
64mac58 = 00-43-02-03-05-06 sp1
65
66#ip0 = ip-address mac-interface
67ip0 = 10.0.0.100 mac0
68ip1 = 10.0.1.100 mac1
69ip2 = 10.0.2.100 mac2
70ip3 = 10.0.0.100 mac3
71ip4 = 10.0.1.100 mac4
72ip5 = 10.0.2.100 mac5
73ip6 = 10.0.0.100 mac6
74ip7 = 10.0.1.100 mac7
75ip8 = 10.0.2.100 mac8
76ip9 = 10.0.0.100 mac9
77ip10 = 10.0.1.100 mac10
78ip11 = 10.0.1.100 mac11
79ip12 = 10.0.1.100 mac12
80ip13 = 10.0.1.100 mac13
81ip14 = 10.0.1.100 mac14
82ip15 = 10.0.1.100 mac15
83ip16 = 10.0.1.100 mac16
84ip17 = 10.0.1.100 mac17
85ip18 = 10.0.1.100 mac18
86ip19 = 10.0.1.100 mac19
87ip20 = 10.0.1.100 mac20
88ip21 = 10.0.1.100 mac21
89ip22 = 10.0.1.100 mac22
90ip23 = 10.0.1.100 mac23
91ip24 = 10.0.1.100 mac24
92ip25 = 10.0.1.100 mac25
93ip26 = 10.0.1.100 mac26
94ip27 = 10.0.1.100 mac27
95ip28 = 10.0.1.100 mac28
96ip29 = 10.0.1.100 mac29
97ip30 = 10.0.1.100 mac30
98ip31 = 10.0.1.100 mac31
99ip32 = 10.0.1.100 mac32
100ip33 = 10.0.1.100 mac33
101ip34 = 10.0.1.100 mac34
102ip35 = 10.0.1.100 mac35
103ip36 = 10.0.1.100 mac36
104ip37 = 10.0.1.100 mac37
105ip38 = 10.0.1.100 mac38
106ip39 = 10.0.1.100 mac39
107ip40 = 10.0.1.100 mac40
108ip41 = 10.0.1.100 mac41
109ip42 = 10.0.1.100 mac42
110ip43 = 10.0.1.100 mac43
111ip44 = 10.0.1.100 mac44
112ip45 = 10.0.1.100 mac45
113ip46 = 10.0.1.100 mac46
114ip47 = 10.0.1.100 mac47
115ip48 = 10.0.1.100 mac48
116ip49 = 10.0.1.100 mac49
117ip50 = 10.0.1.100 mac50
118ip51 = 10.0.1.100 mac51
119ip52 = 10.0.1.100 mac52
120ip53 = 10.0.1.100 mac53
121ip54 = 10.0.1.100 mac54
122ip55 = 10.0.1.100 mac55
123ip56 = 10.0.1.100 mac56
124ip57 = 10.0.1.100 mac57
125ip58 = 10.0.1.100 mac58
126
127local_ipsec_ip = 192.168.1.100
128remote_ipsec_ip = 192.168.1.10
129ipsec_if = 0
130#ipsec_mode_rx = SIDEBAND
131#ipsec_mode_tx = SIDEBAND
132ipsec_mode_rx = INFLOW
133ipsec_mode_tx = INFLOW
134route0 = MAC00-23-24-08-67-46 0
135route1 = MAC00-22-33-44-55-56 1
136
137dstip0 = 10.1.0.100 route1
138dspip1 = 10.0.0.10 route0
139
140
141#sa0 = dir spi prot saMode iptype srcip destip window auth cipher esnlo esphi encrkeysize authkeysize encrkey pauthkey tunnel_id
142
143
diff --git a/ti/runtime/netapi/test/net_test_config_max_sa.txt b/ti/runtime/netapi/test/net_test_config_max_sa.txt
new file mode 100644
index 0000000..30dc165
--- /dev/null
+++ b/ti/runtime/netapi/test/net_test_config_max_sa.txt
@@ -0,0 +1,155 @@
1#sp0 thread-number start-core end-core
2#mac0 = mac-address switch-port
3#mac0 = 00-01-02-03-05-05 sp0
4#mac1 = 00-01-02-03-05-06 sp1
5#ip0 = ip-address mac-interface
6#ip0 = 10.0.0.100 mac0
7#ip1 = 10.0.1.100 mac0
8#ip2 = 10.0.2.100 mac0
9local_ipsec_ip = 192.168.1.100
10remote_ipsec_ip = 192.168.1.10
11ipsec_if = 0
12#ipsec_mode_rx = SIDEBAND
13#ipsec_mode_tx = SIDEBAND
14ipsec_mode_rx = INFLOW
15ipsec_mode_tx = INFLOW
16route0 = MAC00-23-24-08-67-46 0
17route1 = MAC00-22-33-44-55-56 1
18
19dstip0 = 10.1.0.100 route1
20dspip1 = 10.0.0.10 route0
21
22
23#sa0 = dir spi prot saMode iptype srcip destip window auth cipher esnlo esphi encrkeysize authkeysize encrkey pauthkey tunnel_id
24
25sa0 = INBOUND 0x1 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA1 AES_CBC 0 0 32 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
26
27sa1 = OUTBOUND 0x2 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA1 AES_CBC 0 0 32 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
28
29sa2 = INBOUND 0x3 AH TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_MD5 NULL 0 0 0 16 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x1
30
31sa3 = OUTBOUND 0x4 AH TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_MD5 NULL 0 0 0 16 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x1
32
33sa4 = INBOUND 0x5 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA2_256 AES_CTR 0 0 20 32 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x3
34
35sa5 = OUTBOUND 0x6 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA2_256 AES_CTR 0 0 20 32 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x3
36
37sa6 = INBOUND 0x7 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 NULL AES_GCM 0 0 20 0 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x4
38
39sa7 = OUTBOUND 0x8 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 NULL AES_GCM 0 0 20 0 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x4
40
41sa8 = INBOUND 0x9 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 NULL AES_CCM 0 0 19 0 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x5
42
43sa9 = OUTBOUND 0x10 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 NULL AES_CCM 0 0 19 0 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x5
44
45sa10 = INBOUND 0x11 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA2_256 3DES_CBC 0 0 24 32 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x6
46
47sa11 = OUTBOUND 0x12 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA2_256 3DES_CBC 0 0 24 32 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x6
48
49sa12 = INBOUND 0x13 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 AES_XCBC NULL 0 0 0 16 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x7
50
51sa13 = OUTBOUND 0x14 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 AES_XCBC NULL 0 0 0 16 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x7
52
53sa14 = INBOUND 0x15 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 GMAC NULL 0 0 0 20 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x8
54
55sa15 = OUTBOUND 0x16 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 GMAC NULL 0 0 0 20 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x8
56
57sa16 = INBOUND 0x17 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA1 AES_CBC 0 0 32 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
58
59sa17 = OUTBOUND 0x18 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA1 AES_CBC 0 0 32 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
60
61sa18 = INBOUND 0x19 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA1 AES_CBC 0 0 32 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
62
63sa19 = OUTBOUND 0x20 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA1 AES_CBC 0 0 32 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
64
65sa20 = INBOUND 0x21 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA1 AES_CBC 0 0 32 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
66
67sa21 = OUTBOUND 0x22 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA1 AES_CBC 0 0 32 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
68
69sa22 = INBOUND 0x23 AH TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_MD5 NULL 0 0 0 16 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x1
70
71sa23 = OUTBOUND 0x24 AH TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_MD5 NULL 0 0 0 16 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x1
72
73sa24 = INBOUND 0x25 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA2_256 AES_CTR 0 0 20 32 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x3
74
75sa25 = OUTBOUND 0x26 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA2_256 AES_CTR 0 0 20 32 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x3
76
77sa26 = INBOUND 0x27 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 NULL AES_GCM 0 0 20 0 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x4
78
79sa27 = OUTBOUND 0x28 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 NULL AES_GCM 0 0 20 0 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x4
80
81sa28 = INBOUND 0x29 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA1 AES_CBC 0 0 32 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
82
83sa29 = OUTBOUND 0x30 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA1 AES_CBC 0 0 32 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
84
85sa30 = INBOUND 0x31 AH TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_MD5 NULL 0 0 0 16 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x1
86
87sa31 = OUTBOUND 0x32 AH TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_MD5 NULL 0 0 0 16 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x1
88
89sa32 = INBOUND 0x33 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA2_256 AES_CTR 0 0 20 32 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x3
90
91sa33 = OUTBOUND 0x34 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA2_256 AES_CTR 0 0 20 32 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x3
92
93sa34 = INBOUND 0x35 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 NULL AES_GCM 0 0 20 0 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x4
94
95sa35 = OUTBOUND 0x36 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 NULL AES_GCM 0 0 20 0 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x4
96
97sa36 = INBOUND 0x37 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 NULL AES_CCM 0 0 19 0 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x5
98
99sa37 = OUTBOUND 0x38 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 NULL AES_CCM 0 0 19 0 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x5
100
101sa38 = INBOUND 0x39 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA2_256 3DES_CBC 0 0 24 32 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x6
102
103sa39 = OUTBOUND 0x40 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA2_256 3DES_CBC 0 0 24 32 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x6
104
105sa40 = INBOUND 0x41 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 AES_XCBC NULL 0 0 0 16 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x7
106
107sa41 = OUTBOUND 0x42 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 AES_XCBC NULL 0 0 0 16 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x7
108
109sa42 = INBOUND 0x43 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 GMAC NULL 0 0 0 20 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x8
110
111sa43 = OUTBOUND 0x44 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 GMAC NULL 0 0 0 20 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x8
112
113sa44 = INBOUND 0x45 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA1 AES_CBC 0 0 32 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
114
115sa45 = OUTBOUND 0x46 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA1 AES_CBC 0 0 32 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
116
117sa46 = INBOUND 0x47 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA1 AES_CBC 0 0 32 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
118
119sa47 = OUTBOUND 0x48 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA1 AES_CBC 0 0 32 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
120
121sa48 = INBOUND 0x49 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA1 AES_CBC 0 0 32 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
122
123sa49 = OUTBOUND 0x50 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA1 AES_CBC 0 0 32 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
124
125sa50 = INBOUND 0x51 AH TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_MD5 NULL 0 0 0 16 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x1
126
127sa51 = OUTBOUND 0x52 AH TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_MD5 NULL 0 0 0 16 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x1
128
129sa52 = INBOUND 0x53 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA2_256 AES_CTR 0 0 20 32 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x3
130
131sa53 = OUTBOUND 0x54 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA2_256 AES_CTR 0 0 20 32 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x3
132
133sa54 = INBOUND 0x55 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 NULL AES_GCM 0 0 20 0 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x4
134
135sa55 = INBOUND 0x56 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA1 AES_CBC 0 0 32 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
136
137sa56 = OUTBOUND 0x57 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA1 AES_CBC 0 0 32 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
138
139sa57 = INBOUND 0x58 AH TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_MD5 NULL 0 0 0 16 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x1
140
141sa58 = OUTBOUND 0x59 AH TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_MD5 NULL 0 0 0 16 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x1
142
143sa59 = INBOUND 0x60 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA2_256 AES_CTR 0 0 20 32 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x3
144
145sa60 = OUTBOUND 0x61 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA2_256 AES_CTR 0 0 20 32 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x3
146
147sa61 = INBOUND 0x62 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 NULL AES_GCM 0 0 20 0 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x4
148
149sa62 = OUTBOUND 0x63 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA2_256 AES_CTR 0 0 20 32 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x3
150
151sa63 = INBOUND 0x64 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 NULL AES_GCM 0 0 20 0 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x4
152
153sa64 = OUTBOUND 0x65 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA2_256 AES_CTR 0 0 20 32 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x3
154
155
diff --git a/ti/runtime/netapi/test/net_test_loopback.c b/ti/runtime/netapi/test/net_test_loopback.c
new file mode 100755
index 0000000..245828b
--- /dev/null
+++ b/ti/runtime/netapi/test/net_test_loopback.c
@@ -0,0 +1,1359 @@
1/******************************************************************************
2 * File: net_test.c
3 * Purpose: test app for netapi
4 ******************************************************************************
5 * FILE: net_test.c
6 *
7 * DESCRIPTION: netapi user space transport
8 * library test application
9 *
10 * REVISION HISTORY:
11 *
12 * Copyright (c) Texas Instruments Incorporated 2013
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
42 *****************************************************************************/
43
44#include "netapi.h"
45#include "net_test_sa_utils.h"
46#include "net_test_utils.h"
47#include "net_test_thread_utils.h"
48#include "ti/drv/nwal/test/fw_rm.h"
49#include <signal.h>
50#include <pthread.h>
51
52
53#if defined(DEVICE_K2H)
54#include <ti/drv/qmss/device/k2h/src/qmss_device.c>
55#include <ti/drv/cppi/device/k2h/src/cppi_device.c>
56#elif defined (DEVICE_K2K)
57#include <ti/drv/qmss/device/k2k/src/qmss_device.c>
58#include <ti/drv/cppi/device/k2k/src/cppi_device.c>
59#elif defined (DEVICE_K2L)
60#include <ti/drv/qmss/device/k2l/src/qmss_device.c>
61#include <ti/drv/cppi/device/k2l/src/cppi_device.c>
62#elif defined (DEVICE_K2E)
63#include <ti/drv/qmss/device/k2e/src/qmss_device.c>
64#include <ti/drv/cppi/device/k2e/src/cppi_device.c>
65#else /*Default */
66#include <ti/drv/qmss/device/k2h/src/qmss_device.c>
67#include <ti/drv/cppi/device/k2h/src/cppi_device.c>
68#endif /* Device */
69
70
71extern int QUIT;
72extern netTestStats_T stats[];
73extern paSysStats_t netcp_stats;
74
75extern Rm_ServiceHandle *rmClientServiceHandle;
76hplib_spinLock_T net_test_thread_lock;
77
78
79netTestConfig_t netTestCfg;
80static netTestConfigFile_t config_file;
81char input_file_name[] = "/etc/transportnetlib/test/net_test_config.txt";
82nwal_RetValue nwalRetVal;
83Pktlib_HeapHandle ourHeap;
84
85PKTIO_HANDLE_T *netcp_rx_chan;
86PKTIO_HANDLE_T *netcp_tx_chan_no_crypto;
87PKTIO_HANDLE_T *netcp_tx_chan_esp;
88PKTIO_HANDLE_T *netcp_tx_chan_ah;
89PKTIO_HANDLE_T *netcp_sb_tx_chan;
90PKTIO_HANDLE_T *netcp_sb_rx_chan;
91
92PKTIO_CFG_T netcp_rx_cfg={PKTIO_RX, PKTIO_NA, PKTIO_NA, 8};
93PKTIO_CFG_T netcp_rx_cfg2={PKTIO_RX, (PKTIO_GLOBAL|PKTIO_PKT), PKTIO_Q_ANY, 8};
94PKTIO_CFG_T netcp_tx_cfg={PKTIO_TX, PKTIO_NA, PKTIO_NA, 8};
95PKTIO_CFG_T netcp_sb_rx_cfg={PKTIO_RX, PKTIO_NA, PKTIO_NA, 8};
96PKTIO_CFG_T netcp_sb_tx_cfg={PKTIO_TX, PKTIO_NA, PKTIO_NA, 8};
97
98NETCP_CFG_IP_T ip_rule[NET_TEST_MAX_IP];
99NETCP_CFG_MACIF_T mac[NET_TEST_MAX_MAC];
100
101#ifdef netTest_DSP_FASTPATH
102PKTIO_HANDLE_T *dsp_pktio_channels[CPU_NUM_REM_FAST_PATH_CORES];
103NETCP_CFG_CLASS_T dsp_classifers[CPU_NUM_REM_FAST_PATH_CORES];
104NETCP_CFG_FLOW_HANDLE_T dsp_flow_handles[CPU_NUM_REM_FAST_PATH_CORES];
105#endif
106NETCP_CFG_EXCEPTION_PKT_T expPkt_appid;
107
108Trie *p_trie_sa_rx;
109Trie *p_trie_sa_tx;
110
111
112/*******************************************
113 *************NETAPI OBJECTS***************
114 *****************************************/
115static NETAPI_CFG_T our_netapi_default_cfg=
116{
117 TUNE_NETAPI_PERM_MEM_SZ,
118 128, //start of packet offset for hw to place data on rx for default flow
119 TUNE_NETAPI_QM_CONFIG_MAX_DESC_NUM, //max number of descriptors in system
120 TUNE_NETAPI_NUM_GLOBAL_DESC, //total we will use
121 TUNE_NETAPI_DEFAULT_NUM_BUFFERS, //#descriptors+buffers in default heap
122 64, //#descriptors w/o buffers in default heap
123 TUNE_NETAPI_DEFAULT_BUFFER_SIZE+128+128, //size of buffers in default heap
124 128, //tail room
125 256, //extra room
126 0,
127 NULL,
128 -1,
129 -1
130};
131
132NETAPI_T netapi_handle;
133NETAPI_SCHED_HANDLE_T * our_sched;
134#ifdef netTest_MULTI_THREAD
135NETAPI_SCHED_HANDLE_T * scheduler[TUNE_NETAPI_NUM_CORES];
136#endif
137NETAPI_SCHED_CONFIG_T our_sched_cfg={
138 NETAPI_SCHED_DURATION|NETAPI_SCHED_CBV, 0, house, 5000000 //every 5000000 poll loops
139};
140
141netTestSA_t sa_info[MAX_SEC_INDEX];
142NETCP_CFG_IPSEC_POLICY_T rx_policy[MAX_SEC_INDEX];
143
144int masterType = NETAPI_SYS_MASTER;
145
146
147
148
149
150/********************************************************************
151 * FUNCTION PURPOSE: Utility function to flip and packet and send
152 * it back to its source.
153 ********************************************************************
154 * DESCRIPTION: Utility function to flip and packet and send
155 * it back to its source.
156 ********************************************************************/
157void flip_and_send_pkt(Ti_Pkt *tip, unsigned char * p_pkt, int len, int flag, uint16_t enet_port)
158{
159 unsigned char mac_temp[6];
160 unsigned char ip_temp[4];
161 unsigned char new_dest_port[2]={0x75,0x30}; // 30000
162 uint16_t dest_udp_port_config = 0;
163 uint16_t blah;
164 uint16_t i=1; /* for testing only */
165
166 uint8_t *p_spi;
167 netTestSA_t * p_sa_info;
168 netTestSA_t *p_sa_info_tx;
169 uint8_t p_iv[16];
170 uint8_t p_add[8];
171 Cppi_HostDesc* pPloadDesc;
172 uint8_t ah_len;
173 uint32_t tunnel_id;
174 nwalLocCxtInfo_t nwalLocCxt;
175 netTestHead_T * p_head;
176 netTestHead_T temp_head;
177 int pkt_type;
178
179#ifdef netTest_MULTI_THREAD
180 int coreid=Osal_nwalGetProcId(); //who we are(thread local)
181 //int coreid = our_core;
182#else
183int coreid=0;
184#endif
185 // netTest_utilDumpBuffer((long*)p_pkt,len);
186 Pktlib_setPacketLen(tip,len);
187 //flip the mac address
188 memcpy(&mac_temp,&p_pkt[0],6);
189 memcpy(&p_pkt[0],&p_pkt[6],6);
190 memcpy(&p_pkt[6],&mac_temp,6);
191 //memcpy(&p_pkt[0],real_mac_header,6); //for testing to wireshark pc
192
193 //flip the ip (outer in case of ipsec)
194 memcpy(&ip_temp, &p_pkt[netTest_MAC_HEADER_LEN+12],4);
195 memcpy(&p_pkt[netTest_MAC_HEADER_LEN+12],&p_pkt[netTest_MAC_HEADER_LEN+12+4],4);
196 memcpy(&p_pkt[netTest_MAC_HEADER_LEN+12+4],&ip_temp,4);
197
198 p_head=&temp_head;
199
200 //inner ip &udp for ipsec
201 if (flag)
202 {
203 memcpy(p_head,&p_pkt[netTest_MAC_HEADER_LEN],sizeof(netTestHead_T));
204
205 if ((p_head->ip[2]&0x0000ff00)==0x00003300)
206 {
207 p_spi = &(p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN + 4]);
208 pkt_type = netTest_IPSEC_AH_PKT;
209 }
210 else if ((p_head->ip[2]&0x0000ff00)==0x00003200)
211 {
212 p_spi = &(p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN]);
213 pkt_type = netTest_IPSEC_ESP_PKT;
214 }
215 else
216 {
217 netapi_Log("flip_and_send_pkt: un-supported IPSEC protocol\n");
218 Pktlib_freePacket(tip);
219 return;
220 }
221
222 p_sa_info = (netTestSA_t *) trie_lookup(p_trie_sa_rx, (char *)p_spi ,4);
223 if (p_sa_info == NULL)
224 {
225 netapi_Log("flip_and_send_pkt(): trie_lookup() failed\n");
226 Pktlib_freePacket(tip);
227 return;
228 }
229 tunnel_id = p_sa_info->tunnel_id;
230 p_sa_info_tx = (netTestSA_t *) trie_lookup(p_trie_sa_tx, (char *)&tunnel_id ,4);
231 if (p_sa_info_tx == NULL)
232 {
233 netapi_Log("flip_and_send_pkt(): trie_lookup() failed\n");
234 Pktlib_freePacket(tip);
235 return;
236 }
237 //just drop non-udp packet
238 if (p_pkt[p_sa_info->tx_payload_info.encOffset+9]!=0x11)
239 {
240 stats[coreid].n_new+=1;Pktlib_freePacket(tip); return;
241 }
242
243 /* flip inner IP */
244 memcpy(&ip_temp, &p_pkt[p_sa_info->tx_payload_info.encOffset+12],4);
245 memcpy(&p_pkt[p_sa_info->tx_payload_info.encOffset+12],&p_pkt[p_sa_info->tx_payload_info.encOffset+12+4],4);
246 memcpy(&p_pkt[p_sa_info->tx_payload_info.encOffset+12+4],&ip_temp,4);
247 /* setting udp ports */
248 if (netTestCfg.dest_udp_port_config == 0)
249 {
250 memcpy(&p_pkt[p_sa_info->tx_payload_info.encOffset+netTest_IP_HEADER_LEN+2],
251 &p_pkt[p_sa_info->tx_payload_info.encOffset+netTest_IP_HEADER_LEN],2);
252 }
253 else
254 {
255 dest_udp_port_config = htons(netTestCfg.dest_udp_port_config);
256 memcpy(&p_pkt[p_sa_info->tx_payload_info.encOffset+netTest_IP_HEADER_LEN+2],
257 &dest_udp_port_config,2);
258 }
259 memset(&p_pkt[p_sa_info->tx_payload_info.encOffset+netTest_IP_HEADER_LEN+6],0,2); //checksum
260
261 if (netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_SIDEBAND)
262 {
263 /* inner ip checksum : leave alone, outer ip, set to 0 (we will compute on way out */
264 memset(&p_pkt[netTest_MAC_HEADER_LEN+10],0,2);
265 }
266 }
267 else
268 {
269 /* flip udp port */
270 if (netTestCfg.dest_udp_port_config == 0)
271 {
272 memcpy(&p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN+2],
273 &p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN],2);
274 }
275 else
276 {
277 dest_udp_port_config = htons(netTestCfg.dest_udp_port_config);
278 //memcpy(&p_pkt[netTest_MAC_HEADER_LEN+20+2],&new_dest_port[0],2);
279 memcpy(&p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN+2],&dest_udp_port_config,2);
280 }
281 memset(&p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN+6],0,2);//0 udp checksum (we will compute on way out)
282 }
283
284 /*IPSEC case */
285 if (flag)
286 {
287 if (netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_SIDEBAND)
288 //send to crypto for encryption
289 //12 byte auth tag
290 {
291 PKTIO_METADATA_T meta = {PKTIO_META_SB_TX,{0},0};
292 int err;
293 nwalDmTxPayloadInfo_t meta_tx={0};
294
295 meta.sa_handle = (void*)p_sa_info_tx->tx_tunnel; //use TX SA APPID
296
297 memcpy(&meta_tx, &(p_sa_info->tx_payload_info), sizeof(nwalDmTxPayloadInfo_t));
298 meta_tx.appCtxId = (nwal_AppId)p_sa_info_tx;
299 meta_tx.encSize = len - p_sa_info->tx_payload_info.encOffset -p_sa_info->auth_tag_size;
300 meta_tx.authSize = len - meta_tx.authOffset - p_sa_info->auth_tag_size;
301 meta_tx.pAuthIV=NULL;
302 meta_tx.aadSize=0;
303 meta_tx.pAad=NULL;
304 if (p_sa_info->cipherMode == NWAL_SA_EALG_AES_CTR)
305 {
306 memcpy(&p_iv[0], &p_sa_info->key_params->pEncKey[16], 4);
307 memcpy(&p_iv[4], &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN + netTest_ESP_HEADER_LEN], 8);
308 p_iv[12] = 0;
309 p_iv[13] = 0;
310 p_iv[14] = 0;
311 p_iv[15] = 1;
312 meta_tx.pEncIV = &p_iv[0];
313 }
314 else if ((p_sa_info->cipherMode == NWAL_SA_EALG_AES_GCM) || (p_sa_info->cipherMode == NWAL_SA_EALG_AES_CCM))
315 {
316 memcpy(&p_iv[0], &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN + netTest_ESP_HEADER_LEN], 8);
317 meta_tx.pEncIV = &p_iv[0];
318 memcpy(&p_add[0], &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN], 8);
319 meta_tx.pAad= &p_add[0];
320 meta_tx.aadSize = 8;
321 }
322 else if (p_sa_info->authMode == NWAL_SA_AALG_GMAC)
323 {
324 memcpy(&p_iv[0], &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN + netTest_ESP_HEADER_LEN], 8);
325 meta_tx.pAuthIV= &p_iv[0];
326 memcpy(&p_add[0], &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN], 8);
327 meta_tx.pAad= &p_add[0];
328 meta_tx.aadSize = 8;
329 }
330 else if (p_sa_info->cipherMode == NWAL_SA_EALG_NULL)
331 {
332 meta_tx.pEncIV = NULL;
333 }
334 else
335 {
336 meta_tx.pEncIV = &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN + netTest_ESP_HEADER_LEN ];
337 }
338 /* post it to netcp sb tx channel*/
339 meta.u.tx_sb_meta=&meta_tx;
340
341 netapi_pktioSend(netcp_sb_tx_chan,tip,&meta,&err);
342 }
343 else
344 {
345 //INFLOW TX, send pkt directly, asking for IP and UDP checksum offloads AND IPSEC to be applied
346 PKTIO_METADATA_T meta = {PKTIO_META_TX,{0},0};
347 int err;
348 nwalTxPktInfo_t meta_tx={0};
349
350 meta.sa_handle = (void*)p_sa_info_tx->tx_tunnel; //use TX SA APPID
351
352 meta_tx.startOffset = p_sa_info_tx->tx_pkt_info.startOffset;
353 meta_tx.ipOffBytes =p_sa_info_tx->tx_payload_info.encOffset;
354 meta_tx.l4OffBytes = p_sa_info_tx->tx_pkt_info.l4OffBytes;
355 meta_tx.l4HdrLen = p_sa_info_tx->tx_pkt_info.l4HdrLen;
356 meta_tx.ploadLen = (unsigned) ((p_pkt[meta_tx.l4OffBytes+4]<<8)|p_pkt[meta_tx.l4OffBytes+4+1]) -8 ;
357 meta_tx.saOffBytes= p_sa_info_tx->tx_pkt_info.saOffBytes;
358 if (pkt_type == netTest_IPSEC_AH_PKT)
359 {
360 memset(&p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN+netTest_IPSEC_AH_FIXED_HDR_SIZE],0,netTest_IPSEC_AH_FIXED_HDR_SIZE);
361 meta_tx.txFlag1 = p_sa_info_tx->tx_pkt_info.txFlag1;
362 meta_tx.saPayloadLen=len-netTest_MAC_HEADER_LEN; //don't inlcude mac
363 meta_tx.saAhMacSize = 12;
364 meta_tx.saAhIcvOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN + netTest_IPSEC_AH_FIXED_HDR_SIZE;
365
366 meta_tx.enetPort = enet_port;
367 memcpy(&p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN+4],&p_sa_info_tx->spi,4);
368 }
369 else if (pkt_type == netTest_IPSEC_ESP_PKT)
370 {
371 meta_tx.txFlag1 = p_sa_info_tx->tx_pkt_info.txFlag1;
372 meta_tx.saPayloadLen=len-netTest_MAC_HEADER_LEN-netTest_IP_HEADER_LEN; //don't include mac and ip outer header
373 meta_tx.enetPort = 0;
374 memcpy(&p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN],&p_sa_info_tx->spi,4);
375 }
376
377 meta_tx.pseudoHdrChecksum =
378 netTest_utilGetIPv4PsudoChkSum(&p_pkt[meta_tx.ipOffBytes],8+ meta_tx.ploadLen);
379
380
381 /* post it to netcp tx channel*/
382 meta.u.tx_meta=&meta_tx;
383#ifdef DEBUG_DESC
384 if (stats[coreid].sec_tx<20) netTest_utilDumpDescr((long *) tip, stats[coreid].sec_tx);
385#endif
386 if ( pkt_type == netTest_IPSEC_ESP_PKT)
387 netapi_pktioSend(netcp_tx_chan_esp,tip,&meta,&err);
388 else if ( pkt_type == netTest_IPSEC_AH_PKT)
389 netapi_pktioSend(netcp_tx_chan_ah,tip,&meta,&err);
390 stats[coreid].tx +=1;
391 stats[coreid].sec_tx +=1;
392 }
393 }
394 else //non ipsec send pkt directly, asking for IP and UDP checksum ofload
395 {
396 PKTIO_METADATA_T meta2 = {PKTIO_META_TX,{0},0};
397 int err;
398 nwalTxPktInfo_t meta_tx2={0};
399 meta2.sa_handle=nwal_HANDLE_INVALID;
400 meta_tx2.txFlag1 = (NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID );
401 meta_tx2.startOffset = 0;
402 meta_tx2.ipOffBytes = netTest_MAC_HEADER_LEN;
403 meta_tx2.l4OffBytes = netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN;
404 meta_tx2.l4HdrLen = netTest_UDP_HEADER_LEN;
405 meta_tx2.ploadLen = (unsigned) ((p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN+4]<<8)|
406 p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN+4+1]) -8 ;
407 meta_tx2.pseudoHdrChecksum =
408 netTest_utilGetIPv4PsudoChkSum(&p_pkt[netTest_MAC_HEADER_LEN],8+ meta_tx2.ploadLen);
409
410 /* post it to netcp tx channel*/
411 meta2.u.tx_meta=&meta_tx2;
412 netapi_pktioSend(netcp_tx_chan_no_crypto,tip,&meta2,&err);
413 stats[coreid].tx +=1;
414 }
415}
416
417
418/**********************************************************************
419 * FUNCTION PURPOSE: Sideband Accelerator Callback PKT RECEIVE HANDLER
420 **********************************************************************
421 * DESCRIPTION: Sideband Accelerator Callback PKT RECEIVE HANDLER
422 * Handles Decrypt and Encrypt operation callbacks
423 **********************************************************************/
424void recv_sb_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
425 PKTIO_METADATA_T meta[], int n_pkts,
426 uint64_t ts )
427{
428 int i;
429 int len;
430 int p;
431 netTestHead_T * p_res;
432 Ti_Pkt * tip;
433 unsigned int templen;
434 int err;
435 char * p_pkt;
436 netTestHead_T * p_head;
437 netTestHead_T temp_head;
438 int tag_cmp=0;
439 unsigned int hash[4];
440 uint8_t *p_spi;
441 netTestSA_t *p_sa_info;
442
443#ifdef netTest_MULTI_THREAD
444 int coreid=Osal_nwalGetProcId(); //who we are(thread local)
445#else
446 int coreid=0;
447#endif
448 //nwal_AppId time;
449 unsigned long time = 0;
450 unsigned long delta_time = 0;
451 /* loop over received pkts */
452 for(i=0;i<n_pkts;i++)
453 {
454 tip = p_recv[i];
455 Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);//ignore templen
456 len = Pktlib_getPacketLen(tip);//real length
457
458 /*p_sa_info is for rx context */
459 p_sa_info = (netTestSA_t*)meta[i].u.rx_sb_meta->appCtxId;
460 if (p_sa_info == NULL)
461 {
462 printf("recv_sb_cb(): trie_lookup failed\n");
463 continue;
464 }
465
466 //is this a decrypt (rx_tunnel) complete
467 if ((int)meta[i].u.rx_sb_meta->appId == p_sa_info->rx_tunnel)
468 {
469 //time = hplib_mUtilGetPmuCCNT();
470 //delta_time = time -(unsigned long) meta[i].u.rx_sb_meta->appCtxId;
471 stats[coreid].total_decrypt_time += delta_time;
472 stats[coreid].sb_rx+=1;
473 //copy hash out of meta data (for some reason it needs endian conversion)
474 hash[0]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[0]);
475 hash[1]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[1]);
476 hash[2]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[2]);
477 hash[3]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[3]);
478 if(stats[coreid].sb_rx<=16)
479 {
480 char *tp = (char *) &hash[0];
481 //netTest_utilDumpHeader((long*)p_pkt, stats[coreid].sb_rx, (int)meta[i].u.rx_sb_meta->appId,0);
482 }
483 tag_cmp = memcmp(&p_pkt[len-p_sa_info->auth_tag_size],(char*) &hash[0],p_sa_info->auth_tag_size); //todo, really use meta->authTagLen
484 stats[coreid].n_auth_ok += !(tag_cmp);
485 flip_and_send_pkt(tip, p_pkt, len,1, 0); //flip packet to echo back and send
486 }
487 //this is an encrypt (tx tunnel) complete
488 else if((int)meta[i].u.rx_sb_meta->appId== p_sa_info->tx_tunnel )
489 {
490 hash[0]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[0]);
491 hash[1]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[1]);
492 hash[2]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[2]);
493 hash[3]= netTest_utilHtonl( meta[i].u.rx_sb_meta->pAuthTag[3]);
494 stats[coreid].sb_tx+=1;
495 if(stats[coreid].sb_tx<=16)
496 {
497 //netTest_utilDumpHeader((long*)p_pkt, stats[coreid].sb_tx, (int)meta[i].u.rx_sb_meta->appId,0);
498 }
499 //put the computed tag in the packet
500 memcpy(&p_pkt[len-p_sa_info->auth_tag_size],(char*)&hash[0],p_sa_info->auth_tag_size); //todo, really use meta->authTagLen
501 {
502 PKTIO_METADATA_T meta2 = {PKTIO_META_TX,{0},0};
503 nwalTxPktInfo_t meta_tx={0};
504 // now send directly
505 meta2.sa_handle=nwal_HANDLE_INVALID;
506 meta_tx.txFlag1 = (NWAL_TX_FLAG1_DO_IPV4_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID);//only outer IP header checksum. no udp checksum possible since pkt is already encrypted
507 meta_tx.startOffset = 0;
508 meta_tx.ipOffBytes = netTest_MAC_HEADER_LEN;
509 meta_tx.l4OffBytes = 0;
510 meta_tx.l4HdrLen = 0;
511 meta_tx.ploadLen = 0;
512 time = hplib_mUtilGetPmuCCNT();
513 delta_time = time -(unsigned long) meta[i].u.rx_sb_meta->appCtxId;
514 stats[coreid].total_encrypt_time += delta_time;
515
516 /* post it to netcp tx channel*/
517 meta2.u.tx_meta=&meta_tx;
518 netapi_pktioSend(netcp_tx_chan_no_crypto,tip,&meta2,&err);
519 //netapi_pktioSend(netcp_tx_chan_esp,tip,&meta2,&err);
520 hplib_cacheWbInv(p_pkt,len);
521 stats[coreid].tx +=1;
522 }
523 }
524 else printf("netapi recv_sb_cb: unknown appiD %x \n",meta[i].u.rx_sb_meta->appId );
525 }
526}
527
528/**********************************************************************
529 * FUNCTION PURPOSE: Packet receive Callback
530 *
531 **********************************************************************
532 * DESCRIPTION: packet Receive callback
533 **********************************************************************/
534void recv_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
535 PKTIO_METADATA_T meta[], int n_pkts,
536 uint64_t ts )
537{
538 int i;
539 int len;
540 int p;
541 netTestHead_T * p_res;
542 Ti_Pkt * tip;
543 unsigned int templen;
544 int err = 0;
545 char * p_pkt;
546 netTestHead_T * p_head;
547 netTestHead_T temp_head;
548 netTestSA_t *p_sa_info;
549 uint8_t *p_spi;
550 uint8_t p_iv[16];
551 uint8_t p_add[8];
552 uint8_t p_add1[1500];
553 int16_t retVal;
554 unsigned long t1;
555 unsigned long t2;
556 unsigned long long ct1;
557 unsigned long long ct2;
558 unsigned long long n_c_ops;
559 nwalGlobCxtInfo_t nwalGlobCxt;
560 nwalLocCxtInfo_t nwalLocCxt;
561
562 Cppi_HostDesc* pPloadDesc;
563 int ifno;
564 uint16_t enet_port = 0;
565
566#ifdef netTest_MULTI_THREAD
567 int coreid=Osal_nwalGetProcId(); //who we are(thread local)
568#else
569 int coreid=0;
570#endif
571 p_head=&temp_head;
572
573 t1=hplib_mUtilGetPmuCCNT();
574 ct1 =Osal_cache_op_measure(&n_c_ops);
575
576 /* loop over received pkts */
577 for(i=0;i<n_pkts;i++)
578 {
579 ifno = ((unsigned int)meta[i].u.rx_meta->appId)&0xff;
580
581 enet_port = meta[i].u.rx_meta->enetPort;
582 tip = p_recv[i];
583
584 Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);/*ignore templen */
585 len = Pktlib_getPacketLen(tip)-4; /*real length, subtract mac trailer */
586 Cppi_setData (Cppi_DescType_HOST, (Cppi_Desc *) tip, p_pkt,len);
587 Pktlib_setPacketLen(tip,len);
588
589 if(((unsigned int)meta[i].u.rx_meta->appId) == expPkt_appid)
590 {
591 netapi_Log("recv_cb: received exception packet\n");
592 Pktlib_freePacket(tip);
593 if(((unsigned int)meta[i].u.rx_meta->rxFlag1 & NWAL_RX_IP_FRAGMENT_PKT) ==
594 NWAL_RX_IP_FRAGMENT_PKT)
595 {
596 stats[coreid].exceptionPktsFrag+=1;
597 }
598 else
599 {
600 stats[coreid].exceptionPktsOther+=1;
601 }
602 continue;
603 }
604 //debug: validate descriptor */
605 if(Pktlib_getNextPacket(tip) != 0)
606 {
607 printf(" rcv_cb, nexpkt != NULL");
608 }
609
610 if(coreid<TUNE_NETAPI_NUM_CORES)
611 {
612 stats[coreid].rx+=1;
613 if (ifno < TUNE_NETAPI_MAX_NUM_MAC)
614 stats[coreid].if_rx[ifno]+=1;
615 }
616
617#ifdef DEBUG_DESC
618 if(coreid<TUNE_NETAPI_NUM_CORES)
619 {
620 if (stats[coreid].rx<16)
621 {
622 netapi_Log(">rx dmp..");
623 netTest_utilDumpDescr((long *) tip, stats[coreid].rx);
624 }
625 else if (stats[coreid].rx>99)
626 {
627 netapi_Log(">rx dmp..");
628 netTest_utilDumpDescr((long *) tip,stats[coreid].rx);
629 }
630 }
631#endif
632#if 0
633 //
634 if(stats[coreid].rx<=16)
635 {
636 netTest_utilDumpHeader((long*)p_pkt,stats[coreid].rx, (int)meta[i].u.rx_meta->appId,meta[i].u.rx_meta->rxFlag1);
637 netTest_utilDumpBuffer((long*)p_pkt,len);
638 }
639#endif
640 /* check header */
641 memcpy(p_head,&p_pkt[netTest_MAC_HEADER_LEN],sizeof(netTestHead_T));
642
643 /* check for IPSEC ESP or AH packet, 0x32 is ESP tunnel mode, 0x33 is AH tunnel mode*/
644 if (((p_head->ip[2]&0x0000ff00)==0x00003200) || ((p_head->ip[2]&0x0000ff00)==0x00003300))
645 {
646 if (!netTest_utilCheckHeader(p_head,&meta[i]))
647 {
648 printf("recv_cb: error in ipsec pkt\n");
649 stats[coreid].n_bad+=1;Pktlib_freePacket(tip);
650 continue;
651 }
652
653 //process IP SEC PACKET
654 if (netTestCfg.ipsec_mode_rx == IPSEC_MODE_RX_SIDEBAND)
655 {
656 p_spi = &(p_pkt[netTest_MAC_HEADER_LEN+netTest_IP_HEADER_LEN]);
657 p_sa_info = (netTestSA_t *) trie_lookup(p_trie_sa_rx, (char *)p_spi ,4);
658 if (p_sa_info == NULL)
659 {
660 printf("recv_cb(): trie_lookup() failed\n");
661 continue;
662 }
663
664 //ship to crypto for decrypt!!
665 //12 byte auth tag
666 PKTIO_METADATA_T meta2 = {PKTIO_META_SB_TX,{0},0};
667 nwalDmTxPayloadInfo_t meta_tx={0};
668
669 meta2.sa_handle = (void*) p_sa_info->rx_tunnel;
670
671 memcpy(&meta_tx, &(p_sa_info->tx_payload_info), sizeof(nwalDmTxPayloadInfo_t));
672
673 meta_tx.encSize = len - p_sa_info->tx_payload_info.encOffset -p_sa_info->auth_tag_size;
674 meta_tx.authSize = len - meta_tx.authOffset - p_sa_info->auth_tag_size;
675
676 if (p_sa_info->cipherMode == NWAL_SA_EALG_AES_CTR)
677 {
678 memcpy(&p_iv[0], &p_sa_info->key_params->pEncKey[16], 4);
679 memcpy(&p_iv[4], &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN + netTest_ESP_HEADER_LEN], 8);
680 p_iv[12] = 0;
681 p_iv[13] = 0;
682 p_iv[14] = 0;
683 p_iv[15] = 1;
684 meta_tx.pEncIV = &p_iv[0];
685
686 }
687 else if ((p_sa_info->cipherMode == NWAL_SA_EALG_AES_GCM) ||
688 (p_sa_info->cipherMode == NWAL_SA_EALG_AES_CCM))
689 {
690 memcpy(&p_iv[0], &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN + netTest_ESP_HEADER_LEN], 8);
691 meta_tx.pEncIV = &p_iv[0];
692 /* aad is the ESP header which is 8 bytes */
693 memcpy(&p_add[0], &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN], 8);
694 meta_tx.pAad= &p_add[0];
695 meta_tx.aadSize = 8;
696 }
697 else if (p_sa_info->authMode == NWAL_SA_AALG_GMAC)
698 {
699 memcpy(&p_iv[0], &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN + netTest_ESP_HEADER_LEN], 8);
700 meta_tx.pAuthIV= &p_iv[0];
701 /* aad is the ESP header which is 8 bytes */
702 memcpy(&p_add[0], &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN], 8);
703 meta_tx.pAad= &p_add[0];
704 meta_tx.aadSize = 8;
705 }
706 else if (p_sa_info->cipherMode == NWAL_SA_EALG_NULL)
707 {
708 meta_tx.pEncIV = NULL;
709 }
710 else
711 {
712 meta_tx.pEncIV = &p_pkt[netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN + netTest_ESP_HEADER_LEN ];
713 }
714
715 meta_tx.appCtxId = (nwal_AppId)p_sa_info;
716
717 /* post it to netcp sb tx channel*/
718 meta2.u.tx_sb_meta=&meta_tx;
719
720 netapi_pktioSend(netcp_sb_tx_chan,tip,&meta2,&err);
721 continue;
722 }
723 else
724 {
725 //inflow mode. flip and send
726 flip_and_send_pkt(tip,p_pkt,len,1, enet_port);
727 }
728 }
729 /* check for udp protocol */
730 else if ((p_head->ip[2]&0x0000ff00)!=0x00001100)
731 //else if ((p_head->ip[2]&0x00ff0000)!=0x00110000)
732 {
733 stats[coreid].n_new+=1;Pktlib_freePacket(tip); continue;
734 }
735 else //non ipsec
736 {
737 if (!netTest_utilCheckHeader(p_head,&meta[i]))
738 {
739 stats[coreid].n_bad+=1;Pktlib_freePacket(tip);
740 continue;
741 }
742 //just flip and send
743 flip_and_send_pkt(tip,p_pkt,len,0, enet_port);
744 }
745 }
746 t2=hplib_mUtilGetPmuCCNT();
747 ct2 =Osal_cache_op_measure(&n_c_ops);
748 stats[coreid].app_cycles += (unsigned long long) (t2-t1);
749 stats[coreid].tx_cache_cycles += (unsigned long long) (ct2-ct1);
750}
751
752/* Templates to build command labels at startup up time, required by open_pktio_tx_channels() */
753nwalTxPktInfo_t txPktInfoESP =
754{
755 NULL, /* p_pkt */
756 NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
757 0, /* lpbackPass */
758 0, /* enetport */
759 0, /* msuSize */
760 0, /* startOffset */
761 netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN, /* saOffBytes */
762 0, /* saPayLoadLen */
763 0 , /* saAhIcvOffBytes */
764 0, /* saAhMacSize */
765 0, /* etherLenOffBytes */
766 0, /* ipOffBytes */
767 0, /* l4OffBytes */
768 netTest_UDP_HEADER_LEN, /* l4HdrLen */
769 0, /* pseudoHdrChecksum */
770 0 /* pLoadLen */
771};
772
773
774nwalTxPktInfo_t txPktInfoAH =
775{
776 NULL, /* p_pkt */
777 NWAL_TX_FLAG1_DO_IPSEC_AH_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM | NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
778 0, /* lpbackPass */
779 0, /* enetport */
780 0, /* msuSize */
781 0, /* startOffset */
782 netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN, /* saOffBytes */
783 0, /* saPayLoadLen */
784 netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN + netTest_IPSEC_AH_FIXED_HDR_SIZE, /* saAhIcvOffBytes */
785 12, /* saAhMacSize */
786 0, /* etherLenOffBytes */
787 0, /* ipOffBytes */
788 0, /* l4OffBytes */
789 netTest_UDP_HEADER_LEN, /* l4HdrLen */
790 0, /* pseudoHdrChecksum */
791 0 /* pLoadLen */
792};
793
794nwalTxPktInfo_t txPktInfoNoCrypto =
795{
796 NULL, /* p_pkt */
797 NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
798 0, /* lpbackPass */
799 0, /* enetport */
800 0, /* msuSize */
801 0, /* startOffset */
802 0, /* saOffBytes */
803 0, /* saPayLoadLen */
804 0 , /* saAhIcvOffBytes */
805 0, /* saAhMacSize */
806 0, /* etherLenOffBytes */
807 0, /* ipOffBytes */
808 netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN, /* l4OffBytes */
809 netTest_UDP_HEADER_LEN, /* l4HdrLen */
810 0, /* pseudoHdrChecksum */
811 0 /* pLoadLen */
812};
813
814
815void close_pktio_channels(void)
816{
817 int err;
818 netapi_pktioClose(netcp_tx_chan_esp ,&err);
819 netapi_pktioClose(netcp_tx_chan_ah ,&err);
820 netapi_pktioClose(netcp_sb_tx_chan ,&err);
821 netapi_pktioClose(netcp_tx_chan_no_crypto,&err);
822}
823
824void open_pktio_tx_channels(void)
825{
826 int err;
827 /* open netcp default TX for ESP packets */
828 netcp_tx_chan_esp= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
829 if (!netcp_tx_chan_esp)
830 {
831 printf("pktio open TX failed err=%d\n",err);
832 exit(1);
833 }
834 else
835 {
836 if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
837 {
838 PKTIO_CONTROL_T control;
839 control.op = PKTIO_UPDATE_FAST_PATH;
840 PKTIO_CFG_T cfg;
841 cfg.fast_path_cfg.fp_send_option = PKTIO_FP_ESP_L4CKSUM_PORT;
842 cfg.fast_path_cfg.txPktInfo= &txPktInfoESP;
843 netapi_pktioControl(netcp_tx_chan_esp, NULL, &cfg, &control, &err);
844 }
845 }
846
847 /*/* open netcp default TX for AH packets */
848 netcp_tx_chan_ah= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
849 if (!netcp_tx_chan_ah)
850 {
851 printf("pktio open TX failed err=%d\n",err);
852 exit(1);
853 }
854 else
855 {
856 if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
857 {
858 PKTIO_CONTROL_T control;
859 control.op = PKTIO_UPDATE_FAST_PATH;
860 PKTIO_CFG_T cfg;
861 cfg.fast_path_cfg.fp_send_option = PKTIO_FP_AH_L4CKSUM_PORT;
862 cfg.fast_path_cfg.txPktInfo= &txPktInfoAH;
863 netapi_pktioControl(netcp_tx_chan_ah, NULL, &cfg, &control, &err);
864 }
865 }
866
867 /* open netcp default TX channels for non-Crypto packets */
868 netcp_tx_chan_no_crypto= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
869 if (!netcp_tx_chan_no_crypto)
870 {
871 printf("pktio open TX failed err=%d\n",err);
872 exit(1);
873 }
874 else
875 {
876 if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
877 {
878 PKTIO_CONTROL_T control;
879 control.op = PKTIO_UPDATE_FAST_PATH;
880 PKTIO_CFG_T cfg;
881 cfg.fast_path_cfg.fp_send_option = PKTIO_FP_L4CKSUM_PORT;
882 cfg.fast_path_cfg.txPktInfo= &txPktInfoNoCrypto;
883 netapi_pktioControl(netcp_tx_chan_no_crypto, NULL, &cfg, &control, &err);
884 }
885 }
886
887 /* open netcp default TX channels for SB crypto */
888 netcp_sb_tx_chan= netapi_pktioOpen(netapi_handle, NETCP_SB_TX, NULL, &netcp_sb_tx_cfg, &err);
889 if (!netcp_sb_tx_chan)
890 {
891 printf("pktio open SB TX failed err=%d\n",err);
892 exit(1);
893 }
894}
895
896#ifdef netTest_DSP_FASTPATH
897void setup_netTestDSPFastPath(NETAPI_T handle)
898
899{
900 int i;
901 int err = 0;
902 PKTIO_CFG_T dsp_pktio_cfg;
903 NETCP_CFG_CLASSIFIER_T dsp_classi;
904 NETCP_CFG_ROUTE_T dsp_route;
905 char dsp_name[PKTIO_MAX_NAME];
906
907 memset(&dsp_pktio_cfg, 0, sizeof (PKTIO_CFG_T));
908 memset(&dsp_classi, 0, sizeof (NETCP_CFG_CLASSIFIER_T));
909 memset(&dsp_route, 0, sizeof (NETCP_CFG_ROUTE_T));
910 for (i = 0; i < CPU_NUM_REM_FAST_PATH_CORES; i++)
911 {
912 snprintf(&dsp_name[0],PKTIO_MAX_NAME-1, "%s%d","dsp_chan", i);
913 dsp_pktio_cfg.flags1 = PKTIO_RX;
914 dsp_pktio_cfg.flags2 = PKTIO_PKT;
915 dsp_pktio_cfg.qnum = TEST_NWAL_BASE_REM_FP_RX_PKT_QUEUE + i;
916 dsp_pktio_cfg.max_n = 8;
917
918 /* pktio channels created here will NOT be POLLED by net_test arm application */
919 dsp_pktio_channels[i] = netapi_pktioCreate(handle,
920 &dsp_name[0],
921 (PKTIO_CB)recv_cb,
922 &dsp_pktio_cfg,
923 &err);
924
925 dsp_classi.classType =NETCP_CFG_CLASS_TYPE_L4;
926 dsp_classi.u.c_l4.iface = netTestCfg.dsp_mac;
927
928 dsp_classi.u.c_l4.ip = ip_rule[netTestCfg.dsp_ip];
929 dsp_classi.u.c_l4.proto = NWAL_APP_PLOAD_PROTO_UDP;
930 dsp_classi.u.c_l4.appProto.udpPort = TEST_NWAL_BASE_REM_FP_UDP_PORT + i;
931
932 dsp_route.p_dest_q = dsp_pktio_channels[i];
933
934 dsp_route.p_flow = (NETCP_CFG_FLOW_T*)NETCP_DEFAULT_FLOW;
935
936 dsp_classifers[i] = netapi_netcpCfgAddClass(handle,
937 &dsp_classi,
938 (NETCP_CFG_ROUTE_HANDLE_T) &dsp_route,
939 NETCP_CFG_ACTION_TO_SW,
940 NULL,
941 &err);
942
943 if (err != NETAPI_ERR_OK)
944 {
945 netapi_Log("setup_netTestDSPFastPath: netapi_netcpCfgAddClass failed for core %d\n", i);
946 }
947 }
948 printf("DSP Path fath setup complete\n");
949}
950
951void teardown_netTestDSPFastPath()
952{
953 int i;
954 int err=0;
955
956 for (i = 0; i < CPU_NUM_REM_FAST_PATH_CORES; i++)
957 {
958 netapi_netcpCfgDelClass(netapi_handle,
959 dsp_classifers[i],
960 &err);
961 if (err != NETAPI_ERR_OK)
962 {
963 printf("teardown_netTestDSPFastPath: netapi_netcpCfgDelClass failed for core %d\n", i);
964 }
965
966 netapi_pktioDelete(dsp_pktio_channels[i],
967 &err);
968 if (err != NETAPI_ERR_OK)
969 {
970 printf("teardown_netTestDSPFastPath: netapi_pktioDelete failed for core %d\n", i);
971 }
972 }
973 printf("DSP Path fath teardown complete\n");
974}
975#endif
976
977
978#ifdef netTest_MULTI_THREAD
979NETAPI_T worker_nh[TUNE_NETAPI_NUM_CORES];
980
981void slow_path_thread(uint32_t index)
982{
983 int err, i;;
984 uint32_t thread_num;
985 PKTIO_HANDLE_T *rx_chan;
986 PKTIO_HANDLE_T *sb_rx_chan;
987
988
989 cpu_set_t cpu_set;
990
991 thread_num = netTestCfg.sp_thread_num[index];
992 netapi_Log("slow_path_thread, mypid: %d, core_id %d\n", gettid(), netTestCfg.sp_thread_num[index]);
993
994 CPU_ZERO( &cpu_set);
995#ifdef CORTEX_A8
996 for (i = netTestCfg.sp_proc_start[index]; i <= netTestCfg.sp_proc_end[index];i++)
997 {
998 printf("slow_path_thread: setting cpu %d to cpu_set\n", i);
999 CPU_SET( 0, &cpu_set);
1000 }
1001 hplib_utilSetupThread(thread_num, &cpu_set, hplib_spinLock_Type_LOL);
1002#else
1003 for (i = netTestCfg.sp_proc_start[index]; i <= netTestCfg.sp_proc_end[index];i++)
1004 {
1005 CPU_SET( i, &cpu_set);
1006 }
1007 hplib_utilSetupThread(thread_num, &cpu_set, hplib_spinLock_Type_LOL);
1008#endif
1009 worker_nh[thread_num] = netapi_init(NETAPI_CORE_MASTER,NULL);
1010
1011 if (worker_nh[thread_num] == NULL)
1012 {
1013 printf("slow_path_thread: netapi_init failure, exiting\n");
1014 exit(1);
1015 }
1016 netapi_setCookie(worker_nh[thread_num],(void*)(thread_num | NET_TEST_SP_THREAD_MASK));
1017
1018 scheduler[thread_num] =netapi_schedOpen(worker_nh[thread_num],&our_sched_cfg, &err);
1019 if (!scheduler[thread_num])
1020 {
1021 printf("sched create failed for core%d\n",thread_num);
1022 goto ERR_slow_path_thread;
1023 }
1024 scheduler[thread_num]->config.yield = NETAPI_TRUE;
1025 scheduler[thread_num]->config.pollGarbageQ = NETAPI_TRUE;
1026 scheduler[thread_num]->config.pollCtrlQ = NETAPI_TRUE;
1027 printf("Slow Path thread: %d setup complete, running on ARM CORE: %d\n", i,i);
1028 /* Entry point to scheduler */
1029 netapi_schedRun(scheduler[thread_num], &err);
1030
1031ERR_slow_path_thread:
1032 printf("slow_path_thread: calling netapi_shutdown\n");
1033 netapi_shutdown(worker_nh[thread_num]);
1034}
1035
1036void fast_path_thread(uint32_t index)
1037{
1038 int err, i;
1039 PKTIO_HANDLE_T *rx_chan;
1040 PKTIO_HANDLE_T *sb_rx_chan;
1041 uint32_t thread_num;
1042
1043
1044 cpu_set_t cpu_set;
1045
1046 CPU_ZERO( &cpu_set);
1047 thread_num = netTestCfg.fp_thread_num[index];
1048#ifdef CORTEX_A8
1049 for (i = netTestCfg.fp_proc_start[index]; i <= netTestCfg.fp_proc_end[index];i++)
1050 {
1051 CPU_SET( 0, &cpu_set);
1052 }
1053 hplib_utilSetupThread(thread_num, &cpu_set, hplib_spinLock_Type_LOL);
1054#else
1055 for (i = netTestCfg.fp_proc_start[index]; i <= netTestCfg.fp_proc_end[index];i++)
1056 {
1057 CPU_SET( i, &cpu_set);
1058 }
1059 hplib_utilSetupThread(thread_num, &cpu_set, hplib_spinLock_Type_LOL);
1060#endif
1061 hplib_mSpinLockLock(&net_test_thread_lock);
1062 worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,NULL);
1063
1064 if (worker_nh[thread_num] == NULL)
1065 {
1066 printf("fast_path_thread: netapi_init failure, exiting\n");
1067 hplib_mSpinLockUnlock(&net_test_thread_lock);
1068 exit(1);
1069 }
1070 hplib_mSpinLockUnlock(&net_test_thread_lock);
1071 /* open netcp default RX channels*/
1072 rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg, &err);
1073
1074 netcp_rx_cfg.flags2 = PKTIO_PKT;
1075
1076 if(masterType == NETAPI_SYS_MASTER)
1077 netapi_pktioOpen(worker_nh[thread_num], "sysMaster", (PKTIO_CB) recv_cb, &netcp_rx_cfg, &err);
1078
1079 else if(masterType == NETAPI_PROC_MASTER)
1080 netapi_pktioOpen(worker_nh[thread_num], "procMaster", (PKTIO_CB) recv_cb, &netcp_rx_cfg, &err);
1081
1082 /* create a pktio channel for specially classified pkts */
1083 /* open netcp default tx, rx queues for sideband crypto */
1084 sb_rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg, &err);
1085
1086 netapi_setCookie(worker_nh[thread_num],(void*)thread_num);
1087
1088 scheduler[thread_num] =netapi_schedOpen(worker_nh[thread_num],
1089 &our_sched_cfg,
1090 &err);
1091 if (!scheduler[thread_num])
1092 {
1093 printf("sched create failed for core%d\n",thread_num);
1094 goto ERR_fast_path_thread;
1095 }
1096
1097
1098 scheduler[thread_num]->config.yield = NETAPI_FALSE;
1099 scheduler[thread_num]->config.pollGarbageQ = NETAPI_FALSE;
1100 scheduler[thread_num]->config.pollCtrlQ = NETAPI_FALSE;
1101 /* Entry point to scheduler */
1102 printf("Fast Path thread: %d setup complete, running on ARM CORE: %d\n", i,i);
1103 netapi_schedRun(scheduler[thread_num], &err);
1104
1105ERR_fast_path_thread:
1106 netapi_pktioClose(rx_chan, &err);
1107 netapi_pktioClose(sb_rx_chan, &err);
1108
1109 printf("fast_path_thread: calling netapi_shutdown\n");
1110 netapi_shutdown(worker_nh[thread_num]);
1111}
1112
1113#endif
1114/***************************************
1115 ********** test driver*****************
1116 ***************************************/
1117int main(int argc, char **argv)
1118{
1119 int err,i;
1120 Pktlib_HeapCfg heapCfg;
1121 int32_t errCode;
1122 Pktlib_HeapIfTable* pPktifTable;
1123 FILE * fpr = NULL;
1124 int c;
1125 int configFilePresent = 0;
1126
1127 static char usage[] = "usage: %s -f < config File Name> -t <masterType: procMaster or sysMater> >\n";
1128#ifdef netTest_MULTI_THREAD
1129 cpu_set_t cpu_set;
1130#endif
1131 /* install signal handler for ^c */
1132 signal(SIGINT,netTest_utilMySig);
1133
1134
1135 while ((c = getopt (argc, argv, "f:t:?")) != -1)
1136 {
1137 switch (c)
1138 {
1139 case 'f':
1140 fpr = fopen(optarg, "r");
1141 if(fpr)
1142 configFilePresent =1;
1143 break;
1144 case 't':
1145 if(strcmp("sysMaster", optarg) == 0)
1146 {
1147 masterType = NETAPI_SYS_MASTER;
1148 }
1149 else if (strcmp("procMaster", optarg) == 0)
1150 {
1151 masterType = NETAPI_PROC_MASTER;
1152 }
1153 else
1154 {
1155 printf("%s\n", usage);
1156 }
1157 break;
1158
1159 case '?':
1160 printf("optionValue %s: %d\n", optarg, masterType);
1161 exit(EXIT_FAILURE);
1162 break;
1163 default:
1164 break;
1165 }
1166 }
1167
1168 if (!configFilePresent)
1169 {
1170 fpr = fopen(input_file_name, "r");
1171 if (fpr == NULL)
1172 {
1173 printf("main: Missing config file\n");
1174 exit(EXIT_FAILURE);
1175 }
1176 }
1177
1178 if (initRm())
1179 {
1180 printf("main: initRm() returned error\n");
1181 exit(1);
1182 }
1183 hplib_mSpinLockInit(&net_test_thread_lock );
1184 our_netapi_default_cfg.rmHandle = rmClientServiceHandle;
1185 memset(&config_file, 0, sizeof(netTestConfigFile_t));
1186 memset(&netTestCfg, 0, sizeof(netTestConfig_t));
1187
1188 netTest_utilProcessConfigFile(fpr,&config_file);
1189
1190 netTest_utilParseMac(&config_file);
1191
1192 /* parse slow path/fast path thread configuration parameters */
1193 netTest_utilParseThreadParams(&config_file);
1194
1195 netTest_utilParseIP(&config_file);
1196
1197 netTest_utilParseIpsecMode(&config_file);
1198
1199 /* DSP mac processing */
1200 parse_dsp_mac(&config_file.dsp_mac[0]);
1201
1202 /* DSP IP processing */
1203 parse_dsp_ip(&config_file.dsp_ip[0]);
1204
1205 /* IPSEC interface number processing */
1206 parse_simple_param_u32((char*)&config_file.ipsec_if_no[0], &netTestCfg.ipsec_if_no);
1207
1208 netTest_utilParseSA(&config_file);
1209
1210 parse_simple_param_u32(&config_file.dest_udp_port_config, &netTestCfg.dest_udp_port_config);
1211
1212 memset(&sa_info, 0, sizeof(sa_info));
1213
1214
1215#ifdef netTest_MULTI_THREAD
1216 /* assign main net_test thread to run on core 0 */
1217 CPU_ZERO( &cpu_set);
1218 CPU_SET( 0, &cpu_set);
1219 hplib_utilSetupThread(0, &cpu_set, hplib_spinLock_Type_LOL);
1220#endif
1221
1222 /* create netapi */
1223
1224 netapi_handle = netapi_init(masterType,
1225 &our_netapi_default_cfg);
1226
1227 if (netapi_handle == NULL)
1228 {
1229 printf("main: netapi_init failure, exiting\n");
1230 closeRm();
1231 exit(1);
1232 }
1233
1234 /* configure expection packet handling with netapi */
1235 expPkt_appid = netapi_netcpCfgExceptions(netapi_handle,
1236 7,
1237 NETCP_CFG_ACTION_TO_SW,
1238 (NETCP_CFG_ROUTE_HANDLE_T) NULL);
1239
1240 /* open the main heap */
1241 ourHeap = Pktlib_findHeapByName("netapi");
1242 if (!ourHeap)
1243 {
1244 printf("Pktlib_findHeapByName() fail\n");
1245 closeRm();
1246 exit(1);
1247 }
1248
1249 open_pktio_tx_channels();
1250
1251 /* create scheduler instance */
1252 our_sched =netapi_schedOpen(netapi_handle,&our_sched_cfg, &err);
1253 if (!our_sched)
1254 {
1255 printf("sched create failed\n");
1256 closeRm();
1257 exit(1);
1258 }
1259
1260
1261 /*create net_test MAC interfaces, attach IP to created MAC interfaces */
1262 netTest_utilCreateInterfaces(netTestCfg.num_macs, netTestCfg.num_ips, 0);
1263
1264 /* lookup Database for SA context, this is used by packet processing routines to get RX and TX SA information*/
1265 p_trie_sa_rx = trie_new();
1266 p_trie_sa_tx = trie_new();
1267 if (!p_trie_sa_rx || !p_trie_sa_tx)
1268 {
1269 printf("trie alloc for SA failed\n");
1270 closeRm();
1271 exit(1);
1272 }
1273
1274#ifdef netTest_DSP_FASTPATH
1275 if (masterType == NETAPI_SYS_MASTER)
1276 {
1277 setup_netTestDSPFastPath(netapi_handle);
1278 }
1279#endif
1280
1281 netTest_utilCreateDefaultFlow(netapi_handle, masterType);
1282 /* Create RX SA's, RX Policy and TX SA's, all SA configuration parameters are read from net_test_config.txt file */
1283 netTest_utilCreateSecAssoc();
1284
1285#ifdef netTest_MULTI_THREAD
1286{
1287 /* create and set affinity of slow path and fast path threads to
1288 * specific CPU cores as specified in the net_test_config.txt file */
1289 netTest_utilCreateSpFpThreads(netTestCfg.num_sp_threads,
1290 (NET_TEST_FUNC_PTR) slow_path_thread,
1291 netTestCfg.num_fp_threads,
1292 (NET_TEST_FUNC_PTR) fast_path_thread);
1293
1294 printf("\n net_test_loopback running ....\n");
1295 printf("\n Enter 's' for stats or 'q'to quit net_test_loopback app, or 'h' for help\n");
1296
1297
1298
1299
1300 int c;
1301 //this thread of execution (main) now just waits on user input
1302 for(;;)
1303 {
1304 printf(">");
1305 c=getchar();
1306 if (c=='q')
1307 {
1308 QUIT=1;
1309 printf("net_test_loopback: please wait for application shutdown and resource cleanup\n");
1310 break;
1311 }
1312 else if (c=='s') netTest_utilsStatsCb(netapi_handle, &netcp_stats);
1313 else if (c=='h') printf("'q' to quit, 's' for stats, 'h' for help\n");
1314 }
1315
1316 netTest_utilRemoveSpFpThreads(netTestCfg.num_sp_threads, netTestCfg.num_fp_threads);
1317}
1318#else
1319 /*********************************************/
1320 /**************Entry point into scheduler ****/
1321 /*********************************************/
1322 //netTest_utilCreateSecAssoc(netcp_sb_rx_chan, netcp_sb_tx_chan,netcp_tx_chan);
1323 netapi_schedRun(our_sched, &err);
1324#endif
1325
1326 /* done */
1327 netTest_utilsStatsCb(netapi_handle, NULL);
1328
1329
1330 /* cleanup*/
1331 netTest_utilDeleteSecAssoc();
1332
1333 netTest_utilDeleteInterfaces(netTestCfg.num_macs, netTestCfg.num_ips);
1334
1335 /* close pktio channels we opened via open_pktio_tx_channels() */
1336 close_pktio_channels();
1337#ifdef netTest_DSP_FASTPATH
1338 if (masterType == NETAPI_SYS_MASTER)
1339 {
1340 teardown_netTestDSPFastPath();
1341 }
1342#endif
1343
1344 netapi_shutdown(netapi_handle);
1345 closeRm();
1346 printf("net_test shutdown complete\n");
1347
1348}
1349
1350#if 1
1351/* Stub functions */
1352Trie * route_init(void)
1353{
1354 return NULL;
1355}
1356void route_add(Trie * Pt, unsigned long * Pdest_ipBE, void * Pour_route)
1357{
1358}
1359#endif
diff --git a/ti/runtime/netapi/test/net_test_max_params.c b/ti/runtime/netapi/test/net_test_max_params.c
new file mode 100755
index 0000000..888942c
--- /dev/null
+++ b/ti/runtime/netapi/test/net_test_max_params.c
@@ -0,0 +1,462 @@
1/******************************************
2 * File: net_test.c
3 * Purpose: Application for testing out max configuration parameters
4 * such as SA's, MACs/IP interfaces
5 **************************************************************
6 * FILE: net_test.c
7 *
8 * DESCRIPTION: netapi user space transport
9 * library test application
10 *
11 * REVISION HISTORY:
12 *
13 * Copyright (c) Texas Instruments Incorporated 2013
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 *
19 * Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 *
22 * Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the
25 * distribution.
26 *
27 * Neither the name of Texas Instruments Incorporated nor the names of
28 * its contributors may be used to endorse or promote products derived
29 * from this software without specific prior written permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
36 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
37 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
38 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
39 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
41 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42
43 *****************************************/
44
45#include "net_test.h"
46#include "ti/drv/nwal/test/fw_rm.h"
47#include <signal.h>
48#include <pthread.h>
49
50extern int QUIT;
51extern netTestStats_T stats[TUNE_NETAPI_NUM_CORES];
52extern paSysStats_t netcp_stats;
53/* Global definitions */
54#ifdef netTest_MULTI_THREAD
55 cpu_set_t cpu_set;
56#endif
57
58
59#define SA_CREATE_LOOP_COUNT 64
60#define IP_CREATE_LOOP_COUNT 64
61#define MAC_CREATE_LOOP_COUNT 59
62
63
64netTestConfig_t netTestCfg;
65static netTestConfigFile_t config_file;
66
67char input_file_name[] = "net_test_config_max_iface.txt";
68
69nwal_RetValue nwalRetVal;
70Pktlib_HeapHandle ourHeap;
71
72PKTIO_HANDLE_T *netcp_rx_chan;
73PKTIO_HANDLE_T *netcp_tx_chan_no_crypto;
74PKTIO_HANDLE_T *netcp_tx_chan_esp;
75PKTIO_HANDLE_T *netcp_tx_chan_ah;
76PKTIO_HANDLE_T *netcp_sb_tx_chan;
77PKTIO_HANDLE_T *netcp_sb_rx_chan;
78
79PKTIO_CFG_T our_chan_cfg={PKTIO_RX_TX, PKTIO_LOCAL, PKTIO_Q_ANY, 8};
80PKTIO_CFG_T netcp_rx_cfg={PKTIO_RX, PKTIO_NA, PKTIO_NA, 8};
81PKTIO_CFG_T netcp_rx_cfg2={PKTIO_RX, (PKTIO_GLOBAL|PKTIO_PKT), PKTIO_Q_ANY, 8};
82PKTIO_CFG_T netcp_tx_cfg={PKTIO_TX, PKTIO_NA, PKTIO_NA, 8};
83PKTIO_CFG_T netcp_sb_rx_cfg={PKTIO_RX, PKTIO_NA, PKTIO_NA, 8};
84PKTIO_CFG_T netcp_sb_tx_cfg={PKTIO_TX, PKTIO_NA, PKTIO_NA, 8};
85
86
87NETCP_CFG_EXCEPTION_PKT_T expPkt_appid;
88
89Trie *p_trie_sa_rx;
90Trie *p_trie_sa_tx;
91
92
93/*******************************************
94 *************NETAPI OBJECTS***************
95 *****************************************/
96static NETAPI_CFG_T our_netapi_default_cfg=
97{
98TUNE_NETAPI_PERM_MEM_SZ,
99128, //start of packet offset for hw to place data on rx for default flow
100TUNE_NETAPI_QM_CONFIG_MAX_DESC_NUM, //max number of descriptors in system
101TUNE_NETAPI_NUM_GLOBAL_DESC, //total we will use
102TUNE_NETAPI_DEFAULT_NUM_BUFFERS, //#descriptors+buffers in default heap
10364, //#descriptors w/o buffers in default heap
104TUNE_NETAPI_DEFAULT_BUFFER_SIZE+128+128, //size of buffers in default heap
105128, //tail room
106256, //extra room
1070,
108NULL,
10918,
1100x2000
111};
112
113NETAPI_T netapi_handle;
114NETAPI_SCHED_HANDLE_T * our_sched;
115#ifdef netTest_MULTI_THREAD
116NETAPI_SCHED_HANDLE_T * scheduler[TUNE_NETAPI_NUM_CORES];
117#endif
118NETAPI_SCHED_CONFIG_T our_sched_cfg={
119 NETAPI_SCHED_DURATION|NETAPI_SCHED_CBV, 0, house, 5000000 //every 5000000 poll loops
120};
121
122NETCP_CFG_IP_T ip_rule[NET_TEST_MAX_IP];
123NETCP_CFG_MACIF_T mac[NET_TEST_MAX_MAC];
124
125
126
127/* security objects. (for loopback mode) */
128netTestSA_t sa_info[MAX_SEC_INDEX];
129
130NETCP_CFG_IPSEC_POLICY_T rx_policy[MAX_SEC_INDEX];
131
132/* stub functions */
133void recv_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
134 PKTIO_METADATA_T meta[], int n_pkts,
135 uint64_t ts )
136{
137 return;
138}
139
140void flip_and_send_pkt(Ti_Pkt *tip, unsigned char * p_pkt, int len, int flag, uint16_t enet_port)
141{
142 return;
143}
144
145
146
147void recv_sb_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
148 PKTIO_METADATA_T meta[], int n_pkts,
149 uint64_t ts )
150{
151 return;
152}
153
154Trie * route_init(void)
155{
156 return NULL;
157}
158void route_add(Trie * Pt, unsigned long * Pdest_ipBE, void * Pour_route)
159{
160}
161
162#ifdef netTest_MULTI_THREAD
163NETAPI_T worker_nh[TUNE_NETAPI_NUM_CORES];
164
165void slow_path_thread(uint32_t thread_num)
166{
167 return;
168}
169
170void fast_path_thread(uint32_t thread_num)
171{
172 return;
173}
174
175#endif
176
177/* Templates to build command labels at startup up time, required by open_pktio_tx_channels() */
178nwalTxPktInfo_t txPktInfoESP =
179{
180 NULL, /* p_pkt */
181 NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
182 0, /* lpbackPass */
183 0, /* enetport */
184 0, /* msuSize */
185 0, /* startOffset */
186 netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN, /* saOffBytes */
187 0, /* saPayLoadLen */
188 0 , /* saAhIcvOffBytes */
189 0, /* saAhMacSize */
190 0, /* etherLenOffBytes */
191 0, /* ipOffBytes */
192 0, /* l4OffBytes */
193 netTest_UDP_HEADER_LEN, /* l4HdrLen */
194 0, /* pseudoHdrChecksum */
195 0 /* pLoadLen */
196};
197
198
199nwalTxPktInfo_t txPktInfoAH =
200{
201 NULL, /* p_pkt */
202 NWAL_TX_FLAG1_DO_IPSEC_AH_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM | NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
203 0, /* lpbackPass */
204 0, /* enetport */
205 0, /* msuSize */
206 0, /* startOffset */
207 netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN, /* saOffBytes */
208 0, /* saPayLoadLen */
209 netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN + netTest_IPSEC_AH_FIXED_HDR_SIZE, /* saAhIcvOffBytes */
210 12, /* saAhMacSize */
211 0, /* etherLenOffBytes */
212 0, /* ipOffBytes */
213 0, /* l4OffBytes */
214 netTest_UDP_HEADER_LEN, /* l4HdrLen */
215 0, /* pseudoHdrChecksum */
216 0 /* pLoadLen */
217};
218
219nwalTxPktInfo_t txPktInfoNoCrypto =
220{
221 NULL, /* p_pkt */
222 NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
223 0, /* lpbackPass */
224 0, /* enetport */
225 0, /* msuSize */
226 0, /* startOffset */
227 0, /* saOffBytes */
228 0, /* saPayLoadLen */
229 0 , /* saAhIcvOffBytes */
230 0, /* saAhMacSize */
231 0, /* etherLenOffBytes */
232 0, /* ipOffBytes */
233 netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN, /* l4OffBytes */
234 netTest_UDP_HEADER_LEN, /* l4HdrLen */
235 0, /* pseudoHdrChecksum */
236 0 /* pLoadLen */
237};
238
239
240void close_pktio_channels(void)
241{
242 int err;
243 netapi_pktioClose(netcp_tx_chan_esp ,&err);
244 netapi_pktioClose(netcp_tx_chan_ah ,&err);
245 netapi_pktioClose(netcp_sb_tx_chan ,&err);
246 netapi_pktioClose(netcp_tx_chan_no_crypto,&err);
247}
248
249void open_pktio_tx_channels(void)
250{
251 int err;
252 /* open netcp default TX for ESP packets */
253 netcp_tx_chan_esp= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
254 if (!netcp_tx_chan_esp)
255 {
256 printf("pktio open TX failed err=%d\n",err);
257 exit(1);
258 }
259 else
260 {
261 if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
262 {
263 PKTIO_CONTROL_T control;
264 control.op = PKTIO_UPDATE_FAST_PATH;
265 PKTIO_CFG_T cfg;
266 cfg.fast_path_cfg.fp_send_option = PKTIO_FP_ESP_L4CKSUM_PORT;
267 cfg.fast_path_cfg.txPktInfo= &txPktInfoESP;
268 netapi_pktioControl(netcp_tx_chan_esp, NULL, &cfg, &control, &err);
269 }
270 }
271
272 /* open netcp default TX for AH packets */
273 netcp_tx_chan_ah= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
274 if (!netcp_tx_chan_ah)
275 {
276 printf("pktio open TX failed err=%d\n",err);
277 exit(1);
278 }
279 else
280 {
281 if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
282 {
283 PKTIO_CONTROL_T control;
284 control.op = PKTIO_UPDATE_FAST_PATH;
285 PKTIO_CFG_T cfg;
286 cfg.fast_path_cfg.fp_send_option = PKTIO_FP_AH_L4CKSUM_PORT;
287 cfg.fast_path_cfg.txPktInfo= &txPktInfoAH;
288 netapi_pktioControl(netcp_tx_chan_ah, NULL, &cfg, &control, &err);
289 }
290 }
291
292 /* open netcp default TX channels for non-Crypto packets */
293 netcp_tx_chan_no_crypto= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
294 if (!netcp_tx_chan_no_crypto)
295 {
296 printf("pktio open TX failed err=%d\n",err);
297 exit(1);
298 }
299 else
300 {
301 if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
302 {
303 PKTIO_CONTROL_T control;
304 control.op = PKTIO_UPDATE_FAST_PATH;
305 PKTIO_CFG_T cfg;
306 cfg.fast_path_cfg.fp_send_option = PKTIO_FP_L4CKSUM_PORT;
307 cfg.fast_path_cfg.txPktInfo= &txPktInfoNoCrypto;
308 netapi_pktioControl(netcp_tx_chan_no_crypto, NULL, &cfg, &control, &err);
309 }
310 }
311
312 /* open netcp default TX channels for SB crypto */
313 netcp_sb_tx_chan= netapi_pktioOpen(netapi_handle, NETCP_SB_TX, NULL, &netcp_sb_tx_cfg, &err);
314 if (!netcp_sb_tx_chan)
315 {
316 printf("pktio open SB TX failed err=%d\n",err);
317 exit(1);
318 }
319}
320/***************************************
321 ********** test driver*****************
322 ***************************************/
323int main(int argc, char **argv)
324{
325 int err,i;
326 Pktlib_HeapCfg heapCfg;
327 int32_t errCode;
328 Pktlib_HeapIfTable* pPktifTable;
329 FILE * fpr = NULL;
330
331
332 setvbuf(stdout,NULL,_IONBF,0);
333 /* install signal handler for ^c */
334 signal(SIGINT,netTest_utilMySig);
335
336 if (argc == 2)
337 {
338 printf("main: filename1 %s\n", argv[1]);
339 fpr = fopen(argv[1], "r");
340 }
341 else
342 {
343 fpr = fopen(input_file_name, "r");
344 }
345 if (fpr == NULL)
346 {
347 printf("error opening configfile\n");
348 exit(1);
349 }
350 else
351 {
352 memset(&config_file, 0, sizeof(netTestConfigFile_t));
353 memset(&netTestCfg, 0, sizeof(netTestConfig_t));
354 netTest_utilProcessConfigFile(fpr,&config_file);
355#if 1
356 netTest_utilParseMac(&config_file);
357
358 /* parse slow path/fast path thread configuration parameters */
359 netTest_utilParseThreadParams(&config_file);
360
361 netTest_utilParseIP(&config_file);
362
363 netTest_utilParseIpsecMode(&config_file);
364
365 /* DSP mac processing */
366 parse_dsp_mac(&config_file.dsp_mac[0]);
367
368 /* DSP IP processing */
369 parse_dsp_ip(&config_file.dsp_ip[0]);
370
371 /* IPSEC interface number processing */
372 parse_simple_param_u32((char*)&config_file.ipsec_if_no[0], &netTestCfg.ipsec_if_no);
373
374 netTest_utilParseSA(&config_file);
375#endif
376 }
377
378 memset(&sa_info, 0, sizeof(sa_info));
379
380
381#ifdef netTest_MULTI_THREAD
382 /* assign main net_test thread to run on core 0 */
383 CPU_ZERO( &cpu_set);
384 CPU_SET( 0, &cpu_set);
385 hplib_utilSetupThread(0, &cpu_set, hplib_spinLock_Type_LOL);
386#endif
387
388 /* create netapi */
389 netapi_handle = netapi_init(NETAPI_SYS_MASTER, &our_netapi_default_cfg);
390 if (netapi_handle == NULL)
391 {
392 printf("main: netapi_init failure, exiting\n");
393 exit(1);
394 }
395
396 /* open the main heap */
397 ourHeap = Pktlib_findHeapByName("netapi");
398 if (!ourHeap)
399 {
400 printf("Pktlib_findHeapByName() fail\n");
401 exit(1);
402 }
403
404 open_pktio_tx_channels();
405
406 /* create scheduler instance */
407 our_sched =netapi_schedOpen(netapi_handle,&our_sched_cfg, &err);
408 if (!our_sched) {printf("sched create failed\n"); exit(1);}
409
410
411 /*create net_test MAC interfaces, attach IP to created MAC interfaces */
412 netTest_utilCreateInterfaces(netTestCfg.num_macs, netTestCfg.num_ips,0);
413
414 /* lookup Database for SA context, this is used by packet processing routines to get RX and TX SA information*/
415 p_trie_sa_rx = trie_new();
416 p_trie_sa_tx = trie_new();
417 if (!p_trie_sa_rx || !p_trie_sa_tx)
418 {printf("trie alloc for SA failed\n"); exit(1);}
419
420
421#ifdef TEST_SA
422 /* Create RX SA's, RX Policy and TX SA's, all SA configuration parameters are read from net_test_config.txt file */
423 netTest_utilCreateSecAssoc();
424#endif
425#ifdef netTest_MULTI_THREAD
426{
427 int c;
428
429
430 //this thread of execution (main) now just waits on user input
431 for(;;)
432 {
433 printf(">");
434 c=getchar();
435 if (c=='q')
436 {
437 QUIT=1;
438 break;
439 }
440 else if (c=='h')
441 printf("'q' to quit, 's' for stats, 'h' for help\n");
442 }
443}
444#else
445 /*********************************************/
446 /**************Entry point into scheduler ****/
447 /*********************************************/
448 netapi_schedRun(our_sched, &err);
449#endif
450
451 /* cleanup*/
452 netTest_utilDeleteSecAssoc();
453
454 netTest_utilDeleteInterfaces(netTestCfg.num_macs, netTestCfg.num_ips);
455
456 /* close pktio channels we opened via open_pktio_tx_channels() */
457 close_pktio_channels();
458
459 netapi_shutdown(netapi_handle);
460
461}
462
diff --git a/ti/runtime/netapi/test/net_test_router.c b/ti/runtime/netapi/test/net_test_router.c
new file mode 100755
index 0000000..c6d1875
--- /dev/null
+++ b/ti/runtime/netapi/test/net_test_router.c
@@ -0,0 +1,800 @@
1/******************************************************************************
2 * File: net_test_router.c
3 * Purpose: net_test_router application
4 ******************************************************************************
5 * FILE: net_test_router.c
6 *
7 * DESCRIPTION: netapi user space transport
8 * library net_test_router application
9 *
10 * REVISION HISTORY:
11 *
12 * Copyright (c) Texas Instruments Incorporated 2013
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
42 ******************************************************************************/
43
44#include "netapi.h"
45#include "net_test_sa_utils.h"
46#include "net_test_utils.h"
47#include "net_test_thread_utils.h"
48
49#include <signal.h>
50#include <pthread.h>
51#include <sys/resource.h>
52#include "router.h"
53extern int QUIT;
54extern Rm_ServiceHandle *rmClientServiceHandle;
55
56
57#if defined(DEVICE_K2H)
58#include <ti/drv/qmss/device/k2h/src/qmss_device.c>
59#include <ti/drv/cppi/device/k2h/src/cppi_device.c>
60#elif defined (DEVICE_K2K)
61#include <ti/drv/qmss/device/k2k/src/qmss_device.c>
62#include <ti/drv/cppi/device/k2k/src/cppi_device.c>
63#elif defined (DEVICE_K2L)
64#include <ti/drv/qmss/device/k2l/src/qmss_device.c>
65#include <ti/drv/cppi/device/k2l/src/cppi_device.c>
66#elif defined (DEVICE_K2E)
67#include <ti/drv/qmss/device/k2e/src/qmss_device.c>
68#include <ti/drv/cppi/device/k2e/src/cppi_device.c>
69#else /*Default */
70#include <ti/drv/qmss/device/k2h/src/qmss_device.c>
71#include <ti/drv/cppi/device/k2h/src/cppi_device.c>
72#endif
73/* Global definitions */
74
75extern Rm_ServiceHandle *rmClientServiceHandle;
76
77hplib_spinLock_T net_test_thread_lock;
78netTestConfig_t netTestCfg;
79static netTestConfigFile_t config_file;
80
81char input_file_name[] = "/etc/transportnetlib/test/net_test_config.txt";
82
83nwal_RetValue nwalRetVal;
84Pktlib_HeapHandle ourHeap;
85
86PKTIO_HANDLE_T *netcp_tx_chan_no_crypto;
87PKTIO_HANDLE_T *netcp_rx_chan;
88PKTIO_HANDLE_T *netcp_tx_chan_esp;
89PKTIO_HANDLE_T *netcp_tx_chan_ah;
90
91
92
93
94PKTIO_CFG_T netcp_rx_cfg={PKTIO_RX, PKTIO_NA, PKTIO_NA, 8};
95PKTIO_CFG_T netcp_tx_cfg={PKTIO_TX, PKTIO_NA, PKTIO_NA, 8};
96
97
98
99NETCP_CFG_EXCEPTION_PKT_T expPkt_appid;
100
101Trie *p_trie_sa_rx;
102Trie *p_trie_sa_tx;
103
104
105#include "router.c"
106Trie * our_router;
107
108OUR_ROUTE_T routes[MAX_ROUTES]=
109
110{
111 {0,{0xD4,0xbe,0xd9,0x00,0xd3,0x7e, 0x00,0x01,0x02,0x03,0x14,0x02,0x08,0x00},0},
112 {0,{0x00,0x00,0x0,0x00,0x0,0x0, 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00},0},
113 {0,{0xD4,0xbe,0xd9,0x00,0xd3,0x7e, 0x00,0x01,0x02,0x03,0x14,0x02,0x08,0x00},0},
114 {0,{0x00,0x15,0x60,0xa1,0xf7,0xbe, 0x00,0x01,0x02,0x03,0x04,0x05,0x08,0x00},0},
115 {0,{0xd4,0xbe,0xd9,0x00,0xd3,0x7e, 0x00,0x01,0x02,0x03,0x04,0x05,0x08,0x00},0}
116};
117unsigned int ip[MAX_ROUTES]={BE(0x0a0100c8),BE(0x0a00000a),BE(0x0a02000a),BE(0xc0a8010a),BE(0x9eda6719)};
118
119void recv_cb_router(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
120 PKTIO_METADATA_T meta[], int n_pkts,
121 uint64_t ts );
122
123
124extern netTestStats_T stats[];
125extern paSysStats_t netcp_stats;
126
127/*******************************************
128 *************NETAPI OBJECTS***************
129 *****************************************/
130static NETAPI_CFG_T our_netapi_default_cfg=
131{
132 TUNE_NETAPI_PERM_MEM_SZ,
133 128, //start of packet offset for hw to place data on rx for default flow
134 TUNE_NETAPI_QM_CONFIG_MAX_DESC_NUM, //max number of descriptors in system
135 TUNE_NETAPI_NUM_GLOBAL_DESC, //total we will use
136 TUNE_NETAPI_DEFAULT_NUM_BUFFERS, //#descriptors+buffers in default heap
137 64, //#descriptors w/o buffers in default heap
138 TUNE_NETAPI_DEFAULT_BUFFER_SIZE+128+128, //size of buffers in default heap
139 128, //tail room
140 256, //extra room
141 0,
142 NULL,
143 -1,
144 -1
145};
146
147
148
149void house(NETAPI_SCHED_HANDLE_T *s);
150NETAPI_T netapi_handle;
151NETAPI_SCHED_HANDLE_T * our_sched;
152#ifdef netTest_MULTI_THREAD
153NETAPI_SCHED_HANDLE_T * scheduler[TUNE_NETAPI_NUM_CORES];
154#endif
155NETAPI_SCHED_CONFIG_T our_sched_cfg={
156 NETAPI_SCHED_DURATION|NETAPI_SCHED_CBV, 0, house, 5000000 //every 5000000 poll loops
157};
158
159
160NETCP_CFG_IP_T ip_rule[NET_TEST_MAX_IP];
161NETCP_CFG_MACIF_T mac[NET_TEST_MAX_MAC];
162
163
164
165/* security objects. (for loopback mode) */
166netTestSA_t sa_info[MAX_SEC_INDEX];
167
168
169NETCP_CFG_IPSEC_POLICY_T rx_policy[MAX_SEC_INDEX];
170
171
172
173
174/*************************END NETAPI OBJECTS***********************/
175
176void update_header(netTestHead_T * p_head, int len)
177{
178 unsigned char *p = (unsigned char *) &p_head->udp[1];
179 len -= (20+14);
180 /* update ip checksum */
181 /* update udp checksum */
182 /* update length */
183 *p= (len&0xff00)>>8;
184 *(p+1) = len&0xff;
185}
186
187#ifdef netTest_MULTI_THREAD
188/* Templates to build command labels at startup up time, required by open_pktio_tx_channels() */
189nwalTxPktInfo_t txPktInfoESP =
190{
191 NULL, /* p_pkt */
192 NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_IPV4_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
193 0, /* lpbackPass */
194 1, /* enetport */
195 0, /* msuSize */
196 0, /* startOffset */
197 netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN, /* saOffBytes */
198 0, /* saPayLoadLen */
199 0 , /* saAhIcvOffBytes */
200 0, /* saAhMacSize */
201 0, /* etherLenOffBytes */
202 netTest_MAC_HEADER_LEN, /* ipOffBytes */
203 0, /* l4OffBytes */
204 0, /* l4HdrLen */
205 0, /* pseudoHdrChecksum */
206 0 /* pLoadLen */
207};
208
209
210nwalTxPktInfo_t txPktInfoAH =
211{
212 NULL, /* p_pkt */
213 NWAL_TX_FLAG1_DO_IPSEC_AH_CRYPTO| NWAL_TX_FLAG1_DO_IPV4_CHKSUM | NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
214 0, /* lpbackPass */
215 0, /* enetport */
216 0, /* msuSize */
217 0, /* startOffset */
218 netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN, /* saOffBytes */
219 0, /* saPayLoadLen */
220 netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN + netTest_IPSEC_AH_FIXED_HDR_SIZE, /* saAhIcvOffBytes */
221 12, /* saAhMacSize */
222 0, /* etherLenOffBytes */
223 netTest_MAC_HEADER_LEN, /* ipOffBytes */
224 0, /* l4OffBytes */
225 netTest_UDP_HEADER_LEN, /* l4HdrLen */
226 0, /* pseudoHdrChecksum */
227 0 /* pLoadLen */
228};
229
230nwalTxPktInfo_t txPktInfoNoCrypto =
231{
232 NULL, /* p_pkt */
233 NWAL_TX_FLAG1_DO_IPV4_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
234 0, /* lpbackPass */
235 0, /* enetport */
236 0, /* msuSize */
237 0, /* startOffset */
238 0, /* saOffBytes */
239 0, /* saPayLoadLen */
240 0 , /* saAhIcvOffBytes */
241 0, /* saAhMacSize */
242 0, /* etherLenOffBytes */
243 netTest_MAC_HEADER_LEN, /* ipOffBytes */
244 netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN, /* l4OffBytes */
245 netTest_UDP_HEADER_LEN, /* l4HdrLen */
246 0, /* pseudoHdrChecksum */
247 0 /* pLoadLen */
248};
249
250void close_pktio_channels(void)
251{
252 int err;
253 netapi_pktioClose(netcp_tx_chan_no_crypto ,&err);
254 netapi_pktioClose(netcp_tx_chan_esp ,&err);
255 netapi_pktioClose(netcp_tx_chan_ah ,&err);
256}
257
258
259
260void open_pktio_tx_channels()
261{
262 int err;
263 /* open netcp default TX channels for non-ipsec*/
264 netcp_tx_chan_no_crypto= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
265 if (!netcp_tx_chan_no_crypto)
266 {
267 netapi_Log("pktio open TX failed err=%d\n",err);
268 exit(1);
269 }
270 else
271 {
272 PKTIO_CONTROL_T control;
273 control.op = PKTIO_UPDATE_FAST_PATH;
274 PKTIO_CFG_T cfg;
275 cfg.fast_path_cfg.fp_send_option = PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT;
276 cfg.fast_path_cfg.txPktInfo= &txPktInfoNoCrypto;
277 netapi_pktioControl(netcp_tx_chan_no_crypto, NULL, &cfg, &control, &err);
278 }
279 /* open netcp default TX for ESP packets */
280 netcp_tx_chan_esp= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
281 if (!netcp_tx_chan_esp)
282 {
283 netapi_Log("pktio open TX failed err=%d\n",err);
284 exit(1);
285 }
286 else
287 {
288 if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
289 {
290 PKTIO_CONTROL_T control;
291 control.op = PKTIO_UPDATE_FAST_PATH;
292 PKTIO_CFG_T cfg;
293 cfg.fast_path_cfg.fp_send_option = PKTIO_FP_ESP_L3CKSUM_PORT;
294 cfg.fast_path_cfg.txPktInfo= &txPktInfoESP;
295 netapi_pktioControl(netcp_tx_chan_esp, NULL, &cfg, &control, &err);
296 }
297 }
298
299 /*/* open netcp default TX for AH packets */
300 netcp_tx_chan_ah= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg, &err);
301 if (!netcp_tx_chan_ah)
302 {
303 netapi_Log("pktio open TX failed err=%d\n",err);
304 exit(1);
305 }
306 else
307 {
308 if(netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_INFLOW)
309 {
310 PKTIO_CONTROL_T control;
311 control.op = PKTIO_UPDATE_FAST_PATH;
312 PKTIO_CFG_T cfg;
313 cfg.fast_path_cfg.fp_send_option = PKTIO_FP_AH_PORT;
314 cfg.fast_path_cfg.txPktInfo= &txPktInfoAH;
315 netapi_pktioControl(netcp_tx_chan_ah, NULL, &cfg, &control, &err);
316 }
317 }
318}
319
320
321
322
323NETAPI_T worker_nh[TUNE_NETAPI_NUM_CORES];
324void slow_path_thread(uint32_t index)
325{
326 int err,i;
327 uint32_t thread_num;
328 PKTIO_HANDLE_T *rx_chan;
329 PKTIO_HANDLE_T *sb_tx_chan;
330 PKTIO_HANDLE_T *sb_rx_chan;
331 cpu_set_t cpu_set;
332
333 thread_num = netTestCfg.sp_thread_num[index];
334 printf("slow_path_thread for index %d called for thread %d\n", index, thread_num);
335
336 CPU_ZERO( &cpu_set);
337#ifdef CORTEX_A8
338 for (i = netTestCfg.sp_proc_start[index]; i <= netTestCfg.sp_proc_end[index];i++)
339 {
340 printf("slow_path_thread: setting cpu %d to cpu_set\n", i);
341 CPU_SET( i, &cpu_set);
342 }
343 hplib_utilSetupThread(0, &cpu_set, hplib_spinLock_Type_LOL);
344#else
345 for (i = netTestCfg.sp_proc_start[index]; i <= netTestCfg.sp_proc_end[index];i++)
346 {
347 printf("slow_path_thread: setting cpu %d to cpu_set\n", i);
348 CPU_SET( i, &cpu_set);
349 }
350 hplib_utilSetupThread(thread_num, &cpu_set, hplib_spinLock_Type_LOL);
351#endif
352 worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,
353 NULL);
354 if (worker_nh[thread_num] == NULL)
355 {
356 printf("slow_path_thread: netapi_init failure, exiting\n");
357 exit(1);
358 }
359 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[thread_num];
360
361 /* open netcp RX channel */
362 //rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg, &err);
363
364
365
366 netapi_setCookie(worker_nh[thread_num],(void*) (thread_num | NET_TEST_SP_THREAD_MASK));
367
368 scheduler[thread_num] =netapi_schedOpen(worker_nh[thread_num],&our_sched_cfg, &err);
369 if (!scheduler[thread_num])
370 {
371 netapi_Log("sched create failed for core%d\n",thread_num);
372 exit(1);
373 }
374 scheduler[thread_num]->config.yield = NETAPI_FALSE;
375 scheduler[thread_num]->config.pollGarbageQ = NETAPI_TRUE;
376 scheduler[thread_num]->config.pollCtrlQ = NETAPI_TRUE;
377 /*********************************************/
378 /**************Entry point into scheduler ****/
379 /*********************************************/
380 netapi_schedRun(scheduler[thread_num], &err);
381 netapi_Log("slow_path_thread: core %d worker thread done\n",thread_num);
382
383 //netapi_pktioClose(rx_chan, &err);
384 netapi_shutdown(worker_nh[thread_num]);
385}
386
387
388void fast_path_thread(uint32_t index)
389{
390 int err,i;
391 uint32_t thread_num;
392 PKTIO_HANDLE_T *rx_chan;
393 PKTIO_HANDLE_T *sb_tx_chan;
394
395 cpu_set_t cpu_set;
396
397 thread_num = netTestCfg.fp_thread_num[index];
398 printf("fast_path_thread for index %d called for thread %d\n", index, thread_num);
399 CPU_ZERO( &cpu_set);
400#ifdef CORTEX_A8
401 for (i = netTestCfg.fp_proc_start[index]; i <= netTestCfg.fp_proc_end[index];i++)
402 {
403 printf("fast_path_thread: setting cpu %d to cpu_set\n", i);
404 CPU_SET( i, &cpu_set);
405 }
406 hplib_utilSetupThread(thread_num, &cpu_set, hplib_spinLock_Type_LOL);
407#else
408 for (i = netTestCfg.fp_proc_start[index]; i <= netTestCfg.fp_proc_end[index];i++)
409 {
410 printf("fast_path_thread: setting cpu %d to cpu_set\n", i);
411 CPU_SET( i, &cpu_set);
412 }
413 hplib_utilSetupThread(thread_num, &cpu_set, hplib_spinLock_Type_LOL);
414#endif
415 hplib_mSpinLockLock(&net_test_thread_lock);
416 worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,
417 NULL);
418 if (worker_nh[thread_num] == NULL)
419 {
420 printf("fast_path_thread: netapi_init failure, exiting\n");
421 hplib_mSpinLockUnlock(&net_test_thread_lock);
422 exit(1);
423 }
424 hplib_mSpinLockUnlock(&net_test_thread_lock);
425 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[thread_num];
426
427 /* open netcp RX channel */
428 rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg, &err);
429 netapi_setCookie(worker_nh[thread_num],(void*)thread_num);
430
431 scheduler[thread_num] =netapi_schedOpen(worker_nh[thread_num],&our_sched_cfg, &err);
432 if (!scheduler[thread_num])
433 {
434 netapi_Log("sched create failed for core%d\n",thread_num);
435 exit(1);
436 }
437
438 /*********************************************/
439 /**************Entry point into scheduler ****/
440 /*********************************************/
441 scheduler[thread_num]->config.yield = NETAPI_FALSE;
442 scheduler[thread_num]->config.pollGarbageQ = NETAPI_FALSE;
443 scheduler[thread_num]->config.pollCtrlQ = NETAPI_FALSE;
444 //sleep(100000);
445 netapi_schedRun(scheduler[thread_num], &err);
446 netapi_Log("fast_path_thread: core %d worker thread done\n",thread_num);
447
448 netapi_pktioClose(rx_chan, &err);
449 netapi_shutdown(worker_nh[thread_num]);
450}
451#endif
452
453/***************************************
454 ********** test driver*****************
455 ***************************************/
456int main(int argc, char **argv)
457{
458 int err,i;
459 Pktlib_HeapCfg heapCfg;
460 int32_t errCode;
461 Pktlib_HeapIfTable* pPktifTable;
462 FILE * fpr = NULL;
463
464 cpu_set_t cpu_set;
465 /* install signal handler for ^c */
466 signal(SIGINT,netTest_utilMySig);
467
468 if (argc == 2)
469 {
470 fpr = fopen(argv[1], "r");
471 }
472 else
473 {
474 fpr = fopen(input_file_name, "r");
475 }
476 if (fpr == NULL)
477 {
478 exit(1);
479 }
480 else
481 {
482 if (initRm())
483 {
484 printf("main: initRm() returned error\n");
485 exit(1);
486 }
487 hplib_mSpinLockInit(&net_test_thread_lock );
488 our_netapi_default_cfg.rmHandle = rmClientServiceHandle;
489 memset(&config_file, 0, sizeof(netTestConfigFile_t));
490 memset(&netTestCfg, 0, sizeof(netTestConfig_t));
491 netTest_utilProcessConfigFile(fpr,&config_file);
492 netTest_utilParseMac(&config_file);
493
494 /* parse slow path/fast path thread configuration parameters */
495 netTest_utilParseThreadParams(&config_file);
496
497 netTest_utilParseIP(&config_file);
498
499 netTest_utilParseIpsecMode(&config_file);
500
501 /* DSP mac processing */
502 parse_dsp_mac(&config_file.dsp_mac[0]);
503
504 /* DSP IP processing */
505 parse_dsp_ip(&config_file.dsp_ip[0]);
506
507 netTest_utilParseRoutes(&config_file, &routes[0], &our_router);
508
509 /* IPSEC interface number processing */
510 parse_simple_param_u32((char*)&config_file.ipsec_if_no[0], &netTestCfg.ipsec_if_no);
511
512 netTest_utilParseSA(&config_file);
513 }
514
515 memset(&sa_info, 0, sizeof(sa_info));
516
517#ifdef netTest_MULTI_THREAD
518 /* assign main net_test thread to run on core 0 */
519 CPU_ZERO( &cpu_set);
520 CPU_SET( 0, &cpu_set);
521 hplib_utilSetupThread(0, &cpu_set, hplib_spinLock_Type_LOL);
522#endif
523 /* create netapi */
524 our_netapi_default_cfg.rmHandle = rmClientServiceHandle;
525 netapi_handle = netapi_init(NETAPI_SYS_MASTER,
526 &our_netapi_default_cfg);
527
528 if (netapi_handle == NULL)
529 {
530 printf("main: netapi_init failure, exiting\n");
531 exit(1);
532 }
533 /* configure expection packet handling with netapi */
534 expPkt_appid = netapi_netcpCfgExceptions(netapi_handle,
535 7,
536 NETCP_CFG_ACTION_TO_SW,
537 (NETCP_CFG_ROUTE_HANDLE_T) NULL);
538
539 /* open the main heap */
540 ourHeap = Pktlib_findHeapByName("netapi");
541 if (!ourHeap)
542 {
543 netapi_Log("Pktlib_findHeapByName() fail\n");
544 exit(1);
545 }
546
547 /* Open all required PKTIO TX channels */
548 open_pktio_tx_channels();
549
550 netapi_Log("net_test> %d bytes left in our CMA area\n", netapi_getBufMemRemainder());
551 /* create scheduler instance */
552 our_sched =netapi_schedOpen(netapi_handle,&our_sched_cfg, &err);
553 if (!our_sched) {netapi_Log("sched create failed\n"); exit(1);}
554
555
556 /*create net_test MAC interfaces, attach IP to created MAC interfaces */
557 netTest_utilCreateInterfaces(netTestCfg.num_macs, netTestCfg.num_ips,1);
558
559 /* Lookup Database for SA context, this is used by packet processing routines to get RX and TX SA information*/
560 p_trie_sa_rx = trie_new();
561 p_trie_sa_tx = trie_new();
562 if (!p_trie_sa_rx || !p_trie_sa_tx)
563 {netapi_Log("trie alloc for SA failed\n"); exit(1);}
564
565 /* Create RX SA's, RX Policy and TX SA's, all SA configuration parameters are read from net_test_config.txt file */
566 netTest_utilCreateSecAssoc();
567
568
569#ifdef netTest_MULTI_THREAD
570{
571 int c;
572 /* create and set affinity of slow path and fast path threads to
573 * specific CPU cores as specified in the net_test_config.txt file */
574 netTest_utilCreateSpFpThreads(netTestCfg.num_sp_threads,
575 (NET_TEST_FUNC_PTR) slow_path_thread,
576 netTestCfg.num_fp_threads,
577 (NET_TEST_FUNC_PTR) fast_path_thread);
578
579 //this thread of execution (main) now just waits on user input
580 for(;;)
581 {
582 printf(">");
583 c=getchar();
584 if (c=='q') {QUIT=1;break;}
585 else if (c=='s') netTest_utilsStatsCb(netapi_handle, &netcp_stats);
586 else if (c=='h') printf("'q' to quit, 's' for stats, 'h' for help\n");
587 }
588 netTest_utilRemoveSpFpThreads(netTestCfg.num_sp_threads, netTestCfg.num_fp_threads);
589}
590#else
591 /*********************************************/
592 /**************Entry point into scheduler ****/
593 /*********************************************/
594 netapi_schedRun(our_sched, &err);
595#endif
596
597/* done */
598netTest_utilsStatsCb(netapi_handle, NULL);
599
600
601
602 /* cleanup*/
603 netTest_utilDeleteSecAssoc();
604 netTest_utilDeleteInterfaces(netTestCfg.num_macs, netTestCfg.num_ips);
605
606 /* close pktio channels we opened via open_pktio_tx_channels() */
607 close_pktio_channels();
608 netapi_shutdown(netapi_handle);
609}
610
611static inline void send_it(Ti_Pkt *tip, int len, netTestSA_t * p_sec, int out_port)
612{
613 unsigned long st1;
614 unsigned long st2;
615 int err=0;
616 PKTIO_METADATA_T meta2 = {PKTIO_META_TX,{0},0};
617 nwalTxPktInfo_t meta_tx2={0};
618 st1=hplib_mUtilGetPmuCCNT();
619#ifdef netTest_MULTI_THREAD
620 int coreid=Osal_nwalGetProcId(); //who we are(thread local)
621 //int coreid = our_core;
622#else
623 int coreid=0;
624#endif
625 if (len<60)
626 {
627 unsigned int templen;
628 char * p_pkt;
629 len=60;
630 Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);//ignore templen
631 Cppi_setData (Cppi_DescType_HOST, (Cppi_Desc *) tip, p_pkt,len);
632 stats[coreid].tx_min+=1;
633 }
634 Pktlib_setPacketLen(tip,len);
635 meta_tx2.txFlag1 = (NWAL_TX_FLAG1_DO_IPV4_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID );
636 meta_tx2.startOffset = 0;
637 meta_tx2.ipOffBytes = netTest_MAC_HEADER_LEN;
638 meta_tx2.ploadLen = len ;
639 meta_tx2.enetPort=out_port;
640 if(p_sec)
641 {
642 meta_tx2.txFlag1 |= NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO ;
643 meta2.sa_handle = (void*)p_sec->tx_tunnel;
644 meta_tx2.saOffBytes=netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
645 meta_tx2.saPayloadLen=len-netTest_MAC_HEADER_LEN - netTest_IP_HEADER_LEN; //don't include tag, mac and outer header
646 meta2.u.tx_meta=&meta_tx2;
647 netapi_pktioSend(netcp_tx_chan_esp,tip,&meta2,&err);
648 stats[coreid].sec_tx+=1;
649 }
650 else
651 {
652 meta2.u.tx_meta=&meta_tx2;
653 netapi_pktioSend(netcp_tx_chan_no_crypto,tip,&meta2,&err);
654
655 }
656 stats[coreid].tx +=1;
657 st2=hplib_mUtilGetPmuCCNT();
658 stats[coreid].send_cycles += (unsigned long long) (st2-st1);
659}
660void recv_cb_router(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
661 PKTIO_METADATA_T meta[], int n_pkts,
662 uint64_t ts )
663{
664 int i;
665 int len;
666 int p;
667 Ti_Pkt * tip;
668 unsigned int templen;
669 char * p_pkt;
670 netTestHead_T temp_head;
671 unsigned int appid;
672 IP_netTestHead_T th;
673 netTestSA_t *sec_data=NULL;
674 unsigned long t1;
675 unsigned long t2;
676 unsigned long long ct1;
677 unsigned long long ct2;
678 unsigned short ip_pl;
679 unsigned long long n_c_ops;
680 int ifno;
681 int out_port;
682#ifdef netTest_MULTI_THREAD
683 int coreid=Osal_nwalGetProcId(); //who we are(thread local)
684 //int coreid = our_core;
685#else
686 int coreid=0;
687#endif
688 t1=hplib_mUtilGetPmuCCNT();
689 ct1 =Osal_cache_op_measure(&n_c_ops);
690 for(i=0;i<n_pkts;i++)
691 {
692 ifno = ((unsigned int)meta[i].u.rx_meta->appId)&0xff;
693 if(coreid<TUNE_NETAPI_NUM_CORES)
694 {
695 stats[coreid].rx+=1;
696 if (ifno < TUNE_NETAPI_MAX_NUM_MAC)
697 stats[coreid].if_rx[ifno]+=1;
698 }
699 tip = p_recv[i];
700 Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);//ignore templen
701 len = Pktlib_getPacketLen(tip)-4;//real length, subtract mac trailer
702 appid = ((unsigned int)meta[i].u.rx_meta->appId)&0xff000000;
703 switch(appid)
704 {
705 case(NETAPI_NETCP_MATCH_IPSEC):
706 case(NETAPI_NETCP_MATCH_IPSEC_POLICY):
707 {
708 int tailen=12+2;
709 memcpy(&temp_head,&p_pkt[14],sizeof(netTestHead_T));
710 if (!netTest_utilCheckHeader(&temp_head,&meta[i])) {
711 stats[coreid].n_bad+=1;
712 Pktlib_freePacket(tip);
713 continue;
714 }
715 tailen+=p_pkt[len-12-2]; //padding length (12)should come from sec_ptr
716 p_pkt = &p_pkt[8+16+20]; //16= iv len, should come from sec_ptr
717 len -= (8+16+20+tailen); //16= iv len should come from sec ptr
718
719 //now check inner headder.
720 memcpy(&th,&p_pkt[14],20);
721 if (!netTest_utilCheckHeader(&temp_head,&meta[i])) {
722 stats[coreid].n_bad+=1;
723 Pktlib_freePacket(tip);
724 continue;
725 }
726 Cppi_setData (Cppi_DescType_HOST, (Cppi_Desc *) tip, p_pkt,len);
727 Pktlib_setPacketLen(tip,len);
728
729 if (route_pkt(our_router, tip, &th, p_pkt, &len,&sec_data,&out_port)<0)
730 {
731 stats[coreid].n_bad+=1;
732 Pktlib_freePacket(tip);
733 }
734 else
735 {
736 send_it(tip,len,sec_data,out_port);
737 }
738 break;
739 }
740 case(NETAPI_NETCP_MATCH_GENERIC_MAC):
741 if((p_pkt[12]!=0x8)||(p_pkt[13]!=0x00))
742 {
743 stats[coreid].n_new+=1;
744 Pktlib_freePacket(tip);
745 continue;
746 }
747 if (!netTest_utilCheckHeader(&temp_head,&meta[i]))
748 {
749 stats[coreid].n_bad+=1;
750 Pktlib_freePacket(tip);
751 continue;
752 }
753 memcpy(&th,&p_pkt[14],20);
754 ip_pl= (((unsigned char *)&th.w1)[2]<<8) | ((unsigned char *)&th.w1)[3];
755 if ((ip_pl+14)<60)
756 {
757 len-= (60-(ip_pl+14));
758 stats[coreid].rx_min+=1;
759 }
760 Pktlib_setPacketLen(tip,len);
761 if (route_pkt(our_router, tip, &th, p_pkt, &len,&sec_data,&out_port)<0)
762 {
763 stats[coreid].n_bad+=1;
764 Pktlib_freePacket(tip);
765 }
766 else
767 {
768 send_it(tip,len,sec_data,out_port);
769 }
770 break;
771 case(NETAPI_NETCP_MATCH_GENERIC_IP):
772 Pktlib_freePacket(tip);
773 stats[coreid].n_new=1;
774 break;
775 default:
776 stats[coreid].n_new+=1;
777 Pktlib_freePacket(tip);
778 break;
779 }
780}
781t2=hplib_mUtilGetPmuCCNT();
782ct2 =Osal_cache_op_measure(&n_c_ops);
783stats[coreid].app_cycles += (unsigned long long) (t2-t1);
784stats[coreid].tx_cache_cycles += (unsigned long long) (ct2-ct1);
785return;
786}
787
788/* STUB functions required for compilation */
789void recv_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
790 PKTIO_METADATA_T meta[], int n_pkts,
791 uint64_t ts )
792{
793}
794
795void recv_sb_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
796 PKTIO_METADATA_T meta[], int n_pkts,
797 uint64_t ts )
798{
799}
800
diff --git a/ti/runtime/netapi/test/net_test_sa_utils.c b/ti/runtime/netapi/test/net_test_sa_utils.c
new file mode 100755
index 0000000..cdb87a1
--- /dev/null
+++ b/ti/runtime/netapi/test/net_test_sa_utils.c
@@ -0,0 +1,831 @@
1/******************************************
2 * File: net_test_sa_utils.c
3 * Purpose: net_test application security associations utilities
4 **************************************************************
5 * FILE: net_test_sa_utils.c
6 *
7 * DESCRIPTION: net_test application security associations utilities
8 *
9 * REVISION HISTORY:
10 *
11 * Copyright (c) Texas Instruments Incorporated 2013
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 *
20 * Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the
23 * distribution.
24 *
25 * Neither the name of Texas Instruments Incorporated nor the names of
26 * its contributors may be used to endorse or promote products derived
27 * from this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40
41 *****************************************/
42
43#include "net_test.h"
44#include "ti/runtime/netapi/netapi.h"
45#include "net_test_sa_utils.h"
46#include "net_test_utils.h"
47
48#include <signal.h>
49#include <pthread.h>
50
51#include <ti/drv/sa/salld.h>
52#include <ti/drv/pa/pa.h>
53
54extern NETAPI_T netapi_handle;
55extern netTestConfig_t netTestCfg;
56extern netTestConfig_t config;
57extern netTestSA_t sa_info[];
58extern NETCP_CFG_IPSEC_POLICY_T rx_policy[];
59
60/* pktio channels externs */
61extern PKTIO_HANDLE_T *netcp_rx_chan;
62extern PKTIO_HANDLE_T *netcp_rx_chan2;
63extern PKTIO_HANDLE_T *netcp_tx_chan;
64extern PKTIO_HANDLE_T *netcp_tx_chan_ah;
65extern PKTIO_HANDLE_T *netcp_sb_tx_chan;
66extern PKTIO_HANDLE_T *netcp_sb_rx_chan;
67extern PKTIO_CFG_T our_chan_cfg;
68extern PKTIO_CFG_T netcp_rx_cfg;
69extern PKTIO_CFG_T netcp_rx_cfg2;
70extern PKTIO_CFG_T netcp_tx_cfg;
71extern PKTIO_CFG_T netcp_sb_rx_cfg;
72extern PKTIO_CFG_T netcp_sb_tx_cfg;
73/* end pktio channels externs */
74
75extern Trie *p_trie_sa_rx;
76extern Trie *p_trie_sa_tx;
77
78
79
80void netTest_utilBuildSADB(int i)
81{
82 long tmp_spi;
83 long tmp_tunnel;
84 if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_HMAC_SHA1) &&
85 (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_AES_CBC))
86 {
87 /* static configuration, will not change */
88 sa_info[i].tx_payload_info.aadSize = 0;
89 sa_info[i].tx_payload_info.pAad = NULL;
90 sa_info[i].tx_payload_info.pAuthIV = NULL;
91 sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN +
92 netTest_IP_HEADER_LEN;
93
94 sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
95 netTest_IP_HEADER_LEN +
96 netTest_ESP_HEADER_LEN +
97 netTest_AES_CBC_IV_LEN;
98
99 /* dynamic configuration, will be calculated on the fly */
100 sa_info[i].tx_payload_info.authSize = 0;
101 sa_info[i].tx_payload_info.encSize = 0;
102 sa_info[i].tx_payload_info.pEncIV = 0;
103
104 sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
105 sa_info[i].authMode = netTestCfg.sa[i].authMode;
106 sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
107 sa_info[i].auth_tag_size = netTest_ICV_LEN;
108
109 sa_info[i].iv_len=16;
110 sa_info[i].bl=16;
111
112 sa_info[i].tx_pkt_info.enetPort = 0;
113 sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
114 sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN;
115 sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
116 sa_info[i].tx_pkt_info.startOffset = 0;
117 sa_info[i].tx_pkt_info.lpbackPass = 0;
118 sa_info[i].tx_pkt_info.ploadLen = 0;
119 sa_info[i].tx_pkt_info.pPkt = NULL;
120 sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
121 sa_info[i].tx_pkt_info.saPayloadLen = 0;
122 sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
123
124 sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO |
125 NWAL_TX_FLAG1_DO_UDP_CHKSUM |
126 NWAL_TX_FLAG1_META_DATA_VALID ;
127 sa_info[i].dir =netTestCfg.sa[i].dir;
128 tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
129 tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
130 sa_info[i].spi =tmp_spi;
131 sa_info[i].tunnel_id = tmp_tunnel;
132 sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
133 sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
134
135 if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
136 {
137 trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
138 }
139 else
140 {
141 trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
142 }
143 }
144 else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_NULL) &&
145 (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_AES_CTR))
146 {
147 /* static configuration, will not change */
148 sa_info[i].tx_payload_info.aadSize = 0;
149 sa_info[i].tx_payload_info.pAad = NULL;
150 sa_info[i].tx_payload_info.pAuthIV = NULL;
151 sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN +
152 netTest_IP_HEADER_LEN;
153
154 sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
155 netTest_IP_HEADER_LEN +
156 netTest_ESP_HEADER_LEN +
157 netTest_AES_CTR_IV_LEN;
158 /* dynamic configuration, will be calculated on the fly */
159 sa_info[i].tx_payload_info.authSize = 0;
160 sa_info[i].tx_payload_info.encSize = 0;
161 sa_info[i].tx_payload_info.pEncIV = 0;
162
163 sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
164 sa_info[i].authMode = netTestCfg.sa[i].authMode;
165 sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
166 sa_info[i].auth_tag_size = 0;
167 sa_info[i].iv_len=8;
168 sa_info[i].bl=8;
169
170 sa_info[i].tx_pkt_info.enetPort = 0;
171 sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
172 sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN;
173 sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
174 sa_info[i].tx_pkt_info.startOffset = 0;
175 sa_info[i].tx_pkt_info.lpbackPass = 0;
176 sa_info[i].tx_pkt_info.ploadLen = 0;
177 sa_info[i].tx_pkt_info.pPkt = NULL;
178 sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
179 sa_info[i].tx_pkt_info.startOffset = 0;
180 sa_info[i].tx_pkt_info.lpbackPass = 0;
181 sa_info[i].tx_pkt_info.ploadLen = 0;
182 sa_info[i].tx_pkt_info.pPkt = NULL;
183 sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
184 sa_info[i].tx_pkt_info.saPayloadLen = 0;
185 sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
186
187 sa_info[i].key_params = &netTestCfg.key_params[i];
188
189 sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID ;
190 sa_info[i].dir =netTestCfg.sa[i].dir;
191 tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
192 tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
193 sa_info[i].spi =tmp_spi;
194 sa_info[i].tunnel_id = tmp_tunnel;
195 sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
196 sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
197 if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
198 {
199 trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
200 }
201 else
202 {
203 trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
204 }
205 }
206 else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_HMAC_SHA2_256) &&
207 (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_AES_CTR))
208 {
209 /* static configuration, will not change */
210 sa_info[i].tx_payload_info.aadSize = 0;
211 sa_info[i].tx_payload_info.pAad = NULL;
212 sa_info[i].tx_payload_info.pAuthIV = NULL;
213 sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN +
214 netTest_IP_HEADER_LEN;
215
216 sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
217 netTest_IP_HEADER_LEN +
218 netTest_ESP_HEADER_LEN +
219 netTest_AES_CTR_IV_LEN;
220
221 /* dynamic configuration, will be calculated on the fly */
222 sa_info[i].tx_payload_info.authSize = 0;
223 sa_info[i].tx_payload_info.encSize = 0;
224 sa_info[i].tx_payload_info.pEncIV = 0;
225
226 sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
227 sa_info[i].authMode = netTestCfg.sa[i].authMode;
228 sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
229 sa_info[i].auth_tag_size = netTest_ICV_LEN;
230 sa_info[i].iv_len=8;
231 sa_info[i].bl=8;
232
233 sa_info[i].tx_pkt_info.enetPort = 0;
234 sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
235 sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN;
236 sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
237 sa_info[i].tx_pkt_info.startOffset = 0;
238 sa_info[i].tx_pkt_info.lpbackPass = 0;
239 sa_info[i].tx_pkt_info.ploadLen = 0;
240 sa_info[i].tx_pkt_info.pPkt = NULL;
241 sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
242 sa_info[i].tx_pkt_info.saPayloadLen = 0;
243 sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
244
245 sa_info[i].key_params = &netTestCfg.key_params[i];
246
247 sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID ;
248 sa_info[i].dir =netTestCfg.sa[i].dir;
249 tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
250 tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
251 sa_info[i].spi =tmp_spi;
252 sa_info[i].tunnel_id = tmp_tunnel;
253 sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
254 sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
255 if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
256 {
257 trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
258 }
259 else
260 {
261 trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
262 }
263 }
264 else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_HMAC_SHA2_256) &&
265 (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_3DES_CBC))
266 {
267 /* static configuration, will not change */
268 sa_info[i].tx_payload_info.aadSize = 0;
269 sa_info[i].tx_payload_info.pAad = NULL;
270 sa_info[i].tx_payload_info.pAuthIV = NULL;
271 sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN +
272 netTest_IP_HEADER_LEN;
273
274 sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
275 netTest_IP_HEADER_LEN +
276 netTest_ESP_HEADER_LEN +
277 netTest_3DES_CBC_IV_LEN;
278
279 /* dynamic configuration, will be calculated on the fly */
280 sa_info[i].tx_payload_info.authSize = 0;
281 sa_info[i].tx_payload_info.encSize = 0;
282 sa_info[i].tx_payload_info.pEncIV = 0;
283
284 sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
285 sa_info[i].authMode = netTestCfg.sa[i].authMode;
286 sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
287 sa_info[i].auth_tag_size = netTest_ICV_LEN;
288
289 sa_info[i].iv_len=8;
290 sa_info[i].bl=8;
291
292 sa_info[i].tx_pkt_info.enetPort = 0;
293 sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
294 sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN;
295 sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
296 sa_info[i].tx_pkt_info.startOffset = 0;
297 sa_info[i].tx_pkt_info.lpbackPass = 0;
298 sa_info[i].tx_pkt_info.ploadLen = 0;
299 sa_info[i].tx_pkt_info.pPkt = NULL;
300 sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
301 sa_info[i].tx_pkt_info.saPayloadLen = 0;
302 sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
303
304 sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO |
305 NWAL_TX_FLAG1_DO_UDP_CHKSUM |
306 NWAL_TX_FLAG1_META_DATA_VALID ;
307
308 sa_info[i].dir =netTestCfg.sa[i].dir;
309 tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
310 tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
311 sa_info[i].spi =tmp_spi;
312 sa_info[i].tunnel_id = tmp_tunnel;
313 sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
314 sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
315 if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
316 {
317 trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
318 }
319 else
320 {
321 trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
322 }
323 }
324 else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_HMAC_MD5) &&
325 (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_NULL))
326 {
327 /* static configuration, will not change */
328 sa_info[i].tx_payload_info.aadSize = 0;
329 sa_info[i].tx_payload_info.pAad = NULL;
330 sa_info[i].tx_payload_info.pAuthIV = NULL;
331 sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN;
332
333 sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
334 netTest_IP_HEADER_LEN +
335 netTest_NULL_ESP_HEADER_LEN +
336 netTest_NULL_IV_LEN +
337 24;
338 sa_info[i].iv_len=0;
339 sa_info[i].bl=4;
340
341 /* dynamic configuration, will be calculated on the fly */
342 sa_info[i].tx_payload_info.authSize = 0;
343 sa_info[i].tx_payload_info.encSize = 0;
344 sa_info[i].tx_payload_info.pEncIV = 0;
345
346 sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
347 sa_info[i].authMode = netTestCfg.sa[i].authMode;
348 sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
349 sa_info[i].auth_tag_size = netTest_ICV_LEN;
350
351 sa_info[i].tx_pkt_info.enetPort = 0;
352 sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
353 sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN;
354 sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
355 sa_info[i].tx_pkt_info.startOffset = 0;
356 sa_info[i].tx_pkt_info.lpbackPass = 0;
357 sa_info[i].tx_pkt_info.ploadLen = 0;
358 sa_info[i].tx_pkt_info.pPkt = NULL;
359 sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN;
360 sa_info[i].tx_pkt_info.saPayloadLen = 0;
361 sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
362 sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_AH_CRYPTO |
363 NWAL_TX_FLAG1_DO_UDP_CHKSUM |
364 NWAL_TX_FLAG1_META_DATA_VALID;
365 sa_info[i].dir =netTestCfg.sa[i].dir;
366 tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
367 tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
368 sa_info[i].spi =tmp_spi;
369 sa_info[i].tunnel_id = tmp_tunnel;
370 sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
371 sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
372 if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
373 {
374 trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
375 }
376 else
377 {
378 trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
379 }
380 }
381 else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_NULL) &&
382 (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_AES_GCM))
383 {
384 /* static configuration, will not change */
385 sa_info[i].tx_payload_info.aadSize = 0;
386 sa_info[i].tx_payload_info.pAad = NULL;
387 sa_info[i].tx_payload_info.pAuthIV = NULL;
388 sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN +
389 netTest_IP_HEADER_LEN;
390
391 sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
392 netTest_IP_HEADER_LEN +
393 netTest_ESP_HEADER_LEN +
394 netTest_AES_GCM_IV_LEN;
395
396 sa_info[i].iv_len=0;
397 sa_info[i].bl=4;
398
399 /* dynamic configuration, will be calculated on the fly */
400 sa_info[i].tx_payload_info.authSize = 0;
401 sa_info[i].tx_payload_info.encSize = 0;
402 sa_info[i].tx_payload_info.pEncIV = 0;
403
404 sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
405 sa_info[i].authMode = netTestCfg.sa[i].authMode;
406 sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
407 sa_info[i].auth_tag_size = netTest_AES_GCM_CCM_ICV_LEN;
408
409 sa_info[i].tx_pkt_info.enetPort = 0;
410 sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
411 sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN;
412 sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
413 sa_info[i].tx_pkt_info.startOffset = 0;
414 sa_info[i].tx_pkt_info.lpbackPass = 0;
415 sa_info[i].tx_pkt_info.ploadLen = 0;
416 sa_info[i].tx_pkt_info.pPkt = NULL;
417 sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
418 sa_info[i].tx_pkt_info.saPayloadLen = 0;
419 sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
420
421 sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO |
422 NWAL_TX_FLAG1_DO_UDP_CHKSUM |
423 NWAL_TX_FLAG1_META_DATA_VALID;
424
425 sa_info[i].dir =netTestCfg.sa[i].dir;
426 tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
427 tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
428 sa_info[i].spi =tmp_spi;
429 sa_info[i].tunnel_id = tmp_tunnel;
430 sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
431 sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
432 if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
433 {
434 trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
435 }
436 else
437 {
438 trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
439 }
440 }
441 else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_NULL) &&
442 (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_NULL))
443 {
444 /* static configuration, will not change */
445 sa_info[i].tx_payload_info.aadSize = 0;
446 sa_info[i].tx_payload_info.pAad = NULL;
447 sa_info[i].tx_payload_info.pAuthIV = NULL;
448 sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN +
449 netTest_IP_HEADER_LEN;
450 sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
451 netTest_IP_HEADER_LEN +
452 netTest_ESP_HEADER_LEN;
453
454 sa_info[i].iv_len=0;
455 sa_info[i].bl=0;
456
457 /* dynamic configuration, will be calculated on the fly */
458 sa_info[i].tx_payload_info.authSize = 0;
459 sa_info[i].tx_payload_info.encSize = 0;
460 sa_info[i].tx_payload_info.pEncIV = 0;
461
462 sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
463 sa_info[i].authMode = netTestCfg.sa[i].authMode;
464 sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
465 sa_info[i].auth_tag_size = 0;
466
467 sa_info[i].tx_pkt_info.enetPort = 0;
468 sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
469 sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN;
470 sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
471 sa_info[i].tx_pkt_info.startOffset = 0;
472 sa_info[i].tx_pkt_info.lpbackPass = 0;
473 sa_info[i].tx_pkt_info.ploadLen = 0;
474 sa_info[i].tx_pkt_info.pPkt = NULL;
475 sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
476 sa_info[i].tx_pkt_info.saPayloadLen = 0;
477 sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
478 sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO |
479 NWAL_TX_FLAG1_DO_UDP_CHKSUM |
480 NWAL_TX_FLAG1_META_DATA_VALID;
481
482 sa_info[i].dir =netTestCfg.sa[i].dir;
483 tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
484 tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
485 sa_info[i].spi =tmp_spi;
486 sa_info[i].tunnel_id = tmp_tunnel;
487 sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
488 sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
489 if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
490 {
491 trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
492 }
493 else
494 {
495 trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
496 }
497
498 }
499 else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_NULL) &&
500 (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_AES_CCM))
501 {
502 /* static configuration, will not change */
503 sa_info[i].tx_payload_info.aadSize = 0;
504 sa_info[i].tx_payload_info.pAad = NULL;
505 sa_info[i].tx_payload_info.pAuthIV = NULL;
506 sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN +
507 netTest_IP_HEADER_LEN;
508
509 sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
510 netTest_IP_HEADER_LEN +
511 netTest_ESP_HEADER_LEN +
512 netTest_AES_CCM_IV_LEN;
513
514 sa_info[i].iv_len=0;
515 sa_info[i].bl=4;
516
517 /* dynamic configuration, will be calculated on the fly */
518 sa_info[i].tx_payload_info.authSize = 0;
519 sa_info[i].tx_payload_info.encSize = 0;
520 sa_info[i].tx_payload_info.pEncIV = 0;
521
522 sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
523 sa_info[i].authMode = netTestCfg.sa[i].authMode;
524 sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
525 sa_info[i].auth_tag_size = netTest_AES_GCM_CCM_ICV_LEN;
526
527 sa_info[i].tx_pkt_info.enetPort = 0;
528 sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
529 sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN;
530 sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
531 sa_info[i].tx_pkt_info.startOffset = 0;
532 sa_info[i].tx_pkt_info.lpbackPass = 0;
533 sa_info[i].tx_pkt_info.ploadLen = 0;
534 sa_info[i].tx_pkt_info.pPkt = NULL;
535 sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
536 sa_info[i].tx_pkt_info.saPayloadLen = 0;
537 sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
538
539 sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO |
540 NWAL_TX_FLAG1_DO_UDP_CHKSUM |
541 NWAL_TX_FLAG1_META_DATA_VALID;
542
543 sa_info[i].dir =netTestCfg.sa[i].dir;
544 tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
545 tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
546 sa_info[i].spi =tmp_spi;
547 sa_info[i].tunnel_id = tmp_tunnel;
548 sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
549 sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
550 if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
551 {
552 trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
553 }
554 else
555 {
556 trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
557 }
558 }
559 else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_AES_XCBC) &&
560 (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_NULL))
561 {
562 /* static configuration, will not change */
563 sa_info[i].tx_payload_info.aadSize = 0;
564 sa_info[i].tx_payload_info.pAad = NULL;
565 sa_info[i].tx_payload_info.pAuthIV = NULL;
566 sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN +
567 netTest_IP_HEADER_LEN;
568
569 sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
570 netTest_IP_HEADER_LEN +
571 netTest_ESP_HEADER_LEN +
572 netTest_NULL_IV_LEN;
573
574 sa_info[i].iv_len=0;
575 sa_info[i].bl=4;
576
577 /* dynamic configuration, will be calculated on the fly */
578 sa_info[i].tx_payload_info.authSize = 0;
579 sa_info[i].tx_payload_info.encSize = 0;
580 //sa_info[i].tx_payload_info.ploadLen = 0;
581 sa_info[i].tx_payload_info.pEncIV = 0;
582
583 sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
584 sa_info[i].authMode = netTestCfg.sa[i].authMode;
585 sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
586 sa_info[i].auth_tag_size = netTest_ICV_LEN;
587
588 sa_info[i].tx_pkt_info.enetPort = 0;
589 sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
590 sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN;
591 sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
592 sa_info[i].tx_pkt_info.startOffset = 0;
593 sa_info[i].tx_pkt_info.lpbackPass = 0;
594 sa_info[i].tx_pkt_info.ploadLen = 0;
595 sa_info[i].tx_pkt_info.pPkt = NULL;
596 sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
597 sa_info[i].tx_pkt_info.saPayloadLen = 0;
598 sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
599
600 sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO |
601 NWAL_TX_FLAG1_DO_UDP_CHKSUM|
602 NWAL_TX_FLAG1_META_DATA_VALID;
603
604 sa_info[i].dir =netTestCfg.sa[i].dir;
605 tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
606 tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
607 sa_info[i].spi =tmp_spi;
608 sa_info[i].tunnel_id = tmp_tunnel;
609 sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
610 sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
611 if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
612 {
613 trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
614 }
615 else
616 {
617 trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
618 }
619 }
620 else if ((netTestCfg.sa[i].authMode== NWAL_SA_AALG_GMAC) &&
621 (netTestCfg.sa[i].cipherMode == NWAL_SA_EALG_NULL))
622 {
623 /* static configuration, will not change */
624 sa_info[i].tx_payload_info.aadSize = 0;
625 sa_info[i].tx_payload_info.pAad = NULL;
626 sa_info[i].tx_payload_info.pAuthIV = NULL;
627 sa_info[i].tx_payload_info.authOffset = netTest_MAC_HEADER_LEN +
628 netTest_IP_HEADER_LEN;
629
630 sa_info[i].tx_payload_info.encOffset = netTest_MAC_HEADER_LEN +
631 netTest_IP_HEADER_LEN +
632 netTest_ESP_HEADER_LEN +
633 netTest_AES_GMAC_IV_LEN;
634
635 sa_info[i].iv_len=0;
636 sa_info[i].bl=4;
637
638 /* dynamic configuration, will be calculated on the fly */
639 sa_info[i].tx_payload_info.authSize = 0;
640 sa_info[i].tx_payload_info.encSize = 0;
641 sa_info[i].tx_payload_info.pEncIV = 0;
642 sa_info[i].tx_payload_info.pAuthIV = 0;
643
644 sa_info[i].cipherMode = netTestCfg.sa[i].cipherMode;
645 sa_info[i].authMode = netTestCfg.sa[i].authMode;
646 sa_info[i].inner_ip_offset = sa_info[i].tx_payload_info.encOffset;
647 sa_info[i].auth_tag_size = netTest_AES_GMAC_ICV_LEN;
648
649 sa_info[i].tx_pkt_info.enetPort = 0;
650 sa_info[i].tx_pkt_info.ipOffBytes = sa_info[i].tx_payload_info.encOffset;
651 sa_info[i].tx_pkt_info.l4HdrLen = netTest_UDP_HEADER_LEN;
652 sa_info[i].tx_pkt_info.l4OffBytes = sa_info[i].inner_ip_offset + netTest_IP_HEADER_LEN;
653 sa_info[i].tx_pkt_info.startOffset = 0;
654 sa_info[i].tx_pkt_info.lpbackPass = 0;
655 sa_info[i].tx_pkt_info.ploadLen = 0;
656 sa_info[i].tx_pkt_info.pPkt = NULL;
657 sa_info[i].tx_pkt_info.saOffBytes = netTest_MAC_HEADER_LEN + netTest_IP_HEADER_LEN;
658 sa_info[i].tx_pkt_info.saPayloadLen = 0;
659 sa_info[i].tx_pkt_info.pseudoHdrChecksum =0;
660
661 sa_info[i].tx_pkt_info.txFlag1 = NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO |
662 NWAL_TX_FLAG1_DO_UDP_CHKSUM |
663 NWAL_TX_FLAG1_META_DATA_VALID;
664
665 sa_info[i].dir =netTestCfg.sa[i].dir;
666 tmp_spi = netTest_utilHtonl((long)(netTestCfg.sa[i].spi));
667 tmp_tunnel = netTest_utilHtonl((long)(netTestCfg.tunnel_id[i]));
668 sa_info[i].spi =tmp_spi;
669 sa_info[i].tunnel_id = tmp_tunnel;
670 sa_info[i].src = *((long *)&netTestCfg.sa[i].src.ipv4[0]);
671 sa_info[i].dst = *((long *)&netTestCfg.sa[i].dst.ipv4[0]);
672 if (netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
673 {
674 trie_insert(p_trie_sa_rx,(char *)&tmp_spi,4, (void *) &sa_info[i]);
675 }
676 else
677 {
678 trie_insert(p_trie_sa_tx,(char *)&tmp_tunnel,4, (void *) &sa_info[i]);
679 }
680 }
681
682}
683NETCP_CFG_ROUTE_T routeInfo;
684PKTIO_HANDLE_T *pPktioHandle;
685
686int netTest_utilCreateDefaultFlow(NETAPI_T handle, int masterType)
687{
688 int err = 0;
689 PKTIO_CFG_T pktio_cfg;
690 Qmss_QueueHnd qHandle;
691
692 memset(&pktio_cfg, 0, sizeof (PKTIO_CFG_T));
693 memset(&routeInfo, 0, sizeof (NETCP_CFG_ROUTE_T));
694
695 pktio_cfg.flags1 = PKTIO_RX | PKTIO_GLOBAL;
696 pktio_cfg.flags2 = PKTIO_PKT;
697
698 if (nwal_CreateGenPurposeQueue (&qHandle) == nwal_OK)
699 {
700 pktio_cfg.qnum = qHandle ;
701 pktio_cfg.max_n = 8;
702 }
703 else
704 {
705 return -1;
706 }
707
708 if(masterType == NETAPI_PROC_MASTER)
709 {
710 pPktioHandle = netapi_pktioCreate(handle,
711 "procMaster",
712 (PKTIO_CB)recv_cb,
713 &pktio_cfg,
714 &err);
715 }
716 else if(masterType == NETAPI_SYS_MASTER)
717 {
718 pPktioHandle = netapi_pktioCreate(handle,
719 "sysMaster",
720 (PKTIO_CB)recv_cb,
721 &pktio_cfg,
722 &err);
723 }
724 else;
725
726 if (!pPktioHandle)
727 {
728 return -1;
729 }
730 routeInfo.p_dest_q = pPktioHandle;
731
732 routeInfo.p_flow = (NETCP_CFG_FLOW_T*)NETCP_DEFAULT_FLOW;
733 routeInfo.valid_params = NETCP_CFG_VALID_PARAM_ROUTE_TYPE;
734
735 return 0;
736}
737int netTest_utilCreateSecAssoc(void)
738{
739 nwal_RetValue nwalRetVal;
740 int err = 0;
741 int i;
742 nwalSaIpSecId_t nwalSaIpSecId;
743 uint32_t saId;
744 for (i=0; i < netTestCfg.num_sa;i++)
745 {
746 err = 0;
747 if(netTestCfg.sa[i].dir == NWAL_SA_DIR_INBOUND)
748 {
749 netTest_utilBuildSADB(i);
750 saId = i;
751 sa_info[i].rx_tunnel = netapi_secAddSA(
752 netapi_handle,
753 netTestCfg.ipsec_if_no, //iface #0
754 &netTestCfg.sa[i],
755 &netTestCfg.key_params[i],
756 netTestCfg.ipsec_mode_rx == IPSEC_MODE_RX_SIDEBAND ? NETAPI_SEC_SA_SIDEBAND: NETAPI_SEC_SA_INFLOW,
757 (NETCP_CFG_ROUTE_HANDLE_T)&routeInfo,
758 &(sa_info[i].rx_data_mode_handle),
759 &(sa_info[i].rx_inflow_mode_handle),
760 (void*) saId,
761 &err);
762 if (err)
763 {
764 exit(1);
765 }
766
767
768 if (netTestCfg.ipsec_mode_rx == IPSEC_MODE_RX_INFLOW)
769 {
770 //assume inner and outer ip is the same
771 rx_policy[i]= netapi_secAddRxPolicy( netapi_handle,
772 sa_info[i].rx_tunnel, //link to tunnel above
773 4, //ipv4
774 &netTestCfg.sa[i].src,
775 &netTestCfg.sa[i].dst,
776 NULL, // no qualifiers
777 (NETCP_CFG_ROUTE_HANDLE_T)&routeInfo,
778 NULL, //user_data
779 &err);
780 if (err)
781 {
782 exit(1);
783 }
784 }
785 else
786 {
787 rx_policy[i] = 0;
788 }
789 }
790 //tx SA security stuff
791 if(netTestCfg.sa[i].dir == NWAL_SA_DIR_OUTBOUND)
792 {
793 netTest_utilBuildSADB(i);
794 saId = i;
795 sa_info[i].tx_tunnel = netapi_secAddSA( netapi_handle,
796 0, //iface #0
797 &netTestCfg.sa[i],
798 &netTestCfg.key_params[i],
799 netTestCfg.ipsec_mode_tx == IPSEC_MODE_TX_SIDEBAND ? NETAPI_SEC_SA_SIDEBAND: NETAPI_SEC_SA_INFLOW,
800 NULL, //use default route
801 &(sa_info[i].tx_data_mode_handle),
802 &(sa_info[i].tx_inflow_mode_handle),
803 (void*)saId,
804 &err);
805 if (err) {exit(1);}
806 }
807 }
808 return err;
809}
810
811
812void netTest_utilDeleteSecAssoc()
813{
814 int err,i;
815 for (i=0; i < netTestCfg.num_sa;i++)
816 {
817 err = 0;
818 if(sa_info[i].dir == NWAL_SA_DIR_INBOUND)
819 {
820 if (rx_policy[i])
821 netapi_secDelRxPolicy(netapi_handle, rx_policy[i], &err);
822 //delete tunnels
823 netapi_secDelSA(netapi_handle, 0, sa_info[i].rx_tunnel, &err);
824 }
825
826 if(sa_info[i].dir == NWAL_SA_DIR_OUTBOUND)
827 {
828 netapi_secDelSA(netapi_handle, 0, sa_info[i].tx_tunnel, &err);
829 }
830 }
831}
diff --git a/ti/runtime/netapi/test/net_test_sa_utils.h b/ti/runtime/netapi/test/net_test_sa_utils.h
new file mode 100755
index 0000000..dffc7d2
--- /dev/null
+++ b/ti/runtime/netapi/test/net_test_sa_utils.h
@@ -0,0 +1,73 @@
1#ifndef __NET_TEST_SA_UTILS_H__
2#define __NET_TEST_SA_UTILS_H__
3
4//#include "net_test.h"
5//#include "net_test_utils.h"
6//#include "net_test_thread_utils.h"
7#include "ti/runtime/netapi/netapi.h"
8
9#define netTest_MAC_HEADER_LEN 14
10#define netTest_IP_HEADER_LEN 20
11#define netTest_UDP_HEADER_LEN 8
12#define netTest_ESP_HEADER_LEN 8
13#define netTest_AES_CBC_IV_LEN 16
14#define netTest_AES_CTR_IV_LEN 8
15#define netTest_3DES_CBC_IV_LEN 8
16#define netTest_AES_GCM_IV_LEN 8
17#define netTest_AES_CCM_IV_LEN 8
18#define netTest_AES_GMAC_IV_LEN 8
19#define netTest_NULL_IV_LEN 0
20#define netTest_ICV_LEN 12
21#define netTest_HMAC_SHA256_RFC_4868_ICV_LEN 16
22#define netTest_AES_GCM_CCM_ICV_LEN 16
23#define netTest_AES_GMAC_ICV_LEN 16
24
25#define netTest_IPSEC_AH_PKT 1
26#define netTest_IPSEC_ESP_PKT 2
27
28
29#define netTest_IPSEC_AH_FIXED_HDR_SIZE 12
30
31
32#define netTest_NULL_ESP_HEADER_LEN 0
33
34typedef struct {
35 nwalDmTxPayloadInfo_t tx_payload_info;
36 uint8_t inner_ip_offset;
37 NETCP_CFG_SA_T rx_tunnel;
38 void* rx_data_mode_handle;
39 void* rx_inflow_mode_handle;
40 NETCP_CFG_SA_T tx_tunnel;
41 void* tx_data_mode_handle;
42 void* tx_inflow_mode_handle;
43 uint8_t enc_key_length;
44 uint8_t auth_tag_size;
45 nwalTxPktInfo_t tx_pkt_info;
46 nwal_saEALG cipherMode;
47 nwal_saAALG authMode;
48 /*stuff for routing use case */
49 unsigned int src; //BE
50 unsigned int dst; //BE
51 unsigned int spi; //BE
52 unsigned int seq; //BE
53 int iv_len; //iv len (size of iv in pkt)
54 int bl; //block len (for padding calc)
55
56 /* Save NETCP CMD details during create time */
57 nwalTxDmPSCmdInfo_t rx_dmPSCmdInfo;
58 nwalTxDmPSCmdInfo_t tx_dmPSCmdInfo;
59 nwalTxPSCmdInfo_t tx_psCmdInfo;
60 uint32_t swInfo0;
61 uint32_t swInfo1;
62
63 uint32_t dir;
64 uint32_t tunnel_id;
65 nwalSecKeyParams_t* key_params;
66} netTestSA_t;
67
68void netTest_utilBuildSADB(int i);
69int netTest_utilCreateSecAssoc(void);
70
71void netTest_utilDeleteSecAssoc(void);
72
73#endif
diff --git a/ti/runtime/netapi/test/net_test_thread_utils.c b/ti/runtime/netapi/test/net_test_thread_utils.c
new file mode 100755
index 0000000..4b412c2
--- /dev/null
+++ b/ti/runtime/netapi/test/net_test_thread_utils.c
@@ -0,0 +1,109 @@
1/******************************************
2 * File: net_test_thread_utils.c
3 * Purpose: net_test application thread utilities
4 **************************************************************
5 * FILE: net_test_thread_utils.c
6 *
7 * DESCRIPTION: net_test application thread utilities
8 *
9 * REVISION HISTORY:
10 *
11 * Copyright (c) Texas Instruments Incorporated 2013
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 *
20 * Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the
23 * distribution.
24 *
25 * Neither the name of Texas Instruments Incorporated nor the names of
26 * its contributors may be used to endorse or promote products derived
27 * from this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40
41 *****************************************/
42
43#include "net_test.h"
44#include <signal.h>
45#include <pthread.h>
46#include "router.h"
47#include "net_test_thread_utils.h"
48extern netTestConfig_t netTestCfg;
49
50
51/* Global definitions */
52pthread_t *sp_threads;
53pthread_t *fp_threads;
54
55void netTest_utilCreateSpFpThreads(uint8_t num_sp_threads,NET_TEST_FUNC_PTR slow_path_thread,
56 uint8_t num_fp_threads, NET_TEST_FUNC_PTR fast_path_thread)
57{
58 int i;
59
60 sp_threads = malloc( sizeof( pthread_t ) * num_sp_threads );
61 if (sp_threads == NULL)
62 {
63 perror( "malloc" );
64 exit(1);
65 }
66
67 for (i = 0; i < num_sp_threads; i++)
68 {
69 if (pthread_create( &sp_threads[i], NULL, (void*)slow_path_thread,
70 (void *) i))
71 {
72 perror( "pthread_create" );
73 exit(1);
74 }
75 }
76 fp_threads = malloc( sizeof( pthread_t ) * num_fp_threads);
77 if (fp_threads == NULL)
78 {
79 perror( "malloc" );
80 exit(1);
81 }
82 for (i = 0; i < num_fp_threads; i++)
83 {
84 if (pthread_create( &fp_threads[i], NULL, (void*)fast_path_thread,
85 (void *) i))
86 {
87 perror( "pthread_create" );
88 exit(1);
89 }
90 }
91}
92void netTest_utilRemoveSpFpThreads(uint8_t num_sp_threads, uint8_t num_fp_threads)
93{
94 int i;
95 //wait for completion
96 netapi_Log("net_test loopback main task now pending on slow/fast path completion\n");
97 for (i = 0; i < num_sp_threads; i++)
98 {
99 pthread_join( sp_threads[i], NULL );
100 printf("Slow Path thread %d has exited\n", i);
101 }
102 for (i = 0; i < num_fp_threads; i++)
103 {
104 pthread_join( fp_threads[i], NULL );
105 printf("Fast Path thread %d has exited\n", i);
106 }
107 free( sp_threads);
108 free (fp_threads);
109}
diff --git a/ti/runtime/netapi/test/net_test_thread_utils.h b/ti/runtime/netapi/test/net_test_thread_utils.h
new file mode 100755
index 0000000..242591c
--- /dev/null
+++ b/ti/runtime/netapi/test/net_test_thread_utils.h
@@ -0,0 +1,21 @@
1#ifndef __NET_TEST_UTILS_H__
2#define __NET_TEST_UTILS_H__
3
4
5#include "net_test.h"
6
7
8typedef void (*NET_TEST_FUNC_PTR)(int thread_num);
9
10
11void netTest_utilCreateSpFpThreads(uint8_t num_sp_threads,
12 NET_TEST_FUNC_PTR slow_path_thread,
13 uint8_t num_fp_threads,
14 NET_TEST_FUNC_PTR fast_path_thread);
15
16
17void netTest_utilRemoveSpFpThreads(uint8_t num_sp_threads,
18 uint8_t num_fp_threads);
19
20
21#endif
diff --git a/ti/runtime/netapi/test/net_test_utils.c b/ti/runtime/netapi/test/net_test_utils.c
new file mode 100755
index 0000000..c9fe429
--- /dev/null
+++ b/ti/runtime/netapi/test/net_test_utils.c
@@ -0,0 +1,1401 @@
1/******************************************
2 * File: net_test_utils.c
3 * Purpose: net_test application general utilities
4 **************************************************************
5 * FILE: net_test_utils.c
6 *
7 * DESCRIPTION: net_test application general utilities
8 *
9 * REVISION HISTORY:
10 *
11 * Copyright (c) Texas Instruments Incorporated 2010-2011
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 *
20 * Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the
23 * distribution.
24 *
25 * Neither the name of Texas Instruments Incorporated nor the names of
26 * its contributors may be used to endorse or promote products derived
27 * from this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40
41 *****************************************/
42
43#include "net_test_utils.h"
44#include <signal.h>
45#include <pthread.h>
46#include "router.h"
47
48#include "ti/drv/nwal/test/fw_rm.h"
49#include <ti/drv/sa/salld.h>
50#include <ti/drv/pa/pa.h>
51
52extern NETAPI_T netapi_handle;
53extern netTestConfig_t netTestCfg;
54extern netTestConfig_t config;
55extern netTestSA_t sa_info[];
56extern NETAPI_SCHED_HANDLE_T * scheduler[];
57extern Pktlib_HeapHandle ourHeap;
58extern NETCP_CFG_IP_T ip_rule[];
59extern NETCP_CFG_MACIF_T mac[];
60
61
62
63netTestStats_T stats[NET_TEST_MAX_SP_THREAD + NET_TEST_MAX_FP_THREAD +1];
64paSysStats_t netcp_stats;
65
66
67
68static LastPktInfo_t lpInfo;
69int netTest_utilCheckHeader(netTestHead_T * p_head, PKTIO_METADATA_T * p_meta)
70{
71#ifdef netTest_MULTI_THREAD
72 int coreid=Osal_nwalGetProcId(); //who we are(thread local)
73#else
74 int coreid=0;
75#endif
76 if (NWAL_RX_FLAG1_META_DATA_VALID & p_meta->u.rx_meta->rxFlag1)
77 {
78 lpInfo.iface = ((unsigned int)p_meta->u.rx_meta->appId) &0xff; //last byte is interface num
79 lpInfo.ipcsum =(p_meta->u.rx_meta->rxFlag1 & NWAL_RX_FLAG1_IPV4_CHKSUM_VERIFY_MASK )== NWAL_RX_FLAG1_IPV4_CHKSUM_VERIFY_ACK ? 1 : 0;
80 lpInfo.l4csum = (p_meta->u.rx_meta->rxFlag1 & NWAL_RX_FLAG1_L4_CHKSUM_VERIFY_MASK )== ((NWAL_RX_FLAG1_L4_CHKSUM_VERIFY_ACK) << NWAL_RX_FLAG1_L4_CHKSUM_VERIFY_SHIFT) ? 1 : 0;
81 if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_IPSEC)
82 {
83 stats[coreid].sec_rx++;
84 }
85 if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_IPSEC_POLICY)
86 {
87 stats[coreid].secp_rx++;
88 }
89
90 if ((unsigned int)p_meta->u.rx_meta->appId & NETAPI_NETCP_MATCH_CLASS)
91 {
92 int c= ((unsigned int)p_meta->u.rx_meta->appId >>8)&0xffff;
93 if (c==0) stats[coreid].n_class0_rx +=1;
94 else if (c==1) stats[coreid].n_class1_rx +=1;
95 else if (c==2) stats[coreid].n_class2_rx +=1;
96 else netapi_Log("**NET_TEST RX -unknown class: %x\n", p_meta->u.rx_meta->appId);
97 }
98}
99
100 return 1;
101}
102
103
104static int scnt=0;
105int QUIT;
106void netTest_utilMySig(int x)
107{
108 QUIT=1;
109 scnt+=1;
110 printf(">net_test: recv'd signal %d cnt=%d\n",x,scnt);
111 if (scnt > 10)
112 {
113 printf(">net_test: WARNING EXITING WITH PROPER SHUTDOWN, LUTS LEFT ACTIVE\n");
114 exit(1);
115 }
116}
117unsigned long netTest_utilPeek(unsigned long * p)
118{
119 return *p;
120}
121void netTest_utilDumpDescr(unsigned long *p, int n)
122{
123 printf("--------dump of descriptor %d %x\n", n, (int) p);
124 printf("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
125 printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
126 printf("-----------------------------\n");
127}
128void netTest_utilDumpHeader(unsigned long *p, int n, int a, int r)
129{
130 printf("--------dump of header %d %x appID=%x flag1=%x\n", n, (int) p,a,r);
131 printf("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
132 printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
133 printf("> %x %x %x %x %x %x %x %x\n",p[16],p[17],p[18],p[19],p[20],p[21],p[22],p[23]);
134 printf("> %x %x %x %x %x %x %x %x\n",p[24],p[25],p[26],p[27],p[28],p[29],p[30],p[31]);
135 printf("-----------------------------\n");
136}
137
138void netTest_utilDumpBuffer
139(
140 unsigned long * buf,
141 uint32_t buf_length
142)
143{
144 uint8_t count = 0;
145 uint16_t dump_size;
146 uint8_t* tmp_buf;
147 uint8_t row_count;
148 static uint8_t first = 0;
149
150 //if(first > 2) return;
151
152 //first++;
153
154 dump_size = buf_length ;
155
156 tmp_buf = (uint8_t *)(buf);
157
158 printf("netapi *: - 8 bit word hex Length: %d Start \n",buf_length);
159 do
160 {
161 row_count = (dump_size - count);
162
163 if(row_count == 0)
164 {
165 break;
166 }
167
168 if(row_count > 4)
169 {
170 row_count = 4;
171 }
172
173 switch (row_count)
174 {
175 case 4:
176 {
177 printf("netapi *:%02d : %02x %02x %02x %02x \n",
178 count,tmp_buf[0],tmp_buf[1],tmp_buf[2],tmp_buf[3]);
179 break;
180 }
181 case 3:
182 {
183 printf("netapi *: %02d : %02x %02x %02x \n",
184 count,tmp_buf[0],tmp_buf[1],tmp_buf[2]);
185 break;
186 }
187
188 case 2:
189 {
190 printf("netapi *: %02d : %02x %02x \n",
191 count,tmp_buf[0],tmp_buf[1]);
192 break;
193 }
194
195 case 1:
196 {
197 printf("netapi *: %02d : %02x \n",
198 count,tmp_buf[0]);
199 break;
200 }
201
202 }
203
204 tmp_buf = tmp_buf + row_count;
205 count = count + row_count;
206
207 }while(count < dump_size);
208
209 printf("netapi *: - Byte hex Dump End \n");
210
211}
212long netTest_utilHtonl(long x)
213{
214 long temp = (x&0xff000000)>>24 | (x&0xff0000)>>8 | (x&0xff00)<<8 | (x&0xff)<<24 ;
215 return temp;
216}
217
218unsigned char netTest_utilHex2Dec(char *p_s)
219{
220 int val;
221 sscanf(p_s,"%x",&val);
222 return val&0xff;
223}
224
225/********************************************************************
226 * FUNCTION PURPOSE: Ones complement addition utility
227 ********************************************************************
228 ********************************************************************/
229uint16_t netTest_utilOnesComplementAdd (uint16_t v1, uint16_t v2)
230{
231 uint32_t result;
232
233 result = (uint32_t)v1 + (uint32_t)v2;
234 result = (result >> 16) + (result & 0xffff);
235 result = (result >> 16) + (result & 0xffff);
236
237 return ((uint16_t)result);
238}
239
240/********************************************************************
241 * FUNCTION PURPOSE: Ones complement checksum utility
242 ********************************************************************
243 ********************************************************************/
244 uint16_t netTest_utilOnesCompChkSum (uint8_t *p, uint32_t nwords)
245{
246 uint16_t chksum = 0;
247 uint16_t v;
248 uint32_t i;
249 uint32_t j;
250
251 for (i = j = 0; i < nwords; i++, j+=2) {
252 v = (p[j] << 8) | p[j+1];
253 chksum = netTest_utilOnesComplementAdd (chksum, v);
254 }
255 return (chksum);
256} /* utilOnesCompChkSum */
257
258/**************************************************************************************
259 * FUNCTION PURPOSE: Compute ipv4 psudo checksum
260 **************************************************************************************
261 * DESCRIPTION: Compute ipv4 psudo checksum
262 **************************************************************************************/
263uint16_t netTest_utilGetIPv4PsudoChkSum (uint8_t *data, uint16_t payloadLen)
264{
265 uint16_t psudo_chksum;
266
267 psudo_chksum = netTest_utilOnesCompChkSum (&data[12], 4);
268 psudo_chksum = netTest_utilOnesComplementAdd(psudo_chksum, (uint16_t) data[9]);
269 psudo_chksum = netTest_utilOnesComplementAdd(psudo_chksum, payloadLen);
270
271 return (psudo_chksum);
272
273} /* utilGetIpv4PsudoChkSum */
274
275#define CHECK_SET_PARAM(ARG1, ARG2) \
276 do { \
277 if(strcmp(key, ARG1) == 0) { \
278 if(d1)strncpy(ARG2,d1,netTest_CONFIG_STRING_LEN); \
279 continue; \
280 } \
281 } while(0)
282
283#define CHECK_SET_PARAM2(ARG1, ARG2, ARG3) \
284 do { \
285 if(strcmp(key, ARG1) == 0) { \
286 if(d1) strncpy(ARG2,d1,netTest_CONFIG_STRING_LEN); \
287 if(d2) strncpy(ARG3,d2,netTest_CONFIG_STRING_LEN); \
288 continue; \
289 } \
290 } while(0)
291
292#define CHECK_SET_PARAM_SA(ARG1, ARG2, ARG3, ARG4, ARG5, \
293 ARG6, ARG7, ARG8, ARG9, ARG10, \
294 ARG11, ARG12,ARG13, ARG14, ARG15, ARG16,ARG17, ARG18) \
295 do { \
296 if(strcmp(key, ARG1) == 0) { \
297 if(d1) strncpy(ARG2,d1,netTest_CONFIG_STRING_LEN); \
298 if(d2) strncpy(ARG3,d2,netTest_CONFIG_STRING_LEN); \
299 if(d3) strncpy(ARG4,d3,netTest_CONFIG_STRING_LEN); \
300 if(d4) strncpy(ARG5,d4,netTest_CONFIG_STRING_LEN); \
301 if(d5) strncpy(ARG6, d5,netTest_CONFIG_STRING_LEN); \
302 if(d6) strncpy(ARG7,d6,netTest_CONFIG_STRING_LEN); \
303 if(d7) strncpy(ARG8,d7,netTest_CONFIG_STRING_LEN); \
304 if(d8) strncpy(ARG9,d8,netTest_CONFIG_STRING_LEN); \
305 if(d9) strncpy(ARG10,d9,netTest_CONFIG_STRING_LEN); \
306 if(d10) strncpy(ARG11,d10,netTest_CONFIG_STRING_LEN); \
307 if(d11) strncpy(ARG12,d11,netTest_CONFIG_STRING_LEN); \
308 if(d12) strncpy(ARG13,d12,netTest_CONFIG_STRING_LEN); \
309 if(d13) strncpy(ARG14,d13,netTest_CONFIG_STRING_LEN); \
310 if(d14) strncpy(ARG15,d14,netTest_CONFIG_STRING_LEN); \
311 if(d15) strncpy(ARG16,d15,netTest_CONFIG_STRING_LEN); \
312 if(d16) strncpy(ARG17,d16,netTest_CONFIG_STRING_LEN); \
313 if(d17) strncpy(ARG18,d17,netTest_CONFIG_STRING_LEN); \
314 continue; \
315 } \
316 } while(0)
317
318void netTest_utilPrintIPSecStats(Sa_IpsecStats_t *p_saIpsecStats, nwal_saAALG auth, nwal_saEALG cipher)
319{
320#if 0
321 if(retVal != nwal_OK)
322 {
323 System_System_netapi_Log("CORE: %d Error getting IP Sec Stats: Ret Status: %d \n",
324 retVal);
325 return(nwal_FALSE);
326 }
327 if((p_saIpsecStats->pktEncHi) ||(p_saIpsecStats->pktEncLo))
328 {
329 Debug_netapi_Log("------------- IPSec TX (Encryption Channel) Stats BEGIN --\n");
330 }
331 else
332 {
333 netapi_Log("------------- IPSec RX (Decryption Channel) Stats BEGIN --\n");
334 }
335#endif
336 printf("\nAutentication mode: %d, Encryption Mode: %d\n", auth, cipher);
337 printf("IPSec replayOld:0x%x,replayDup:0x%x,authFail:0x%x \n",
338 p_saIpsecStats->replayOld,p_saIpsecStats->replayDup,p_saIpsecStats->authFail);
339 printf("IPSec txESN:0x%x,rxESN:0x%x,pktEncHi:0x%x,pktEncLo:0x%x,pktDecHi:0x%x,pktDecLo:0x%x \n",
340 p_saIpsecStats->txESN,p_saIpsecStats->rxESN,p_saIpsecStats->pktEncHi,
341 p_saIpsecStats->pktEncLo,p_saIpsecStats->pktDecHi,p_saIpsecStats->pktDecLo);
342}
343
344void netTest_utilPrintDataModeStats(Sa_DataModeStats_t *p_saDataModeStats, nwal_saAALG auth, nwal_saEALG cipher)
345{
346
347 printf("\nAutentication mode: %d, Encryption Mode: %d\n", auth, cipher);
348 printf(" Packets processedHi: 0x%x, Packets processed Lo:0x%x\n",
349 p_saDataModeStats->pktHi, p_saDataModeStats->pktLo);
350}
351
352/******************************************************
353 * stats callback
354 *******************************************************/
355void netTest_utilStatsCbMt(NETAPI_T h, paSysStats_t* pPaStats)
356{
357
358#ifdef netTest_MULTI_THREAD
359 int coreid=Osal_nwalGetProcId(); //who we are(thread local)
360 //int coreid = our_core;
361#else
362int coreid=0;
363#endif
364
365 stats[coreid].n_stats_cb +=1;
366 if(pPaStats) memcpy(&netcp_stats,pPaStats, sizeof(paSysStats_t));
367}
368void netTest_utilsStatsCb(NETAPI_T h, paSysStats_t* pPaStats)
369{
370 uint32_t numFreeDataPackets;
371 uint32_t numZeroBufferPackets;
372 uint32_t numPacketsinGarbage;
373 Pktlib_HeapStats pktLibHeapStats;
374 int i,j;
375 unsigned long long bcpp = 0;
376 unsigned long long bcpp_noc = 0;
377 unsigned long long bcpp_app = 0;
378 unsigned long long bcpp_tx = 0;
379 unsigned long long npL = 0;
380 unsigned long long cyclesL = 0;
381 unsigned long long ccyclesL = 0; //cache cycles
382 unsigned long long tmp_npL[TUNE_NETAPI_NUM_CORES];
383 unsigned long long tmp_cyclesL[TUNE_NETAPI_NUM_CORES];
384 unsigned long long tmp_ccyclesL[TUNE_NETAPI_NUM_CORES]; //cache cycles
385 NETAPI_SA_STATS_T netapi_sa_stats;
386
387 uint8_t num_threads = netTestCfg.num_fp_threads;
388 for (j= 0;j < num_threads;j++)
389 {
390 if (netTestCfg.fp_thread_num[j] == 0)
391 continue;
392 i = netTestCfg.fp_thread_num[j];
393 printf("Per THREAD Statistics for Thread %d\n", netTestCfg.fp_thread_num[j]);;
394 printf(">*****stats @ %lld (#cbs%d) \n", hplib_mUtilGetTimestamp(),stats[i].n_stats_cb);
395 printf(">itx=%d rx=%d tx=%d bad=%d slow=%d \n>rx_class0=%d rx_class1=%d rx_class2=%dsecRx=%d\t"
396 "secPRX=%d sb_rx=%d sb_tx=%d auth_ok=%d sec_tx=%d min_rx=%d min_tx=%d fragPkt=%d, exceptionPktOther=%d\n",
397 stats[i].itx, stats[i].rx, stats[i].tx, stats[i].n_bad, stats[i].n_new,
398 stats[i].n_class0_rx, stats[i].n_class1_rx, stats[i].n_class2_rx, stats[i].sec_rx,
399 stats[i].secp_rx, stats[i].sb_rx, stats[i].sb_tx, stats[i].n_auth_ok,
400 stats[i].sec_tx, stats[i].rx_min, stats[i].tx_min, stats[i].exceptionPktsFrag, stats[i].exceptionPktsOther);
401 printf(">if rx stats: %d %d %d\n",stats[i].if_rx[0],stats[i].if_rx[1],stats[i].if_rx[2]);
402 printf(">thread rx stats: %d \n",stats[i].core_rx);
403
404 if (stats[i].rx && stats[i].tx)
405 printf("decrypt time per packet(avg): %lu, encrypt time per packet(avg): %lu\n",
406 (unsigned long) stats[i].total_decrypt_time/stats[i].rx, (unsigned long) stats[i].total_encrypt_time/stats[i].tx);
407
408
409 netapi_schedGetStats(scheduler[i],&tmp_npL[i],&tmp_cyclesL[i],&tmp_ccyclesL[i]);
410 if (tmp_npL[i] && stats[i].rx)
411 {
412 bcpp = tmp_cyclesL[i]/tmp_npL[i];
413 bcpp_noc = bcpp;
414 bcpp_app = (stats[i].app_cycles)/stats[i].rx;
415 }
416 if (stats[i].tx)
417 {
418 bcpp_tx = (stats[i].send_cycles)/stats[i].tx;
419 }
420 else
421 {
422 bcpp_tx = 0L;
423 }
424 printf("> ++ busy cycles pp=%lld (%lld wo cache ops) (app+tx= %lld) (tx= %lld) ++\n",
425 bcpp,bcpp_noc,bcpp_app, bcpp_tx);
426 printf("\n");
427 }
428
429
430
431if(pPaStats)
432{
433 printf("C1 number of packets: %d\n", pPaStats->classify1.nPackets);
434 printf("C1 number IPv4 packets: %d\n", pPaStats->classify1.nIpv4Packets);
435 printf("C1 number IPv6 packets: %d\n", pPaStats->classify1.nIpv6Packets);
436 printf("C1 number Custom packets: %d\n", pPaStats->classify1.nCustomPackets);
437 printf("C1 number SRIO packets: %d\n", pPaStats->classify1.nSrioPackets);
438 printf("C1 number LLC/SNAP Fail packets: %d\n", pPaStats->classify1.nLlcSnapFail);
439 printf("C1 number table matched: %d\n", pPaStats->classify1.nTableMatch);
440 printf("C1 number failed table matched: %d\n", pPaStats->classify1.nNoTableMatch);
441 printf("C1 number IP Fragmented packets: %d\n", pPaStats->classify1.nIpFrag);
442 printf("C1 number IP Depth Overflow: %d\n", pPaStats->classify1.nIpDepthOverflow);
443 printf("C1 number VLAN Depth Overflow: %d\n", pPaStats->classify1.nVlanDepthOverflow);
444 printf("C1 number GRE Depth Overflow: %d\n", pPaStats->classify1.nGreDepthOverflow);
445 printf("C1 number MPLS Packets: %d\n", pPaStats->classify1.nMplsPackets);
446 printf ("C1 number of parse fail: %d\n",pPaStats->classify1.nParseFail);
447 printf("C1 number of Invalid IPv6 Opt: %d\n", pPaStats->classify1.nInvalidIPv6Opt);
448 printf("C1 number of TX IP Fragments: %d\n", pPaStats->classify1.nTxIpFrag);
449 printf ("C1 number of silent discard: %d\n",pPaStats->classify1.nSilentDiscard);
450 printf("C1 number of invalid control: %d\n", pPaStats->classify1.nInvalidControl);
451 printf ("C1 number of invalid states: %d\n",pPaStats->classify1.nInvalidState);
452 printf ("C1 number of system fails: %d\n",pPaStats->classify1.nSystemFail);
453 printf ("C2 number Packets : %d\n",pPaStats->classify2.nPackets);
454 printf ("C2 number udp : %d\n",pPaStats->classify2.nUdp);
455 printf ("C2 number tcp : %d\n",pPaStats->classify2.nTcp);
456 printf ("C2 number Custom : %d\n",pPaStats->classify2.nCustom);
457 printf ("C2 number silent drop : %d\n",pPaStats->classify2.nSilentDiscard);
458 printf ("C2 number invalid cntrl : %d\n\n",pPaStats->classify2.nInvalidControl);
459 printf ("C2 number Modify Stats Cmd Fail : %d\n\n",pPaStats->modify.nCommandFail);
460}
461Pktlib_getHeapStats(ourHeap, &pktLibHeapStats);
462printf("main heap stats> #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
463 pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
464printf(" > #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
465 pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
466 pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
467
468#if 0
469netapi_Log("pa2sa descriptor area dump\n");
470for(i=0;i<TUNE_NETAPI_CONFIG_MAX_PA_TO_SA_DESC;i++)
471{
472 extern long * pa2sa_descr_base;
473 long * tip= &pa2sa_descr_base[32*i];
474 netTest_utilDumpDescr(tip, i);
475}
476netapi_Log("sa2pa descriptor area dump\n");
477for(i=0;i<TUNE_NETAPI_CONFIG_MAX_SA_TO_PA_DESC;i++)
478{
479 extern long * sa2pa_descr_base;
480 long * tip= &sa2pa_descr_base[32*i];
481 netTest_utilDumpDescr(tip, i);
482}
483#endif
484 for (i = 0; i < netTestCfg.num_sa; i++)
485 {
486 /* Statistics for RX Tunnel */
487 memset(&netapi_sa_stats, 0, sizeof(netapi_sa_stats));
488 if (netTestCfg.sa[i].dir ==NWAL_SA_DIR_INBOUND )
489 {
490 netapi_getSaStats(netapi_handle, sa_info[i].rx_tunnel, &netapi_sa_stats);
491 if (netapi_sa_stats.validParams & NETAPI_IPSEC_STAT_VALID)
492 {
493 netTest_utilPrintIPSecStats(&(netapi_sa_stats.saIpsecStats),
494 netTestCfg.sa[i].authMode,
495 netTestCfg.sa[i].cipherMode);
496 }
497 if (netapi_sa_stats.validParams & NETAPI_SIDEBAND_DATA_MODE_STAT_VALID)
498 {
499 netTest_utilPrintDataModeStats(&(netapi_sa_stats.dataModeStats),
500 netTestCfg.sa[i].authMode,
501 netTestCfg.sa[i].cipherMode);
502 }
503 }
504 else if (netTestCfg.sa[i].dir ==NWAL_SA_DIR_OUTBOUND)
505 {
506 netapi_getSaStats(netapi_handle, sa_info[i].tx_tunnel, &netapi_sa_stats);
507 if (netapi_sa_stats.validParams & NETAPI_IPSEC_STAT_VALID)
508 {
509 netTest_utilPrintIPSecStats(&(netapi_sa_stats.saIpsecStats),
510 netTestCfg.sa[i].authMode,
511 netTestCfg.sa[i].cipherMode);
512 }
513 if (netapi_sa_stats.validParams & NETAPI_SIDEBAND_DATA_MODE_STAT_VALID)
514 {
515 netTest_utilPrintDataModeStats(&(netapi_sa_stats.dataModeStats),
516 netTestCfg.sa[i].authMode,
517 netTestCfg.sa[i].cipherMode);
518 }
519 }
520 else
521 netapi_Log("netTest_utilsStatsCb: invalid SA direction\n");
522 }
523 netapi_dump_internal_heap_stats();
524}
525
526
527
528
529void parse_dsp_mac(char * p_mac_str)
530{
531 if (strlen(&p_mac_str[0]))
532 {
533 sscanf(p_mac_str,"mac%d",&netTestCfg.dsp_mac);
534 }
535}
536
537void parse_dsp_ip(char * p_ip_str)
538{
539 if (strlen(&p_ip_str[0]))
540 {
541 sscanf(p_ip_str,"ip%d",&netTestCfg.dsp_ip);
542 }
543}
544
545void netTest_utilParseOneKey(char *p_key_str, unsigned char *p_key)
546{
547 int index = 0;
548 int i;
549 if (strlen(&p_key_str[0]))
550 {
551 char * pch = strtok (&p_key_str[0],",");
552
553 while (pch != NULL)
554 {
555 p_key[index] = netTest_utilHex2Dec(pch);
556 index++;
557 pch = strtok (NULL,",");
558 }
559 }
560}
561
562void netTest_utilParseOneIP(char * p_ip_addr_str, unsigned char * p_ip)
563{
564 int index = 0;
565 int i;
566 if (strlen(&p_ip_addr_str[0]))
567 {
568 char * pch = strtok (&p_ip_addr_str[0],".");
569
570 while (pch != NULL)
571 {
572 p_ip[index] = atoi(pch);
573 index++;
574 pch = strtok (NULL,".");
575 }
576 }
577}
578
579void netTest_utilParseOneMac(char * p_mac_str, unsigned char *p_mac)
580{
581 int index = 0;
582 int i;
583 if (strlen(&p_mac_str[0]))
584 {
585 char *pch = strtok (&(p_mac_str[0]),"-");
586
587 while (pch != NULL)
588 {
589 p_mac[index] = netTest_utilHex2Dec(pch);
590 index++;
591 pch = strtok (NULL,"-");
592 }
593 }
594}
595
596void netTest_utilParseMac(netTestConfigFile_t *pConfig)
597{
598 int i;
599 int port = 0;
600 for(i=0;i<NET_TEST_MAX_MAC;i++)
601 {
602 if (strlen(&pConfig->mac[i][0]))
603 {
604 netTestCfg.num_macs++;
605 netTest_utilParseOneMac(&pConfig->mac[i][0],&netTestCfg.mac[i][0]);
606 sscanf(&pConfig->switch_port[i][0],"swp%d",&netTestCfg.switch_port[i]);
607 }
608 }
609 netapi_Log("netTest_utilParseMac: number of mac address %d\n", netTestCfg.num_macs);
610
611}
612void netTest_utilParseIP(netTestConfigFile_t *pConfig)
613{
614 int i;
615
616 for(i=0;i<NET_TEST_MAX_IP;i++)
617 {
618 if (strlen(&pConfig->ip[i][0]))
619 {
620 netTestCfg.num_ips++;
621 netTest_utilParseOneIP(&pConfig->ip[i][0],&netTestCfg.ip[i].ipv4[0]);
622 sscanf(&pConfig->attach_iface[i][0],"mac%d",&netTestCfg.attach_iface[i]);
623 }
624 }
625 netapi_Log("netTest_utilParseIP: number of ip address %d\n", netTestCfg.num_ips);
626}
627void netTest_utilParseIpsecMode(netTestConfigFile_t *pConfig)
628{
629
630 if (strlen(&pConfig->ipsec_mode_rx[0]))
631 {
632 if (strcmp(pConfig->ipsec_mode_rx, "SIDEBAND") == 0)
633 {
634 netTestCfg.ipsec_mode_rx = IPSEC_MODE_RX_SIDEBAND;
635 }
636 else if (strcmp(pConfig->ipsec_mode_rx, "INFLOW") == 0)
637 {
638 netTestCfg.ipsec_mode_rx = IPSEC_MODE_RX_INFLOW;
639 }
640 else
641 {
642 netapi_Log("netTest_utilParseIpsecMode(), invalid RX ipsec mode in config file \n");
643 }
644 }
645
646 if (strlen(&pConfig->ipsec_mode_tx[0]))
647 {
648 if (strcmp(pConfig->ipsec_mode_tx, "SIDEBAND") == 0)
649 {
650 netTestCfg.ipsec_mode_tx = IPSEC_MODE_TX_SIDEBAND;
651 }
652 else if (strcmp(pConfig->ipsec_mode_tx, "INFLOW") == 0)
653 {
654 netTestCfg.ipsec_mode_tx = IPSEC_MODE_TX_INFLOW;
655 }
656 else
657 {
658 netapi_Log("netTest_utilParseIpsecMode(), invalid TX ipsec mode in config file \n");
659 }
660 }
661
662}
663
664void netTest_utilParseAuthMode(char *auth_mode_str, nwal_saAALG *auth_mode)
665{
666 if (strlen(auth_mode_str))
667 {
668 netapi_Log("strlen of auth_mode_str is %d\n", strlen(auth_mode_str));
669
670 if (strcmp(auth_mode_str, "NULL") == 0)
671 {
672 *auth_mode= NWAL_SA_AALG_NULL;
673 }
674 else if (strcmp(auth_mode_str, "HMAC_MD5") == 0)
675 {
676 *auth_mode= NWAL_SA_AALG_HMAC_MD5;
677 }
678 else if (strcmp(auth_mode_str, "HMAC_SHA1") == 0)
679 {
680 *auth_mode= NWAL_SA_AALG_HMAC_SHA1;
681 }
682 else if (strcmp(auth_mode_str, "HMAC_SHA2_224") == 0)
683 {
684 *auth_mode= NWAL_SA_AALG_HMAC_SHA2_224;
685 }
686 else if (strcmp(auth_mode_str, "HMAC_SHA2_256") == 0)
687 {
688 *auth_mode= NWAL_SA_AALG_HMAC_SHA2_256;
689 }
690 else if (strcmp(auth_mode_str, "GMAC") == 0)
691 {
692 *auth_mode= NWAL_SA_AALG_GMAC;
693 }
694 else if (strcmp(auth_mode_str, "AES_XCBC") == 0)
695 {
696 *auth_mode= NWAL_SA_AALG_AES_XCBC;
697 }
698 else
699 {
700 netapi_Log("netTest_utilParseAuthMode: invalid auth mode specified\n");
701 }
702 }
703}
704
705void netTest_utilParseEncryptMode(char *ency_mode_str, nwal_saEALG*encr_mode)
706{
707 if (strlen(ency_mode_str))
708 {
709 if (strcmp(ency_mode_str, "NULL") == 0)
710 {
711 *encr_mode= NWAL_SA_EALG_NULL;
712 }
713 else if (strcmp(ency_mode_str, "AES_CTR") == 0)
714 {
715 *encr_mode= NWAL_SA_EALG_AES_CTR;
716 }
717 else if (strcmp(ency_mode_str, "AES_CBC") == 0)
718 {
719 *encr_mode= NWAL_SA_EALG_AES_CBC;
720 }
721 else if (strcmp(ency_mode_str, "3DES_CBC") == 0)
722 {
723 *encr_mode= NWAL_SA_EALG_3DES_CBC;
724 }
725 else if (strcmp(ency_mode_str, "AES_CCM") == 0)
726 {
727 *encr_mode= NWAL_SA_EALG_AES_CCM;
728 }
729 else if (strcmp(ency_mode_str, "AES_GCM") == 0)
730 {
731 *encr_mode= NWAL_SA_EALG_AES_GCM;
732 }
733 else if (strcmp(ency_mode_str, "AES_XCBC") == 0)
734 {
735 *encr_mode= NWAL_SA_AALG_AES_XCBC;
736 }
737 else
738 {
739 netapi_Log("netTest_utilParseEncryptMode: invalid auth mode specified\n");
740 }
741 }
742}
743
744void netTest_utilParseProto(char *proto_str, nwal_IpSecProto *proto)
745{
746 if (strlen(proto_str))
747 {
748 if (strcmp(proto_str, "ESP") == 0)
749 {
750 *proto= nwal_IpSecProtoESP;
751 netapi_Log("netTest_utilParseProto(): setting proto to ESP\n");
752 }
753 else if (strcmp(proto_str, "AH") == 0)
754 {
755 *proto = nwal_IpSecProtoAH;
756 netapi_Log("netTest_utilParseProto(): setting proto to AH\n");
757 }
758 else
759 {
760 netapi_Log("netTest_utilParseProto(), invalid RX ipsec mode in config file \n");
761 }
762 }
763}
764
765
766
767void netTest_utilParseSaMode(char *mode_str, nwal_saMode *mode)
768{
769 if (strlen(mode_str))
770 {
771 if (strcmp(mode_str, "TUNNEL") == 0)
772 {
773 *mode= nwal_SA_MODE_TUNNEL;
774 }
775 else if (strcmp(mode_str, "TRANSPORT") == 0)
776 {
777 *mode = nwal_SA_MODE_TRANSPORT;
778 }
779 else
780 {
781 netapi_Log("netTest_utilParseSaMode(), invalid RX ipsec mode in config file \n");
782 }
783 }
784}
785
786void netTest_utilParseIPType(char *ip_type_str, nwal_IpType *ipType)
787{
788 if (strlen(ip_type_str))
789 {
790 if (strcmp(ip_type_str, "IPV4") == 0)
791 {
792 *ipType= nwal_IPV4;
793 }
794 else if (strcmp(ip_type_str, "IPV6") == 0)
795 {
796 *ipType = nwal_IPV6;
797 }
798 else
799 {
800 netapi_Log("netTest_utilParseIPType(), invalid RX ipsec mode in config file \n");
801 }
802 }
803}
804
805
806void parse_simple_param_u8(char* input_str, uint8_t *val)
807{
808 if (strlen(input_str))
809 {
810 *val = (uint8_t)strtol(input_str, NULL, 0);
811 }
812}
813
814void parse_simple_param_u16(char* input_str, uint16_t *val)
815{
816 if (strlen(input_str))
817 {
818 *val = (uint16_t)strtol(input_str, NULL, 0);
819 }
820}
821
822void parse_simple_param_u32(char* input_str, uint32_t *val)
823{
824 if (strlen(input_str))
825 {
826 *val = (uint32_t)strtol(input_str, NULL, 0);
827 }
828}
829
830void netTest_utilParseSADir(char* dir_str, nwal_SaDir *dir)
831{
832 if (strlen(dir_str))
833 {
834 if (strcmp(dir_str, "INBOUND") == 0)
835 {
836 *dir= NWAL_SA_DIR_INBOUND;
837 }
838 else if (strcmp(dir_str, "OUTBOUND") == 0)
839 {
840 *dir = NWAL_SA_DIR_OUTBOUND;
841 }
842 else
843 netapi_Log("netTest_utilParseSADir: invalid direction\n");
844 }
845}
846void netTest_utilParseThreadConfig(char * p_thread_str, uint8_t* start, uint8_t* end)
847{
848 int index = 0;
849 int i;
850
851 if (strlen(p_thread_str))
852 {
853 char *pch = strtok (&(p_thread_str[0]),"-");
854 *start = atoi(pch);
855 pch = strtok (NULL,"-");
856 *end = atoi(pch);
857 }
858}
859
860void netTest_utilParseThreadParams(netTestConfigFile_t *pConfig)
861{
862 int i;
863 for(i=0;i<NET_TEST_MAX_FP_THREAD;i++)
864 {
865 if (strlen(&pConfig->fp[i][0]))
866 {
867 netTestCfg.num_fp_threads++;
868 netTest_utilParseThreadConfig(&pConfig->fp[i][0],
869 (uint8_t*)&netTestCfg.fp_proc_start[i],
870 (uint8_t*)&netTestCfg.fp_proc_end[i]);
871 }
872 if (strlen(&pConfig->fp_thread_num[i][0]))
873 {
874 netTestCfg.fp_thread_num[i] = atoi((char*)(&pConfig->fp_thread_num[i]));
875 }
876 }
877
878 for(i=0;i<NET_TEST_MAX_SP_THREAD;i++)
879 {
880 if (strlen(&pConfig->sp[i][0]))
881 {
882 netTestCfg.num_sp_threads++;
883 netTest_utilParseThreadConfig(&pConfig->sp[i][0],
884 (uint8_t*)&netTestCfg.sp_proc_start[i],
885 (uint8_t*)&netTestCfg.sp_proc_end[i]);
886 }
887 if (strlen(&pConfig->sp_thread_num[i][0]))
888 {
889 netTestCfg.sp_thread_num[i] = atoi((char*)(&pConfig->sp_thread_num[i]));
890 }
891 }
892}
893void netTest_utilParseSA(netTestConfigFile_t *pConfig)
894{
895 int i;
896 for(i=0;i<MAX_SEC_INDEX;i++)
897 {
898 if (strlen((char*)&pConfig->sa_config[i][0].dir))
899 {
900 netTest_utilParseSADir((char*) &pConfig->sa_config[i][0].dir, &netTestCfg.sa[i].dir);
901 parse_simple_param_u32((char*)&pConfig->sa_config[i][0].spi, &netTestCfg.sa[i].spi);
902 netTest_utilParseProto((char*)&pConfig->sa_config[i][0].proto, &netTestCfg.sa[i].proto);
903 netTest_utilParseSaMode((char*)&pConfig->sa_config[i][0].saMode, &netTestCfg.sa[i].saMode);
904 netTest_utilParseIPType((char*)&pConfig->sa_config[i][0].ipType, &netTestCfg.sa[i].ipType);
905 netTest_utilParseOneIP((char*)&pConfig->sa_config[i][0].src, (unsigned char *)&netTestCfg.sa[i].src);
906 netTest_utilParseOneIP((char*)&pConfig->sa_config[i][0].dst, (unsigned char *)&netTestCfg.sa[i].dst);
907 parse_simple_param_u32((char*)&pConfig->sa_config[i][0].replayWindow, &netTestCfg.sa[i].replayWindow);
908 netTest_utilParseAuthMode((char*)&pConfig->sa_config[i][0].authMode, &netTestCfg.sa[i].authMode);
909 netTest_utilParseEncryptMode((char*)&pConfig->sa_config[i][0].cipherMode, &netTestCfg.sa[i].cipherMode);
910 parse_simple_param_u32((char*)&pConfig->sa_config[i][0].esnLo, &netTestCfg.sa[i].esnLo);
911 parse_simple_param_u32((char*)&pConfig->sa_config[i][0].esnHi, &netTestCfg.sa[i].esnHi);
912 parse_simple_param_u16((char*)&pConfig->sa_config[i][0].encKeySize, &netTestCfg.key_params[i].encKeySize);
913 parse_simple_param_u16((char*)&pConfig->sa_config[i][0].macKeySize, &netTestCfg.key_params[i].macKeySize);
914
915
916 netTest_utilParseOneKey((char*) &pConfig->sa_config[i][0].encr_key, &netTestCfg.encr_key[i][0]);
917 netTestCfg.key_params[i].pEncKey = (uint8_t*)&netTestCfg.encr_key[i][0];
918
919 netTest_utilParseOneKey((char*)&pConfig->sa_config[i][0].auth_key, &netTestCfg.auth_key[i][0]);
920 netTestCfg.key_params[i].pAuthKey= (uint8_t*)&netTestCfg.auth_key[i][0];
921
922
923 parse_simple_param_u32((char*)&pConfig->sa_config[i][0].tunnel_id, &netTestCfg.tunnel_id[i]);
924
925 netTestCfg.num_sa++;
926 }
927 }
928}
929void netTest_utilParseRoutes(netTestConfigFile_t *pConfig, OUR_ROUTE_T *routes, Trie ** our_router)
930{
931 int i;
932 int said=0;
933 for(i=0;i<MAX_ROUTES;i++)
934 {
935 int port;
936 if (pConfig->routes[i][0])
937 {
938 port=atoi(&pConfig->ports[i][0]);
939 if((port<1)||(port>2)) continue; //bad port #: only 1 or 2 valid
940
941 if(strncmp(&pConfig->routes[i][0],"MAC",3)==0)
942 {
943 routes[i].out_port = port;
944 netTest_utilParseOneMac(&pConfig->routes[i][3],&routes[i].out_mac[0]);
945 //memcpy(&routes[i].out_mac[6], ((port==1) ?&config.mac0[0]: &config.mac1[0] ),6);
946 memcpy(&routes[i].out_mac[6], ((port==1) ?&netTestCfg.mac[0][0]: &netTestCfg.mac[1][0] ),6);
947 routes[i].out_mac[12]=0x08;
948 routes[i].out_mac[13]=0x00;
949 routes[i].sec_ptr=NULL;
950 }
951 else if (strncmp(&pConfig->routes[i][0],"SA",2)==0)
952 {
953 said=atoi(&pConfig->routes[i][2]) ;
954 routes[i].sec_ptr=&sa_info[said];
955 }
956 }
957 }
958 *our_router = route_init();
959 for (i=0;i<MAX_ROUTES;i++)
960 {
961 unsigned long ip_be;
962 int route_index;
963 if (pConfig->dst_ips[i][0])
964 {
965 netTest_utilParseOneIP(&pConfig->dst_ips[i][0],(unsigned char *)&ip_be);
966 sscanf(&pConfig->paths[i][0],"route%d",&route_index);
967 route_add(*our_router,&ip_be,(void*)&routes[route_index]);
968 }
969 }
970}
971
972void netTest_utilProcessConfigFile(FILE * fpr, netTestConfigFile_t *pConfig)
973{
974 char line[MAX_LINE_LENGTH + 1];
975 int i;
976 static int sa_count = 0;
977
978 char *key, *ep;
979 char * d1, *d2, *d3, *d4;
980 char * d5, *d6, *d7, *d8;
981 char * d9, *d10, *d11, *d12;
982 char * d13, *d14, *d15, *d16, *d17;
983 char tokens[] = " :=;\n";
984 char temp_str[TEMP_STR_LEN];
985 memset(line, 0, MAX_LINE_LENGTH + 1);
986 memset(pConfig, 0, sizeof(netTestConfigFile_t));
987 while (fgets(line, MAX_LINE_LENGTH + 1, fpr))
988 {
989 if(line[0]=='#')
990 continue; //skip comment
991 key = (char *)strtok(line, tokens);
992
993 d1 = (char *)strtok(NULL, tokens);
994 if (!key)
995 continue;
996 if (!d1)
997 continue;
998
999 if(strlen(d1) == 0)
1000 {
1001 continue;
1002 }
1003
1004
1005 d2 = (char *)strtok(NULL, tokens);
1006 d3 = (char *)strtok(NULL, tokens);
1007 d4 = (char *)strtok(NULL, tokens);
1008 d5 = (char *)strtok(NULL, tokens);
1009 d6 = (char *)strtok(NULL, tokens);
1010 d7 = (char *)strtok(NULL, tokens);
1011 d8 = (char *)strtok(NULL, tokens);
1012 d9 = (char *)strtok(NULL, tokens);
1013 d10 = (char *)strtok(NULL, tokens);
1014 d11 = (char *)strtok(NULL, tokens);
1015 d12 = (char *)strtok(NULL, tokens);
1016 d13 = (char *)strtok(NULL, tokens);
1017 d14 = (char *)strtok(NULL, tokens);
1018 d15 = (char *)strtok(NULL, tokens);
1019 d16 = (char *)strtok(NULL, tokens);
1020 d17 = (char *)strtok(NULL, tokens);
1021
1022 CHECK_SET_PARAM(netTest_INIT_CONFIG_IPSEC_MODE_RX,&(pConfig->ipsec_mode_rx[0]));
1023 CHECK_SET_PARAM(netTest_INIT_CONFIG_IPSEC_MODE_TX,&(pConfig->ipsec_mode_tx[0]));
1024 CHECK_SET_PARAM(netTest_INIT_CONFIG_IPSEC_IF_NO,&(pConfig->ipsec_if_no[0]));
1025 CHECK_SET_PARAM(netTest_INIT_CONFIG_DSP_MAC,&(pConfig->dsp_mac[0]));
1026 CHECK_SET_PARAM(netTest_INIT_CONFIG_DSP_IP,&(pConfig->dsp_ip[0]));
1027 CHECK_SET_PARAM(netTest_INIT_CONFIG_STATIC_LOOPBACK_PORT,&(pConfig->dest_udp_port_config[0]));
1028
1029
1030 for(i=0;i<MAX_SEC_INDEX;i++)
1031 {
1032 snprintf(temp_str, TEMP_STR_LEN-1, "sa%d",i);
1033 CHECK_SET_PARAM_SA(temp_str,
1034 (char*)&pConfig->sa_config[i][0].dir,
1035 (char*)&pConfig->sa_config[i][0].spi,
1036 (char*)&pConfig->sa_config[i][0].proto,
1037 (char*)&pConfig->sa_config[i][0].saMode,
1038 (char*)&pConfig->sa_config[i][0].ipType,
1039 (char*)&pConfig->sa_config[i][0].src,
1040 (char*)&pConfig->sa_config[i][0].dst,
1041 (char*)&pConfig->sa_config[i][0].replayWindow,
1042 (char*)&pConfig->sa_config[i][0].authMode,
1043 (char*)&pConfig->sa_config[i][0].cipherMode,
1044 (char*)&pConfig->sa_config[i][0].esnLo,
1045 (char*)&pConfig->sa_config[i][0].esnHi,
1046 (char*)&pConfig->sa_config[i][0].encKeySize,
1047 (char*)&pConfig->sa_config[i][0].macKeySize,
1048 (char*)&pConfig->sa_config[i][0].encr_key,
1049 (char*)&pConfig->sa_config[i][0].auth_key,
1050 (char*)&pConfig->sa_config[i][0].tunnel_id);
1051 }
1052
1053 for(i=0;i<MAX_ROUTES;i++)
1054 {
1055 snprintf(temp_str, TEMP_STR_LEN-1, "route%d",i);
1056 CHECK_SET_PARAM2(temp_str,&pConfig->routes[i][0],&pConfig->ports[i][0] );
1057 }
1058
1059 for(i=0;i<MAX_ROUTES;i++)
1060 {
1061 snprintf(temp_str, TEMP_STR_LEN-1, "dstip%d",i);
1062 CHECK_SET_PARAM2(temp_str,&pConfig->dst_ips[i][0],&pConfig->paths[i][0] );
1063 }
1064 for(i=0;i<NET_TEST_MAX_MAC;i++)
1065 {
1066 snprintf(temp_str, TEMP_STR_LEN-1, "mac%d",i);
1067 CHECK_SET_PARAM2(temp_str,&pConfig->mac[i][0],&pConfig->switch_port[i][0] );
1068 }
1069 for(i=0;i<NET_TEST_MAX_IP;i++)
1070 {
1071 snprintf(temp_str, TEMP_STR_LEN-1, "ip%d",i);
1072 CHECK_SET_PARAM2(temp_str,&pConfig->ip[i][0], &pConfig->attach_iface[i][0]);
1073 }
1074 for(i=0;i<NET_TEST_MAX_FP_THREAD;i++)
1075 {
1076 snprintf(temp_str, TEMP_STR_LEN-1, "fp%d",i);
1077 CHECK_SET_PARAM2(temp_str, &pConfig->fp_thread_num[i][0],&pConfig->fp[i][0]);
1078 }
1079 for(i=0;i<NET_TEST_MAX_SP_THREAD;i++)
1080 {
1081 snprintf(temp_str, TEMP_STR_LEN-1, "sp%d",i);
1082 CHECK_SET_PARAM2(temp_str, &pConfig->sp_thread_num[i][0],&pConfig->sp[i][0]);
1083 }
1084 }
1085}
1086
1087//******************************************************
1088//use scheduling housekeeping callback to generate pkts
1089//******************************************************
1090static int done_burst=0;
1091void house(NETAPI_SCHED_HANDLE_T * s)
1092{
1093 Ti_Pkt * tip;
1094 unsigned int len;
1095 nwalTxPktInfo_t meta_tx = {0};
1096 PKTIO_METADATA_T meta = {PKTIO_META_TX,{0},0};
1097 int err;
1098 static int house_pkts_gened=0;
1099 int p;
1100 unsigned char * pIpHdr,* pData;
1101 unsigned int vv1,vv2,vv3;
1102 unsigned int sum_vv1=0;
1103 unsigned int sum_vv2=0;
1104 unsigned int sum_vv3=0;
1105 unsigned int sum_vv4=0;
1106 unsigned int sum_vv5=0;
1107
1108 unsigned int nwal_flow_vv1,nwal_flow_vv2;
1109 unsigned int nwal_sum_vv1=0;
1110 unsigned int nwal_sum_vv2=0;
1111 unsigned int nwal_sum_vv3=0;
1112 unsigned int nwal_sum_vv4=0;
1113 unsigned int nwal_sum_vv5=0;
1114 unsigned int nwal_sum_vv6=0;
1115
1116 unsigned int nwal_sum_flow_vv1=0;
1117 unsigned int nwal_sum_flow_vv2=0;
1118 unsigned long long cache_op_b1;
1119 unsigned long long cache_op_b2;
1120 unsigned long long n_c_ops;
1121 static int first =0;
1122 Cppi_HostDesc* pPktDesc;
1123 NETAPI_SCHED_SHUTDOWN_T sched_shutdown;
1124
1125 uint32_t coreid = 0; //who we are
1126#ifdef netTest_MULTI_THREAD
1127 NETAPI_T nh= netapi_schedGetHandle(s);
1128 coreid=(uint32_t) netapi_getCookie(nh);
1129
1130 if (QUIT)
1131 {
1132 sched_shutdown.shutdown_type = NETAPI_SCHED_SHUTDOWN_NOW;
1133 netapi_schedClose(s,&sched_shutdown,&err);
1134 return;
1135 }
1136
1137
1138 /* only slow path threads get netcp stats */
1139 if (coreid & NET_TEST_SP_THREAD_MASK)
1140 {
1141 netapi_netcpCfgReqStats(nh, netTest_utilStatsCbMt, 0,&err);
1142 }
1143
1144 coreid = NET_TEST_THREAD_NUM_MASK & coreid;
1145#else
1146 coreid = NET_TEST_THREAD_NUM_MASK & coreid;
1147 if(done_burst)
1148 {
1149 house_pkts_gened+=TX_BURST;
1150 netapi_Log("net_test> request stats at n=%d \n",house_pkts_gened);
1151 netapi_netcpCfgReqStats(netapi_handle, netTest_utilsStatsCb, 0,&err);
1152 if (err!=0) {netapi_Log("stats req failed\n");}
1153 if (house_pkts_gened >= np2process+ 100)
1154 {
1155 sched_shutdown.shutdown_type = NETAPI_SCHED_SHUTDOWN_NOW;
1156 netapi_schedClose(s,&sched_shutdown,&err);
1157 }
1158 return;
1159 }
1160 done_burst=1;
1161 Osal_cache_op_measure_reset();
1162 memset(&meta_tx,0,sizeof(meta_tx));
1163 for(p=0;p<TX_BURST;p++) {
1164 //reguest stats
1165 if ((house_pkts_gened>0) && (! (house_pkts_gened%1000)) )
1166 {
1167 netapi_Log("net_test> request stats at n=%d \n",house_pkts_gened);
1168 netapi_netcpCfgReqStats(netapi_handle, netTest_utilsStatsCb, 0,&err);
1169 if (err!=0) {netapi_Log("stats req failed\n");}
1170 }
1171
1172
1173 if (house_pkts_gened >= np2process+ 100)
1174 {
1175 //shutdown
1176 sched_shutdown.shutdown_type = NETAPI_SCHED_SHUTDOWN_NOW;
1177 netapi_schedClose(s,&sched_shutdown,&err);
1178 continue;
1179 }
1180
1181 else if (house_pkts_gened >= np2process) { house_pkts_gened+=1; continue;}
1182
1183 /* manufacture a pkt to transmit */
1184 tip = get_pkt(house_pkts_gened, &len, ourHeap, netTest_PKT_LEN,&testPkt[0] , TEST_netTest_PKT_LEN);
1185 if(!tip) { house_pkts_gened +=1; continue; }
1186
1187
1188 /* set the pkt length */
1189 vv1 = hplib_mUtilGetPmuCCNT();
1190 Pktlib_setPacketLen(tip, len);
1191
1192 /* set up meta data */
1193 meta.sa_handle=nwal_HANDLE_INVALID;
1194 /* #define BENCH_UDP_SEND */
1195#ifdef BEND_UDP_SEND
1196 meta_tx.txFlag1 = (NWAL_TX_FLAG1_DO_IPV4_CHKSUM | NWAL_TX_FLAG1_DO_UDP_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID);
1197 meta_tx.startOffset = 0;
1198 /* GONE in V2 meta_tx.pktLen = len; */
1199 meta_tx.ipOffBytes = TEST_PKT_IP_OFFSET_BYTES;
1200 meta_tx.l4OffBytes = TEST_PKT_UDP_OFFSET_BYTES;
1201 meta_tx.l4HdrLen = TEST_PKT_UDP_HDR_LEN;
1202 //GONE in V2 meta_tx.ploadOffBytes = TEST_PKT_PLOAD_OFFSET_BYTES;
1203 meta_tx.ploadLen = TEST_PAYLOAD_LEN;
1204
1205 Pktlib_getDataBuffer(tip,&pData,&len);
1206 if(house_pkts_gened &0x1)
1207 {
1208 memcpy(&pData[6],&netTestCfg.mac[1][0] ,6);
1209 }
1210 pIpHdr = pData + meta_tx.ipOffBytes;
1211 meta_tx.pseudoHdrChecksum =
1212 netTest_utilGetIPv4PsudoChkSum(pIpHdr,(TEST_PAYLOAD_LEN+TEST_PKT_UDP_HDR_LEN));
1213#else
1214 Pktlib_getDataBuffer(tip,&pData,&len);
1215 if(house_pkts_gened &0x1)
1216 {
1217 memcpy(&pData[6],&netTestCfg.mac[1][0] ,6);
1218 }
1219 meta_tx.txFlag1 = NWAL_TX_FLAG1_META_DATA_VALID;
1220 meta_tx.startOffset = 0;
1221 meta_tx.ploadLen = TEST_PAYLOAD_LEN;
1222#endif
1223 /* post it to netcp tx channel*/
1224 meta.u.tx_meta=&meta_tx;
1225#ifdef DEBUG_DESC
1226 if (house_pkts_gened<16) netTest_utilDumpDescr((long *) tip, house_pkts_gened);
1227 else if (house_pkts_gened>99) netTest_utilDumpDescr((long *) tip,house_pkts_gened);
1228#endif
1229
1230 if(!first)
1231 {
1232 first++;
1233 nwal_flow_vv1= hplib_mUtilGetPmuCCNT();
1234 if(nwal_initPSCmdInfo(pktio_mGetNwalInstance(netcp_tx_chan),
1235 &meta_tx,
1236 &flowPSCmdInfo) != nwal_OK)
1237 {
1238 netapi_Log("nwal_initPSCmdInfo() ERROR \n");
1239 }
1240 nwal_flow_vv2= hplib_mUtilGetPmuCCNT();
1241 nwal_sum_flow_vv1 += (nwal_flow_vv1-vv1);
1242 nwal_sum_flow_vv2 += (nwal_flow_vv2-nwal_flow_vv1);
1243 }
1244 cache_op_b1= Osal_cache_op_measure(&n_c_ops);
1245 vv2= hplib_mUtilGetPmuCCNT();
1246#ifdef BEND_UDP_SEND
1247 nwal_mCmdSetL4CkSumPort( tip,
1248 &flowPSCmdInfo,
1249 TEST_PKT_UDP_OFFSET_BYTES,
1250 (TEST_PKT_UDP_HDR_LEN + TEST_PAYLOAD_LEN),
1251 meta_tx.pseudoHdrChecksum,
1252 meta_tx.enetPort);
1253#else
1254 nwal_mCmdSetPort (tip,
1255 &flowPSCmdInfo, //could be NULL
1256 0); //port 0 -> switch decides
1257
1258#endif
1259
1260 pPktDesc = Pktlib_getDescFromPacket(tip);
1261 /* Send the packet out to transmit Q*/
1262 Qmss_queuePushDescSize (flowPSCmdInfo.txQueue,
1263 pPktDesc,
1264 NWAL_DESC_SIZE);
1265 vv3= hplib_mUtilGetPmuCCNT();
1266 cache_op_b2= Osal_cache_op_measure(&n_c_ops);
1267
1268 sum_vv1 += (vv2-vv1);
1269 if(!house_pkts_gened)
1270 {
1271 /* first packet. Take out the PS command label creation cost */
1272 sum_vv1 = sum_vv1 - nwal_sum_flow_vv2;
1273 }
1274
1275 sum_vv3 += (vv3-vv2)-(long) (cache_op_b2-cache_op_b1); //sub out cache op cost
1276
1277 // netapi_Log("pktio send. full=%d metadata=%d netapi_pktioSend=%d\n", vv3-vv1, vv2-vv1, vv3-vv2);
1278 stats[coreid].itx +=1;
1279 house_pkts_gened +=1;
1280 }
1281 {
1282 unsigned long long ccycles;
1283 ccycles =Osal_cache_op_measure(&n_c_ops);
1284 if (sum_vv1)
1285 {
1286 netapi_Log("BURST NWAL Fast send %d pkts. metadata=%d Cmd Label Creation Cost=%d nwal Fast Send Cost (less cacheop)= %d n_c_ops=%lld cache_op_time=%lld (pp-> %d)\n",
1287 stats[coreid].itx, sum_vv1/stats[coreid].itx, nwal_sum_flow_vv2, sum_vv3/stats[coreid].itx,
1288 n_c_ops, ccycles, n_c_ops? (ccycles/(n_c_ops/2L)) : 0);
1289#if 0
1290 netapi_Log("NWAL Profile Cycles: Prof1= %d,Prof2=%d,Prof3=%d,Prof4=%d,Prof5=%d ,Prof6=%d \n",
1291 nwal_sum_vv1/stats[coreid].itx,nwal_sum_vv2/stats[coreid].itx,nwal_sum_vv3/stats[coreid].itx,
1292 nwal_sum_vv4/stats[coreid].itx,nwal_sum_vv5/stats[coreid].itx,nwal_sum_vv6/stats[coreid].itx);
1293
1294#endif
1295
1296 if(stats[core_id].itx2)
1297 {
1298 netapi_Log("nwal_flowSend Profile Cycles: Prof1= %d,Prof2=%d \n",
1299 nwal_sum_flow_vv1/stats[coreid].itx2,nwal_sum_flow_vv2/stats[coreid].itx2);
1300 }
1301 }
1302 }
1303#endif
1304}
1305NETCP_CFG_ROUTE_T test_route;
1306
1307void netTest_utilCreateInterfaces(uint8_t num_macs, uint8_t num_ips, Bool match_action_host)
1308{
1309 int err, i;
1310
1311 if (match_action_host)
1312 {
1313 memset(&test_route, 0, sizeof(NETCP_CFG_ROUTE_T));
1314 test_route.valid_params = NETCP_CFG_VALID_PARAM_MATCH_ACTION_DEST;
1315 test_route.match_destination = NETCP_CFG_ACTION_TO_SW;
1316 test_route.routeType = 0;
1317 test_route.p_flow = NULL;
1318 test_route.p_dest_q = NULL;
1319
1320 for (i = 0; i < num_macs; i++)
1321 {
1322 /* add mac intefaces */
1323 mac[i] = netapi_netcpCfgCreateMacInterface(
1324 netapi_handle,
1325 &netTestCfg.mac[i][0],
1326 NULL,
1327 i,
1328 netTestCfg.switch_port[i],
1329 (NETCP_CFG_ROUTE_HANDLE_T) &test_route,
1330 (NETCP_CFG_VLAN_T ) NULL , //future
1331 0,
1332 1,
1333 &err);
1334 if (err)
1335 netapi_Log("netapi_netcpCfgCreateMacInterface failed with error: %d\n",err);
1336
1337 }
1338 }
1339 else
1340 {
1341 for (i = 0; i < num_macs; i++)
1342 {
1343 /* add mac intefaces */
1344 mac[i] = netapi_netcpCfgCreateMacInterface(
1345 netapi_handle,
1346 &netTestCfg.mac[i][0],
1347 NULL,
1348 i,
1349 netTestCfg.switch_port[i],
1350 (NETCP_CFG_ROUTE_HANDLE_T) NULL,
1351 (NETCP_CFG_VLAN_T ) NULL , //future
1352 0,
1353 1,
1354 &err);
1355 if (err)
1356 netapi_Log("netapi_netcpCfgCreateMacInterface failed with error: %d\n",err);
1357
1358 }
1359
1360 }
1361 for (i = 0; i < num_ips; i++)
1362 {
1363 //attach an IP to this interface
1364 ip_rule[i]=netapi_netcpCfgAddIp(
1365 netapi_handle,
1366 netTestCfg.attach_iface[i],
1367 nwal_IPV4,
1368 (nwalIpAddr_t*)&netTestCfg.ip[i].ipv4[0],
1369 NULL,
1370 NULL, //all IP
1371 (NETCP_CFG_ROUTE_HANDLE_T) NULL,
1372 (void*)NULL,
1373 &err
1374 );
1375 if (err)
1376 netapi_Log("netapi_netcpCfgAddIp: add ip failed with error %d\n", err);
1377 }
1378}
1379
1380void netTest_utilDeleteInterfaces(uint8_t num_macs, uint8_t num_ips)
1381{
1382 int err,i;
1383 //delete IPs and MAC Interfacess
1384 for (i = 0; i < num_ips; i++)
1385 {
1386 err = 0;
1387 netapi_netcpCfgDelIp(netapi_handle, netTestCfg.attach_iface[i], nwal_IPV4,
1388 NULL, NULL, ip_rule[i], &err);
1389 }
1390 for (i = 0; i < num_macs; i++)
1391 {
1392 err = 0;
1393 netapi_netcpCfgDelMac(netapi_handle,i,&err);
1394 }
1395
1396 //netapi_netcpCfgDelMac(netapi_handle,0,&err);
1397 //netapi_netcpCfgDelMac(netapi_handle,1,&err);
1398
1399}
1400
1401
diff --git a/ti/runtime/netapi/test/net_test_utils.h b/ti/runtime/netapi/test/net_test_utils.h
new file mode 100755
index 0000000..f7706fa
--- /dev/null
+++ b/ti/runtime/netapi/test/net_test_utils.h
@@ -0,0 +1,228 @@
1#ifndef __NET_TEST_UTIL_H__
2#define __NET_TEST_UTIL_H__
3
4
5#include "trie.h"
6//#include "net_test.h"
7#include "ti/runtime/netapi/netapi.h"
8#include "net_test_sa_utils.h"
9
10#define MAX_SEC_INDEX 64
11#define NET_TEST_MAX_MAC 64
12#define NET_TEST_MAX_IP 64
13#define NET_TEST_MAX_FP_THREAD 5
14#define NET_TEST_MAX_SP_THREAD 5
15#define MAX_LINE_LENGTH 512
16#define MAX_ROUTES 16
17
18#define TEMP_STR_LEN 32
19
20#define BE(x) ( (((x)&0xff000000)>>24) | (((x)&0xff0000)>>8) | (((x)&0xff00)<<8) | (((x)&0xff)<<24) )
21
22/* The input strings requirEd for parsing certain configuration
23 * paremeters from the config file */
24#define netTest_INIT_CONFIG_IPSEC_MODE_RX "ipsec_mode_rx"
25#define netTest_INIT_CONFIG_IPSEC_MODE_TX "ipsec_mode_tx"
26#define netTest_INIT_CONFIG_IPSEC_IF_NO "ipsec_if"
27#define netTest_INIT_CONFIG_DSP_MAC "dsp_mac"
28#define netTest_INIT_CONFIG_DSP_IP "dsp_ip"
29#define netTest_INIT_CONFIG_STATIC_LOOPBACK_PORT "dest_udp_port_config"
30#define netTest_CONFIG_STRING_LEN 512
31
32//IPSEC MODE(only choose one rx and one tx)
33#define IPSEC_MODE_RX_INFLOW 1
34#define IPSEC_MODE_TX_INFLOW 2
35#define IPSEC_MODE_RX_SIDEBAND 3
36#define IPSEC_MODE_TX_SIDEBAND 4
37
38#define netTest_PKT_LEN 1400
39
40#define NET_TEST_SP_THREAD_MASK 0xF0000000
41#define NET_TEST_THREAD_NUM_MASK 0x000000FF
42
43typedef struct {
44 unsigned char mac[NET_TEST_MAX_MAC][6];
45 uint8_t num_macs;
46 uint8_t switch_port[NET_TEST_MAX_MAC];
47 nwalIpAddr_t ip[NET_TEST_MAX_IP];
48 uint8_t num_ips;
49 uint8_t attach_iface[NET_TEST_MAX_IP];
50 nwalIpAddr_t local_ipsec_ip;
51 nwalIpAddr_t remote_ipsec_ip;
52 uint8_t ipsec_mode_rx;
53 uint8_t ipsec_mode_tx;
54 int ipsec_if_no;
55 int dest_udp_port_config;
56 uint8_t fp_proc_start[NET_TEST_MAX_FP_THREAD];
57 uint8_t fp_proc_end[NET_TEST_MAX_FP_THREAD];
58 uint32_t fp_thread_num[NET_TEST_MAX_FP_THREAD];
59 uint8_t num_fp_threads;
60 uint8_t sp_proc_start[NET_TEST_MAX_SP_THREAD];
61 uint8_t sp_proc_end[NET_TEST_MAX_SP_THREAD];
62 uint32_t sp_thread_num[NET_TEST_MAX_SP_THREAD];
63 uint8_t num_sp_threads;
64
65 uint8_t auth_key[MAX_SEC_INDEX][36];
66 uint8_t encr_key[MAX_SEC_INDEX][36];
67 uint32_t tunnel_id[MAX_SEC_INDEX];
68 NETAPI_SEC_SA_INFO_T sa[MAX_SEC_INDEX];
69 uint8_t num_sa;
70 nwalSecKeyParams_t key_params[MAX_SEC_INDEX];
71 uint8_t dsp_mac;
72 uint8_t dsp_ip;
73
74} netTestConfig_t;
75
76typedef struct
77{
78 char dir[netTest_CONFIG_STRING_LEN];
79 char spi[netTest_CONFIG_STRING_LEN];
80 char proto[netTest_CONFIG_STRING_LEN];
81 char saMode[netTest_CONFIG_STRING_LEN];
82 char ipType[netTest_CONFIG_STRING_LEN];
83 char src[netTest_CONFIG_STRING_LEN];
84 char dst[netTest_CONFIG_STRING_LEN];
85 char replayWindow[netTest_CONFIG_STRING_LEN];
86 char authMode[netTest_CONFIG_STRING_LEN];
87 char cipherMode[netTest_CONFIG_STRING_LEN];
88 char esnLo[netTest_CONFIG_STRING_LEN];
89 char esnHi[netTest_CONFIG_STRING_LEN];
90 char encKeySize[netTest_CONFIG_STRING_LEN];
91 char macKeySize[netTest_CONFIG_STRING_LEN];
92 char auth_key[netTest_CONFIG_STRING_LEN];
93 char encr_key[netTest_CONFIG_STRING_LEN];
94 char tunnel_id[netTest_CONFIG_STRING_LEN];
95} netTestConfigSA_t;
96
97typedef struct{
98 char mac[NET_TEST_MAX_MAC][netTest_CONFIG_STRING_LEN];
99 char switch_port[NET_TEST_MAX_MAC][netTest_CONFIG_STRING_LEN];
100 char ip[NET_TEST_MAX_IP][netTest_CONFIG_STRING_LEN];
101 char attach_iface [NET_TEST_MAX_MAC][netTest_CONFIG_STRING_LEN];
102 char ipsec_mode_rx[netTest_CONFIG_STRING_LEN];
103 char ipsec_mode_tx[netTest_CONFIG_STRING_LEN];
104 char routes[MAX_ROUTES][netTest_CONFIG_STRING_LEN];
105 char ports[MAX_ROUTES][netTest_CONFIG_STRING_LEN];
106 char dst_ips[MAX_ROUTES][netTest_CONFIG_STRING_LEN];
107 char paths[MAX_ROUTES][netTest_CONFIG_STRING_LEN];
108 char ipsec_if_no[netTest_CONFIG_STRING_LEN];
109 char fp_thread_num[NET_TEST_MAX_FP_THREAD][netTest_CONFIG_STRING_LEN];
110 char sp_thread_num[NET_TEST_MAX_SP_THREAD][netTest_CONFIG_STRING_LEN];
111 char sp[NET_TEST_MAX_SP_THREAD][netTest_CONFIG_STRING_LEN];
112 char fp[NET_TEST_MAX_FP_THREAD][netTest_CONFIG_STRING_LEN];
113 char tunnel_id[netTest_CONFIG_STRING_LEN];
114 netTestConfigSA_t sa_config[MAX_SEC_INDEX][netTest_CONFIG_STRING_LEN];
115 char dsp_mac[netTest_CONFIG_STRING_LEN];
116 char dsp_ip[netTest_CONFIG_STRING_LEN];
117 char dest_udp_port_config[netTest_CONFIG_STRING_LEN];
118} netTestConfigFile_t;
119
120typedef struct {
121 int iface;
122 int ipcsum;
123 int l4csum;
124} LastPktInfo_t;
125
126
127//#define netTestSA_t netTestSA_t
128
129typedef struct our_route_t
130{
131 int out_port;
132 unsigned char out_mac[14];
133 netTestSA_t * sec_ptr;
134} OUR_ROUTE_T;
135
136typedef struct {
137 long itx; //initially generated
138 long itx2;
139 long rx;
140 long tx;
141 long n_bad;
142 long n_new;
143 long n_class0_rx; //count of pkts classified
144 long n_class1_rx; //count of pkts classified
145 long n_class2_rx; //count of pkts classified
146 long n_t1;
147 long n_t2;
148 long n_t3;
149 long sec_tx;
150 long sec_rx;
151 long sb_tx;
152 long sb_rx;
153 long secp_rx;
154 long n_auth_ok;
155 unsigned long long app_cycles;
156 unsigned long long send_cycles;
157 unsigned long long tx_cache_cycles;
158 unsigned long long total_decrypt_time;
159 unsigned long long total_encrypt_time;
160 long rx_min;
161 long tx_min;
162 long if_rx[TUNE_NETAPI_MAX_NUM_MAC];
163 long core_rx;
164 long n_stats_cb;
165 long ip;
166 long exceptionPktsFrag;
167 long exceptionPktsOther;
168} netTestStats_T;
169
170typedef struct
171{
172 long ip[5];
173 long udp[2];
174} netTestHead_T;
175
176
177
178
179
180
181void house(NETAPI_SCHED_HANDLE_T *s);
182void netTest_utilCreateInterfaces(uint8_t num_macs, uint8_t num_ips, Bool match_action_host);
183void netTest_utilDeleteInterfaces(uint8_t num_macs, uint8_t num_ips);
184
185int netTest_utilCheckHeader(netTestHead_T * p_head, PKTIO_METADATA_T * p_meta);
186void netTest_utilMySig(int x);
187unsigned long netTest_utilPeek(unsigned long * p);
188void netTest_utilDumpDescr(unsigned long *p, int n);
189void netTest_utilDumpHeader(unsigned long *p, int n, int a, int r);
190void netTest_utilDumpBuffer(unsigned long * buf,uint32_t buf_length);
191long netTest_utilHtonl(long x);
192unsigned char netTest_utilHex2Dec(char *p_s);
193uint16_t netTest_utilOnesComplementAdd (uint16_t v1, uint16_t v2);
194uint16_t netTest_utilOnesCompChkSum (uint8_t *p, uint32_t nwords);
195uint16_t netTest_utilGetIPv4PsudoChkSum (uint8_t *data, uint16_t payloadLen);
196void netTest_utilPrintIPSecStats(Sa_IpsecStats_t *p_saIpsecStats, nwal_saAALG auth, nwal_saEALG cipher);
197void netTest_utilPrintDataModeStats(Sa_DataModeStats_t *p_saDataModeStats, nwal_saAALG auth, nwal_saEALG cipher);
198void netTest_utilStatsCbMt(NETAPI_T h, paSysStats_t* pPaStats);
199void netTest_utilsStatsCb(NETAPI_T h, paSysStats_t* pPaStats);
200
201
202void netTest_utilParseOneMac(char * p_mac_str, unsigned char *p_mac);
203void netTest_utilParseOneKey(char *p_key_str, unsigned char *p_key);
204void netTest_utilParseOneIP(char * p_ip_addr_str, unsigned char * p_ip);
205void netTest_utilParseMac(netTestConfigFile_t *pConfig);
206void netTest_utilParseIP(netTestConfigFile_t *pConfig);
207void netTest_utilParseThreadParams(netTestConfigFile_t *pConfig);
208void netTest_utilParseIpsecMode(netTestConfigFile_t *pConfig);
209void netTest_utilParseAuthMode(char *auth_mode_str, nwal_saAALG *auth_mode);
210void netTest_utilParseEncryptMode(char *ency_mode_str, nwal_saEALG*encr_mode);
211void netTest_utilParseProto(char *proto_str, nwal_IpSecProto *proto);
212void netTest_utilParseSaMode(char *mode_str, nwal_saMode *mode);
213void netTest_utilParseIPType(char *ip_type_str, nwal_IpType *ipType);
214void netTest_utilParseSADir(char* dir_str, nwal_SaDir *dir);
215void netTest_utilParseSA(netTestConfigFile_t *pConfig);
216void netTest_utilParseRoutes(netTestConfigFile_t* pConfig, OUR_ROUTE_T* routes, Trie** our_router);
217void netTest_utilProcessConfigFile(FILE* fpr, netTestConfigFile_t* pConfig);
218void recv_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
219 PKTIO_METADATA_T meta[], int n_pkts,
220 uint64_t ts );
221
222void parse_simple_param_u8(char* input_str, uint8_t *val);
223void parse_simple_param_u16(char* input_str, uint16_t *val);
224void parse_simple_param_u32(char* input_str, uint32_t *val);
225
226
227#endif
228
diff --git a/ti/runtime/netapi/test/nt_bridge.c b/ti/runtime/netapi/test/nt_bridge.c
new file mode 100755
index 0000000..839bfb6
--- /dev/null
+++ b/ti/runtime/netapi/test/nt_bridge.c
@@ -0,0 +1,1225 @@
1/******************************************
2 * File: nt_bridge.c
3 * Purpose: netcp bridge offload prototypes.
4 **************************************************************
5 * FILE: nt_bench.c
6 *
7 * DESCRIPTION: netapi user space transport
8 * library test application : benchmarks
9 *
10 * REVISION HISTORY: rev 0.0.1
11 *
12 * Copyright (c) Texas Instruments Incorporated 2013-2014
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
42 *****************************************/
43
44#include <stdio.h>
45#include <stdlib.h>
46#include <unistd.h>
47#include <string.h>
48#include <signal.h>
49#include <pthread.h>
50#include <sched.h>
51
52#include "trie.h"
53#include "string.h"
54#include "netapi.h"
55#include "pktio.h"
56#include <ti/drv/sa/salld.h>
57#include "net_test_sa_utils.h"
58#include "net_test_utils.h"
59#include "net_test_thread_utils.h"
60#include "fdb.h"
61
62#if defined(DEVICE_K2H)
63#include <ti/drv/qmss/device/k2h/src/qmss_device.c>
64#include <ti/drv/cppi/device/k2h/src/cppi_device.c>
65#elif defined (DEVICE_K2K)
66#include <ti/drv/qmss/device/k2k/src/qmss_device.c>
67#include <ti/drv/cppi/device/k2k/src/cppi_device.c>
68#elif defined (DEVICE_K2L)
69#include <ti/drv/qmss/device/k2l/src/qmss_device.c>
70#include <ti/drv/cppi/device/k2l/src/cppi_device.c>
71#elif defined (DEVICE_K2E)
72#include <ti/drv/qmss/device/k2e/src/qmss_device.c>
73#include <ti/drv/cppi/device/k2e/src/cppi_device.c>
74#else /*Default */
75#include <ti/drv/qmss/device/k2h/src/qmss_device.c>
76#include <ti/drv/cppi/device/k2h/src/cppi_device.c>
77#endif /* Device */
78
79#define netapi_timing_start hplib_mUtilGetPmuCCNT
80
81extern Rm_ServiceHandle *rmClientServiceHandle;
82
83static int scnt=0;
84static int QUIT=0;
85static int XMIT=0;
86static int CAP=0;
87volatile int RESET=0; //to reset stats
88volatile int MAC=0;
89volatile int FAST=1;
90
91uint16_t num_learned_macs = 0;
92
93uint16_t num_configured_interfaces = 0;
94
95static ntBridgeCfgFile_T config_file[MAX_INTERFACES];
96
97NETCP_CFG_ROUTE_T test_route[MAX_INTERFACES];
98
99static ntBridgeAleCfgFile_T ale_config_file;
100FDB_ENTRY_T ale_cfg[32];
101
102
103//*********************for checksum test
104unsigned short checksum(unsigned short *p, int len)
105{
106 unsigned short s=0;
107 int i;
108 for(i=0;i<len/2;i++) s+=p[i];
109 if (len&0x1) s+=(p[len/2+1]<<8);
110 return s;
111}
112
113#define NCSUM 1600
114unsigned long csum_val[NCSUM];
115unsigned long csum_num[NCSUM];
116unsigned long long csum_tim[NCSUM];
117//***********************************************
118
119#define CHECK_SET_PARAM(ARG1, ARG2) \
120 do { \
121 if(strcmp(key, ARG1) == 0) { \
122 if(d1)strncpy(ARG2,d1,netTest_CONFIG_STRING_LEN); \
123 continue; \
124 } \
125 } while(0)
126
127#define CHECK_SET_PARAM2(ARG1, ARG2, ARG3) \
128 do { \
129 if(strcmp(key, ARG1) == 0) { \
130 if(d1) strncpy(ARG2,d1,netTest_CONFIG_STRING_LEN); \
131 if(d2) strncpy(ARG3,d2,netTest_CONFIG_STRING_LEN); \
132 continue; \
133 } \
134 } while(0)
135
136
137void parse_simple_param_u8(char* input_str, uint8_t *val)
138{
139 if (strlen(input_str))
140 {
141 *val = (uint8_t)strtol(input_str, NULL, 0);
142 }
143}
144
145void parse_simple_param_u16(char* input_str, uint16_t *val)
146{
147 if (strlen(input_str))
148 {
149 *val = (uint16_t)strtol(input_str, NULL, 0);
150 }
151}
152
153void parse_simple_param_u32(char* input_str, uint32_t *val)
154{
155 if (strlen(input_str))
156 {
157 *val = (uint32_t)strtol(input_str, NULL, 0);
158 }
159}
160void parse_dscp_entry_default(char* input_str_queue,
161 char* input_str_flow,
162 paEQosModeConfig_t* pQosShapperCfg)
163{
164 int i;
165 if (strlen(input_str_queue) && strlen(input_str_flow))
166 {
167 for(i=0;i<MAX_DSCP_ENTRIES;i++)
168 {
169 pQosShapperCfg->dscpMap[i].flowOffset =(uint16_t)strtol(input_str_flow, NULL, 0);
170 pQosShapperCfg->dscpMap[i].queueOffset = (uint16_t)strtol(input_str_queue, NULL, 0);
171 }
172 }
173}
174void parse_dscp_entry(ntBridgeCfgFile_T *pConfig, paEQosModeConfig_t* pQosShapperCfg)
175{
176 int i;
177
178 for(i=0;i<MAX_DSCP_ENTRIES;i++)
179 {
180 if ((pConfig->dscpMapF[i][0]) && (pConfig->dscpMapQ[i][0]))
181 {
182 pQosShapperCfg->dscpMap[i].flowOffset =atoi(&pConfig->dscpMapF[i][0]);
183 pQosShapperCfg->dscpMap[i].queueOffset = atoi(&pConfig->dscpMapQ[i][0]);
184 printf("parse_dsp_entry[%d]: flowOffset: %d, queueOffset: %d\n",
185 i,
186 pQosShapperCfg->dscpMap[i].flowOffset,
187 pQosShapperCfg->dscpMap[i].queueOffset);
188 }
189 else
190 {
191 pQosShapperCfg->dscpMap[i].flowOffset =0;
192 pQosShapperCfg->dscpMap[i].queueOffset = 0;
193 }
194 }
195}
196
197unsigned char ntUtilHex2Dec(char *p_s)
198{
199 int val;
200 sscanf(p_s,"%x",&val);
201 return val&0xff;
202}
203
204void parse_pbit_entry_default(char* input_str_queue,
205 char* input_str_flow,
206 paEQosModeConfig_t* pQosShapperCfg)
207{
208 int i;
209 if (strlen(input_str_queue) && strlen(input_str_flow))
210 {
211 for(i=0;i<MAX_PBIT_ENTRIES;i++)
212 {
213 pQosShapperCfg->pbitMap[i].flowOffset =(uint16_t)strtol(input_str_flow, NULL, 0);
214 pQosShapperCfg->pbitMap[i].queueOffset = (uint16_t)strtol(input_str_queue, NULL, 0);
215 }
216 }
217}
218
219void parse_pbit_entry(ntBridgeCfgFile_T *pConfig, paEQosModeConfig_t* pQosShapperCfg)
220{
221 int i;
222
223 for(i=0;i<MAX_PBIT_ENTRIES;i++)
224 {
225 if ((pConfig->pbitMapF[i][0]) && (pConfig->pbitMapQ[i][0]))
226 {
227 pQosShapperCfg->pbitMap[i].flowOffset =atoi(&pConfig->pbitMapF[i][0]);
228 pQosShapperCfg->pbitMap[i].queueOffset = atoi(&pConfig->pbitMapQ[i][0]);
229 printf("parse_pbit_entry[%d]: flowOffset: %d, queueOffset: %d\n",
230 i,
231 pQosShapperCfg->pbitMap[i].flowOffset,
232 pQosShapperCfg->pbitMap[i].queueOffset);
233 }
234 else
235 {
236 pQosShapperCfg->pbitMap[i].flowOffset =0;
237 pQosShapperCfg->pbitMap[i].queueOffset = 0;
238 }
239 }
240}
241void parseOneMac(char * p_mac_str, uint8_t *p_mac)
242{
243 int index = 0;
244 int i;
245 if (strlen(&p_mac_str[0]))
246 {
247 char *pch = strtok (&(p_mac_str[0]),":");
248
249 while (pch != NULL)
250 {
251 p_mac[index] = ntUtilHex2Dec(pch);
252 index++;
253 pch = strtok (NULL,":");
254 }
255 //printf("parseOneMac: 0x%x: 0x%x: 0x%x: 0x%x: 0x%x:0x%x\n",
256 //p_mac[0],p_mac[1],p_mac[2],p_mac[3],p_mac[4],p_mac[5]);
257 }
258}
259
260
261
262void parseMac(ntBridgeAleCfgFile_T *pConfig, FDB_ENTRY_T *pAleCfg)
263{
264 int i;
265 int port = 0;
266 FDB_ENTRY_T *tmp = pAleCfg;
267 for(i=0;i<32;i++)
268 {
269 if (strlen(&pConfig->mac[i][0]))
270 {
271 parseOneMac((char*)&pConfig->mac[i][0], (uint8_t*)&tmp->mac_addr);
272 sscanf(&pConfig->switch_port[i][0],"swp%d",&tmp->switch_port);
273 tmp++;
274 num_learned_macs++;
275 /* check port to be 1 or 2 */
276 //printf("parseMac: port: %d\n", tmp->switch_port);
277 }
278}
279
280
281
282}
283void parseMode(ntBridgeCfgFile_T *pConfig, paEQosModeConfig_t* pQosShapperCfg)
284{
285
286 if (strlen(&pConfig->ctrlBitMap[0]))
287 {
288 printf("parseMode: mode: %s\n", &pConfig->ctrlBitMap[0]);
289 if (strcmp(pConfig->ctrlBitMap, "dscp") == 0)
290 {
291 pQosShapperCfg->ctrlBitMap = 0; pa_IF_EQoS_ROUTE_DP_BIT_MODE;
292
293 }
294 else if (strcmp(pConfig->ctrlBitMap, "pbit") == 0)
295 {
296 pQosShapperCfg->ctrlBitMap = pa_IF_EQoS_ROUTE_DP_BIT_MODE;
297 }
298 else
299 {
300 netapi_Log("parseMode(), invalid QOS Mode in config file \n");
301 }
302 }
303}
304
305
306
307paEQosModeConfig_t netTestQosShapperCfg[MAX_INTERFACES];
308
309
310/* Default Qos Shapper configuration for eth0 and eth1 */
311paEQosModeConfig_t netTestQosShapperCfg1 =
312{
313 pa_IF_EQoS_ROUTE_DP_BIT_MODE,
314 {0,0,0,1,0,2,0,3,0,4,0,5,0,6,0,7},
315 {0,0,0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,0,0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,0,0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,0,0,1,0,2,0,3,0,4,0,5,0,6,0,7},
316 1,
317 0,
318 0,
319 0,
320 0
321};
322paEQosModeConfig_t netTestQosShapperCfg2 =
323{
324 pa_IF_EQoS_ROUTE_DP_BIT_MODE,
325 {0,0,0,1,0,2,0,3,0,4,0,5,0,6,0,7},
326 {0,0,0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,0,0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,0,0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,0,0,1,0,2,0,3,0,4,0,5,0,6,0,7},
327 2,
328 0,
329 0,
330 0,
331 0
332};
333
334void ntBrideProcessCfgFile(FILE * fpr, ntBridgeCfgFile_T *pConfig)
335{
336 char line[MAX_LINE_LENGTH + 1];
337 int i;
338 static int sa_count = 0;
339
340 char *key, *ep;
341 char * d1, *d2, *d3;
342 char tokens[] = " :=;\n";
343 char temp_str[TEMP_STR_LEN];
344 memset(line, 0, MAX_LINE_LENGTH + 1);
345 //memset(pConfig, 0, sizeof(netTestConfigFile_t));
346 while (fgets(line, MAX_LINE_LENGTH + 1, fpr))
347 {
348 if(line[0]=='#')
349 continue; //skip comment
350 key = (char *)strtok(line, tokens);
351
352 d1 = (char *)strtok(NULL, tokens);
353 if (!key)
354 continue;
355 if (!d1)
356 continue;
357
358 if(strlen(d1) == 0)
359 {
360 continue;
361 }
362
363 d2 = (char *)strtok(NULL, tokens);
364
365 CHECK_SET_PARAM(ntBridge_INIT_CONFIG_FLOW_BASE,&(pConfig->flowBase[0]));
366
367 CHECK_SET_PARAM(ntBridge_INIT_CONFIG_QUEUE_BASE,&(pConfig->queueBase[0]));
368
369 CHECK_SET_PARAM(ntBridge_INIT_CONFIG_VLAN_ID,&(pConfig->vlanId[0]));
370
371 CHECK_SET_PARAM(ntBridge_INIT_CONFIG_PORT,&(pConfig->port[0]));
372 CHECK_SET_PARAM(ntBridge_INIT_CONFIG_INGRESS_DEF_PRI,&(pConfig->ingressDefPri[0]));
373
374 CHECK_SET_PARAM(ntBridge_INIT_CONFIG_QOS_MODE,&(pConfig->ctrlBitMap[0]));
375 CHECK_SET_PARAM2(ntBridge_INIT_CONFIG_DSCP_MAP_DEFAULT,&pConfig->dscpMapFDefault[0],&pConfig->dscpMapQDefault[0]);
376 CHECK_SET_PARAM2(ntBridge_INIT_CONFIG_PBIT_MAP_DEFAULT,&pConfig->pbitMapFDefault[0],&pConfig->pbitMapQDefault[0]);
377
378
379 for(i=0;i<MAX_DSCP_ENTRIES;i++)
380 {
381 snprintf(temp_str,TEMP_STR_LEN-1,"dscp_map_%d",i);
382
383 CHECK_SET_PARAM2(temp_str,&pConfig->dscpMapF[i][0],&pConfig->dscpMapQ[i][0]);
384 }
385
386 for(i=0;i< MAX_PBIT_ENTRIES;i++)
387 {
388 snprintf(temp_str,TEMP_STR_LEN-1,"pbit_map_%d",i);
389 CHECK_SET_PARAM2(temp_str,&pConfig->pbitMapF[i][0],&pConfig->pbitMapQ[i][0]);
390 }
391 }
392}
393void ntBrideProcessAleCfgFile(FILE * fpr, ntBridgeAleCfgFile_T *pConfig)
394{
395 char line[MAX_LINE_LENGTH + 1];
396 int i;
397 static int sa_count = 0;
398
399 char *key, *ep;
400 char * d1, *d2, *d3;
401 char tokens[] = " =;\n";
402 char temp_str[TEMP_STR_LEN];
403 memset(line, 0, MAX_LINE_LENGTH + 1);
404 //memset(pConfig, 0, sizeof(netTestConfigFile_t));
405 while (fgets(line, MAX_LINE_LENGTH + 1, fpr))
406 {
407 if(line[0]=='#')
408 continue; //skip comment
409 key = (char *)strtok(line, tokens);
410
411 d1 = (char *)strtok(NULL, tokens);
412 if (!key)
413 continue;
414 if (!d1)
415 continue;
416
417 if(strlen(d1) == 0)
418 {
419 continue;
420 }
421
422 d2 = (char *)strtok(NULL, tokens);
423
424
425 for(i=0;i< 32;i++)
426 {
427 snprintf(temp_str,TEMP_STR_LEN-1,"mac%d",i);
428 CHECK_SET_PARAM2(temp_str,&pConfig->mac[i][0],&pConfig->switch_port[i][0]);
429 }
430 }
431}
432
433//sig handler
434void netTest_utilMySig(int x)
435{
436 QUIT=1;
437 scnt+=1;
438 printf(">ifdma-test: recv'd signal %d cnt=%d\n",x,scnt);
439 if (scnt > 10) {printf(">ifdma-test: WARNING EXITING WITH PROPER SHUTDOWN, LUTS LEFT ACTIVE\n");exit(1);}
440}
441void recv_cb_net(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
442 PKTIO_METADATA_T meta[], int n_pkts,
443 uint64_t ts );
444
445
446/*************debug********************/
447void netTest_utilDumpDescr(unsigned long *p, int n)
448{
449 printf("--------dump of descriptor %d %x\n", n, (int) p);
450 printf("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
451 printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
452 printf("-----------------------------\n");
453}
454void netTest_utilDumpHeader(unsigned long *p, int n, int a, int r)
455{
456 printf("--------dump of header %d %x appID=%x flag1=%x\n", n, (int) p,a,r);
457 printf("> %0x %0x %0x %0x %0x %0x %0x %0x\n",
458 ntohl(p[0]),ntohl(p[1]),ntohl(p[2]),ntohl(p[3]),
459 ntohl(p[4]),ntohl(p[5]),ntohl(p[6]),ntohl(p[7]) );
460
461 printf("-----------------------------\n");
462}
463/*****************************************/
464
465
466unsigned long long CALIB=0;
467unsigned long long calibrate_idle(void)
468{
469 volatile unsigned long long at1;
470 volatile unsigned long long at2;
471 volatile unsigned long pt1;
472 volatile unsigned long pt2;
473 unsigned long long calib;
474 at1 = hplib_mUtilGetTimestamp();
475 pt1=netapi_timing_start();
476 for(;;)
477 {
478 pt2=netapi_timing_start() ;
479 if ((pt2-pt1) >= 100000) break;
480 }
481 at2 = hplib_mUtilGetTimestamp();
482
483 calib = ((unsigned long long) (pt2-pt1))/(at2-at1);
484 printf("calibrate: arm time=%lld -> arm cycles=%d calib=%lld\n", at2-at1, pt2-pt1, calib);
485
486 return calib;
487}
488
489/*******************************************
490 *************NETAPI OBJECTS***************
491 *****************************************/
492static NETAPI_CFG_T our_netapi_default_cfg=
493{
494TUNE_NETAPI_PERM_MEM_SZ,
495128, //start of packet offset for hw to place data on rx for default flow
496TUNE_NETAPI_QM_CONFIG_MAX_DESC_NUM, //max number of descriptors in system
497TUNE_NETAPI_NUM_GLOBAL_DESC, //total we will use
498TUNE_NETAPI_DEFAULT_NUM_BUFFERS*2, //#descriptors+buffers in default heap
49964, //#descriptors w/o buffers in default heap
500TUNE_NETAPI_DEFAULT_BUFFER_SIZE+128+128, //size of buffers in default heap
501128, //tail room
502256, //extra room,
5030,
504NULL,
50518,
5060x2000
507};
508
509Pktlib_HeapHandle OurHeap; //default heap, used by producer
510PKTIO_CFG_T netcp_rx_cfg={PKTIO_RX, PKTIO_NA, PKTIO_NA, 8};
511PKTIO_CFG_T netcp_tx_cfg={PKTIO_TX, PKTIO_NA, PKTIO_NA, 12};
512PKTIO_HANDLE_T * netcp_rx_chan;
513PKTIO_HANDLE_T * netcp_tx_chan;
514NETAPI_T netapi_handle;
515
516PKTIO_CONTROL_T zap_channel_control={PKTIO_CLEAR, NULL};
517PKTIO_CONTROL_T poll_cannel_control={PKTIO_SET_POLL_FLAGS, NULL, nwal_POLL_DEFAULT_GLOB_PKT_Q};
518
519//template for fast path
520nwalTxPktInfo_t txPktInfoNoCrypto =
521{
522 NULL, /* p_pkt */
523 NWAL_TX_FLAG1_META_DATA_VALID, /* txFlags */
524 0, /* lpbackPass */
525 0, /* enetport */
526 0, /* msuSize */
527 0, /* startOffset */
528 0, /* saOffBytes */
529 0, /* saPayLoadLen */
530 0, /* saAhIcvOffBytes */
531 0, /* saAhMacSize */
532 0, /* etherLenOffBytes */
533 netTest_MAC_HEADER_LEN, /* ipOffBytes */
534 netTest_MAC_HEADER_LEN +netTest_IP_HEADER_LEN, /* l4OffBytes */
535 netTest_UDP_HEADER_LEN, /* l4HdrLen */
536 0, /* pseudoHdrChecksum */
537 0 /* pLoadLen */
538};
539
540
541
542NETCP_CFG_ROUTE_T test_route1 =
543{
5440,
545NULL,
546NULL,
5470,
5481,
5490,
5501
551};
552NETCP_CFG_ROUTE_T test_route2 =
553{
5540,
555NULL,
556NULL,
5570,
5582,
5590,
5601
561};
562
563
564//#define WITH_QOS
565#ifdef WITH_QOS //send to qos input queue, set in device tree (6409)
566//#define QOSQ 6410 /* for wrr */
567#define QOSQ 6409 /* for SP */
568PKTIO_CFG_T direct_to_cpsw_cfg={PKTIO_TX, PKTIO_GLOBAL, QOSQ, 8};
569#else //send direct to 648, the CPSW input queue
570PKTIO_CFG_T direct_to_cpsw_cfg={PKTIO_TX, PKTIO_GLOBAL, 648, 8};
571#endif
572
573PKTIO_HANDLE_T * cpsw_tx_chan[MAX_INTERFACES];
574
575//NETCP_CFG_FLOW_T flow;
576
577
578/*************************END NETAPI OBJECTS***********************/
579
580static unsigned char all_mac[]={0,0,0,0,0,0};
581static unsigned char test_mac0[]={0,0,0,0,0,0xf};
582static unsigned char test_mac1[]={0,0,0,0,0,0xff};
583static unsigned char test_mac2[]={0xd4,0xbe,0xd9,0,0xd3,0x7e};
584static unsigned char test_mac3[]={0,0x15,0x60,0xa1,0xf7,0xbe};
585static unsigned char test_mac4[]={0xff,0xff,0xff,0x00,0x00,0x00};
586//static unsigned char test_mac0[]={0xd4,0xbe,0xd9,0x00,0xd3,0x7e};
587int test_port0 = 1;
588//static unsigned char test_mac1[]={0x00,0x15,0x60,0xa1,0xf7,0xbe};
589int test_port1 = 2;
590
591static unsigned long last_header[32/sizeof(unsigned long)];
592
593
594//stats
595int pkt_rx=0;
596int pkt_tx=0;
597unsigned long long pkt_rx_cycles=0L;
598unsigned long long pkt_tx_cycles=0L;
599unsigned long long pkt_cb_cycles=0L;
600unsigned long long idle_cycles=0L;
601volatile unsigned long long start_time;
602unsigned long long end_time;
603
604paSysStats_t netcp_stats;
605
606
607
608void netTest_utilStatsCbMt(NETAPI_T h, paSysStats_t* pPaStats)
609{
610 if(pPaStats)
611 {
612 memcpy(&netcp_stats,pPaStats, sizeof(paSysStats_t));
613 }
614}
615void netTest_utilsStatsCb(NETAPI_T h, paSysStats_t* pPaStats)
616{
617 if(pPaStats)
618 {
619 printf("C1 number of packets: %d\n", pPaStats->classify1.nPackets);
620 printf("C1 number IPv4 packets: %d\n", pPaStats->classify1.nIpv4Packets);
621 printf("C1 number IPv6 packets: %d\n", pPaStats->classify1.nIpv6Packets);
622 printf("C1 number Custom packets: %d\n", pPaStats->classify1.nCustomPackets);
623 printf("C1 number SRIO packets: %d\n", pPaStats->classify1.nSrioPackets);
624 printf("C1 number LLC/SNAP Fail packets: %d\n", pPaStats->classify1.nLlcSnapFail);
625 printf("C1 number table matched: %d\n", pPaStats->classify1.nTableMatch);
626 printf("C1 number failed table matched: %d\n", pPaStats->classify1.nNoTableMatch);
627 printf("C1 number IP Fragmented packets: %d\n", pPaStats->classify1.nIpFrag);
628 printf("C1 number IP Depth Overflow: %d\n", pPaStats->classify1.nIpDepthOverflow);
629 printf("C1 number VLAN Depth Overflow: %d\n", pPaStats->classify1.nVlanDepthOverflow);
630 printf("C1 number GRE Depth Overflow: %d\n", pPaStats->classify1.nGreDepthOverflow);
631 printf("C1 number MPLS Packets: %d\n", pPaStats->classify1.nMplsPackets);
632 printf ("C1 number of parse fail: %d\n",pPaStats->classify1.nParseFail);
633 printf("C1 number of Invalid IPv6 Opt: %d\n", pPaStats->classify1.nInvalidIPv6Opt);
634 printf("C1 number of TX IP Fragments: %d\n", pPaStats->classify1.nTxIpFrag);
635 printf ("C1 number of silent discard: %d\n",pPaStats->classify1.nSilentDiscard);
636 printf("C1 number of invalid control: %d\n", pPaStats->classify1.nInvalidControl);
637 printf ("C1 number of invalid states: %d\n",pPaStats->classify1.nInvalidState);
638 printf ("C1 number of system fails: %d\n",pPaStats->classify1.nSystemFail);
639 printf ("C2 number Packets : %d\n",pPaStats->classify2.nPackets);
640 printf ("C2 number udp : %d\n",pPaStats->classify2.nUdp);
641 printf ("C2 number tcp : %d\n",pPaStats->classify2.nTcp);
642 printf ("C2 number Custom : %d\n",pPaStats->classify2.nCustom);
643 printf ("C2 number silent drop : %d\n",pPaStats->classify2.nSilentDiscard);
644 printf ("C2 number invalid cntrl : %d\n\n",pPaStats->classify2.nInvalidControl);
645 printf ("C2 number Modify Stats Cmd Fail : %d\n\n",pPaStats->modify.nCommandFail);
646 }
647}
648
649
650//**********************************
651//producer thread
652//*********************************
653void producer_thread(int coreid)
654{
655int err;
656int i;
657Ti_Pkt * tip;
658unsigned char * pData;
659int len;
660PKTIO_METADATA_T meta = {PKTIO_META_IFDMA_TX,{0},0};
661int np;
662cpu_set_t cpu_set;
663unsigned long t1;
664unsigned long t2;
665
666 CPU_ZERO( &cpu_set);
667 CPU_SET( coreid, &cpu_set);
668 hplib_utilSetupThread(coreid,
669 &cpu_set,
670 hplib_spinLock_Type_LOL);
671 start_time = hplib_mUtilGetTimestamp();
672
673 /* Poll the default pktio channel for pkts from network */
674 for(i=0;!((volatile int) QUIT);i++)
675 {
676 if (FAST)
677 {
678 //netapi_netcpCfgReqStats(netapi_handle, netTest_utilStatsCbMt, 0,&err);
679 sleep(2);
680 continue;
681 }
682 t1 = netapi_timing_start();
683 np = netapi_pktioPoll(netcp_rx_chan,NULL,&err);
684 t2 = netapi_timing_start();
685 pkt_rx+=np;
686 if (np)
687 {
688 pkt_rx_cycles += (t2-t1);
689 }
690 else
691 {
692 idle_cycles += (t2-t1);
693 }
694 if (RESET)
695 {
696 idle_cycles=0LL;
697 start_time = hplib_mUtilGetTimestamp();
698 pkt_rx=pkt_tx=0;
699 pkt_rx_cycles=pkt_tx_cycles=0LL;
700 pkt_cb_cycles=0LL;
701 RESET=0;
702 }
703 }
704 end_time = hplib_mUtilGetTimestamp();
705 printf("nt-bench: receiver DONE %d pkts rx, pkt poll cycles=% u; pkt rx cycle=%u pkt tx cycles=%u idle cycles=%lld duration=%lld ticks idle pct= %lld\n",
706 pkt_rx,
707 (unsigned)(pkt_rx ? (pkt_rx_cycles - pkt_cb_cycles)/pkt_rx : 0),
708 (unsigned) (pkt_rx ? (pkt_rx_cycles) /pkt_rx : 0),
709 (unsigned) (pkt_tx ? (pkt_tx_cycles) /pkt_tx : 0),
710 idle_cycles, (end_time-start_time),
711 (idle_cycles*100) /( CALIB* (end_time-start_time))
712 );
713 printf("Leaving producer_thread\n");
714}
715
716
717void nt_setupQosShapper(NETAPI_T h, paEQosModeConfig_t *pqosCfg)
718{
719 int i;
720 paEmacPortConfig_t ctrl;
721 nwalLocCxtInfo_t info;
722 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
723
724 memset(&info, 0, sizeof(nwalLocCxtInfo_t));
725
726 memset(&ctrl, 0, sizeof(paEmacPortConfig_t));
727
728 ctrl.cfgType = pa_EMAC_PORT_CFG_EQoS_MODE;
729 ctrl.numEntries = 1;
730
731 ctrl.u.eQoSModeCfg = pqosCfg;
732
733 if(pqosCfg->flowBase)
734 {
735 printf("nt_setupQosShapper: flowBase from config file: %d\n", pqosCfg->flowBase);
736 ctrl.u.eQoSModeCfg->flowBase = pqosCfg->flowBase;
737 }
738 else
739 {
740 nwal_getLocCxtInfo(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle, &info);
741 printf("nt_setupQosShapper: flowBase from nwal: %d\n", info.rxPktFlowId);
742 ctrl.u.eQoSModeCfg->flowBase = info.rxPktFlowId;
743 }
744 nwal_emacPortCfg(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle, &ctrl);
745}
746
747
748
749//******************************
750// main program
751//*****************************
752int main(int argc, char **argv)
753{
754 int err,i;
755 int32_t errCode;
756 Pktlib_HeapIfTable* pPktifTable;
757 Pktlib_HeapCfg heapCfg;
758 long t1, t2 ;
759 cpu_set_t cpu_set;
760 FILE* fpr[MAX_INTERFACES];
761
762 //install signal handler for ^c
763 signal(SIGINT,netTest_utilMySig);
764
765 for(i=0; i < MAX_INTERFACES; i++)
766 {
767 fpr[i] = NULL;
768 }
769
770 memset(&config_file[0], 0, sizeof(ntBridgeCfgFile_T)*MAX_INTERFACES);
771 memset(&netTestQosShapperCfg[0], 0, sizeof(paEQosModeConfig_t)*MAX_INTERFACES);
772 memset(&ale_cfg, 0, sizeof(ntBridgeAleCfg_T));
773 memset(&ale_cfg, 0, sizeof(FDB_ENTRY_T)*32);
774
775 /* USE defautl Qos Shapper Configuration for 2 ports unless config files provided */
776 memcpy(&netTestQosShapperCfg[0], &netTestQosShapperCfg1, sizeof(paEQosModeConfig_t));
777 memcpy(&netTestQosShapperCfg[1], &netTestQosShapperCfg2, sizeof(paEQosModeConfig_t));
778
779 if (argc == 2)
780 {
781 fpr[0] = fopen(argv[1], "r");
782 num_configured_interfaces = 1;
783 }
784 else if (argc == 3)
785 {
786 fpr[0] = fopen(argv[1], "r");
787 fpr[1] = fopen(argv[2], "r");
788 num_configured_interfaces = 2;
789
790 }
791 else
792 {
793 printf("No qos shapper input files, using default settings\n");
794 num_configured_interfaces = 2;
795 }
796
797 for (i=0;i< num_configured_interfaces;i++)
798 {
799 if (fpr[i])
800 {
801 ntBrideProcessCfgFile(fpr[i], &config_file[i]);
802
803 parse_dscp_entry_default((char*)&config_file[i].dscpMapQDefault,
804 (char*)&config_file[i].dscpMapFDefault,
805 &netTestQosShapperCfg[i]);
806 parse_pbit_entry_default((char*)&config_file[i].pbitMapQDefault,
807 (char*)&config_file[i].pbitMapFDefault,
808 &netTestQosShapperCfg[i]);
809
810 parse_simple_param_u16((char*)&config_file[i].queueBase, &netTestQosShapperCfg[i].queueBase);
811 printf("main: netTestQos Cfg: queueBase: %d\n",netTestQosShapperCfg[i].queueBase);
812
813 parse_simple_param_u8((char*)&config_file[i].flowBase, &netTestQosShapperCfg[i].flowBase);
814 printf("main: netTestQos Cfg: flowBase: %d\n",netTestQosShapperCfg[i].flowBase);
815
816 parse_simple_param_u16((char*)&config_file[i].vlanId, &netTestQosShapperCfg[i].vlanId);
817 printf("main: netTestQos Cfg: vlanId: %d\n",netTestQosShapperCfg[i].vlanId);
818
819 parse_simple_param_u8((char*)&config_file[i].port, &netTestQosShapperCfg[i].port);
820 printf("main: netTestQos Cfg: port: %d\n",netTestQosShapperCfg[i].port);
821
822 parse_simple_param_u8((char*)&config_file[i].ingressDefPri, &netTestQosShapperCfg[i].ingressDefPri);
823 printf("main: netTestQos Cfg: ingressDefPri: %d\n",netTestQosShapperCfg[i].ingressDefPri);
824
825 parse_dscp_entry(&config_file[i], &netTestQosShapperCfg[i]);
826 parse_pbit_entry(&config_file[i], &netTestQosShapperCfg[i]);
827 parseMode(&config_file[i], &netTestQosShapperCfg[i]);
828
829 }
830 }
831
832#if 0
833 if (initRm())
834 {
835 printf("main: initRm() returned error\n");
836 exit(1);
837 }
838#endif
839 CPU_ZERO( &cpu_set);
840 CPU_SET( 0, &cpu_set);
841 hplib_utilSetupThread(0,
842 &cpu_set,
843 hplib_spinLock_Type_LOL);
844
845
846 /*******************************************/
847 /*************NETAPI STARTUP****************/
848 /*******************************************/
849
850 /* create netapi */
851 our_netapi_default_cfg.rmHandle = rmClientServiceHandle;
852 netapi_handle = netapi_init(NETAPI_SYS_MASTER, &our_netapi_default_cfg);
853 if (netapi_handle == NULL)
854 {
855 printf("main: netapi_init failure, exiting\n");
856 exit(1);
857 }
858
859
860 /* open the main heap */
861 OurHeap = Pktlib_findHeapByName("netapi");
862 if (!OurHeap) {printf("findheapbyname fail\n"); exit(1);}
863
864 for(i = 0; i < MAX_INTERFACES; i++)
865 {
866 char temp_str[PKTIO_MAX_NAME] = {0};
867 direct_to_cpsw_cfg.qnum = netTestQosShapperCfg[i].queueBase;
868 snprintf(temp_str, PKTIO_MAX_NAME, "cpsw_tx%d",i);
869 cpsw_tx_chan[i]= netapi_pktioCreate(netapi_handle,&temp_str[0],NULL,
870 &direct_to_cpsw_cfg, &err);
871 if (!cpsw_tx_chan[i])
872 {
873 printf("pktio open %s failed err=%d\n", &temp_str[0], err);
874 exit(1);
875 }
876 }
877
878#if 0
879 direct_to_cpsw_cfg.qnum = netTestQosShapperCfg2.queueBase;
880
881 cpsw_tx_chan2= netapi_pktioCreate(netapi_handle,"cpsw_tx2",NULL,
882 &direct_to_cpsw_cfg, &err);
883 if (!cpsw_tx_chan2){printf("pktio open CPSW TX2 failed err=%d\n",err); exit(1);}
884#endif
885
886
887 //if we want to relay network packets, we create a handle to the
888 //default netcp receive queue here
889 netcp_rx_chan= netapi_pktioOpen(netapi_handle, NETCP_RX, (PKTIO_CB) recv_cb_net, &netcp_rx_cfg, &err);
890 if (!netcp_rx_chan) {printf("pktio open RX failed err=%d\n",err); exit(1);}
891
892 netcp_tx_chan= netapi_pktioOpen(netapi_handle, NETCP_TX, (PKTIO_CB) NULL, &netcp_tx_cfg, &err);
893 if (!netcp_tx_chan) {printf("pktio open TX failed err=%d\n",err); exit(1);}
894 else //install a fast path template into the NETCP TX channel
895 {
896 PKTIO_CONTROL_T control2;
897 control2.op = PKTIO_UPDATE_FAST_PATH;
898 PKTIO_CFG_T cfg2;
899 cfg2.fast_path_cfg.fp_send_option = PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT;
900 cfg2.fast_path_cfg.txPktInfo= &txPktInfoNoCrypto;
901 netapi_pktioControl(netcp_tx_chan, NULL, &cfg2, &control2, &err);
902 }
903
904 //build route for cpsw
905 NETCP_CFG_FLOW_T flow;
906 flow.dma_engine = 1;
907 for (i = 0; i < MAX_INTERFACES;i++)
908 {
909 if(netTestQosShapperCfg[i].flowBase)
910 {
911 flow.dma_engine = 1;
912 flow.flowid = netTestQosShapperCfg[i].flowBase;
913 test_route[i].p_flow = &flow;
914 }
915 else
916 {
917 test_route[i].p_flow =NETCP_DEFAULT_FLOW;
918 }
919 test_route[i].egress_swith_port = netTestQosShapperCfg[i].port;
920 test_route[i].routeType = NWAL_ROUTE_PKTTYPE_EQOS;
921 test_route[i].valid_params = NETCP_CFG_VALID_PARAM_ROUTE_TYPE;
922 test_route[i].p_dest_q = cpsw_tx_chan[i];
923 }
924
925/*********************************************/
926/*****************end NETAPI STARTUP**********/
927/*********************************************/
928
929
930
931 //calibrate idle
932 CALIB = calibrate_idle();
933 ntoff_start();
934 ntoff_add_do_perm(&test_mac0[0],test_port0);
935 ntoff_add_do_perm(&test_mac1[0],test_port1);
936 //ntoff_add_do_perm(&test_mac2[0],test_port0);
937 //ntoff_add_do_perm(&test_mac3[0],test_port1);
938 //ntoff_add_do_perm(&test_mac4[0],test_port0);
939
940//**************************************
941//Create a worked thread
942//***************************************
943 {
944 pthread_t *thrs;
945 int procs =1;
946 int c;
947 thrs = malloc( sizeof( pthread_t ) * procs );
948 if (thrs == NULL)
949 {
950 perror( "malloc" );
951 return -1;
952 }
953 printf( "net_test_bridge: Starting %d threads...\n", procs );
954
955 if (pthread_create( &thrs[0], NULL, (void*)producer_thread,
956 (void *)1 ))
957 {
958 perror( "pthread_create" );
959 exit(1);
960 }
961 //this thread of execution (main) now just waits on user input
962 for(;;)
963 {
964 printf(">");
965 c=getchar();
966 if (c=='c') {CAP=!CAP; printf("CAPTURE= %d\n", CAP); }
967 else if (c=='t') {XMIT=!XMIT; printf("XMIT= %d\n", XMIT); }
968 else if (c=='l')
969 {
970 FILE* fprAle = NULL;
971 system("/etc/transportnetlib/test/parse_ale.sh");
972 fprAle = fopen("ale_table.txt","r");
973 if (fprAle)
974 {
975 ntBrideProcessAleCfgFile(fprAle, &ale_config_file);
976 //for(i=0;i<32;i++)
977 parseMac(&ale_config_file, &ale_cfg[0]);
978 for(i=0;i<num_learned_macs;i++)
979 {
980 printf("parseOneMac[%d]: 0x%x: 0x%x: 0x%x: 0x%x: 0x%x:0x%x, switch port: %d\n",
981 i,
982 ale_cfg[i].mac_addr[0],
983 ale_cfg[i].mac_addr[1],
984 ale_cfg[i].mac_addr[2],
985 ale_cfg[i].mac_addr[3],
986 ale_cfg[i].mac_addr[4],
987 ale_cfg[i].mac_addr[5],
988 ale_cfg[i].switch_port);
989 }
990 ntoff_learn();
991 ntoff_show();
992 }
993 }
994 else if (c=='m')
995 {
996 unsigned add1 = netapi_timing_start();
997 if (!MAC)
998 {
999 //add macs
1000 ntoff_add_macs(netapi_handle,
1001 FAST? &test_route1: NULL,
1002 FAST );
1003
1004 add1 = netapi_timing_start()-add1;
1005 printf("adding MACs cycles=%d err=%x\n", add1,err);
1006 MAC=1;
1007 }
1008
1009 else
1010 printf("MAC already offloaded\n");
1011 }
1012
1013 else if (c=='!') system("sh");
1014 else if (c=='n')
1015 {
1016 unsigned add2 = netapi_timing_start();
1017 if (MAC)
1018 {
1019 ntoff_del_macs(netapi_handle);
1020
1021 add2 = netapi_timing_start()-add2;
1022 printf("removing MAC cycles=%d\n",add2);
1023 MAC=0;
1024 } else printf("no mac offloaded\n");
1025 }
1026 else if (c=='f')
1027 {
1028 FAST=!FAST; printf("bridge offload = %s\n", FAST ? "netcp" : "user space");
1029 if (!FAST) XMIT=1;
1030 }
1031 else if (c=='j')
1032 {
1033 netapi_netcpCfgReqStats(netapi_handle, netTest_utilStatsCbMt, 0,&err);
1034 sleep(1);
1035 netapi_netcpPoll(netapi_handle);
1036 netTest_utilsStatsCb(netapi_handle, &netcp_stats);
1037
1038 }
1039 else if (c=='s')
1040 {
1041 unsigned long long et= hplib_mUtilGetTimestamp();
1042 printf(">NT_BENCH STATS: %d received %d xmitted, %lld idle cycles, %lld duration ticks idle=%lld\n",
1043 pkt_rx,pkt_tx,
1044 idle_cycles,
1045 (et-start_time),
1046 (idle_cycles*100)/(CALIB*(et-start_time))
1047 );
1048 Pktlib_HeapStats pktLibHeapStats;
1049 Pktlib_getHeapStats(OurHeap, &pktLibHeapStats);
1050 printf("main heap stats> #free=%d #zb=%d #garbage=%d\n",
1051 pktLibHeapStats.numFreeDataPackets,
1052 pktLibHeapStats.numZeroBufferPackets,
1053 pktLibHeapStats.numPacketsinGarbage);
1054 }
1055 else if (c=='S')
1056 {
1057 system("/usr/bin/dumpqos.sh");
1058 }
1059 else if (c=='r')
1060 {
1061 RESET=1;
1062 }
1063 else if (c=='h')
1064 {
1065 printf("> 'q' to quit, 's' for Heap stats, 'S' for QOS stats \n");
1066 printf(" 'c' to toggle capture, 'd' to dump capture, 'r' to reset idle counters\n");
1067 printf(" 'm' to add macs, 'n' to remove macs 'l' to learn macs\n");
1068 printf(" 'f' toggle s/w or netcp offload, '!' shell, 'S' Chksum Stats, 'h' for help\n");
1069 }
1070 else if (c=='d')
1071 {
1072 netTest_utilDumpHeader(&last_header[0], 0,0,0);
1073 }
1074 else if (c == 'z')
1075 {
1076 nwalCtlInfo_t nwalCtrl;
1077 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) netapi_handle;
1078 memset(&nwalCtrl, 0, sizeof(nwalCtlInfo_t));
1079 nwalCtrl.pktCtl= NWAL_CTRL_CFG_EMAC_IF_EGRESS_EQOS_MODE;
1080 nwalCtrl.matchAction = NWAL_MATCH_ACTION_HOST;
1081 nwalCtrl.appRxPktFlowId = NWAL_FLOW_NOT_SPECIFIED;
1082 nwalCtrl.appRxPktQueue = NWAL_QUEUE_NOT_SPECIFIED;
1083
1084 for (i=0; i < MAX_INTERFACES;i++)
1085 {
1086 nt_setupQosShapper(netapi_handle,(paEQosModeConfig_t*)&netTestQosShapperCfg[i]);
1087 }
1088 nwal_control(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle, &nwalCtrl);
1089 }
1090 else if (c=='q')
1091 {
1092 nwalCtlInfo_t nwalCtrl;
1093 NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) netapi_handle;
1094 memset(&nwalCtrl, 0, sizeof(nwalCtlInfo_t));
1095 nwalCtrl.pktCtl = NWAL_CTRL_CFG_EMAC_IF_EGRESS_EQOS_MODE;
1096 nwalCtrl.matchAction = NWAL_MATCH_ACTION_DISCARD;
1097 nwal_control(((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle, &nwalCtrl);
1098
1099 QUIT=1;
1100 break;
1101 }
1102 }
1103
1104 //wait for completion
1105 printf("main task now pending on thread completion\n");
1106 for (i = 0; i < procs; i++)
1107 pthread_join( thrs[i], NULL );
1108
1109 free( thrs);
1110 }
1111
1112 /*************************************************
1113 ************CLEAN UP****************************
1114 ************************************************/
1115 //get rid of rule, in the case that we are relaying packets
1116 //also close our netcp rx channel
1117 if (MAC)
1118 {
1119 ntoff_del_macs(netapi_handle);
1120#if 0
1121 netapi_netcpCfgDelMac(netapi_handle,0,&err);
1122 netapi_netcpCfgDelMac(netapi_handle,1,&err);
1123#endif
1124 }
1125 ntoff_stop();
1126 netapi_pktioClose(netcp_rx_chan,&err);
1127 netapi_pktioClose(netcp_tx_chan,&err);
1128 for(i=0;i < MAX_INTERFACES; i++)
1129 {
1130 netapi_pktioDelete(cpsw_tx_chan[i],&err);
1131 }
1132
1133
1134 //done
1135 netapi_shutdown(netapi_handle);
1136 //!finished!
1137}
1138static inline void sendit(Ti_Pkt *tip, int len, int out_port)
1139{
1140 int err=0;
1141 PKTIO_METADATA_T meta2 = {PKTIO_META_TX,{0},0};
1142 nwalTxPktInfo_t meta_tx2={0};
1143 if (len<60)
1144 {
1145 unsigned int templen;
1146 char * p_pkt;
1147 len=60;
1148 Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);//ignore templen
1149 Cppi_setData (Cppi_DescType_HOST, (Cppi_Desc *) tip, p_pkt,len);
1150 }
1151 Pktlib_setPacketLen(tip,len);
1152 meta_tx2.txFlag1 = NWAL_TX_FLAG1_META_DATA_VALID ;
1153 meta_tx2.ploadLen = len ;
1154 meta_tx2.enetPort=out_port;
1155 meta2.u.tx_meta=&meta_tx2;
1156 netapi_pktioSend(netcp_tx_chan,tip,&meta2,&err);
1157}
1158
1159//receive callback for packets from net (for consumer)
1160void recv_cb_net(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
1161 PKTIO_METADATA_T meta[], int n_pkts,
1162 uint64_t ts )
1163{
1164 int i;
1165 Ti_Pkt * tip;
1166 int len;
1167 unsigned long t1;
1168 unsigned long t2;
1169 unsigned long t3;
1170 unsigned long t4;
1171 pasahoLongInfo_t* protoInfo;
1172 int ifno;
1173 int out_port;
1174
1175 t1= netapi_timing_start();
1176 for(i=0;i<n_pkts;i++)
1177 {
1178 tip = p_recv[i];
1179 len = Pktlib_getPacketLen(tip);
1180
1181 if (CAP)
1182 {
1183 unsigned int templen;
1184 char * p_pkt;
1185 unsigned long val;
1186 unsigned long cs1;
1187 unsigned long cs2;
1188 Pktlib_getDataBuffer(tip,(uint8_t**)&p_pkt,&templen);//ignore templen
1189 memcpy(last_header,p_pkt,32);
1190 cs1= netapi_timing_start();
1191 val= (unsigned long) checksum((unsigned short *)p_pkt,len);
1192 cs2= netapi_timing_start();
1193 templen = (len >= NCSUM)? NCSUM-1: len;
1194 csum_num[templen]+=1;
1195 csum_val[templen]+=val;
1196 csum_tim[templen]+= (unsigned long long) (cs2-cs1);
1197 }
1198
1199 if (XMIT)
1200 {
1201 protoInfo=nwal_mGetProtoInfo(tip);
1202 ifno = nwal_mGetRxEmacPort( protoInfo);
1203 //----------------------------------------------------
1204 //very trivial bridging -> just output to other port!
1205 //----------------------------------------------------
1206 if (ifno ==1) out_port=2; else out_port=1;
1207 t3= netapi_timing_start();
1208 sendit(tip,len,out_port);
1209 pkt_tx+=1;
1210 t4= netapi_timing_start();
1211 pkt_tx_cycles += (t4-t3);
1212 }
1213 else
1214 {
1215 Pktlib_freePacket((Ti_Pkt*)tip);
1216 }
1217 }
1218 t2 = netapi_timing_start();
1219 pkt_cb_cycles += (t2-t1);
1220 }
1221
1222
1223
1224
1225
diff --git a/ti/runtime/netapi/test/router.c b/ti/runtime/netapi/test/router.c
new file mode 100755
index 0000000..d580578
--- /dev/null
+++ b/ti/runtime/netapi/test/router.c
@@ -0,0 +1,173 @@
1#include "trie.h"
2#include "net_test.h"
3#include "router.h"
4
5
6
7
8Trie * route_init(void)
9{
10 Trie *Pt = trie_new();
11 return Pt;
12}
13
14
15
16void route_add(Trie * Pt, unsigned long * Pdest_ipBE, void * Pour_route)
17{
18
19 trie_insert(Pt,(char *)Pdest_ipBE, sizeof(int), Pour_route);
20}
21
22//route the packet
23// lookup next hop in route trie
24int route_pkt(Trie *Pt, void * Ppkt, IP_netTestHead_T *Phead, unsigned char * Pbuf, int * Plen, netTestSA_t **Prs, int *PoutPort)
25{
26 OUR_ROUTE_T *Pr;
27 int ret;
28 Pr = trie_lookup(Pt, (char *) &Phead->dst, 4);
29 if (!Pr ) return -1; //can't route
30 if (Pr->sec_ptr)
31 {
32 if(!Prs) return -3;
33 //tunnel i/f
34 ret=process_tunnel(Pt, Ppkt, Phead, Pbuf, Plen, Pr, PoutPort);
35 *Prs = Pr->sec_ptr;
36 return ret;
37 }
38 if (Prs) *Prs=NULL;
39 //simple route
40 //copy new mac
41 memcpy(Pbuf,Pr->out_mac,14);
42 Pbuf[14+8]-=1; //ttl--
43 //todo do check ttl!
44 Pbuf[14+10]=0; Pbuf[14+11]=0; //zap [outer] header checksum
45 if(PoutPort) *PoutPort=Pr->out_port;
46 return 1;
47}
48
49int process_tunnel(Trie *Pt, void *Ppkt, IP_netTestHead_T * Phead,
50 unsigned char * Pbuf, int* Plen, OUR_ROUTE_T * Proute,
51 int * PoutPort)
52{
53unsigned char *sb = Pbuf;
54unsigned char *eb= &Pbuf[*Plen];
55int newlen=*Plen;
56int seq;
57int pl_len;
58int new_pl_len;
59int pad_len;
60//unsigned char IV[20];
61netTestSA_t * p_sec=Proute->sec_ptr;
62unsigned char *pc;
63int nb;
64int i;
65int ret;
66
67/* move sb to new start */
68sb = sb - p_sec->iv_len-8-20; //make room for esp header and new outer ip
69newlen += (Pbuf-sb);
70
71//adjust IP_Header to make outer:
72Phead->src=p_sec->src;
73Phead->dst=p_sec->dst;
74
75//next_proto
76pc = (unsigned char *)&Phead->w3;
77pc[1]=50;
78
79//payload len
80pc= (unsigned char*)&Phead->w1;
81pl_len= ((pc[2]<<8) | (pc[3]));
82
83//only for non-zero bl
84if (p_sec->bl)
85{
86 nb = pl_len/ (p_sec->bl); //128bits for AES
87 pad_len = pl_len - nb*p_sec->bl;
88 if (p_sec->bl==16) //AES based
89 {
90 switch(pad_len)
91 {
92 case(15):
93 pad_len=15;
94 break;
95 default:
96 pad_len = p_sec->bl-pad_len-2;
97 }
98 }
99 else //assume 8 byte block (DES)
100 {
101 switch(pad_len)
102 {
103 case(7):
104 pad_len=7;
105 break;
106 default:
107 pad_len = p_sec->bl-pad_len-2;
108 }
109 }
110}
111else
112{
113 pad_len=0;
114}
115
116new_pl_len = pl_len +20+ 8 + p_sec->iv_len + pad_len + p_sec->auth_tag_size +2;
117pc[2] = (new_pl_len&0xff00)>>8;
118pc[3] = (new_pl_len&0xff);
119memcpy(&sb[14],Phead,20); //copy outer ip header into buffer
120
121//build esp header
122memcpy(&sb[14+20],(unsigned char *)&p_sec->spi,4);
123seq=BE(p_sec->seq); //TODO: multicore safe ; CHECK to make sure that SA does this, if so remove this code
124p_sec->seq+=1;
125memcpy(&sb[14+24],(unsigned char *)&seq,4);
126
127//IV: don't need: Sa does it.
128//memcpy(&sb[14+28],&IV[0],p_sec->iv_len);
129
130//Padding, trailer, room for tag
131for(i=1;i<=pad_len;i++) *eb++ = i;
132*eb++=pad_len; //pad len
133*eb++=4; //next proto= ipinip
134newlen += pad_len+2+p_sec->auth_tag_size;
135Cppi_setData (Cppi_DescType_HOST, (Cppi_Desc *) Ppkt, sb,newlen);
136Pktlib_setPacketLen(Ppkt,newlen);
137
138//now route based on outer ip
139ret=route_pkt(Pt, Ppkt, Phead, sb, &newlen,NULL,PoutPort);
140if (ret<0) return ret;
141*Plen=newlen;
142return 1;
143}
144//#define TEST
145#ifdef TEST
146#define NR 4
147OUR_ROUTE_T routes[]=
148{
149{1,{0x00,0x01,0x2,0x03,0x4,0x2, 0x00,0x01,0x02,0x03,0x14,0x02,0x00,0x80},0},
150{2,{0x00,0x01,0x2,0x03,0x4,0x3, 0x00,0x01,0x02,0x03,0x24,0x02,0x00,0x80},0},
151{3,{0x00,0x01,0x2,0x03,0x4,0x4, 0x00,0x01,0x02,0x03,0x34,0x02,0x00,0x80},0},
152{4,{0x00,0x01,0x2,0x03,0x4,0x5, 0x00,0x01,0x02,0x03,0x44,0x02,0x00,0x80},0}};
153
154unsigned int ip[]={BE(0x0a000010),BE(0xa0000110),BE(0x0a000210),BE(0x0a000310)};
155Trie *rt;
156char tp[1500];
157IP_netTestHead_T th={0x00,0x00,0x00,0x01020304,0x1002000a};
158main()
159{
160int i;
161int l;
162int out_port;
163rt = route_init();
164for (i=0;i<NR;i++)
165{
166 route_add(rt,&ip[i],&routes[i]);
167}
168
169memcpy(&tp[14],&th,20);
170l=1500;
171route_pkt(rt, 0, &th, &tp[0],&l,NULL,&out_port);
172}
173#endif
diff --git a/ti/runtime/netapi/test/router.h b/ti/runtime/netapi/test/router.h
new file mode 100755
index 0000000..5377400
--- /dev/null
+++ b/ti/runtime/netapi/test/router.h
@@ -0,0 +1,34 @@
1#ifndef __ROUTER_H__
2#define __ROUTER_H__
3
4
5
6#include <stdio.h>
7#include <stdlib.h>
8#include <unistd.h>
9#include <string.h>
10
11
12#include "net_test.h"
13#include "net_test_sa_utils.h"
14#include "net_test_utils.h"
15
16typedef struct
17{
18 unsigned long w1;
19 unsigned long w2;
20 unsigned long w3;
21 unsigned long src;
22 unsigned long dst;
23} IP_netTestHead_T;
24
25Trie * route_init(void);
26void route_add(Trie * Pt, unsigned long * Pdest_ipBE, void * Pour_route);
27
28
29int route_pkt(Trie *Pt, void * Ppkt, IP_netTestHead_T *Phead, unsigned char * Pbuf, int * Plen, netTestSA_t **Prs, int *PoutPort);
30int process_tunnel(Trie *Pt, void *Ppkt, IP_netTestHead_T * Phead,
31 unsigned char * Pbuf, int* Plen, OUR_ROUTE_T * Proute,
32 int * PoutPort);
33
34#endif
diff --git a/ti/runtime/netapi/test/stubs.c b/ti/runtime/netapi/test/stubs.c
new file mode 100755
index 0000000..b8ce04b
--- /dev/null
+++ b/ti/runtime/netapi/test/stubs.c
@@ -0,0 +1,2 @@
1/* stubs .. */
2/* place holder...*/
diff --git a/ti/runtime/netapi/test/trie.c b/ti/runtime/netapi/test/trie.c
new file mode 100755
index 0000000..b407c52
--- /dev/null
+++ b/ti/runtime/netapi/test/trie.c
@@ -0,0 +1,327 @@
1/*
2
3Copyright (c) 2005, Simon Howard
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions
8are met:
9
10 * Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in
14 the documentation and/or other materials provided with the
15 distribution.
16 * Neither the name of the C Algorithms project nor the names of its
17 contributors may be used to endorse or promote products derived
18 from this software without specific prior written permission.
19
20THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31POSSIBILITY OF SUCH DAMAGE.
32
33 *ALSO: TI modifications made to support binary data keys
34*
35 * Copyright (c) Texas Instruments Incorporated 2010-2011
36*/
37
38/* Trie: fast mapping of strings to values */
39
40#include <stdlib.h>
41#include <string.h>
42
43#include "trie.h"
44
45typedef struct _TrieNode TrieNode;
46
47struct _TrieNode {
48 void *data;
49 unsigned int use_count;
50 TrieNode *next[256];
51};
52
53struct _Trie {
54 TrieNode *root_node;
55};
56
57static void trie_free_node(TrieNode *node)
58{
59 int i;
60
61 if (node == NULL)
62 return;
63
64 /* First, free all subnodes */
65
66 for (i=0; i<256; ++i) {
67 trie_free_node(node->next[i]);
68 }
69
70 /* Free this node */
71
72 free(node);
73}
74
75Trie *trie_new(void)
76{
77 Trie *new_trie;
78
79 new_trie = (Trie *) malloc(sizeof(Trie));
80 new_trie->root_node = NULL;
81
82 return new_trie;
83}
84
85void trie_free(Trie *trie)
86{
87 /* Free the subnode, and all others by implication */
88
89 trie_free_node(trie->root_node);
90
91 /* Free the trie */
92
93 free(trie);
94}
95
96void trie_insert(Trie *trie, char *key, int keylen, void *value)
97{
98 TrieNode **rover;
99 TrieNode *node;
100 unsigned char *p;
101 unsigned char c;
102 int k;
103
104 /* Cannot insert NULL values */
105
106 if (value == NULL) {
107 return;
108 }
109
110 /* Search down the trie until we reach the end of string,
111 * creating nodes as necessary */
112
113 rover = &trie->root_node;
114 p = (unsigned char *) key;
115
116 for (k=0;;) {
117
118 node = *rover;
119
120 if (node == NULL) {
121
122 /* Node does not exist, so create it */
123
124 node = (TrieNode *) malloc(sizeof(TrieNode));
125 memset(node, 0, sizeof(TrieNode));
126
127 /* Link in to the trie */
128
129 *rover = node;
130 }
131
132 /* One more use of this node */
133
134 ++node->use_count;
135
136 /* Current character */
137
138 c = *p;
139
140 /* Reached the end of string? If so, we're finished. */
141
142 if (k>=keylen) {
143
144 /* Set the data at the node we have reached */
145
146 node->data = value;
147
148 break;
149 }
150
151 /* Advance to the next node in the chain */
152
153 rover = &node->next[c];
154 ++p;
155 k+=1;
156 }
157}
158
159void trie_remove(Trie *trie, char *key, int keylen)
160{
161 TrieNode *node;
162 TrieNode *next;
163 TrieNode **last_next_ptr;
164 unsigned char *p;
165 unsigned char c;
166 int k=0;
167
168 /* First, search down to the ending node so that the data can
169 * be removed. */
170
171 /* Search down the trie until the end of string is reached */
172
173 node = trie->root_node;
174
175 for (p=(unsigned char *) key, k=0; k<keylen; ++p, k+=1) {
176
177 if (node == NULL) {
178 /* Not found in the tree. Return. */
179
180 return;
181 }
182
183 /* Jump to the next node */
184
185 c = *p;
186 node = node->next[c];
187 }
188
189 /* Remove the data at this node */
190
191 node->data = NULL;
192
193 /* Now traverse the tree again as before, decrementing the use
194 * count of each node. Free back nodes as necessary. */
195
196 node = trie->root_node;
197 last_next_ptr = &trie->root_node;
198 p = key;
199
200 for (k=0;;k++) {
201
202 /* Find the next node */
203
204 c = *p;
205 next = node->next[c];
206
207 /* Free this node if necessary */
208
209 --node->use_count;
210
211 if (node->use_count <= 0) {
212 free(node);
213
214 /* Set the "next" pointer on the previous node to NULL,
215 * to unlink the free'd node from the tree. This only
216 * needs to be done once in a remove. After the first
217 * unlink, all further nodes are also going to be
218 * free'd. */
219
220 if (last_next_ptr != NULL) {
221 *last_next_ptr = NULL;
222 last_next_ptr = NULL;
223 }
224 }
225
226 /* Go to the next character or finish */
227
228 if (k>=keylen) {
229 break;
230 } else {
231 ++p;
232 }
233
234 /* If necessary, save the location of the "next" pointer
235 * so that it may be set to NULL on the next iteration if
236 * the next node visited is freed. */
237
238 if (last_next_ptr != NULL) {
239 last_next_ptr = &node->next[c];
240 }
241
242 /* Jump to the next node */
243
244 node = next;
245 }
246}
247
248void *trie_lookup(Trie *trie, char *key, int keylen)
249{
250 TrieNode *node;
251 unsigned char *p;
252 unsigned char c;
253 int k=0;
254
255 /* Search down the trie until the end of string is found */
256
257 node = trie->root_node;
258 p = (unsigned char *) key;
259
260 while (k<keylen ) {
261 if (node == NULL) {
262 /* Not found - reached end of branch */
263
264 return NULL;
265 }
266
267 /* Advance to the next node in the chain, next character */
268
269 c = *p;
270 node = node->next[c];
271 ++p;
272 k+=1;
273 }
274 /* bug! */
275
276 return (node ? node->data : NULL);
277
278}
279
280int trie_num_entries(Trie *trie)
281{
282 /* To find the number of entries, simply look at the use count
283 * of the root node. */
284
285 if (trie->root_node == NULL) {
286 return 0;
287 } else {
288 return trie->root_node->use_count;
289 }
290}
291
292//#define TEST
293#ifdef TEST
294main()
295{
296Trie * p_trie;
297char * p_res;
298p_trie = trie_new();
299if (!p_trie) {netapi_Log("trie alloc failed\n"); exit(1);}
300
301trie_insert(p_trie,"key1","this is key 1");
302trie_insert(p_trie,"key12","this is key 2");
303trie_insert(p_trie,"key3","this is key 3");
304trie_insert(p_trie,"key4","this is key 4");
305
306p_res= trie_lookup(p_trie,"key1");
307netapi_Log("lookup %s = %s\n", "key1", p_res ? p_res : "not found");
308
309p_res= trie_lookup(p_trie,"key12");
310netapi_Log("lookup %s = %s\n", "key2", p_res ? p_res : "not found");
311
312p_res= trie_lookup(p_trie,"key3");
313netapi_Log("lookup %s = %s\n", "key3", p_res ? p_res : "not found");
314
315p_res= trie_lookup(p_trie,"key4");
316netapi_Log("lookup %s = %s\n", "key4", p_res ? p_res : "not found");
317
318p_res= trie_lookup(p_trie,"key5");
319netapi_Log("lookup %s = %s\n", "key5", p_res ? p_res : "not found");
320
321p_res= trie_lookup(p_trie,"k5");
322netapi_Log("lookup %s = %s\n", "k5", p_res ? p_res : "not found");
323
324trie_free(p_trie);
325
326}
327#endif
diff --git a/ti/runtime/netapi/test/trie.h b/ti/runtime/netapi/test/trie.h
new file mode 100755
index 0000000..e77dcc6
--- /dev/null
+++ b/ti/runtime/netapi/test/trie.h
@@ -0,0 +1,127 @@
1/*
2
3Copyright (c) 2005, Simon Howard
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions
8are met:
9
10 * Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in
14 the documentation and/or other materials provided with the
15 distribution.
16 * Neither the name of the C Algorithms project nor the names of its
17 contributors may be used to endorse or promote products derived
18 from this software without specific prior written permission.
19
20THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31POSSIBILITY OF SUCH DAMAGE.
32
33 * Copyright (c) Texas Instruments Incorporated 2010-2011
34 * ALSO: TI mods to support binary keys
35 * REVISION HISTORY: rev 0.0.1
36 *
37*/
38
39/**
40 * @file trie.h
41 *
42 * @brief Fast string lookups
43 *
44 * A trie is a data structure which provides fast mappings from strings
45 * to values.
46 *
47 * To create a new trie, use @ref trie_new. To destroy a trie,
48 * use @ref trie_free.
49 *
50 * To insert a value into a trie, use @ref trie_insert. To remove a value
51 * from a trie, use @ref trie_remove.
52 *
53 * To look up a value from its key, use @ref trie_lookup.
54 *
55 * To find the number of entries in a trie, use @ref trie_num_entries.
56 */
57
58#ifndef ALGORITHM_TRIE_H
59#define ALGORITHM_TRIE_H
60
61#ifdef __cplusplus
62extern "C" {
63#endif
64
65typedef struct _Trie Trie;
66
67/**
68 * Create a new trie.
69 *
70 * @return Pointer to a new trie structure.
71 */
72
73Trie *trie_new(void);
74
75/**
76 * Destroy a trie.
77 *
78 * @param trie The trie to destroy.
79 */
80
81void trie_free(Trie *trie);
82
83/**
84 * Insert a new key-value pair into a trie.
85 *
86 * @param trie The trie.
87 * @param key The key to access the new value.
88 * @param value The value.
89 */
90
91void trie_insert(Trie *trie, char *key, int keylen, void *value);
92
93/**
94 * Look up a value from its key in a trie.
95 *
96 * @param trie The trie.
97 * @param key The key.
98 * @return The value associated with the key, or NULL if
99 * not found in the trie.
100 */
101
102void *trie_lookup(Trie *trie, char *key, int keylen);
103
104/**
105 * Remove an entry from a trie.
106 *
107 * @param trie The trie.
108 * @param key The key of the entry to remove.
109 */
110
111void trie_remove(Trie *trie, char *key, int keylen);
112
113/**
114 * Find the number of entries in a trie.
115 *
116 * @param trie The trie.
117 * @return Count of the number of entries in the trie.
118 */
119
120int trie_num_entries(Trie *trie);
121
122#ifdef __cplusplus
123}
124#endif
125
126#endif /* #ifndef ALGORITHM_TRIE_H */
127
diff --git a/ti/runtime/netapi/tools/armcc b/ti/runtime/netapi/tools/armcc
new file mode 100755
index 0000000..617e400
--- /dev/null
+++ b/ti/runtime/netapi/tools/armcc
@@ -0,0 +1,2 @@
1#!/bin/sh
2/opt/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-gcc -march=armv7-a -O2 -mcpu='cortex-a8' -pthread -D _GNU_SOURCE $1.c -o $1 -static-libgcc -lpthread
diff --git a/ti/runtime/netapi/tools/armdump b/ti/runtime/netapi/tools/armdump
new file mode 100755
index 0000000..1f4c09a
--- /dev/null
+++ b/ti/runtime/netapi/tools/armdump
@@ -0,0 +1,2 @@
1
2/opt/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-objdump -D $1
diff --git a/ti/runtime/netapi/tools/davinci_clocks b/ti/runtime/netapi/tools/davinci_clocks
new file mode 100755
index 0000000..2f7137a
--- /dev/null
+++ b/ti/runtime/netapi/tools/davinci_clocks
@@ -0,0 +1,56 @@
1ref_clk users=39 122880000 Hz
2 main_pll users=38 pll 983040000 Hz
3 main_div_chip_clk1 users= 3 pll 983040000 Hz
4 emif4f users= 1 psc 983040000 Hz
5 crypto users= 0 psc 983040000 Hz
6 monza_rst_ctrl users= 1 psc 983040000 Hz
7 rac users= 0 psc 983040000 Hz
8 gem0 users= 0 psc 983040000 Hz
9 gem1 users= 0 psc 983040000 Hz
10 gem2 users= 0 psc 983040000 Hz
11 gem3 users= 0 psc 983040000 Hz
12 rsax2_1 users= 0 psc 983040000 Hz
13 rsax2_0 users= 0 psc 983040000 Hz
14 main_div_gem_trace_clk users= 1 pll 245760000 Hz
15 main_div_chip_clk2 users= 1 pll 491520000 Hz
16 vusr users= 0 psc 491520000 Hz
17 pciex users= 0 psc 491520000 Hz
18 msmcsram users= 0 psc 491520000 Hz
19 tcp3d users= 0 psc 491520000 Hz
20 tcp3d_b users= 0 psc 491520000 Hz
21 main_div_chip_clk3 users= 3 pll 327680000 Hz
22 vcp2_a users= 0 psc 327680000 Hz
23 debugss_trc users= 0 psc 327680000 Hz
24 tetb_trc users= 0 psc 327680000 Hz
25 pktproc users= 1 psc 327680000 Hz
26 cpgmac users= 1 psc 327680000 Hz
27 bcp users= 0 psc 327680000 Hz
28 tac users= 0 psc 327680000 Hz
29 fftc users= 0 psc 327680000 Hz
30 aif2 users= 0 psc 327680000 Hz
31 vcp2_b users= 0 psc 327680000 Hz
32 vcp2_c users= 0 psc 327680000 Hz
33 vcp2_d users= 0 psc 327680000 Hz
34 main_div_stm_clk users= 1 pll 163840000 Hz
35 main_div_emif_ptv_clk users= 1 pll 15360000 Hz
36 main_div_chip_clk6 users=20 pll 163840000 Hz
37 modrst0 users=19 163840000 Hz
38 timer0 users= 2 163840000 Hz
39 timer1 users= 2 163840000 Hz
40 uart0 users= 2 163840000 Hz
41 uart1 users= 2 163840000 Hz
42 aemif users= 2 163840000 Hz
43 usim users= 1 163840000 Hz
44 i2c users= 2 163840000 Hz
45 spi users= 2 163840000 Hz
46 gpio users= 2 163840000 Hz
47 key_mgr users= 1 163840000 Hz
48 main_div_slowsys_clk users= 1 pll 15360000 Hz
49 main_div_chip_smreflex_clk users= 2 pll 81920000 Hz
50 src3_pwr users= 1 psc 81920000 Hz
51 main_div_chip_clk3_srio users= 1 pll 327680000 Hz
52 srio users= 0 psc 327680000 Hz
53 main_div_psc_clk6 users= 1 pll 163840000 Hz
54 main_div_chip_dftclk4 users= 1 pll 245760000 Hz
55 main_div_chip_dftclk8 users= 1 pll 122880000 Hz
56
diff --git a/ti/runtime/netapi/tools/dsp_core_setup.sh b/ti/runtime/netapi/tools/dsp_core_setup.sh
new file mode 100755
index 0000000..c36a9c9
--- /dev/null
+++ b/ti/runtime/netapi/tools/dsp_core_setup.sh
@@ -0,0 +1,35 @@
1#!/bin/sh
2
3mpmcl load dsp7 /home/root/nwalPktRouterArmMASTERk2hTestProject.out
4#
5mpmcl run dsp7
6#
7mpmcl load dsp6 /home/root/nwalPktRouterArmMASTERk2hTestProject.out
8#
9mpmcl run dsp6
10#
11mpmcl load dsp5 /home/root/nwalPktRouterArmMASTERk2hTestProject.out
12#
13mpmcl run dsp5
14#
15mpmcl load dsp4 /home/root/nwalPktRouterArmMASTERk2hTestProject.out
16#
17mpmcl run dsp4
18#
19mpmcl load dsp3 /home/root/nwalPktRouterArmMASTERk2hTestProject.out
20#
21mpmcl run dsp3
22#
23mpmcl load dsp2 /home/root/nwalPktRouterArmMASTERk2hTestProject.out
24#
25mpmcl run dsp2
26#
27mpmcl load dsp1 /home/root/nwalPktRouterArmMASTERk2hTestProject.out
28#
29mpmcl run dsp1
30#
31mpmcl load dsp0 /home/root/nwalPktRouterArmMASTERk2hTestProject.out
32#
33mpmcl run dsp0
34#
35#
diff --git a/ti/runtime/netapi/tools/dumpdesc.c b/ti/runtime/netapi/tools/dumpdesc.c
new file mode 100755
index 0000000..2e2a1d6
--- /dev/null
+++ b/ti/runtime/netapi/tools/dumpdesc.c
@@ -0,0 +1,132 @@
1/*
2 * devmem2.c: Simple program to read/write from/to any location in memory.
3 *
4 * Copyright (C) 2000, Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl)
5 *
6 *
7 * This software has been developed for the LART computing board
8 * (http://www.lart.tudelft.nl/). The development has been sponsored by
9 * the Mobile MultiMedia Communications (http://www.mmc.tudelft.nl/)
10 * and Ubiquitous Communications (http://www.ubicom.tudelft.nl/)
11 * projects.
12 *
13 * The author can be reached at:
14 *
15 * Jan-Derk Bakker
16 * Information and Communication Theory Group
17 * Faculty of Information Technology and Systems
18 * Delft University of Technology
19 * P.O. Box 5031
20 * 2600 GA Delft
21 * The Netherlands
22 *
23 *
24 * This program is free software; you can redistribute it and/or modify
25 * it under the terms of the GNU General Public License as published by
26 * the Free Software Foundation; either version 2 of the License, or
27 * (at your option) any later version.
28 *
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
33 *
34 * You should have received a copy of the GNU General Public License
35 * along with this program; if not, write to the Free Software
36 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
37 *
38 */
39
40#include <stdio.h>
41#include <stdlib.h>
42#include <unistd.h>
43#include <string.h>
44#include <errno.h>
45#include <signal.h>
46#include <fcntl.h>
47#include <ctype.h>
48#include <termios.h>
49#include <sys/types.h>
50#include <sys/mman.h>
51
52//netTest_utilDumpDescr
53void netTest_utilDumpDescr(unsigned long *p, int n)
54{
55 printf("--------dump of descriptor %d %x\n", n, (int) p);
56 printf("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
57 printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
58 printf("-----------------------------\n");
59}
60
61static inline unsigned long netapi_timing_start(void)
62{
63 volatile int vval;
64 //read clock
65 asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(vval));
66 return vval;
67}
68static inline unsigned long netapi_timing_stop(void)
69{
70 volatile int vval2;
71 //read clock
72 asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(vval2));
73 return vval2;
74}
75
76
77#define FATAL do { fprintf(stderr, "Error at line %d, file %s (%d) [%s]\n", \
78 __LINE__, __FILE__, errno, strerror(errno)); exit(1); } while(0)
79
80#define MAP_SIZE 4096UL
81#define MAP_MASK (MAP_SIZE - 1)
82
83
84int cached = 0;
85int test_loc = 1;
86int sum=0;
87
88int main(int argc, char **argv) {
89 int fd;
90 void *map_base, *virt_addr;
91#define N 50
92 unsigned long read_result[N], writeval;
93 off_t target;
94 int access_type = 'w';
95volatile unsigned long t1;
96volatile unsigned long t2;
97int i;
98int num2dump=32;
99
100
101 if(argc < 2) {
102 fprintf(stderr, "\nUsage:\t%s { address } nun ] ]\n"
103 "\taddress : memory address to act upon\n"
104 "\tnum : #descriptors to be dumped (def 32)\n\n",
105 argv[0]);
106 exit(1);
107 }
108 target = strtoul(argv[1], 0, 0);
109 if (argc ==3) num2dump=atoi(argv[2]);
110
111
112 if((fd = open("/dev/mem", ((cached) ? (O_RDWR) : (O_RDWR | O_SYNC)))) == -1) FATAL;
113 netapi_Log("/dev/mem opened.\n");
114 fflush(stdout);
115
116 /* Map one page */
117 map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, target & ~MAP_MASK);
118 if(map_base == (void *) -1) FATAL;
119 netapi_Log("Memory mapped at address %p. (cached=%d)\n", map_base,cached);
120 fflush(stdout);
121
122 virt_addr = map_base + (target & MAP_MASK);
123for(i=0;i<num2dump;i++)
124{
125 long * tip= &((long *)virt_addr)[32*i];
126 netTest_utilDumpDescr(tip, i);
127}
128 if(munmap(map_base, MAP_SIZE) == -1) FATAL;
129 close(fd);
130 return 0;
131}
132
diff --git a/ti/runtime/netapi/tools/eqos/dumpqos.sh b/ti/runtime/netapi/tools/eqos/dumpqos.sh
new file mode 100755
index 0000000..b17701a
--- /dev/null
+++ b/ti/runtime/netapi/tools/eqos/dumpqos.sh
@@ -0,0 +1,118 @@
1#!/bin/sh
2#dump L2 Shaper Config and Stats
3#
4echo "**************eth0 L2 QOS:*********************"
5echo " "
6echo "HP Queue: "
7echo " - Packets Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-hp/packets_forwarded`
8echo " - Packets Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-hp/packets_discarded`
9echo " - Bytes Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-hp/bytes_forwarded`
10echo " - Bytes Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-hp/bytes_discarded`
11echo " "
12
13echo "WRR0 Queue: "
14echo " - Packets Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr0/packets_forwarded`
15echo " - Packets Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr0/packets_discarded`
16echo " - Bytes Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr0/bytes_forwarded`
17echo " - Bytes Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr0/bytes_discarded`
18echo " "
19
20echo "WRR1 Queue: "
21echo " - Packets Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr1/packets_forwarded`
22echo " - Packets Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr1/packets_discarded`
23echo " - Bytes Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr1/bytes_forwarded`
24echo " - Bytes Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr1/bytes_discarded`
25echo " "
26
27echo "WRR2 Queue: "
28echo " - Packets Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr2/packets_forwarded`
29echo " - Packets Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr2/packets_discarded`
30echo " - Bytes Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr2/bytes_forwarded`
31echo " - Bytes Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr2/bytes_discarded`
32echo " "
33
34echo "WRR3 Queue:"
35echo " - Packets Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr3/packets_forwarded`
36echo " - Packets Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr3/packets_discarded`
37echo " - Bytes Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr3/bytes_forwarded`
38echo " - Bytes Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr3/bytes_discarded`
39echo " "
40
41echo "WRR4 Queue: "
42echo " - Packets Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr4/packets_forwarded`
43echo " - Packets Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr4/packets_discarded`
44echo " - Bytes Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr4/bytes_forwarded`
45echo " - Bytes Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr4/bytes_discarded`
46echo " "
47
48echo "WRR5 Queue: "
49echo " - Packets Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr5/packets_forwarded`
50echo " - Packets Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr5/packets_discarded`
51echo " - Bytes Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr5/bytes_forwarded`
52echo " - Bytes Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-wrr5/bytes_discarded`
53echo " "
54
55echo "BE Queue: "
56echo " - Packets Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-be/packets_forwarded`
57echo " - Packets Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-be/packets_discarded`
58echo " - Bytes Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-be/bytes_forwarded`
59echo " - Bytes Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l21-be/bytes_discarded`
60echo " "
61
62echo "***********eth1 L2 QOS:**********************"
63echo " "
64echo "HP Queue: "
65echo " - Packets Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-hp/packets_forwarded`
66echo " - Packets Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-hp/packets_discarded`
67echo " - Bytes Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-hp/bytes_forwarded`
68echo " - Bytes Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-hp/bytes_discarded`
69echo " "
70
71echo "WRR0 Queue: "
72echo " - Packets Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr0/packets_forwarded`
73echo " - Packets Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr0/packets_discarded`
74echo " - Bytes Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr0/bytes_forwarded`
75echo " - Bytes Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr0/bytes_discarded`
76echo " "
77
78echo "WRR1 Queue: "
79echo " - Packets Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr1/packets_forwarded`
80echo " - Packets Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr1/packets_discarded`
81echo " - Bytes Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr1/bytes_forwarded`
82echo " - Bytes Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr1/bytes_discarded`
83echo " "
84
85echo "WRR2 Queue: "
86echo " - Packets Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr2/packets_forwarded`
87echo " - Packets Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr2/packets_discarded`
88echo " - Bytes Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr2/bytes_forwarded`
89echo " - Bytes Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr2/bytes_discarded`
90echo " "
91
92echo "WRR3 Queue: "
93echo " - Packets Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr3/packets_forwarded`
94echo " - Packets Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr3/packets_discarded`
95echo " - Bytes Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr3/bytes_forwarded`
96echo " - Bytes Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr3/bytes_discarded`
97echo " "
98
99echo "WRR4 Queue: "
100echo " - Packets Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr4/packets_forwarded`
101echo " - Packets Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr4/packets_discarded`
102echo " - Bytes Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr4/bytes_forwarded`
103echo " - Bytes Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr4/bytes_discarded`
104echo " "
105
106echo "WRR5 Queue: "
107echo " - Packets Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr5/packets_forwarded`
108echo " - Packets Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr5/packets_discarded`
109echo " - Bytes Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr5/bytes_forwarded`
110echo " - Bytes Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-wrr5/bytes_discarded`
111echo " "
112
113echo "BE Queue: "
114echo " - Packets Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-be/packets_forwarded`
115echo " - Packets Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-be/packets_discarded`
116echo " - Bytes Sent = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-be/bytes_forwarded`
117echo " - Bytes Dropped = " `cat /sys/devices/soc.0/hwqueue.6/qos-inputs-2//statistics/l22-be/bytes_discarded`
118echo " "
diff --git a/ti/runtime/netapi/tools/eqos/parse_ale.awk b/ti/runtime/netapi/tools/eqos/parse_ale.awk
new file mode 100755
index 0000000..fa8a7fd
--- /dev/null
+++ b/ti/runtime/netapi/tools/eqos/parse_ale.awk
@@ -0,0 +1,21 @@
1BEGIN {j=0}
2// { for(i=1;i<=NF;i++){
3 if ($i ~ "addr") {f=1}
4 else if ($i ~ "port") {f=2;}
5 else if (f==1)
6 {
7 split($i,x,",")
8 printf("mac%d = %s ", j,x[1]);
9 j++;
10 f=0;
11 }
12 else if (f==2)
13 {
14 printf("swp%d \n", $i);
15 f=0;
16 }
17 }
18 }
19
20END {}
21
diff --git a/ti/runtime/netapi/tools/eqos/parse_ale.sh b/ti/runtime/netapi/tools/eqos/parse_ale.sh
new file mode 100755
index 0000000..e4f6b09
--- /dev/null
+++ b/ti/runtime/netapi/tools/eqos/parse_ale.sh
@@ -0,0 +1 @@
cat /sys/devices/soc.0/2090000.netcp/ale_table| grep "touched" | grep "addr" | awk -f /etc/transportnetlib/test/parse_ale.awk > ale_table.txt
diff --git a/ti/runtime/netapi/tools/ipsec_tools/aes_ccm.sh b/ti/runtime/netapi/tools/ipsec_tools/aes_ccm.sh
new file mode 100755
index 0000000..9cf2590
--- /dev/null
+++ b/ti/runtime/netapi/tools/ipsec_tools/aes_ccm.sh
@@ -0,0 +1,8 @@
1
2sudo ip xfrm state add src 192.168.1.10 dst 192.168.1.100 proto esp spi 0x66666666 mode tunnel reqid 100 replay-window 64 aead "rfc4309(ccm(aes))" 0x00112233445566778899aabbccddeeff001122 128;
3
4sudo ip xfrm policy add dir out src 192.168.1.10 dst 192.168.1.100 proto udp tmpl src 192.168.1.10 dst 192.168.1.100 proto esp mode tunnel reqid 100;
5
6sudo ip xfrm state add src 192.168.1.100 dst 192.168.1.10 proto esp spi 0x66666666 mode tunnel reqid 100 replay-window 64 aead "rfc4309(ccm(aes))" 0x00112233445566778899aabbccddeeff001122 128;
7
8sudo ip xfrm policy add dir in src 192.168.1.100 dst 192.168.1.10 proto udp tmpl src 192.168.1.100 dst 192.168.1.10 proto esp mode tunnel reqid 100;
diff --git a/ti/runtime/netapi/tools/ipsec_tools/aes_ccm.txt b/ti/runtime/netapi/tools/ipsec_tools/aes_ccm.txt
new file mode 100644
index 0000000..a79bfbe
--- /dev/null
+++ b/ti/runtime/netapi/tools/ipsec_tools/aes_ccm.txt
@@ -0,0 +1 @@
Cipher: aes-ccm loopback sucess.
diff --git a/ti/runtime/netapi/tools/ipsec_tools/aes_gcm.sh b/ti/runtime/netapi/tools/ipsec_tools/aes_gcm.sh
new file mode 100755
index 0000000..c5ac88a
--- /dev/null
+++ b/ti/runtime/netapi/tools/ipsec_tools/aes_gcm.sh
@@ -0,0 +1,8 @@
1
2sudo ip xfrm state add src 192.168.1.10 dst 192.168.1.100 proto esp spi 0x55555555 mode tunnel reqid 100 replay-window 64 aead "rfc4106(gcm(aes))" 0x00112233445566778899aabbccddeeff00112233 128;
3
4sudo ip xfrm policy add dir out src 192.168.1.10 dst 192.168.1.100 proto udp tmpl src 192.168.1.10 dst 192.168.1.100 proto esp mode tunnel reqid 100;
5
6sudo ip xfrm state add src 192.168.1.100 dst 192.168.1.10 proto esp spi 0x55555555 mode tunnel reqid 100 replay-window 64 aead "rfc4106(gcm(aes))" 0x00112233445566778899aabbccddeeff00112233 128;
7
8sudo ip xfrm policy add dir in src 192.168.1.100 dst 192.168.1.10 proto udp tmpl src 192.168.1.100 dst 192.168.1.10 proto esp mode tunnel reqid 100;
diff --git a/ti/runtime/netapi/tools/ipsec_tools/aes_gcm.txt b/ti/runtime/netapi/tools/ipsec_tools/aes_gcm.txt
new file mode 100644
index 0000000..366162e
--- /dev/null
+++ b/ti/runtime/netapi/tools/ipsec_tools/aes_gcm.txt
@@ -0,0 +1 @@
Cipher: aes-gcm loopback sucess.
diff --git a/ti/runtime/netapi/tools/ipsec_tools/aes_xcbc.txt b/ti/runtime/netapi/tools/ipsec_tools/aes_xcbc.txt
new file mode 100644
index 0000000..e167ddc
--- /dev/null
+++ b/ti/runtime/netapi/tools/ipsec_tools/aes_xcbc.txt
@@ -0,0 +1 @@
Cipher: aes-xcbc-mac loopback sucess.
diff --git a/ti/runtime/netapi/tools/ipsec_tools/hmac-sha1_aes-cbc.txt b/ti/runtime/netapi/tools/ipsec_tools/hmac-sha1_aes-cbc.txt
new file mode 100644
index 0000000..c6f2bdf
--- /dev/null
+++ b/ti/runtime/netapi/tools/ipsec_tools/hmac-sha1_aes-cbc.txt
@@ -0,0 +1 @@
Cipher: aes-cbc, Authentication: hmac-sha1 loopback sucess.
diff --git a/ti/runtime/netapi/tools/ipsec_tools/hmac-sha256_aes-ctr.conf b/ti/runtime/netapi/tools/ipsec_tools/hmac-sha256_aes-ctr.conf
new file mode 100644
index 0000000..3696745
--- /dev/null
+++ b/ti/runtime/netapi/tools/ipsec_tools/hmac-sha256_aes-ctr.conf
@@ -0,0 +1,15 @@
1#!/mnt/host/netbench/setkey -f
2#pc->shannon
3flush;
4spdflush;
5add -4 192.168.1.10 192.168.1.100 esp 0x22222222 -m tunnel -E aes-ctr 0x00112233445566778899aabbccddeeff00112233 -A hmac-sha256 0x000102030405060708090a0b0c0d0e0f101112131415161718191A1B1C1D1E1F;
6
7spdadd 192.168.1.10 192.168.1.100 any -P out ipsec
8 esp/tunnel/192.168.1.10-192.168.1.100/require;
9
10
11add -4 192.168.1.100 192.168.1.10 esp 0x22222222 -m tunnel -E aes-ctr 0x00112233445566778899aabbccddeeff00112233 -A hmac-sha256 0x000102030405060708090a0b0c0d0e0f101112131415161718191A1B1C1D1E1F;
12
13spdadd 192.168.1.100 192.168.1.10 any -P in ipsec
14 esp/tunnel/192.168.1.100-192.168.1.10/require;
15
diff --git a/ti/runtime/netapi/tools/ipsec_tools/hmac-sha256_aes_ctr.txt b/ti/runtime/netapi/tools/ipsec_tools/hmac-sha256_aes_ctr.txt
new file mode 100644
index 0000000..27aa0b9
--- /dev/null
+++ b/ti/runtime/netapi/tools/ipsec_tools/hmac-sha256_aes_ctr.txt
@@ -0,0 +1 @@
Cipher: aes-ctr, Authentication: hmac-sha256 loopback sucess.
diff --git a/ti/runtime/netapi/tools/ipsec_tools/hmac_md5_ah.txt b/ti/runtime/netapi/tools/ipsec_tools/hmac_md5_ah.txt
new file mode 100644
index 0000000..2fb415f
--- /dev/null
+++ b/ti/runtime/netapi/tools/ipsec_tools/hmac_md5_ah.txt
@@ -0,0 +1 @@
Cipher: NULL, Autentication: hmac_md5 loopback sucess for AH mode.
diff --git a/ti/runtime/netapi/tools/ipsec_tools/sample_evm_ipsec.conf b/ti/runtime/netapi/tools/ipsec_tools/sample_evm_ipsec.conf
new file mode 100755
index 0000000..c7d46e2
--- /dev/null
+++ b/ti/runtime/netapi/tools/ipsec_tools/sample_evm_ipsec.conf
@@ -0,0 +1,83 @@
1# ipsec.conf - strongSwan IPsec configuration file
2# The following variables will have to be replaced by the automation setup:
3# %LOCAL_IP_ADDRESS% = IP address for the side where the ipsec.conf file will reside
4# %LOCAL_IP_SUBNET% = IP address or the public side NAT address for the side where the ipsec.conf file will reside
5# %CERT_FILE_PATH_NAME% = Certification file and path name. (alpha side = /home/gguser/ipsec/alphaCert.der, beta side = /etc/ipsec.d/certs/betaCert.der)
6# %LOCAL_CN% = Local network name (alpha.test.org or beta.test.org)
7# %REMOTE_CN% = Remote network name (beta.test.org or alpha.test.org)
8# %REMOTE_IP_ADDRESS% = IP address for the remote side
9# %REMOTE_IP_SUBNET% = IP address or the public side NAT address for the remote side
10# %IKE_LIFETIME% = IKE rekey lifetime (48H for 48 hours)
11# %LIFETIME% = Rekey lifetime (48H for 48 hours)"
12# %LOCAL_IPV6_ADDRESS% = Local side IPV6 address (2000::1)
13# %REMOTE_IPV6_ADDRESS% = Remote side IPV6 address (2000::2)
14# %CONNECTION_SIDE% = Connection side indicator. (Alpha for alpha side, Beta for beta side)
15# %CONNECTION_NAME% = Connection side name. (Udp, Tcp, Sctp, Link, Conn ...)
16# %PROTOCOL% = Protocol to be used for link (udp, tcp, sctp ...)
17# %ESP_ENCRYPTION% = Esp encryption to be used (aes128, aes192, 3des ...)
18# %ESP_INTEGRITY% = Esp integrity to be used (sha1, aesxcbc ...)
19
20# basic configuration
21config setup
22 strictcrlpolicy=no
23 charondebug=all
24
25# Add connections here.
26conn %default
27 left=192.168.1.50
28 leftcert=/etc/ipsec.d/certs/betaCert.der
29 leftid="C=US, O=Test, CN=beta.test.org"
30 right=192.168.1.84
31 rightid="C=US, O=Test, CN=alpha.test.org"
32 keyexchange=ikev2
33 ike=aes128-sha1-modp2048!
34 type=tunnel
35 esp=aes128-sha1-modp2048-noesn!
36 margintime=1h
37 ikelifetime=168h
38 lifetime=168h
39 reauth=no
40
41conn Beta-Conn1
42 leftsubnet=192.168.1.50/32[udp],192.168.1.51/32[udp]
43 rightsubnet=192.168.1.84/32[udp],192.168.1.85/32[udp]
44 auto=add
45
46conn Beta-Conn9
47 leftprotoport=udp
48 leftsubnet=192.168.1.51/32
49 rightprotoport=udp
50 rightsubnet=192.168.1.85/32
51 auto=add
52
53conn Beta-Conn2
54 leftprotoport=udp
55 leftsubnet=2000::3/64
56 rightprotoport=udp
57 rightsubnet=2000::1/64
58 auto=add
59
60conn Beta-Conn3
61 leftprotoport=udp
62 leftsubnet=192.168.1.50/32
63 rightprotoport=udp
64 rightsubnet=192.168.1.84/32
65 type=passthrough
66 authby=never
67 auto=add
68
69conn Beta-Conn4
70 leftprotoport=udp
71 leftsubnet=2000::3/64
72 rightprotoport=udp
73 rightsubnet=2000::1/64
74 type=passthrough
75 authby=never
76 auto=add
77
78conn Beta-Icmp1
79 leftprotoport=icmp
80 leftsubnet=192.168.1.50/32
81 rightprotoport=icmp
82 rightsubnet=192.168.1.84/32
83 auto=add
diff --git a/ti/runtime/netapi/tools/ipsec_tools/sample_pc_ipsec.conf b/ti/runtime/netapi/tools/ipsec_tools/sample_pc_ipsec.conf
new file mode 100755
index 0000000..73ee1ce
--- /dev/null
+++ b/ti/runtime/netapi/tools/ipsec_tools/sample_pc_ipsec.conf
@@ -0,0 +1,84 @@
1# ipsec.conf - strongSwan IPsec configuration file
2# The following variables will have to be replaced by the automation setup:
3# %LOCAL_IP_ADDRESS% = IP address for the side where the ipsec.conf file will reside
4# %LOCAL_IP_SUBNET% = IP address or the public side NAT address for the side where the ipsec.conf file will reside
5# %CERT_FILE_PATH_NAME% = Certification file and path name. (alpha side = /home/gguser/ipsec/alphaCert.der, beta side = /etc/ipsec.d/certs/betaCert.der)
6# %LOCAL_CN% = Local network name (alpha.test.org or beta.test.org)
7# %REMOTE_CN% = Remote network name (beta.test.org or alpha.test.org)
8# %REMOTE_IP_ADDRESS% = IP address for the remote side
9# %REMOTE_IP_SUBNET% = IP address or the public side NAT address for the remote side
10# %IKE_LIFETIME% = IKE rekey lifetime (48H for 48 hours)
11# %LIFETIME% = Rekey lifetime (48H for 48 hours)"
12# %LOCAL_IPV6_ADDRESS% = Local side IPV6 address (2000::1)
13# %REMOTE_IPV6_ADDRESS% = Remote side IPV6 address (2000::2)
14# %CONNECTION_SIDE% = Connection side indicator. (Alpha for alpha side, Beta for beta side)
15# %CONNECTION_NAME% = Connection side name. (Udp, Tcp, Sctp, Link, Conn ...)
16# %PROTOCOL% = Protocol to be used for link (udp, tcp, sctp ...)
17# %ESP_ENCRYPTION% = Esp encryption to be used (aes128, aes192, 3des ...)
18# %ESP_INTEGRITY% = Esp integrity to be used (sha1, aesxcbc ...)
19
20# basic configuration
21config setup
22 strictcrlpolicy=no
23 charondebug=all
24
25# Add connections here.
26conn %default
27 left=192.168.1.84
28 leftcert=/etc/ipsec.d/certs/alphaCert.der
29 leftid="C=US, O=Test, CN=alpha.test.org"
30 right=192.168.1.50
31 rightid="C=US, O=Test, CN=beta.test.org"
32 keyexchange=ikev2
33 ike=aes128-sha1-modp2048!
34 type=tunnel
35 esp=aes128-sha1-modp2048-noesn!
36 margintime=1h
37 ikelifetime=168h
38 lifetime=168h
39 reauth=no
40
41conn Alpha-Conn1
42 leftsubnet=192.168.1.84/32[udp],192.168.1.85/32[udp]
43 rightsubnet=192.168.1.50/32[udp],192.168.1.51/32[udp]
44 auto=add
45
46conn Alpha-Conn9
47 leftprotoport=udp
48 leftsubnet=192.168.1.85/32
49 rightprotoport=udp
50 rightsubnet=192.168.1.51/32
51 auto=add
52
53conn Alpha-Conn2
54 leftprotoport=udp
55 leftsubnet=2000::1/64
56 rightprotoport=udp
57 rightsubnet=2000::3/64
58 auto=add
59
60conn Alpha-Conn3
61 leftprotoport=udp
62 leftsubnet=192.168.1.84/32
63 rightprotoport=udp
64 rightsubnet=192.168.1.50/32
65 type=passthrough
66 authby=never
67 auto=add
68
69conn Alpha-Conn4
70 leftprotoport=udp
71 leftsubnet=2000::1/64
72 rightprotoport=udp
73 rightsubnet=2000::3/64
74 type=passthrough
75 authby=never
76 auto=add
77
78conn Alpha-Icmp1
79 leftprotoport=icmp
80 leftsubnet=192.168.1.84/32
81 rightprotoport=icmp
82 rightsubnet=192.168.1.50/32
83 auto=add
84
diff --git a/ti/runtime/netapi/tools/ipsec_tools/sectest.sh b/ti/runtime/netapi/tools/ipsec_tools/sectest.sh
new file mode 100755
index 0000000..61786e3
--- /dev/null
+++ b/ti/runtime/netapi/tools/ipsec_tools/sectest.sh
@@ -0,0 +1,50 @@
1if [ $# -ne 2 ]; then
2 echo "Usage ./sectest.sh <dest udp port> <dest ip address>"
3 exit
4fi
5sudo setkey -f setkeycleanup.conf
6sudo setkey -f setkey_hmac-sha1_aes-cbc.conf
7echo "Sending packet with hmac-sha1_aes-cbc"
8../udpif S hmac-sha1_aes-cbc.txt $1 $2
9sleep 1
10#
11echo "Cleaning up SAD entries"
12sudo setkey -f setkeycleanup.conf
13echo "Sending packet with aes_gcm"
14./aes_gcm.sh
15../udpif S aes_gcm.txt $1 $2
16sleep 1
17#
18echo "Cleaning up SAD entries"
19sudo setkey -f setkeycleanup.conf
20echo "Sending packet with aes_ccm"
21./aes_ccm.sh
22../udpif S aes_ccm.txt $1 $2
23sleep 1
24#
25echo "Cleaning up SAD entries"
26sudo setkey -f setkeycleanup.conf
27echo "Sending packet with aes_xcbc"
28sudo setkey -f setkey_aes_xcbc.conf
29../udpif S aes_xcbc.txt $1 $2
30sleep 1
31#
32echo "Cleaning up SAD entries"
33sudo setkey -f setkeycleanup.conf
34echo "Sending packet with hmac-sha256_aes-ctr"
35sudo setkey -f hmac-sha256_aes-ctr.conf
36../udpif S hmac-sha256_aes_ctr.txt $1 $2
37sleep 1
38#
39echo "Cleaning up SAD entries"
40sudo setkey -f setkeycleanup.conf
41echo "Sending packet with hmac-md5 AH mode"
42sudo setkey -f setkey_hmac-md5_ah.conf
43../udpif S hmac_md5_ah.txt $1 $2
44sleep 1
45
46sudo setkey -f setkeycleanup.conf
47
48#sudo setkey -f setkeycleanup.conf
49#sudo setkey -f setkey_3des_cbc.conf
50#./udpif S 3des_cbc.txt $1 $2
diff --git a/ti/runtime/netapi/tools/ipsec_tools/setkey_aes_xcbc.conf b/ti/runtime/netapi/tools/ipsec_tools/setkey_aes_xcbc.conf
new file mode 100644
index 0000000..915ac4c
--- /dev/null
+++ b/ti/runtime/netapi/tools/ipsec_tools/setkey_aes_xcbc.conf
@@ -0,0 +1,15 @@
1#!/mnt/host/netbench/setkey -f
2#pc->shannon
3flush;
4spdflush;
5add -4 192.168.1.10 192.168.1.100 esp 0x77777777 -m tunnel -E null -A aes-xcbc-mac 0x000102030405060708090a0b0c0d0e0f;
6
7spdadd 192.168.1.10 192.168.1.100 any -P out ipsec
8 esp/tunnel/192.168.1.10-192.168.1.100/require;
9
10
11add -4 192.168.1.100 192.168.1.10 esp 0x77777777 -m tunnel -E null -A aes-xcbc-mac 0x000102030405060708090a0b0c0d0e0f;
12
13spdadd 192.168.1.100 192.168.1.10 any -P in ipsec
14 esp/tunnel/192.168.1.100-192.168.1.10/require;
15
diff --git a/ti/runtime/netapi/tools/ipsec_tools/setkey_hmac-md5_ah.conf b/ti/runtime/netapi/tools/ipsec_tools/setkey_hmac-md5_ah.conf
new file mode 100644
index 0000000..bd05fa0
--- /dev/null
+++ b/ti/runtime/netapi/tools/ipsec_tools/setkey_hmac-md5_ah.conf
@@ -0,0 +1,15 @@
1#!/mnt/host/netbench/setkey -f
2#pc->shannon
3flush;
4spdflush;
5add -4 192.168.1.10 192.168.1.100 ah 0x44444444 -m tunnel -E null -A hmac-md5 0x000102030405060708090a0b0c0d0e0f;
6
7spdadd 192.168.1.10 192.168.1.100 any -P out ipsec
8 ah/tunnel/192.168.1.10-192.168.1.100/require;
9
10
11add -4 192.168.1.100 192.168.1.10 ah 0x44444444 -m tunnel -E null -A hmac-md5 0x000102030405060708090a0b0c0d0e0f;
12
13spdadd 192.168.1.100 192.168.1.10 any -P in ipsec
14 ah/tunnel/192.168.1.100-192.168.1.10/require;
15
diff --git a/ti/runtime/netapi/tools/ipsec_tools/setkey_hmac-sha1_aes-cbc.conf b/ti/runtime/netapi/tools/ipsec_tools/setkey_hmac-sha1_aes-cbc.conf
new file mode 100644
index 0000000..d65b144
--- /dev/null
+++ b/ti/runtime/netapi/tools/ipsec_tools/setkey_hmac-sha1_aes-cbc.conf
@@ -0,0 +1,15 @@
1#!/mnt/host/netbench/setkey -f
2#pc->shannon
3flush;
4spdflush;
5add -4 192.168.1.10 192.168.1.100 esp 0x11111111 -m tunnel -E rijndael-cbc 0x55112233445566778899aabbccddeeff00112233445566778899aabbccddeeff -A hmac-sha1 0x000102030405060708090a0b0c0d0e0f10111213;
6
7spdadd 192.168.1.10 192.168.1.100 any -P out ipsec
8 esp/tunnel/192.168.1.10-192.168.1.100/require;
9
10
11add -4 192.168.1.100 192.168.1.10 esp 0x11111111 -m tunnel -E rijndael-cbc 0x55112233445566778899aabbccddeeff00112233445566778899aabbccddeeff -A hmac-sha1 0x000102030405060708090a0b0c0d0e0f10111213;
12
13spdadd 192.168.1.100 192.168.1.10 any -P in ipsec
14 esp/tunnel/192.168.1.100-192.168.1.10/require;
15
diff --git a/ti/runtime/netapi/tools/ipsec_tools/setkeycleanup.conf b/ti/runtime/netapi/tools/ipsec_tools/setkeycleanup.conf
new file mode 100644
index 0000000..05a0dc4
--- /dev/null
+++ b/ti/runtime/netapi/tools/ipsec_tools/setkeycleanup.conf
@@ -0,0 +1,4 @@
1#!/mnt/host/netbench/setkey -f
2#pc->shannon
3flush;
4spdflush;
diff --git a/ti/runtime/netapi/tools/irqset.sh b/ti/runtime/netapi/tools/irqset.sh
new file mode 100755
index 0000000..d86b85e
--- /dev/null
+++ b/ti/runtime/netapi/tools/irqset.sh
@@ -0,0 +1,7 @@
1#!/bin/bash
2# set smp_affinity of IRQs to core slow path core 1
3DEFAULT_IRQ_MASK=1
4for I in /proc/irq/*/smp_affinity
5do
6/bin/echo $DEFAULT_IRQ_MASK > $I 2> /dev/null
7done
diff --git a/ti/runtime/netapi/tools/kernel_patches/0001-PA-Firmware-Update-and-dma-config.patch b/ti/runtime/netapi/tools/kernel_patches/0001-PA-Firmware-Update-and-dma-config.patch
new file mode 100644
index 0000000..94b50fe
--- /dev/null
+++ b/ti/runtime/netapi/tools/kernel_patches/0001-PA-Firmware-Update-and-dma-config.patch
@@ -0,0 +1,2453 @@
1From 1f8bbe608022fe8c3733d60fd235bf8ee50d9bbc Mon Sep 17 00:00:00 2001
2From: Raghu Nambiath <a0850439@gtlnx01.gt.design.ti.com>
3Date: Thu, 20 Sep 2012 14:58:28 +0000
4Subject: [PATCH] Update PA Firmware and QMSS Device memory config
5
6---
7 arch/arm/include/asm/pgtable.h | 2 +-
8 drivers/net/ethernet/ti/keystone_pa.c | 6 +-
9 firmware/Makefile | 6 +-
10 firmware/keystone/pa_pdsp02_1_2_1_2.fw.ihex | 471 -------------------------
11 firmware/keystone/pa_pdsp02_1_3_0_2.fw.ihex | 501 +++++++++++++++++++++++++++
12 firmware/keystone/pa_pdsp3_1_2_1_2.fw.ihex | 280 ---------------
13 firmware/keystone/pa_pdsp3_1_3_0_2.fw.ihex | 282 +++++++++++++++
14 firmware/keystone/pa_pdsp45_1_2_1_2.fw.ihex | 357 -------------------
15 firmware/keystone/pa_pdsp45_1_3_0_2.fw.ihex | 445 ++++++++++++++++++++++++
16 9 files changed, 1235 insertions(+), 1115 deletions(-)
17 mode change 100644 => 100755 arch/arm/include/asm/pgtable.h
18 mode change 100644 => 100755 drivers/net/ethernet/ti/keystone_pa.c
19 delete mode 100644 firmware/keystone/pa_pdsp02_1_2_1_2.fw.ihex
20 create mode 100755 firmware/keystone/pa_pdsp02_1_3_0_2.fw.ihex
21 delete mode 100644 firmware/keystone/pa_pdsp3_1_2_1_2.fw.ihex
22 create mode 100755 firmware/keystone/pa_pdsp3_1_3_0_2.fw.ihex
23 delete mode 100644 firmware/keystone/pa_pdsp45_1_2_1_2.fw.ihex
24 create mode 100755 firmware/keystone/pa_pdsp45_1_3_0_2.fw.ihex
25
26diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
27old mode 100644
28new mode 100755
29index f66626d..95bd431
30--- a/arch/arm/include/asm/pgtable.h
31+++ b/arch/arm/include/asm/pgtable.h
32@@ -105,7 +105,7 @@ extern pgprot_t pgprot_kernel;
33
34 #ifdef CONFIG_ARM_DMA_MEM_BUFFERABLE
35 #define pgprot_dmacoherent(prot) \
36- __pgprot_modify(prot, L_PTE_MT_MASK, L_PTE_MT_BUFFERABLE | L_PTE_XN)
37+ __pgprot_modify(prot, L_PTE_MT_MASK, L_PTE_MT_WRITEBACK| L_PTE_XN)
38 #define __HAVE_PHYS_MEM_ACCESS_PROT
39 struct file;
40 extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
41diff --git a/drivers/net/ethernet/ti/keystone_pa.c b/drivers/net/ethernet/ti/keystone_pa.c
42old mode 100644
43new mode 100755
44index 76426b4..1a44b6a
45--- a/drivers/net/ethernet/ti/keystone_pa.c
46+++ b/drivers/net/ethernet/ti/keystone_pa.c
47@@ -1158,11 +1158,11 @@ int pa_open(struct netcp_module_data *data, const u8 *mac_addr)
48
49 for (i = 0; i <= 5; i++) {
50 if (i <= 2)
51- ret = request_firmware(&fw, "keystone/pa_pdsp02_1_2_1_2.fw", pa_dev->dev);
52+ ret = request_firmware(&fw, "keystone/pa_pdsp02_1_3_0_2.fw", pa_dev->dev);
53 else if (i == 3)
54- ret = request_firmware(&fw, "keystone/pa_pdsp3_1_2_1_2.fw", pa_dev->dev);
55+ ret = request_firmware(&fw, "keystone/pa_pdsp3_1_3_0_2.fw", pa_dev->dev);
56 else if (i > 3)
57- ret = request_firmware(&fw, "keystone/pa_pdsp45_1_2_1_2.fw", pa_dev->dev);
58+ ret = request_firmware(&fw, "keystone/pa_pdsp45_1_3_0_2.fw", pa_dev->dev);
59 if (ret != 0) {
60 dev_err(pa_dev->dev, "cannot find firmware for pdsp %d\n", i);
61 ret = -ENODEV;
62diff --git a/firmware/Makefile b/firmware/Makefile
63index 0b37f5b..2dc4b54 100644
64--- a/firmware/Makefile
65+++ b/firmware/Makefile
66@@ -104,9 +104,9 @@ fw-shipped-$(CONFIG_TI_KEYSTONE) += keystone/sa_pdsp0_1_0_2_1.fw \
67 keystone/sa_pdsp1_1_0_2_1.fw \
68 keystone/qmss_pdsp_acc48_le_1_0_2_0.fw \
69 keystone/qmss_pdsp_acc48_be_1_0_2_0.fw \
70- keystone/pa_pdsp02_1_2_1_2.fw \
71- keystone/pa_pdsp3_1_2_1_2.fw \
72- keystone/pa_pdsp45_1_2_1_2.fw
73+ keystone/pa_pdsp02_1_3_0_2.fw \
74+ keystone/pa_pdsp3_1_3_0_2.fw \
75+ keystone/pa_pdsp45_1_3_0_2.fw
76 fw-shipped-$(CONFIG_TYPHOON) += 3com/typhoon.bin
77 fw-shipped-$(CONFIG_USB_DABUSB) += dabusb/firmware.fw dabusb/bitstream.bin
78 fw-shipped-$(CONFIG_USB_EMI26) += emi26/loader.fw emi26/firmware.fw \
79diff --git a/firmware/keystone/pa_pdsp02_1_2_1_2.fw.ihex b/firmware/keystone/pa_pdsp02_1_2_1_2.fw.ihex
80deleted file mode 100644
81index 83e12c3..0000000
82--- a/firmware/keystone/pa_pdsp02_1_2_1_2.fw.ihex
83+++ /dev/null
84@@ -1,471 +0,0 @@
85-:100000000079002184505024C4848410E5E4E41075
86-:10001000E6E4E410E7E4E410E8E4E410E9E4E410E2
87-:10002000EAE4E410EBE4E41084E3008384E3208357
88-:1000300084E3408384E3608384E3808384E3A08358
89-:1000400084E3C08384E3E0830443002464030481E5
90-:100050000444002464032981040A002464033281D7
91-:10006000040C0024640333810409002464032F81F9
92-:100070000453002464030681040500246403008102
93-:100080000406002464032B810407002464032C81EC
94-:100090000408002464033C8104510024640311819A
95-:1000A0000452002464038881040F002464038481C3
96-:1000B00080A7FF2E80F3008980F3508980FA0087A3
97-:1000C00080FA408780FA808780FAC087E5000024A4
98-:1000D000E1E001248887FF2E6805002488F4E5808C
99-:1000E000E5E51001FEE5E16EC800812488A88824BA
100-:1000F000C900082489DD8624CA4788248A488824C0
101-:10010000CB6488248B63882488F54081E500002433
102-:1001100085356081899FFF2E85000024C500082455
103-:1001200089F6858685854001FE85C56E040000241C
104-:100130006418008104010024641820810402002452
105-:1001400064184081040300246418608104040024BE
106-:1001500064188081040500246418A081E001002453
107-:10016000E1640024806A0481828DFF2E82B3A08323
108-:100170006202002442020024220200248233A08171
109-:1001800065400024454000248533AC81F4000424FC
110-:10019000F50008248000A024C000A0248020F48062
111-:1001A000F4F40401FEF4F56EF4000824F5001024C4
112-:1001B000809FFF2E80E0F486F4F44001FEF4F56E9B
113-:1001C000F480002480E0F480F480012480E0F48056
114-:1001D000F480022480E0F480F480032480E0F48042
115-:1001E00000009E209E0F02238285FF2E82A40481A0
116-:1001F000E20100248224008100FF00C900FF00D139
117-:1002000004FF01C99E010023E2000024822404812E
118-:100210009D81FF2E9B81FF2E1D17009105FF09C9AF
119-:10022000FFFF091F81356091E1E1010181356081A6
120-:1002300013FF01C9017D03110301025181A40024B0
121-:100240000092002181A800248E3381908FBB009101
122-:10025000046E00697D7D031D8F85FF2E009C0021AB
123-:100260007D7D031F6F6E6E10D08E8E10304E4E103F
124-:100270008FBB0081E10000248124048108FF03C9B1
125-:1002800081240C91030100515D5D071F00A5002131
126-:100290005D5D071DE100002481240C811DFF05C95F
127-:1002A000177D07C9027D06C900FF0AD119FF0AD1CF
128-:1002B0008501812E030503C99ECE002300B10021D4
129-:1002C0009E6A01230C7D06C97D7D061D047D04D137
130-:1002D000050400248501012F00C400217D7D041D3B
131-:1002E00003DE03519E91012300BD0021E42300247D
132-:1002F0008401002F7D7D071D00C4002104FC11C96D
133-:100300008181FF2EE1E1111F812D0081FBFB131F75
134-:10031000027D05D1D1FF04D1027D05C905FF0AC9BF
135-:10032000BFFB00579B2C08819B81FF2E008700217B
136-:1003300000EC042100C80021FBFB061F81250609F3
137-:1003400088318192817D031181E106098181251225
138-:1003500081810A1FC1082681D00824911C69026985
139-:100360007A1903D106680051C808228161082D91CD
140-:100370000101E0110101481261082D810E4A00516E
141-:100380006108269101010711212A030901012112A7
142-:100390006108268161082D910101E011034A015194
143-:1003A0002116002400EB0021210D0024010121125F
144-:1003B00061082D81E4235024446A6A1064180024E3
145-:1003C0008403002F686C035100009E20216900699E
146-:1003D0008A281881050B00516208099102020F1149
147-:1003E00002020B126208098196682091021C002407
148-:1003F0004C5605D1486C0151476C0451096B00699A
149-:10040000E423F0244406002464180024C5898910DC
150-:10041000054949108403002F536C035100009E20AE
151-:100420007676A0135656071F37370711034B03097B
152-:100430003737031296682081E4235024641800247F
153-:10044000442B2B108403002F476C035100009E2087
154-:100450000D6901693D1903D18A6818812E6C01511B
155-:100460002D6C0451E423F024641800244406002475
156-:10047000C5898910054949108403002F3A6C03513E
157-:1004800000009E200E6904698A6820816208089134
158-:1004900002020711226C030902022212620808817B
159-:1004A000E423F0246408002444060024C58989104C
160-:1004B000054949108403002F00009E200B69036941
161-:1004C0006208099102020F1102026A126208098190
162-:1004D000E423502464000024440700248403002FF4
163-:1004E000216C035100009E2006690551FBFB141F7F
164-:1004F00004FC14C98281FF2EE2E2141F822D0081C8
165-:10050000FBFB111F042400248403002F166C0351ED
166-:1005100000009E205656061F2C0830810218002429
167-:100520007676A0139668208129080B81C90812816C
168-:10053000E423502444040024640202108403002FA6
169-:10054000096C045100009E201919031D373707114B
170-:1005500037373813570826818170002489F4819039
171-:1005600000D60021D08C8C108F198091014F04018E
172-:1005700001011F11036F0168FBFB141F00009E2087
173-:10058000C14F90019039C1806119818100009E2086
174-:10059000DEDE040986F4DE908381FF2EE3E3111F83
175-:1005A0009EC6002400F70321FBFB071F96682091DD
176-:1005B00001560F110E010051035603C981F00024AA
177-:1005C00000780121035602C981E00024007801214E
178-:1005D000035600C981C000240078012181D0002485
179-:1005E00089F481900269055100D6002106970AD14D
180-:1005F0003737F81137370013D708268189F400916F
181-:1006000000D6002181973F118181060981810C1F4D
182-:1006100081811401C197060BC1C1071103C1006993
183-:1006200089E0819000D6002103C1016989E18190B0
184-:1006300000D6002103C1026989E2819000D6002121
185-:10064000003B012196682091DE37030BDEDE0409B2
186-:1006500086F4DE9000D60021FBFB001F8124009170
187-:10066000E1E1010181240081868F802E09CA0ED12B
188-:10067000CA810E1F8A80002FE1003024802108F1FA
189-:10068000C0FFFF248BC080048B1562918B81002FEB
190-:10069000040800248403002F0431002424200024B3
191-:1006A0008403002F13C9005104C908690168030BB2
192-:1006B00017011E5116011F519689802E0176050BD8
193-:1006C0001C0100515C010551A8010451FBFB121FE4
194-:1006D00004FC13C98081FF2EE0E0131F802D0081F0
195-:1006E0008483FF2E042100248403002F008700212F
196-:1006F0009689FF2ED789891010FC00C98081FF2EB2
197-:10070000E0E0001F802D008100CE01219689FF2EA0
198-:10071000D789891004FC00C98081FF2EE0E0001F0A
199-:10072000802D0081591000249EE701240028072114
200-:10073000040D00248403002F04000024C4969610A6
201-:100740008403002F03591F11DE0000241D00002424
202-:100750000B030D5137370711090310613737281381
203-:10076000FBFB0D1FDE0200240DFC07C98081FF2E5C
204-:10077000E0E0071F802D008100E701218E8FFF2E12
205-:100780008E87012F8E0F022F8E87022F0003010903
206-:10079000801500909E00C022FDDE00575959E011DF
207-:1007A0005959031200FF07C97618002496272083A1
208-:1007B0000EDE016904200024240800248403002F95
209-:1007C000091D1D106980022F067D07D17D7D071F41
210-:1007D0000504002400FF0AD18501012F00C6002175
211-:1007E0007D7D061F00C6002111DE0451087D07C96A
212-:1007F0007D7D041F04200024245800246418002454
213-:10080000440600248403002F00F8012103DE035175
214-:10081000DE37030B00640121842050246418002477
215-:10082000440600248403002F00C600210421002474
216-:10083000000902219E87002400D50321E300002443
217-:1008400007E3405900FF0AD125E3E3100502002425
218-:100850008501012FE3E30101001002218391FF2EA6
219-:10086000630000246405002468050024820000243D
220-:10087000C20010248331828482824001FE82C26ED3
221-:100880008883FF2E887900818A81FF2E8A3908812A
222-:10089000C8F80424884B0524C9FB0524895F052476
223-:1008A000CA2606248A5A0624CB7706248B8206247D
224-:1008B000CC9206248C9D0624CDC406248DCE06241D
225-:1008C000CED806248E070724CF0E06248FE60624F2
226-:1008D000D0FF0624002000240000020108D5008F6C
227-:1008E0009C81FF2E60170091030000518E85FF2E22
228-:1008F0008EBB008100009E208A81802E046A407198
229-:10090000E60400248681002F00790221817900917C
230-:10091000036A2059E2E26A1C004902214A6A200562
231-:10092000E1E14A1C817900818D91FF2E6E05002442
232-:100930007205002407FF0AD1256A6A100502002407
233-:100940008501012F806A06098D318084007902219A
234-:100950006B0000244B6A6A108B3908818D390C8535
235-:100960007D7D051F00790221DA000024808989102D
236-:10097000040D00248403002F8687802E00FF07C902
237-:10098000882718810447CE51E60100248681002F74
238-:10099000007902215A0000240F6701510F670251AC
239-:1009A0000F6703510F670451A667065157670C5133
240-:1009B0004B670A53D267085105670B5324670953E5
241-:1009C00024670551C5670751E60200248681002F80
242-:1009D0000079022100870421003E022100840421C5
243-:1009E000008404211529066981240891E1E10101AF
244-:1009F00081240881067A00C904430024C45A5A108D
245-:100A000024040024E5E6E6108403002F640000249B
246-:100A100044292910C5C9C91005090910042000245A
247-:100A200024F0002461170091020003599EE404237E
248-:100A30008403002F00C80021E42100248401002F3A
249-:100A400081240C91E1E1010181240C8100C8002185
250-:100A500004803459E60F00248681002F007902219A
251-:100A6000E60000248681002F8A87802E040000245F
252-:100A7000C42000248403002F8E87802E026A00C9C0
253-:100A80008B33A081056A01C98C33A48161010024E4
254-:100A9000E2100024812204E1056A02C98D33A88195
255-:100AA00061010024E2200024812204E1026A03C9DA
256-:100AB0008E33AC81026A04C98F33B081026A05C9E2
257-:100AC0009033B4810E6A06C9C1000124810000245C
258-:100AD000027100C981010024E200002481220CE19E
259-:100AE00081000024027101C981010024E210002468
260-:100AF00081220CE1E220002481220CE1BA6A07CFB6
261-:100B0000FCF2F21000790221E60000248681002F19
262-:100B10008A83802E04000024096A0069C0F8012439
263-:100B20000480C058E60F00248681002F007902213E
264-:100B3000C41800248403002F00060321C4140024D9
265-:100B40008403002F176A016904803C59E60F0024D2
266-:100B50007A7A001F007902218E83802E046E047140
267-:100B6000E61000247A7A001F00790221816E0509BF
268-:100B7000C16E03098181C100818100018E73818072
269-:100B8000C40800248403002F8E8F802E81810801E9
270-:100B90008EF38182C42000248403002F0079022177
271-:100BA0000E6A026904802459E60F00247A7A001F35
272-:100BB000007902218E87802E046E1071E6110024C8
273-:100BC0007A7A001F00790221816E04098181000177
274-:100BD0008EFA8180007902210D6A03690480185918
275-:100BE000E60F00247A7A001F007902218E81802E80
276-:100BF0005D5D061D056E00C95D5D061F5D5D051D21
277-:100C0000026E01C95D5D051F00790221E602002424
278-:100C10007A7A001F00790221E1000024C410002428
279-:100C20008E87802E8403002F02EB01C88EF4C180D2
280-:100C300001010101C1C11001FA011E670079022101
281-:100C40008A83802E04000024C41800248403002F0B
282-:100C5000194A0151E1000024026A00518101FF2E6E
283-:100C6000812C0C8183000F2486E28380C20400243F
284-:100C700082804F24E120602486E100F786E200E7CD
285-:100C80008483FF2E2440002404370024E5E2E21090
286-:100C90008403002FE1E14001E2E2400186E100F738
287-:100CA00086E200E7E5E2E2108403002F86E283900B
288-:100CB00000790221086A00518E8FFF2EE20008247D
289-:100CC000E1000824E1E1E2008EE0E282E2E22001BC
290-:100CD000FEE2E16E0079022104000024C410002429
291-:100CE0008403002F240C0024043300248403002FE9
292-:100CF0008EB700918E85002F00790221C054002408
293-:100D00000480C058E60F00248681002F007902215C
294-:100D10008A81802E046A2071E60E00248681002FCD
295-:100D2000007902218E8FFF2EC26A0609144A0069DB
296-:100D300004000024C41400248403002F6020002435
297-:100D4000022A0459602A03098EBF802E8EF6C282C1
298-:100D50008E8FFF2EC2C22001072A047104000024D6
299-:100D6000C42000248403002F602A04056060030966
300-:100D70008EBF802E8EF6C28200790221054A01695B
301-:100D80008EF6C282C2C220018EF6C2820079022192
302-:100D90000C4A026904000024C41400248403002FB8
303-:100DA0008483FF2E2440002404470024C50400242B
304-:100DB00085006624E5E5C2008403002F0079022146
305-:100DC000E60F00248681002F00790221C014002440
306-:100DD0000480C058E60F00248681002F007902218C
307-:100DE0008A81802E8B33B091048ACB70E613002465
308-:100DF0008681002F00790221086A00C9820004243C
309-:100E0000C20008248100A024C100A0248120828087
310-:100E100082820401FE82C26E04000024C4140024F5
311-:100E20008403002FC404002482000424EE8A0055A9
312-:100E30008E81802EC2CE0109C2C28200CE00C28045
313-:100E40008A8A01058403002F008B0321C0580024E7
314-:100E50000480C058E60F00248681002F007902210B
315-:100E60007D7D021F8A83802E246A6A10E5EBEB10D9
316-:100E7000046300248403002F04000024C418002409
317-:100E80008403002F8E8F802E24000024046200240F
318-:100E900001380024E501222C8403002F0101040104
319-:100EA00024240101FC24086704000024C420002439
320-:100EB0008403002F8E8F802E2408002404620024D7
321-:100EC00001380024E501222C8403002F01010401D4
322-:100ED00024240101FC24106700790221C090002421
323-:100EE0000480C058E60F00248681002F007902217B
324-:100EF0008A81802E8B33AC91046A6B60E6120024E9
325-:100F00008681002F00790221816A0609024B8069DF
326-:100F1000818101098A2181808181040104000024EA
327-:100F2000C41400248403002FC4200024404B040573
328-:100F30008E8F802E8EE181828403002F4040200519
329-:100F400081812001FB40204F0EBF802E0EE1818E5B
330-:100F5000007902210037030B3737071176761F110E
331-:100F600056560F111683002FC000060900000024FA
332-:100F70008E76C090046E07D1042100248403002FD4
333-:100F800000009E20056E00C9040C00248403002F7D
334-:100F9000041100248403002F036E01C900FF06D151
335-:100FA0008F2718818483FF2E24F00024042200243C
336-:100FB00044060024C58E8E10054E4E108403002F6B
337-:100FC000C0C008010000010100FF04C9040800249A
338-:100FD0008403002FE900085700DC032190D7D710C5
339-:100FE000156602690E47005161072691010107113C
340-:100FF000212703090101211261072681C1072C91D4
341-:101000008181E01103470151C1160024000504212C
342-:10101000C10D00248181C112C1072C81E42050241C
343-:1010200064180024446767108403002F6E6903511D
344-:1010300000009E2027660069872718810508005157
345-:101040006207099102020F11020208126207098168
346-:1010500058690151576904510869026924494910C6
347-:1010600004300024C58989108403002F9707249138
348-:10107000D7D749009707248109680069E420F02444
349-:101080006418002444060024C586861005464610D0
350-:101090008403002F5469035100009E20966720911D
351-:1010A0007676A0135656071F3737071102480309F3
352-:1010B0003737021296672081E420502464180024F8
353-:1010C000442828108403002F4769035100009E2004
354-:1010D00014660169876718813669015135690451C1
355-:1010E000086902692449491004300024C58989101F
356-:1010F0008403002F97072491D7D7490097072481AD
357-:10110000E420F0246418002444060024C5868610D8
358-:10111000054646108403002F3369035100009E20CA
359-:101120000E66046987672081620708910202071131
360-:10113000226903090202221262070881E420F024D6
361-:101140006408002444060024C5868610054646101F
362-:101150008403002F00009E200B660369620709913B
363-:1011600002020F110202671262070981E420502473
364-:1011700064000024440700248403002F1A690351EB
365-:1011800000009E2006660551FBFB141F04FC14C9D9
366-:101190008281FF2EE2E2141F822D0081FBFBE3120D
367-:1011A000042100248403002F0F69035100009E20B6
368-:1011B000966720917676A0135656061F2907308130
369-:1011C0009607208126070B81C6071281E420502450
370-:1011D00064180024440400248403002F026904518D
371-:1011E00000009E20D08989108F198091014F040141
372-:1011F00001011F11036F0168FBFB141F00009E20FB
373-:10120000C14F90019039C1806119818100009E20F9
374-:10121000E60C00248681002F007902218A81802E2D
375-:101220008D81FF2EC0340024C0C04001C0C0040125
376-:101230000480C058E60F00248681002F0079022127
377-:10124000817900910B6A406960E10027066020699E
378-:1012500060E2002705602069E60400248681002FF3
379-:1012600000790221606020016A6060100A80002F0E
380-:10127000046A4061E60400248681002F007902217F
381-:101280006B0100244B6A6A1004000024C41400247B
382-:101290008403002F194A0051184A01512C4A025167
383-:1012A000E60300247A7A001F00790221046A206193
384-:1012B000606A2005E1E1601E00B00421E2E26A1EDE
385-:1012C000817900818E8F802E08FF0AD1804B06091C
386-:1012D0008D318084C58B8B10254B4B10050100246C
387-:1012E0008501012F007902218B3908818D390C8508
388-:1012F0007D7D051F007902218E87802E8E87012F2C
389-:10130000C41000248403002F8E8F802E8E0F022F96
390-:10131000C42000248403002F8E87802E8E87022F06
391-:10132000044A01696D0100244D3030108DD0D01079
392-:10133000C41000248403002F8E81802E8BCECE100B
393-:10134000C40400248403002F00AB04218E87802E68
394-:101350008E87012FC41000248403002F8E8F802ECF
395-:101360008E0F022FC42000248403002F8E87802E2E
396-:101370008E87022FC41000248403002F8E81802EBC
397-:101380008BCECE10C40400248403002F00AB0421B4
398-:10139000077D07C9242408137D7D041F7D7D061F5A
399-:1013A000DE0300248403002F00C8002100009E20DB
400-:1013B0007D7D051D8B3908918D390C95804B060973
401-:1013C0008D318084C58B8B10254B4B10050100247B
402-:1013D000026B0169050200248501012F00C800216C
403-:1013E000D9D9051F28280711191928001D1D001F0C
404-:1013F000292828104980022F8685802E8900802484
405-:101400008687012F96960C01C40C00248403002FBC
406-:1014100008C608C95656011FE0FFFF2405C6E0684C
407-:101420000486E06803C7E0685656011D5656001F43
408-:1014300092F54091C40200248E85802EE3DC0524C1
409-:1014400007CEE348362EAA69350EAA69346F0369C0
410-:101450001919071FCED0D010C4C40801C9CECE10B0
411-:101460008980012F8403002F9696C400DE0100249A
412-:1014700003CED3680303002400009E2003CE9368AC
413-:101480000304002400009E2004CED268DE00002465
414-:101490000301002400009E2004CE9268DE00002498
415-:1014A0000301002400009E2004CED468DE00002446
416-:1014B0000302002400009E2004CE9468DE00002475
417-:1014C0000302002400009E2004CED568DE00002424
418-:1014D000030E002400009E2002CE95681919061FF5
419-:1014E000031000240D5D06C9800289240BCE80689C
420-:1014F0000A660169094680690826C269055D05C951
421-:1015000006060069056700690047F01103003069AD
422-:1015100037C00024DE02002400009E20FBFB051FD4
423-:1015200037280024DE02002400009E20D9D9061F9F
424-:101530008039060B8213A091088062603737081348
425-:1015400004FC0CC98181FF2EE1E10C1F812D00817B
426-:10155000DE02002400009E20393940018E80802E5A
427-:1015600089CECE1029290F11C980012F969602012C
428-:10157000C40200248403002F000D0521617D03D1E6
429-:101580008013A1918039071105C0804837100024CD
430-:10159000FBFB091FDE02002400009E2039390101F7
431-:1015A000D9D9081FFBFB011F0278006978969610B5
432-:1015B000C997060BC9C9071189173F118981012FE6
433-:1015C0008689802EE066F0114BE04069085D07C90E
434-:1015D0004986147100660F114700056146EA005103
435-:1015E00045680051E0E9002743E0205183FF3F2494
436-:1015F00083878310078300511919031FFBFB081F02
437-:1016000004FC09C98181FF2EE1E1091F812D0081C0
438-:10161000EDEAEA108685FF2E8A85FF2E860F022FBF
439-:101620008689802E8483FF2E82660F11C482020970
440-:10163000045000248403002FD79686009696C40099
441-:10164000E1E9EA00E181C102DA81C10001EA002793
442-:10165000030120695656021F009A0521036AE061C2
443-:10166000026AEF495656031F6003489003003F117A
444-:10167000DE00060B82C4C4108483FF2E0400002405
445-:10168000C41400248403002F8282C40413820071D6
446-:101690008681802E66661F110666036903462658FA
447-:1016A000C446461000A10521C482821000A1052174
448-:1016B0000266096900A7052103660169C4010024C7
449-:1016C00000A1052103660069C482821000A10521E2
450-:1016D000C446461000A105216948481049464610F5
451-:1016E0008980022F1D1D031F00009E203728002423
452-:1016F00000BE052137C80024DE02002400009E2021
453-:101700002A5604D18689802EE066F011FAE0406FF7
454-:101710008EBB0091F1F0F0100BF100517AF101272E
455-:10172000F1F17A1C8E7A04098BBA8E90FBECE96E8B
456-:10173000FAEDEA6EF94B486E6B6B01010B1A8E8065
457-:1017400000E2052181FF3F24818781108D810057B0
458-:101750000D4E6E587AF000270B7A2051F0F07A1E69
459-:101760004E4E01018EBB0081ECE9E910EDEAEA1072
460-:101770004B4848106B0100248E7A04098BBA8E8086
461-:1017800000E205217AFF00245A0100245656041F66
462-:1017900000FF07C98F0712814F070B81DE0300246A
463-:1017A0000303002400009E205656041D0D7AFF51AD
464-:1017B000CF7A205F817A04098B3A8190046B5A704A
465-:1017C0006B6B5A048B3A818000F805218EBB009127
466-:1017D000F0F07A1C024E00514E4E01058EBB008186
467-:1017E000685605CFDE04002400009E20D9D9071FCB
468-:1017F000FBFB0C1F8E83802EF0EE0C0B9081022FD2
469-:1018000096960401C40400248403002FDE01002402
470-:1018100008EE08C9006F040B0300046903030024E9
471-:1018200000009E20030006690304002400009E209F
472-:101830000310002400009E208E83802E035D07C9C4
473-:10184000126E1169114E00691919061F969606014C
474-:10185000D796CF00DE01002480210024048F806809
475-:10186000969602010303002400009E208057002466
476-:10187000048F8068969602010304002400009E20D5
477-:1018800037B800240023062137B00024DE020024EC
478-:101890000310002400009E208013A19180390711BD
479-:1018A00005C0804837100024FBFB091FDE0200241E
480-:1018B00000009E2039390101FBFB021FD9D9081F06
481-:1018C0001D1D041F0278006978969610C997060BB3
482-:1018D000C9C9071189173F118981012F8683802E7D
483-:1018E0000066F0118400606F8483FF2E04000024E2
484-:1018F000C40800248403002F8E8F802E8E0F022FA9
485-:10190000E0EEEF00E0E0F002E0E0F102E0E0F20201
486-:10191000E0E0F302E0E0F402E0E0F502E080C00283
487-:10192000DA80C0000372FF69025200695656031F35
488-:10193000EFE6E610CFCF0F118F81022F712727100E
489-:1019400051C6040B9180022F96962801D796C700A6
490-:101950006003279003003F11DE00060BC420002423
491-:101960008403002F00009E208680802E804603097D
492-:1019700080800801C40200248403002FC0020024D8
493-:1019800011C080580E80802EC40100248403002FD3
494-:1019900080800101FB6E006F056EC269FBFB0E1FAC
495-:1019A00037374013DE02002400009E200E80802E78
496-:1019B000C46E01018403002FC0C0C400C0C0010177
497-:1019C00000600621716666100680022F6103669032
498-:1019D00003013F11DE01060B00009E208681802E50
499-:1019E000716666100680022F6103669003013F1145
500-:1019F000DE01060B80460309C48008018403002F22
501-:101A00009696C40000009E208683802EC408002481
502-:101A10008403002F716666100680022F04FC09C93A
503-:101A20008181FF2EE1E1091F812D00811919031F1A
504-:101A300096960801FBFB081F6103669003013F11A6
505-:101A4000DE01060B00009E208680802E71666610E7
506-:101A50000680022F6103669003013F11DE01060B31
507-:101A600080460309C48008018403002F9696C400B1
508-:101A700000009E208013A2918039030B8080071103
509-:101A80008DC0804E37200024FBFB0B1FDE0200249C
510-:101A900000009E2039390801389696108681802EE4
511-:101AA000C40400248403002F06C60FC98483FF2EBC
512-:101AB000C4D79604045200248403002F0400002499
513-:101AC000EE8686108E81022F310200245180022F73
514-:101AD000C400002402C60DC9C480040102C60CC99A
515-:101AE000C48004018403002F8000082403868068DA
516-:101AF0000303002400009E2080DD86240386806886
517-:101B00000304002400009E200310002400009E20F7
518-:101B10008681802E8681022F310100245180022F80
519-:101B200003100024DE010024D9D9091F189696104D
520-:101B30009696080100009E20C0D73801C0C002055B
521-:101B400000FF06D1C006C090D7D72004D7D7020522
522-:101B50006103009003013F11DE00002400009E207D
523-:101B600018969610D9D90A1F8685802EEEE7E710C1
524-:101B70008E81022F310100245180022F8046020104
525-:101B800080800209969680006103669003013F11F0
526-:101B9000DE01002400009E208E85802EE68E8E10B1
527-:101BA0008681022F290400244980022F031000247B
528-:101BB000DE0100241919041F0E7D02C9F2F0F01095
529-:101BC000D39608019081FF2E9081002F8483FF2EF1
530-:101BD000C4D79604850800242424001F046100242F
531-:101BE0008403002F040000245656051F9267348199
532-:101BF0005896961096960C0100009E20FBFB0D1F38
533-:101C00003737281304FC07C98181FF2EE1E1071F44
534-:101C1000812D0081DE02002400009E20D9D90F1FF3
535-:101C200078969610C997060BC9C9071189173F11F5
536-:101C30008981012F0137F8110101030B1D010110EA
537-:101C4000C1010509810103098181C1008181000170
538-:101C50008E738190C48E8E10034E4E108403002F1D
539-:101C60009696CF00818108018EF38192868F802E17
540-:101C7000E6E6EE10E7E7EF10E8E8F010E9E9F1102A
541-:101C8000EAEAF210EBEBF310ECECF410EDEDF510EA
542-:101C9000860F022FDE0100241D1D071F00009E205D
543-:101CA0008E83802E040D00248403002FDE01002487
544-:101CB0001D0000241D1D071F868FFF2E860F022F7B
545-:101CC00015011E51052F01C91D1D031FC7CECE10C2
546-:101CD000878E8E10003907211D1D021FC7CEFF11F0
547-:101CE000878EFF118687012F8D0F3F11CD00022FA8
548-:101CF0008687FF2E012F78116901030BC1C00124D3
549-:101D0000818FC1104981060B2929011F8687022F67
550-:101D100000009E20052F02C91D1D031FC7CECE1037
551-:101D2000878E8E10004D07211D1D021FC7CEFF118B
552-:101D3000878EFF118687012F8DCFCF10CD00022F08
553-:101D40008687FF2E012F78116901030B490F0F10B1
554-:0C1D50002929001F8687022F00009E201A
555-:00000001FF
556diff --git a/firmware/keystone/pa_pdsp02_1_3_0_2.fw.ihex b/firmware/keystone/pa_pdsp02_1_3_0_2.fw.ihex
557new file mode 100755
558index 0000000..cbc4e86
559--- /dev/null
560+++ b/firmware/keystone/pa_pdsp02_1_3_0_2.fw.ihex
561@@ -0,0 +1,501 @@
562+:10000000007B00210100BEBA02000301845050248D
563+:10001000C4848410E5E4E410E6E4E410E7E4E410CA
564+:10002000E8E4E410E9E4E410EAE4E410EBE4E410CA
565+:1000300084E3008384E3208384E3408384E3608358
566+:1000400084E3808384E3A08384E3C08384E3E08348
567+:1000500004430024640304810444002464032981CC
568+:10006000040A002464033281040C002464033381F5
569+:100070000409002464032F810453002464030681CF
570+:1000800004050024640300810406002464032B811A
571+:100090000407002464032C810408002464033C81C9
572+:1000A00004510024640311810452002464038881F4
573+:1000B000040F00246403848180A7FF2E80F300894D
574+:1000C00080F3508980FA008780FA408780FA808721
575+:1000D00080FAC087E5000024E1E001248887FF2E34
576+:1000E0006805002488F4E580E5E51001FEE5E16E91
577+:1000F000C800812488A88824C900082489DD8624B2
578+:10010000CA4788248A488824CB6488248B6388243F
579+:1001100088F54081E500002485356081899FFF2EA8
580+:1001200085000024C500082489F685868585400160
581+:10013000FE85C56E040000246418008104010024BB
582+:100140006418208104020024641840810403002400
583+:10015000641860810404002464188081040500246C
584+:100160006418A081E0010024E1640024806A048115
585+:10017000828FFF2E82F3A0836202002442020024B9
586+:10018000220200248233A0816540002445400024DF
587+:100190008533AC81F4000424F50008248000A024F9
588+:1001A000C000A0248020F480F4F40401FEF4F56E75
589+:1001B000F4000824F5001024809FFF2E80E0F486D0
590+:1001C000F4F44001FEF4F56EF480002480E0F48045
591+:1001D000F480012480E0F480F480022480E0F48044
592+:1001E000F480032480E0F48000009E209E210223FE
593+:1001F0008285FF2E82A40481E201002482240081F2
594+:1002000000FF00C900FF00D104FF01C99E030023C5
595+:10021000E2000024822404819D81FF2E9B81FF2E19
596+:100220001D17009182020024C20301248237048139
597+:1002300005FF09C9FFFF091F81356091E1E1010157
598+:100240008135608113FF01C9017D03110301025152
599+:1002500081A400240097002181A800248E3381907E
600+:100260008FBB0091046E00697D7D031D8F85FF2E7D
601+:1002700000A100217D7D031F6F6E6E10D08E8E1049
602+:10028000304E4E108FBB0081E10000248124048198
603+:1002900006FF03C981240C915D5D3F115D5D011274
604+:1002A000E100002481240C8122FF05C91B7D07C9C0
605+:1002B000027D06C900FF0AD11EFF0AD18501812EE9
606+:1002C000030503C99ED6002300B400219E750123B7
607+:1002D000107D06C97D7D061D047D04D10504002422
608+:1002E0008501012F00CC00217D7D041D075D00D11B
609+:1002F00003DE03519E9C012300C40021E42300245B
610+:100300008401002F00C400215D5D001D9E75012346
611+:100310007D7D071D00CC0021F45D00D704FC11C9D0
612+:100320008181FF2EE1E1111F812D0081FBFB141F54
613+:10033000027D05D1D4FF04D1027D05C905FF0AC99C
614+:10034000BCFB00579B2C08819B81FF2E008C002159
615+:100350000006052100D00021FBFB081F81250609AE
616+:1003600088318192817D031181E106098181251205
617+:1003700081810A1FC1082681D008249179082F9114
618+:100380001C6902697C1903D106680051C8082281E2
619+:1003900061082D910101E0110101481261082D81D0
620+:1003A0000E4A00516108269101010711212A030913
621+:1003B000010121126108268161082D910101E011DE
622+:1003C000034A01512116002400F40021210D0024CC
623+:1003D0000101211261082D81E4235024446A6A102E
624+:1003E000641800248403002F6A6C035100009E20CF
625+:1003F00023690069025D06C95F1903D18A28188143
626+:10040000050B00516208099102020F1102020B1242
627+:100410006208098196682091021C00244C5605D17F
628+:10042000486C0151476C0451096B0069E423F024C6
629+:100430004406002464180024C58989100549491020
630+:100440008403002F536C035100009E207676A01386
631+:100450005656071F37370711034B03093737031267
632+:1004600096682081E423502464180024442B2B1028
633+:100470008403002F476C035100009E200D69016921
634+:100480003D1903D18A6818812E6C01512D6C0451DD
635+:10049000E423F0246418002444060024C58989104C
636+:1004A000054949108403002F3A6C035100009E2037
637+:1004B0000E6904698A6820816208089102020711A6
638+:1004C000226C03090202221262080881E423F0244C
639+:1004D0006408002444060024C58989100549491090
640+:1004E0008403002F00009E200B69036962080991B4
641+:1004F00002020F1102026A1262080981E4235024E9
642+:1005000064000024440700248403002F216C03515D
643+:1005100000009E2006690551FBFB151F04FC14C951
644+:100520008281FF2EE2E2141F822D0081FBFB121F4D
645+:10053000042400248403002F166C035100009E2025
646+:100540005656061F2C083081021800247676A01318
647+:100550009668208129080B81C9081281E423502460
648+:1005600044040024640202108403002F096C045127
649+:1005700000009E201919031D37370711373738132C
650+:10058000570826818170002489F4819000E00021C1
651+:10059000D08C8C108F198091014F040101011F1123
652+:1005A000036F0168FBFB151F00009E20C14F9001E7
653+:1005B0009039C1806119818100009E20DEDE04092E
654+:1005C00086F4DE908381FF2EE3E3121F9ECE00248B
655+:1005D00000100421FBFB091F9668209101560F11A2
656+:1005E0000E010051035603C981F00024008301214C
657+:1005F000035602C981E0002400830121035600C98B
658+:1006000081C000240083012181D0002489F48190DD
659+:100610000269055100DE002106970AD13737F8112B
660+:1006200037370013D708268189F4009100DE0021B6
661+:1006300081973F118181060981810C1F81811401FD
662+:10064000C197060BC1C1071103C1006989E0819000
663+:1006500000DE002103C1016989E1819000DE0021F3
664+:1006600003C1026989E2819000DE00210046012178
665+:1006700096682091DE37030BDEDE040989F4DE90F4
666+:1006800000DE0021FBFB001F81240091E1E101015C
667+:1006900081240081868F802E12CA0ED1CA810E1F3E
668+:1006A0008A80002F017D03110E010069E1003024D2
669+:1006B000802108F1C0FFFF248BC080048035609149
670+:1006C000058B644904FF09C9FFFF091FE0E0010130
671+:1006D00080356081CB8080109AC0C0108B81002F44
672+:1006E000040800248403002F043100242420002463
673+:1006F0008403002F13C9005104C908690168030B62
674+:1007000013011E5112011F519689802E0176050B8F
675+:10071000180100515A010551A8010451FBFB131F98
676+:1007200004FC13C98081FF2EE0E0131F802D00819F
677+:100730008483FF2E042100248403002F008C0021D9
678+:100740009688FF2ED789891000DE01219688FF2E1A
679+:10075000D789891004FC00C98081FF2EE0E0001FCA
680+:10076000802D0081591000249EF2012400A0072151
681+:10077000040D00248403002F04000024C496961066
682+:100780008403002F03591F11DE0000241D000024E4
683+:1007900006030D5137370711040310615D5D001F1B
684+:1007A000DE02002400F401218E8FFF2E8E87012FA0
685+:1007B0008E0F022F8E87022F0003010980150090F3
686+:1007C0009E00C022FDDE00575959E011595903120D
687+:1007D00000FF07C976180024962720830EDE0169E2
688+:1007E00004200024240800248403002F091D1D1068
689+:1007F0006980022F067D07D17D7D071F0504002437
690+:1008000000FF0AD18501012F00CE00217D7D061F4A
691+:1008100000CE002112DE0451135D00D1087D07C90E
692+:100820007D7D041F04200024245800246418002423
693+:10083000440600248403002F0003022103DE035139
694+:10084000DE37030B006F012184205024641800243C
695+:10085000440600248403002F00CE0021042100243C
696+:10086000001502217D7D041F04200024240800249B
697+:100870008403002FE67D07D700CE00219E8C002444
698+:1008800000EE0321E300002407E3405900FF0AD1F2
699+:1008900025E3E310050200248501012FE3E30101B4
700+:1008A000002202218391FF2E6300002464050024AE
701+:1008B0006805002482000024C20010248331828451
702+:1008C00082824001FE82C26E8883FF2E8879008179
703+:1008D0008A81FF2E8A390881C81F05248883052450
704+:1008E000C920062489970524CA4B06248ACE0624EB
705+:1008F000CBEE06248BF90624CC0907248C1407249C
706+:10090000CD3B07248D450724CE4F07248E7E072438
707+:10091000CF3306248F5D0724D076072400200024DF
708+:100920000000020108D5008F9C81FF2E6017009106
709+:10093000030000518E85FF2E8EBB008100009E209B
710+:100940008A81802E046A4071E60400248681002F8B
711+:10095000008D022181790091036A2059E2E26A1C2C
712+:10096000005B02214A6A2005E1E14A1C8D91FF2EBD
713+:100970006E050024720500244EDE0024097D07D197
714+:100980008179008100FF0AD1256A6A1005020024DE
715+:100990008501012F806A06098D318084008D022136
716+:1009A0006B0000244B6A6A108B3908818D390C85E5
717+:1009B0007D7D051F008D0221DA00002480898910C9
718+:1009C000040D00248403002F8687802E00FF07C9B2
719+:1009D000882718810447CE51E60100248681002F24
720+:1009E000008D02215A0000240F6701510F67025148
721+:1009F0000F6703510F670451AB6706515C670C51D9
722+:100A000050670A53D76708510A670B532967095380
723+:100A100024670551CA670751E60200248681002F2A
724+:100A2000008D022100A0042100500221009D04211C
725+:100A3000009D04211529066981240891E1E1010145
726+:100A400081240881067A00C904430024C45A5A103C
727+:100A500024040024E5E6E6108403002F640000244B
728+:100A600044292910C5C9C91005090910042000240A
729+:100A700024F0002461170091020003599EFE042314
730+:100A80008403002F00D00021E42100248401002FE2
731+:100A900081240C91E1E1010181240C8100D000212D
732+:100AA00004803859E60F00248681002F008D022132
733+:100AB000E60000248681002F8A87802E040000240F
734+:100AC000C42000248403002F8E8B802E026A00C96C
735+:100AD0008B33A081056A01C98C33A4816101002494
736+:100AE000E2100024812204E1056A02C98D33A88145
737+:100AF00061010024E2200024812204E1026A03C98A
738+:100B00008E33AC81026A04C98F33B081026A05C991
739+:100B10009033B481136A06C99233BC81C1000124A9
740+:100B200081000024027100C90101071F027102C97E
741+:100B30000101061FE200002481220CE18100002453
742+:100B4000027101C90101071F027103C90101061FDA
743+:100B5000E210002481220CE1E220002481220CE139
744+:100B6000B56A07CFFCF3F310008D0221E6000024E4
745+:100B70008681002F8A83802E04000024096A006980
746+:100B8000C0F801240480C058E60F00248681002F9D
747+:100B9000008D0221C41800248403002F001F0321AC
748+:100BA000C41400248403002F176A016904803C598F
749+:100BB000E60F00247A7A001F008D02218E83802E9A
750+:100BC000046E0471E61000247A7A001F008D022161
751+:100BD000816E0509C16E03098181C1008181000117
752+:100BE0008E738180C40800248403002F8E8F802E92
753+:100BF000818108018EF38182C42000248403002FA8
754+:100C0000008D02210E6A026904802459E60F002437
755+:100C10007A7A001F008D02218E87802E046E10715B
756+:100C2000E61100247A7A001F008D0221816E0409EA
757+:100C3000818100018EFA8180008D02210D6A036995
758+:100C400004801859E60F00247A7A001F008D0221D3
759+:100C50008E81802E5D5D041D056E00C95D5D041FE3
760+:100C60005D5D051D026E01C95D5D051F008D0221E0
761+:100C7000E60200247A7A001F008D0221E1000024A0
762+:100C8000C41000248E87802E8403002F02EB01C83D
763+:100C90008EF4C18001010101C1C11001FA011E677A
764+:100CA000008D02218A83802E04000024C4180024B1
765+:100CB0008403002F194A0151E1000024026A005107
766+:100CC0008101FF2E812C0C8183000F2486E283801A
767+:100CD000C204002482804F24E120602486E100F7D2
768+:100CE00086E200E78483FF2E24400024043700249A
769+:100CF000E5E2E2108403002FE1E14001E2E240017D
770+:100D000086E100F786E200E7E5E2E2108403002FC7
771+:100D100086E28390008D0221086A00518E8FFF2E9B
772+:100D2000E2000824E1000824E1E1E2008EE0E28232
773+:100D3000E2E22001FEE2E16E008D022104000024C7
774+:100D4000C41000248403002F240C00240433002446
775+:100D50008403002F8EB700918E85002F008D022115
776+:100D6000C05400240480C058E60F00248681002F60
777+:100D7000008D02218A81802E046A2071E60E0024F3
778+:100D80008681002F008D02218E8FFF2EC26A0609F8
779+:100D9000144A006904000024C41400248403002FB2
780+:100DA00060200024022A0459602A03098EBF802E85
781+:100DB0008EF6C2828E8FFF2EC2C22001072A0471D6
782+:100DC00004000024C42000248403002F602A0405AA
783+:100DD000606003098EBF802E8EF6C282008D0221D4
784+:100DE000054A01698EF6C282C2C220018EF6C28215
785+:100DF000008D02210C4A026904000024C41400245E
786+:100E00008403002F8483FF2E244000240447002401
787+:100E1000C504002485006624E5E5C2008403002F94
788+:100E2000008D0221E60F00248681002F008D022113
789+:100E3000C01400240480C058E60F00248681002FCF
790+:100E4000008D02218A81802E8B33B091048ACB7071
791+:100E5000E61300248681002F008D0221086A00C954
792+:100E600082000424C20008248100A024C100A02420
793+:100E70008120828082820401FE82C26E04000024EE
794+:100E8000C41400248403002FC4040024820004241A
795+:100E9000E98A00558E81802EC2CE0109C2C282002D
796+:100EA000CE00C2808A8A01058403002F00A403219A
797+:100EB000C05800240480C058E60F00248681002F0B
798+:100EC000008D02217D7D021F8A83802E246A6A1094
799+:100ED000E5EBEB10046300248403002F04000024DE
800+:100EE000C41800248403002F8E8F802E2400002439
801+:100EF0000462002401380024E501222C8403002F21
802+:100F00000101040124240101FC24086704000024D9
803+:100F1000C42000248403002F8E8F802E24080024F8
804+:100F20000462002401380024E501222C8403002FF0
805+:100F30000101040124240101FC241067008D022119
806+:100F4000C09000240480C058E60F00248681002F42
807+:100F5000008D02218A81802E8B33AC91046A6B60F4
808+:100F6000E61200248681002F008D0221816A060985
809+:100F7000024B8069818101098A218180818104017C
810+:100F800004000024C41400248403002FC42000247F
811+:100F9000404B04058E8F802E8EE181828403002FCA
812+:100FA0004040200581812001FB40204F0EBF802E54
813+:100FB0000EE1818E008D02210037030B37370711B8
814+:100FC00076761F1156560F111683002FC0000609A2
815+:100FD000000000248E76C090046E07D10421002406
816+:100FE0008403002F00009E20056E00C9040C00241D
817+:100FF0008403002F041100248403002F036E01C911
818+:1010000000FF06D18F2718818483FF2E24F000244F
819+:101010000422002444060024C58E8E10054E4E1076
820+:101020008403002FC0C008010000010100FF04C9B3
821+:10103000040800248403002FE900085700F5032169
822+:1010400090D7D710156602690E47005161072691A7
823+:1010500001010711212703090101211261072681DE
824+:10106000C1072C918181E01103470151C116002471
825+:10107000001E0421C10D00248181C112C1072C81F1
826+:10108000E420502464180024446767108403002F70
827+:101090006E69035100009E2027660069872718812A
828+:1010A000050800516207099102020F11020208129D
829+:1010B0006207098158690151576904510869026939
830+:1010C0002449491004300024C58989108403002F65
831+:1010D00097072491D7D749009707248109680069A9
832+:1010E000E420F0246418002444060024C5868610F9
833+:1010F000054646108403002F5469035100009E20CA
834+:10110000966720917676A0135656071F373707113A
835+:10111000024803093737021296672081E4205024E1
836+:1011200064180024442828108403002F47690351C1
837+:1011300000009E2014660169876718813669015195
838+:1011400035690451086902692449491004300024B2
839+:10115000C58989108403002F97072491D7D74900A8
840+:1011600097072481E420F024641800244406002416
841+:10117000C5868610054646108403002F3369035147
842+:1011800000009E200E66046987672081620708912F
843+:101190000202071122690309020222126207088172
844+:1011A000E420F0246408002444060024C586861048
845+:1011B000054646108403002F00009E200B6603693D
846+:1011C0006207099102020F11020267126207098188
847+:1011D000E420502464000024440700248403002FEA
848+:1011E0001A69035100009E2006660551FBFB151F7E
849+:1011F00004FC14C98281FF2EE2E2141F822D0081BB
850+:10120000FBFBE312042100248403002F0F69035128
851+:1012100000009E20966720917676A0135656061FF2
852+:10122000290730819607208126070B81C607128186
853+:10123000E420502464180024440400248403002F74
854+:101240000269045100009E20D08989108F19809175
855+:10125000014F040101011F11036F0168FBFB151F02
856+:1012600000009E20C14F90019039C1806119818199
857+:1012700000009E20E60C00248681002F008D0221B4
858+:101280008A81802E8D81FF2EC0340024C0C0400191
859+:10129000C0C004010480C058E60F00248681002FDE
860+:1012A000008D0221817900910B6A406960E100277D
861+:1012B0000660206960E2002705602069E6040024DA
862+:1012C0008681002F008D0221606020016A6060101D
863+:1012D0000A80002F046A4061E60400248681002F02
864+:1012E000008D02216B0100244B6A6A100400002467
865+:1012F000C41400248403002F1A4A0051194A0151D2
866+:101300002D4A0251E60300247A7A001F008D022143
867+:10131000046A2061606A2005E1E1601E00C90421C1
868+:10132000E2E26A1E8E8F802E0A7D07D181790081CC
869+:1013300000FF0AD1804B06098D318084C58B8B104C
870+:10134000254B4B10050100248501012F008D022142
871+:101350008B3908818D390C857D7D051F008D02211B
872+:101360008E87802E8E87012FC41000248403002FC7
873+:101370008E8F802E8E0F022FC42000248403002F16
874+:101380008E87802E8E87022F044A01696D0100240A
875+:101390004D3030108DD0D010C41000248403002FA5
876+:1013A0008E81802E8BCECE10C40400248403002FA7
877+:1013B00000C404218E87802E8E87012FC410002444
878+:1013C0008403002F8E8F802E8E0F022FC4200024C6
879+:1013D0008403002F8E87802E8E87022FC410002456
880+:1013E0008403002F8E81802E8BCECE10C404002467
881+:1013F0008403002F00C40421077D07C92424081397
882+:101400007D7D041F7D7D061FDE0300248403002FE5
883+:1014100000D0002100009E207D7D051D8B390891A4
884+:101420008D390C95804B06098D318084C58B8B10CE
885+:10143000254B4B1005010024026B015105020024CD
886+:101440008501012F81790091064B2059036B0151D1
887+:10145000E2E24B1C001D0521E2E24B1E001D0521AE
888+:101460004B4B2005036B0151E1E14B1C001D052195
889+:10147000E1E14B1E8179008100D00021D9D9051FFF
890+:10148000282807111919280002280051D7D7040568
891+:101490001D1D001F292828104980022F8685802EB7
892+:1014A000890080248687012F96960C01C40C0024A5
893+:1014B0008403002F08C608C95656011FE0FFFF2409
894+:1014C00005C6E0680486E06803C7E0685656011D5B
895+:1014D0005656001F92F54091C40200248E85802E3E
896+:1014E000E3DC052416CEE348452EAA69440EAA691A
897+:1014F000436F03690F5D06C90ECE2E590DD74051BB
898+:1015000091D7D7109113BC91D0198091011004018B
899+:1015100001011F1103300168FBFB151F008005212D
900+:10152000C11090019139C18061198181008005212C
901+:101530001919071FCED0D010C4C40801C9CECE10CF
902+:101540008980012F8403002F9696C400DE010024B9
903+:1015500003CED3680303002400009E2003CE9368CB
904+:101560000304002400009E2004CED268DE00002484
905+:101570000301002400009E2004CE9268DE000024B7
906+:101580000301002400009E2004CED468DE00002465
907+:101590000302002400009E2004CE9468DE00002494
908+:1015A0000302002400009E2004CED568DE00002443
909+:1015B000030E002400009E2002CE95681919061F14
910+:1015C000031000240D5D04C9800289240BCE8068BD
911+:1015D0000A660169094680690826C269055D05C970
912+:1015E00006060069056700690047F01103003069CD
913+:1015F00037C00024DE02002400009E20FBFB071FF2
914+:1016000037280024DE02002400009E20D9D9061FBE
915+:101610008039060B8213A091088062603737081367
916+:1016200004FC0CC98181FF2EE1E10C1F812D00819A
917+:10163000DE02002400009E20393940018E80802E79
918+:1016400089CECE1029290F11C980012F969602014B
919+:10165000C40200248403002F003605214C7D03D1F1
920+:101660008013A1918039071105C0804837100024EC
921+:10167000FBFB0B1FDE02002400009E203939010114
922+:10168000D9D9081FFBFB011F027D00D1FBFB021F04
923+:101690000278006978969610C997060BC9C9071198
924+:1016A00089173F118981012F8689802EE066F0110C
925+:1016B00034E04069085D07C93286147100660F1175
926+:1016C000300005612FEA00512E680051E0E9002743
927+:1016D0002CE0205183FF3F24838783100783005130
928+:1016E0001919031FFBFB0A1F04FC09C98181FF2E86
929+:1016F000E1E1091F812D0081EDEAEA108685FF2EC8
930+:101700008A85FF2E860F022F8689802E8483FF2EE6
931+:1017100082660F11C4820209045000248403002F42
932+:10172000D79686009696C400E1E9EA00E181C102FD
933+:10173000DA81C10001EA0027030120695656021F21
934+:1017400000D40521036AE061026AEF495656031F7F
935+:101750006003489003003F11DE00060B04000024E4
936+:101760008403002F69484810494646108980022F9B
937+:101770001D1D031F00009E203728002400E10521C5
938+:1017800037C80024DE02002400009E202C5604D11D
939+:101790008689802EE066F011FAE0406F81FF3F24D9
940+:1017A0008187811002810051FBFB0A1F8EBB0091D3
941+:1017B000F1F0F0100BF100517AF10127F1F17A1CF0
942+:1017C0008E7A04098BBA8E90FBECE96EFAEDEA6E24
943+:1017D000F94B486E6B6B01010B1A8E8000070621D6
944+:1017E000A0FB0ACF0D4E6E587AF000270B7A2051DD
945+:1017F000F0F07A1E4E4E01018EBB0081ECE9E9103B
946+:10180000EDEAEA104B4848106B0100248E7A040977
947+:101810008BBA8E80000706217AFF00245A0100242B
948+:101820005656041F00FF07C98F0712814F070B810F
949+:10183000DE0300240303002400009E205656041DEE
950+:101840000D7AFF51CD7A205F817A04098B3A81901D
951+:10185000046B5A706B6B5A048B3A8180001D062111
952+:101860008EBB0091F0F07A1C024E00514E4E0105E5
953+:101870008EBB00817B5605CFDE04002400009E2035
954+:10188000D9D9071FFBFB0E1F8E83802EF0EE0C0BA9
955+:101890009081022F96960401C40400248403002F33
956+:1018A000DE01002408EE08C9006F040B0300046980
957+:1018B0000303002400009E200300066903040024A3
958+:1018C00000009E200310002400009E208E83802EA6
959+:1018D000035D07C9126E1169114E00691919061FBF
960+:1018E00096960601D796CF00DE01002480210024C1
961+:1018F000048F8068969602010303002400009E2056
962+:1019000080570024048F8068969602010304002407
963+:1019100000009E2037B800240048062137B000247C
964+:10192000DE0200240310002400009E20445605D14E
965+:101930008683802E0066F0119200606F8483FF2EF4
966+:1019400004000024C40800248403002F8E8F802EFE
967+:101950008E0F022F4B7D03C9395604D10827005141
968+:1019600007272B5106273B5105273C5103272C51B4
969+:10197000DE020024005F0621FBFB0A1F8096600147
970+:101980000CDE0251800680900820005107202B5168
971+:1019900006203B5105203C5103202C51DE0200243F
972+:1019A000006A0621FBFB0A1F808000000060062100
973+:1019B000E1F1F1108EBB0091F1F0F0100AF100514D
974+:1019C0007AF10127F1F17A1C8E7A04098BBA8E9094
975+:1019D000FBECE16EFAEDF56E6B6B01010B1A8E807C
976+:1019E0000087062127FB0AC90C4E6E587AF00027A3
977+:1019F0000A7A2051F0F07A1E4E4E01018EBB008112
978+:101A0000ECE1E110EDF5F5106B0100248E7A04098C
979+:101A10008BBA8E80008706217AFF00245A010024A9
980+:101A20005656041F00FF07C98F0712814F070B810D
981+:101A3000DE0300240304002400009E205656041DEB
982+:101A40000D7AFF514D7A205F817A04098B3A81909B
983+:101A5000046B5A706B6B5A048B3A8180009D06218F
984+:101A60008EBB0091F0F07A1C024E00514E4E0105E3
985+:101A70008EBB0081035605C9DE04002400009E20B1
986+:101A80008E8F802E8013A1918039071105C0804868
987+:101A900037100024FBFB0B1FDE02002400009E20F9
988+:101AA00039390101FBFB031F027D00D1FBFB041F41
989+:101AB000D9D9081F1D1D041F027800697896961059
990+:101AC000C997060BC9C9071189173F118981012FD1
991+:101AD000E0EEEF00E0E0F002E0E0F102E0E0F20230
992+:101AE000E0E0F302E0E0F402E0E0F502E080C002B2
993+:101AF000DA80C0000372FF69025200695656031F64
994+:101B0000EFE6E610CFCF0F118F81022F712727103C
995+:101B100051C6040B9180022F96962801D796C700D4
996+:101B20006003279003003F11DE00060BC420002451
997+:101B30008403002F00009E208680802E80460309AB
998+:101B40008080080196968000C40200248403002F40
999+:101B5000C00200240866005107662B5106663B51FF
1000+:101B600005663C5103662C51DE02002400DD06218F
1001+:101B7000FBFB0A1F0BC080580E80802EC40100247E
1002+:101B80008403002FC0C00101FB6E006F0E80802E09
1003+:101B9000C46E01018403002FC0C0C40000DD062113
1004+:101BA000716666100680022F6103669003013F1183
1005+:101BB000DE01060B00009E208681802E7166661075
1006+:101BC0000680022F6103669003013F11DE01060BC0
1007+:101BD00080460309C48008018403002F9696C40040
1008+:101BE00000009E208683802EC40800248403002FDA
1009+:101BF000716666100680022F04FC09C98181FF2EE0
1010+:101C0000E1E1091F812D00811919031F9696080132
1011+:101C1000FBFB0A1F6103669003013F11DE01060B07
1012+:101C200000009E208680802E716666100680022F3E
1013+:101C30006103669003013F11DE01060B8046030934
1014+:101C4000C48008018403002F9696C40000009E20E3
1015+:101C50008013A2918039030B8080071191C0804EC0
1016+:101C600037200024FBFB0D1FDE02002400009E2015
1017+:101C700039390801389696108681802EC4040024D4
1018+:101C80008403002F06C60FC98483FF2EC4D7960491
1019+:101C9000045200248403002F04000024EE868610E2
1020+:101CA0008E81022F310200245180022FC4000024B3
1021+:101CB00002C60DC9C480040102C60CC9C480040157
1022+:101CC0008403002F80000824038680680303002417
1023+:101CD00000009E2080DD86240386806803040024A3
1024+:101CE00000009E200310002400009E208681802E8C
1025+:101CF0008681022F310100245180022F031000241D
1026+:101D0000DE010024D9D9091F18969610969608016D
1027+:101D100000009E20C0D73801C0C0020500FF06D1D8
1028+:101D2000C006C090D7D72004D7D702056103009022
1029+:101D300003013F11DE00002400009E20189696103B
1030+:101D4000D9D90A1F8685802EEEE7E7108E81022FF3
1031+:101D5000310100245180022F804602018080020957
1032+:101D6000969680006103669003013F11DE01002416
1033+:101D700000009E208E85802EE68E8E108681022F9A
1034+:101D8000290400244980022F03100024DE010024CE
1035+:101D90001919041F0E7D02C9F2F0F010D396080144
1036+:101DA0009081FF2E9081002F8483FF2EC4D796044C
1037+:101DB000850800242424001F046100248403002FCC
1038+:101DC000040000245656051F9267348158969610D9
1039+:101DD00096960C0100009E20FBFB0F1F373728133F
1040+:101DE00004FC07C98181FF2EE1E1071F812D0081DD
1041+:101DF000DE02002400009E20D9D90F1F789696108D
1042+:101E0000FBFB051FC997060BC9C9071189173F11AD
1043+:101E10008981012F0137F8110101030B1D01011008
1044+:101E2000C1010509810103098181C100818100018E
1045+:101E30008E738190C48E8E10034E4E108403002F3B
1046+:101E40009696CF00818108018EF38192868F802E35
1047+:101E5000E6E6EE10E7E7EF10E8E8F010E9E9F11048
1048+:101E6000EAEAF210EBEBF310ECECF410EDEDF51008
1049+:101E7000860F022FDE0100241D1D071F00009E207B
1050+:101E8000FBFB061F8E83802E040D00248403002F8D
1051+:101E9000DE0100241D0000241D1D071F868FFF2E5C
1052+:101EA000860F022F15011E51052F01C91D1D031F8D
1053+:101EB000C7CECE10878E8E1000B207211D1D021FC7
1054+:101EC000C7CEFF11878EFF118687012F8D0F3F111F
1055+:101ED000CD00022F8687FF2E012F78116901030B99
1056+:101EE000C1C00124818FC1104981060B2929011F1E
1057+:101EF0008687022F00009E20052F02C91D1D031F8B
1058+:101F0000C7CECE10878E8E1000C607211D1D021F62
1059+:101F1000C7CEFF11878EFF118687012F8DCFCF107F
1060+:101F2000CD00022F8687FF2E012F78116901030B48
1061+:101F3000490F0F102929001F8687022F00009E20BD
1062+:00000001FF
1063diff --git a/firmware/keystone/pa_pdsp3_1_2_1_2.fw.ihex b/firmware/keystone/pa_pdsp3_1_2_1_2.fw.ihex
1064deleted file mode 100644
1065index e6caf4f..0000000
1066--- a/firmware/keystone/pa_pdsp3_1_2_1_2.fw.ihex
1067+++ /dev/null
1068@@ -1,280 +0,0 @@
1069-:100000000079002184505024C4848410E5E4E41075
1070-:10001000E6E4E410E7E4E410E8E4E410E9E4E410E2
1071-:10002000EAE4E410EBE4E41084E3008384E3208357
1072-:1000300084E3408384E3608384E3808384E3A08358
1073-:1000400084E3C08384E3E0830443002464030481E5
1074-:100050000444002464032981040A002464033281D7
1075-:10006000040C0024640333810409002464032F81F9
1076-:100070000453002464030681040500246403008102
1077-:100080000406002464032B810407002464032C81EC
1078-:100090000408002464033C8104510024640311819A
1079-:1000A0000452002464038881040F002464038481C3
1080-:1000B00080A7FF2E80F3008980F3508980FA0087A3
1081-:1000C00080FA408780FA808780FAC087E5000024A4
1082-:1000D000E1E001248887FF2E6805002488F4E5808C
1083-:1000E000E5E51001FEE5E16EC800812488A88824BA
1084-:1000F000C900082489DD8624CA4788248A488824C0
1085-:10010000CB6488248B63882488F54081E500002433
1086-:1001100085356081899FFF2E85000024C500082455
1087-:1001200089F6858685854001FE85C56E040000241C
1088-:100130006418008104010024641820810402002452
1089-:1001400064184081040300246418608104040024BE
1090-:1001500064188081040500246418A081E001002453
1091-:10016000E1640024806A0481828DFF2E82B3A08323
1092-:100170006202002442020024220200248233A08171
1093-:1001800065400024454000248533AC81F4000424FC
1094-:10019000F50008248000A024C000A0248020F48062
1095-:1001A000F4F40401FEF4F56EF4000824F5001024C4
1096-:1001B000809FFF2E80E0F486F4F44001FEF4F56E9B
1097-:1001C000F480002480E0F480F480012480E0F48056
1098-:1001D000F480022480E0F480F480032480E0F48042
1099-:1001E00000009E209E5B01238285FF2E82A4048155
1100-:1001F000E20100248224008100FF00C900FF00D139
1101-:1002000004FF01C99E010023E2000024822404812E
1102-:100210009D81FF2E9B81FF2E5D17009103FB0051F6
1103-:100220009B2C08819B81FF2EFDFF04CF8124009130
1104-:10023000E1E1010181240081868F802E03CA0ED165
1105-:10024000CAE10E1F868F002F09C9006904FC13C97B
1106-:100250008081FF2EE0E0131F802D008137370711CA
1107-:1002600037375813FBFB1D1F00FA00210408002438
1108-:100270008403002F04310024242000248403002F51
1109-:100280009689802E0176050B0B0100513301055133
1110-:100290009101045304FC0BC98081FF2EE0E00B1F89
1111-:1002A000802D0081FBFB1C1F042100248403002FF0
1112-:1002B0000087002103591F11020316513737071118
1113-:1002C000040D00248403002F04000024C49696101B
1114-:1002D0008403002FDE00002402030B6903150024B1
1115-:1002E00002031071090316713737071137372813C6
1116-:1002F000DE02002409FC08C98081FF2EE0E0081F0F
1117-:10030000802D008100C600210003010980150090A6
1118-:100310009E00C022FDDE00575959E01159590312C1
1119-:1003200000FF07C99627208305DE016900FF0BD176
1120-:100330009E8700240BFF0CD100DD0021DE37030B6C
1121-:10034000DEDE040986F4DE908381FF2EE3E31C1FCA
1122-:100350009E87002400CF03219E87002400AD032147
1123-:100360008687812E8381FF2EE3E31C1F9E87002456
1124-:1003700000CF03218687812E04970AD137370711D2
1125-:100380003737301300FA002181173F1181810609A8
1126-:1003900081810C1F81811401C197060BC1C1071116
1127-:1003A0008381FF2EE3E31C1F03C1006986E0819077
1128-:1003B00000CF032103C1016986E1819000CF0321B1
1129-:1003C00003C1026986E2819000CF0321373707110C
1130-:1003D0003737581305FC14C98281FF2EE2E2141F3F
1131-:1003E000822D008100FA00218137030B81810409ED
1132-:1003F00086F481908381FF2EE3E31C1F9E870024F7
1133-:1004000000CF0321E60C00248681002F0054022136
1134-:1004100004FF0AC9E60A00248681002F0054022145
1135-:1004200004801859E60F00248681002F0054022111
1136-:100430008A83802E062A00D1DDDD0101810020247F
1137-:1004400003DD8170E608002400140121E600002489
1138-:100450008681002F04000024C41800248403002F88
1139-:100460008E89802EE3F2F210F2EBEB10096A005154
1140-:10047000044A1061E61100247A7A001F0054022118
1141-:10048000814A040981810101011A8190727261120D
1142-:10049000022A01C91D1D001F9381FF2E73C0002475
1143-:1004A0008E6B2083142A02C98C33B4918327148164
1144-:1004B0000180002461072081640400244406002494
1145-:1004C000C5CCCC10052C2C100420002424F00024D2
1146-:1004D0008403002F81240891E1E101018124088136
1147-:1004E000E10100248124048100FF0AD100FF01D131
1148-:1004F000008700210054022104FF0AC9E60A0024F3
1149-:100500008681002F0054022104DD0069E6090024E1
1150-:100510008681002F00490121E60000248681002FFA
1151-:10052000DDDD01058A83802EF2EBEB109381FF2E37
1152-:10053000738000240A6A0051044A1071E6110024F5
1153-:100540008681002F00540221814A04098181010122
1154-:10055000011A81907272611200590121022A01C9A7
1155-:100560001D1D001D926B308100540221E301002407
1156-:10057000832B04819D81FF2E5D170091906B0124D8
1157-:10058000D19E012491C20124D2D70124922B0224AE
1158-:10059000D3080224002C00240000020100002205E0
1159-:1005A00050D5228F9C81FF2E00009E20D9D90B1F91
1160-:1005B000589696108685802E08870051DADAC70093
1161-:1005C000DADA1103C5DA0003C4C7C7102400002417
1162-:1005D000045200248403002FD796C7009696080182
1163-:1005E00038969610FBFB171F091D00D18068082460
1164-:1005F00007868068D9D90E1F031400240400002444
1165-:10060000C40800248403002F00009E20151D01C98A
1166-:10061000C013BA910286805012C680681919051F4E
1167-:100620000310002437370711DE02002407C70C71BE
1168-:1006300004E800513737E013030A002400009E202D
1169-:100640003737D81300009E2004C709690368FF6983
1170-:100650003737D01300009E203737E81300009E2064
1171-:100660008581FF2E05171710A58686108501012F9D
1172-:10067000DE01002400009E20D9D90B1F5896961049
1173-:100680008683802E8296D704C4C7C71002C700692C
1174-:10069000C482821019C4824818C40861DADA820060
1175-:1006A000DADA8803C5DA00032400002404520024A7
1176-:1006B0008403002F9696080138969610FBFB171FAF
1177-:1006C000081D00D180680824068680680314002471
1178-:1006D00004000024C40800248403002F00009E208E
1179-:1006E0008581FF2E05171710A58686108501012F1D
1180-:1006F000DE01002400009E203737071137374813EA
1181-:10070000DE02002400009E20D9D90D1F58969610B5
1182-:100710008689802E8581FF2E05171710A5868610E5
1183-:100720008501012FC4D79604DADAC400DADA0603A9
1184-:10073000C5DA000324000024045200248403002F9F
1185-:1007400081C90C0B8181020996968100389696101A
1186-:10075000DE010024FBFB181F00009E203737071125
1187-:10076000DE020024031000248687802E0166E0113B
1188-:10077000030120513737A81300009E20036604D1DF
1189-:100780003737A81300009E201546FF692108002472
1190-:10079000016607110901005121210401076602C900
1191-:1007A000060800511D08C0691C09006921210401C7
1192-:1007B0005656041FA9073481969621000400002490
1193-:1007C000C42121108403002F8581FF2EE5E7E71067
1194-:1007D0008501012FDE01002400009E2003460169EF
1195-:1007E0003737801300009E2003460269373788138D
1196-:1007F00000009E2003461A693737901300009E20A0
1197-:1008000003461F693737981300009E200346FE6990
1198-:100810003737A01300009E203737A81300009E2012
1199-:10082000D9D90F1F0137F8110101030B8101040908
1200-:10083000818100018EFA819081000024040000244F
1201-:10084000C4CF81048181C4008403002F0680802EE0
1202-:100850006566711065654E12C48F81048181C40084
1203-:100860008403002F0680802E45665110C4D0810479
1204-:100870008181C4008403002F0680802E25663110FC
1205-:1008800005171710062E00D1C49081048181C40081
1206-:100890008403002F0680802E056611108501012F2C
1207-:1008A000DE010024FBFB191F00009E20C0D7380189
1208-:1008B000C0C00205C006C090D7D72004D7D7020514
1209-:1008C0006103009003013F11DE00002400009E2020
1210-:1008D00000009E20DA00002480898910040D002485
1211-:1008E0008403002F8687802E00FF07C98827188180
1212-:1008F0000447CE51E60100248681002F00540221D6
1213-:100900005A0000240F6701510F6702510F6703510E
1214-:100910000F670451A467065157670C5148670A5383
1215-:10092000D067085103670B532267095324670551A9
1216-:10093000C3670751E60200248681002F005402217C
1217-:10094000000101210001012100040121003E0121DB
1218-:100950001529066981240891E1E1010181240881BA
1219-:10096000067A00C904430024C45A5A1024040024FF
1220-:10097000E5E6E6108403002F6400002444292910D2
1221-:10098000C5C9C910050909100420002424F0002459
1222-:1009900061170091020003599E3402238403002F43
1223-:1009A00000870021E42100248401002F81240C9180
1224-:1009B000E1E1010181240C81008700210480345988
1225-:1009C000E60F00248681002F00540221E600002457
1226-:1009D0008681002F8A87802E04000024C4200024F2
1227-:1009E0008403002F8E87802E026A00C98B33A0817A
1228-:1009F000056A01C98C33A48161010024E21000243E
1229-:100A0000812204E1056A02C98D33A88161010024B5
1230-:100A1000E2200024812204E1026A03C98E33AC8102
1231-:100A2000026A04C98F33B081026A05C99033B48168
1232-:100A30000E6A06C9C100012481000024027100C9A8
1233-:100A400081010024E200002481220CE181000024C5
1234-:100A5000027101C981010024E210002481220CE10D
1235-:100A6000E220002481220CE1BA6A07CFFCF2F210E6
1236-:100A700000540221E60000248681002F8A83802E04
1237-:100A800004000024096A0069C0F801240480C058E9
1238-:100A9000E60F00248681002F00540221C418002490
1239-:100AA0008403002F00DF0221C41400248403002FDC
1240-:100AB000176A016904803C59E60F00247A7A001F06
1241-:100AC000005402218E83802E046E0471E6100024EF
1242-:100AD0007A7A001F00540221816E0509C16E030954
1243-:100AE0008181C100818100018E738180C40800244E
1244-:100AF0008403002F8E8F802E818108018EF38182E6
1245-:100B0000C42000248403002F005402210E6A0269CD
1246-:100B100004802459E60F00247A7A001F0054022131
1247-:100B20008E87802E046E1071E61100247A7A001FE1
1248-:100B300000540221816E0409818100018EFA8180B6
1249-:100B4000005402210B6A046904801859E60F00243E
1250-:100B50007A7A001F005402218E81802E1D1D011DF6
1251-:100B6000026E00C91D1D011F8E33B8810054022181
1252-:100B7000E60200247A7A001F00540221E1000024DA
1253-:100B8000C41000248E87802E8403002F02EB01C83E
1254-:100B90008EF4C18001010101C1C11001FA011E677B
1255-:100BA000005402218A83802E04000024C4180024EB
1256-:100BB0008403002F194A0151E1000024026A005108
1257-:100BC0008101FF2E812C0C8183000F2486E283801B
1258-:100BD000C204002482804F24E120602486E100F7D3
1259-:100BE00086E200E78483FF2E24400024043700249B
1260-:100BF000E5E2E2108403002FE1E14001E2E240017E
1261-:100C000086E100F786E200E7E5E2E2108403002FC8
1262-:100C100086E2839000540221086A00518E8FFF2ED5
1263-:100C2000E2000824E1000824E1E1E2008EE0E28233
1264-:100C3000E2E22001FEE2E16E005402210400002401
1265-:100C4000C41000248403002F240C00240433002447
1266-:100C50008403002F8EB700918E85002F005402214F
1267-:100C6000C05400240480C058E60F00248681002F61
1268-:100C7000005402218A81802E046A2071E60E00242D
1269-:100C80008681002F005402218E8FFF2EC26A060932
1270-:100C9000144A006904000024C41400248403002FB3
1271-:100CA00060200024022A0459602A03098EBF802E86
1272-:100CB0008EF6C2828E8FFF2EC2C22001072A0471D7
1273-:100CC00004000024C42000248403002F602A0405AB
1274-:100CD000606003098EBF802E8EF6C282005402210E
1275-:100CE000054A01698EF6C282C2C220018EF6C28216
1276-:100CF000005402210C4A026904000024C414002498
1277-:100D00008403002F8483FF2E244000240447002402
1278-:100D1000C504002485006624E5E5C2008403002F95
1279-:100D200000540221E60F00248681002F0054022186
1280-:100D3000C01400240480C058E60F00248681002FD0
1281-:100D4000005402218A81802E8B33B091048ACB70AB
1282-:100D5000E61300248681002F00540221086A00C98E
1283-:100D600082000424C20008248100A024C100A02421
1284-:100D70008120828082820401FE82C26E04000024EF
1285-:100D8000C41400248403002FC4040024820004241B
1286-:100D9000F08A00558E81802EC2CE0109C2C2820027
1287-:100DA000CE00C2808A8A01058403002F00640321DB
1288-:100DB000C05800240480C058E60F00248681002F0C
1289-:100DC000005402218A83802E246A6A10E5EBEB101E
1290-:100DD000046300248403002F04000024C4180024AA
1291-:100DE0008403002F8E8F802E2400002404620024B0
1292-:100DF00001380024E501222C8403002F01010401A5
1293-:100E000024240101FC24086704000024C4200024D9
1294-:100E10008403002F8E8F802E240800240462002477
1295-:100E200001380024E501222C8403002F0101040174
1296-:100E300024240101FC24106700540221C0900024E6
1297-:100E40000480C058E60F00248681002F0054022140
1298-:100E50008A81802E8B33AC91046A6B60E612002489
1299-:100E60008681002F00540221816A0609024B8069A5
1300-:100E7000818101098A21818081810401040000248B
1301-:100E8000C41400248403002FC4200024404B040514
1302-:100E90008E8F802E8EE181828403002F40402005BA
1303-:100EA00081812001FB40204F0EBF802E0EE1818EFC
1304-:100EB000005402210037030B3737071176761F11D4
1305-:100EC00056560F111683002FC0000609000000249B
1306-:100ED0008E76C090046E07D1042100248403002F75
1307-:100EE00000009E20056E00C9040C00248403002F1E
1308-:100EF000041100248403002F036E01C900FF06D1F2
1309-:100F00008F2718818483FF2E24F0002404220024DC
1310-:100F100044060024C58E8E10054E4E108403002F0B
1311-:100F2000C0C008010000010100FF04C9040800243A
1312-:100F30008403002FE900085700B4032190D7D7108D
1313-:100F4000156602690E4700516107269101010711DC
1314-:100F5000212703090101211261072681C1072C9174
1315-:100F60008181E01103470151C116002400DD0321F6
1316-:100F7000C10D00248181C112C1072C81E4205024BD
1317-:100F800064180024446767108403002F6E690351BE
1318-:100F900000009E20276600698727188105080051F8
1319-:100FA0006207099102020F11020208126207098109
1320-:100FB0005869015157690451086902692449491067
1321-:100FC00004300024C58989108403002F97072491D9
1322-:100FD000D7D749009707248109680069E420F024E5
1323-:100FE0006418002444060024C58686100546461071
1324-:100FF0008403002F5469035100009E2096672091BE
1325-:101000007676A0135656071F373707110248030993
1326-:101010003737021296672081E42050246418002498
1327-:10102000442828108403002F4769035100009E20A4
1328-:101030001466016987671881366901513569045161
1329-:10104000086902692449491004300024C5898910BF
1330-:101050008403002F97072491D7D74900970724814D
1331-:10106000E420F0246418002444060024C586861079
1332-:10107000054646108403002F3369035100009E206B
1333-:101080000E660469876720816207089102020711D2
1334-:10109000226903090202221262070881E420F02477
1335-:1010A0006408002444060024C586861005464610C0
1336-:1010B0008403002F00009E200B66036962070991DC
1337-:1010C00002020F110202671262070981E420502414
1338-:1010D00064000024440700248403002F1A6903518C
1339-:1010E00000009E2006660551FBFB141F04FC14C97A
1340-:1010F0008281FF2EE2E2141F822D0081FBFBE312AE
1341-:10110000042100248403002F0F69035100009E2056
1342-:10111000966720917676A0135656061F29073081D0
1343-:101120009607208126070B81C6071281E4205024F0
1344-:1011300064180024440400248403002F026904512D
1345-:1011400000009E20D08989108F198091014F0401E1
1346-:1011500001011F11036F0168FBFB141F00009E209B
1347-:10116000C14F90019039C1806119818100009E209A
1348-:00000001FF
1349diff --git a/firmware/keystone/pa_pdsp3_1_3_0_2.fw.ihex b/firmware/keystone/pa_pdsp3_1_3_0_2.fw.ihex
1350new file mode 100755
1351index 0000000..6170c9c
1352--- /dev/null
1353+++ b/firmware/keystone/pa_pdsp3_1_3_0_2.fw.ihex
1354@@ -0,0 +1,282 @@
1355+:10000000007B00210200BEBA02000301845050248C
1356+:10001000C4848410E5E4E410E6E4E410E7E4E410CA
1357+:10002000E8E4E410E9E4E410EAE4E410EBE4E410CA
1358+:1000300084E3008384E3208384E3408384E3608358
1359+:1000400084E3808384E3A08384E3C08384E3E08348
1360+:1000500004430024640304810444002464032981CC
1361+:10006000040A002464033281040C002464033381F5
1362+:100070000409002464032F810453002464030681CF
1363+:1000800004050024640300810406002464032B811A
1364+:100090000407002464032C810408002464033C81C9
1365+:1000A00004510024640311810452002464038881F4
1366+:1000B000040F00246403848180A7FF2E80F300894D
1367+:1000C00080F3508980FA008780FA408780FA808721
1368+:1000D00080FAC087E5000024E1E001248887FF2E34
1369+:1000E0006805002488F4E580E5E51001FEE5E16E91
1370+:1000F000C800812488A88824C900082489DD8624B2
1371+:10010000CA4788248A488824CB6488248B6388243F
1372+:1001100088F54081E500002485356081899FFF2EA8
1373+:1001200085000024C500082489F685868585400160
1374+:10013000FE85C56E040000246418008104010024BB
1375+:100140006418208104020024641840810403002400
1376+:10015000641860810404002464188081040500246C
1377+:100160006418A081E0010024E1640024806A048115
1378+:10017000828FFF2E82F3A0836202002442020024B9
1379+:10018000220200248233A0816540002445400024DF
1380+:100190008533AC81F4000424F50008248000A024F9
1381+:1001A000C000A0248020F480F4F40401FEF4F56E75
1382+:1001B000F4000824F5001024809FFF2E80E0F486D0
1383+:1001C000F4F44001FEF4F56EF480002480E0F48045
1384+:1001D000F480012480E0F480F480022480E0F48044
1385+:1001E000F480032480E0F48000009E209E5D0123C3
1386+:1001F0008285FF2E82A40481E201002482240081F2
1387+:1002000000FF00C900FF00D104FF01C99E030023C5
1388+:10021000E2000024822404819D81FF2E9B81FF2E19
1389+:100220005D17009182020024C203012482370481F9
1390+:1002300003FB00519B2C08819B81FF2EFDFF04CF07
1391+:10024000FBFB161F81240091E1E101018124008163
1392+:10025000868F802E03CA0ED1CAE10E1F868F002F13
1393+:1002600009C9006904FC13C98081FF2EE0E0131F57
1394+:10027000802D00813737071137375813FBFB1D1FBF
1395+:1002800000FC0021040800248403002F0431002412
1396+:10029000242000248403002F9689802E0176050BEC
1397+:1002A0000B0100512F0105518D01045304FC0BC9B2
1398+:1002B0008081FF2EE0E00B1F802D0081FBFB1C1FC7
1399+:1002C000042100248403002F008C002103591F11F6
1400+:1002D0000203165137370711040D00248403002F41
1401+:1002E00004000024C49696108403002FDE0000242E
1402+:1002F00002030B6903150024020310710503167134
1403+:100300009E8C002400FF07C99627208300DF002170
1404+:1003100000030109801500909E00C022FDDE0057F9
1405+:100320005959E0115959031200FF07C99627208334
1406+:1003300005DE016900FF0BD19E8C00240BFF0CD160
1407+:1003400000DF0021DE37030BDEDE040986F4DE90D9
1408+:100350008381FF2EE3E31C1F9E8C002400D6032123
1409+:100360009E8C002400B403218687812E8381FF2E7A
1410+:10037000E3E31C1F9E8C002400D603218687812E78
1411+:1003800004970AD1373707113737301300FC0021A3
1412+:1003900081173F118181060981810C1F8181140120
1413+:1003A000C197060BC1C107118381FF2EE3E31C1F18
1414+:1003B00003C1006986E0819000D6032103C1016971
1415+:1003C00086E1819000D6032103C1026986E2819013
1416+:1003D00000D60321373707113737581305FC14C9E6
1417+:1003E0008281FF2EE2E2141F822D008100FC002199
1418+:1003F0008137030B8181040986F481908381FF2E6C
1419+:10040000E3E31C1F9E8C002400D60321E60C00248D
1420+:100410008681002F0056022104FF0AC9E60A002443
1421+:100420008681002F0056022104801859E60F00240F
1422+:100430008681002F005602218A83802E062A00D151
1423+:10044000DDDD01018100202403DD8170E608002448
1424+:1004500000160121E60000248681002F04000024FC
1425+:10046000C41800248403002F8E89802EE3F2F2103A
1426+:10047000F2EBEB10096A0051044A1061E611002406
1427+:100480007A7A001F00560221814A04098181010104
1428+:10049000011A819072726112022A01C91D1D001F8A
1429+:1004A0009381FF2E73C000248E6B2083142A02C90F
1430+:1004B0008C33B4918327148101800024610720814B
1431+:1004C0006404002444060024C5CCCC10052C2C1058
1432+:1004D0000420002424F000248403002F81240891A8
1433+:1004E000E1E1010181240881E101002481240481EA
1434+:1004F00000FF0AD100FF01D1008C0021005602212B
1435+:1005000004FF0AC9E60A00248681002F0056022152
1436+:1005100004DD0069E60900248681002F004B0121DB
1437+:10052000E60000248681002FDDDD01058A83802E10
1438+:10053000F2EBEB109381FF2E738000240A6A0051C6
1439+:10054000044A1071E61100248681002F0056022112
1440+:10055000814A040981810101011A8190727261123C
1441+:10056000005B0121022A01C91D1D001D926B308113
1442+:1005700000560221E3010024832B04819D81FF2E7C
1443+:100580005D170091906D0124D1A0012491C4012434
1444+:10059000D2D90124922D0224D30A0224002C002453
1445+:1005A000000002010000220550D5228F9C81FF2E01
1446+:1005B00000009E20D9D90B1F589696108685802E54
1447+:1005C00008870051DADAC700DADA1103C5DA000366
1448+:1005D000C4C7C71024000024045200248403002F41
1449+:1005E000D796C7009696080138969610FBFB171F02
1450+:1005F000091D00D18068082407868068D9D90E1F9C
1451+:100600000314002404000024C40800248403002FE1
1452+:1006100000009E20151D01C9C013BA9102868050AA
1453+:1006200012C680681919051F0310002437370711F7
1454+:10063000DE02002407C70C7104E800513737E013CD
1455+:10064000030A002400009E203737D81300009E20A4
1456+:1006500004C709690368FF693737D01300009E207B
1457+:100660003737E81300009E208581FF2E05171710ED
1458+:10067000A58686108501012FDE01002400009E2042
1459+:10068000D9D90B1F589696108683802E8296D70450
1460+:10069000C4C7C71002C70069C482821019C4824847
1461+:1006A00018C40861DADA8200DADA8803C5DA0003EE
1462+:1006B00024000024045200248403002F969608018D
1463+:1006C00038969610FBFB171F081D00D18068082480
1464+:1006D000068680680314002404000024C408002453
1465+:1006E0008403002F00009E208581FF2E0517171020
1466+:1006F000A58686108501012FDE01002400009E20C2
1467+:100700003737071137374813DE02002400009E20D8
1468+:10071000D9D90D1F589696108689802E8581FF2E77
1469+:1007200005171710A58686108501012FC4D79604DA
1470+:10073000DADAC400DADA0603C5DA0003240000249A
1471+:10074000045200248403002F81C90C0B818102090B
1472+:100750009696810038969610DE010024FBFB181F48
1473+:1007600000009E2037370711DE020024031000240A
1474+:100770008687802E0166E011030120513737A813C8
1475+:1007800000009E20036604D13737A81300009E2086
1476+:100790001546FF692108002401660711090100516F
1477+:1007A00021210401076602C9060800511D08C0691D
1478+:1007B0001C090069212104015656041FA907348130
1479+:1007C0009696210004000024C42121108403002FE8
1480+:1007D0008581FF2EE5E7E7108501012FDE0100246A
1481+:1007E00000009E20034601693737801300009E20D9
1482+:1007F000034602693737881300009E2003461A69B2
1483+:100800003737901300009E2003461F69373798132F
1484+:1008100000009E200346FE693737A01300009E208B
1485+:100820003737A81300009E20D9D90F1F0137F811C0
1486+:100830000101030B81010409818100018EFA81907D
1487+:100840008100002404000024C4CF81048181C400FD
1488+:100850008403002F0680802E6566711065654E1238
1489+:10086000C48F81048181C4008403002F0680802E00
1490+:1008700045665110C4D081048181C4008403002FD7
1491+:100880000680802E2566311005171710062E00D120
1492+:10089000C49081048181C4008403002F0680802ECF
1493+:1008A000056611108501012FDE010024FBFB191FD5
1494+:1008B00000009E20C0D73801C0C00205C006C0900D
1495+:1008C000D7D72004D7D702056103009003013F1159
1496+:1008D000DE00002400009E2000009E20DA0000249C
1497+:1008E00080898910040D00248403002F8687802EC0
1498+:1008F00000FF07C9882718810447CE51E60100246C
1499+:100900008681002F005602215A0000240F670151F2
1500+:100910000F6702510F6703510F670451A967065112
1501+:100920005C670C514D670A53D567085108670B5334
1502+:100930002767095324670551C8670751E602002459
1503+:100940008681002F005602210003012100030121AE
1504+:100950000006012100400121152906698124089122
1505+:10096000E1E1010181240881067A00C904430024E1
1506+:10097000C45A5A1024040024E5E6E6108403002F2C
1507+:100980006400002444292910C5C9C91005090910AB
1508+:100990000420002424F00024611700910200035970
1509+:1009A0009E3602238403002F008C0021E4210024C2
1510+:1009B0008401002F81240C91E1E1010181240C814B
1511+:1009C000008C002104803859E60F00248681002F16
1512+:1009D00000560221E60000248681002F8A87802E9F
1513+:1009E00004000024C42000248403002F8E8B802E5A
1514+:1009F000026A00C98B33A081056A01C98C33A481C6
1515+:100A000061010024E2100024812204E1056A02C988
1516+:100A10008D33A88161010024E2200024812204E1B9
1517+:100A2000026A03C98E33AC81026A04C98F33B08174
1518+:100A3000026A05C99033B481136A06C99233BC8136
1519+:100A4000C100012481000024027100C90101071FB7
1520+:100A5000027102C90101061FE200002481220CE19B
1521+:100A600081000024027101C90101071F027103C93D
1522+:100A70000101061FE210002481220CE1E220002483
1523+:100A800081220CE1B56A07CFFCF3F3100056022176
1524+:100A9000E60000248681002F8A83802E0400002433
1525+:100AA000096A0069C0F801240480C058E60F0024D8
1526+:100AB0008681002F00560221C41800248403002FD1
1527+:100AC00000E60221C41400248403002F176A016980
1528+:100AD00004803C59E60F00247A7A001F0056022158
1529+:100AE0008E83802E046E0471E61000247A7A001F33
1530+:100AF00000560221816E0509C16E03098181C10082
1531+:100B0000818100018E738180C40800248403002F3A
1532+:100B10008E8F802E818108018EF38182C420002473
1533+:100B20008403002F005602210E6A026904802459B2
1534+:100B3000E60F00247A7A001F005602218E87802E4D
1535+:100B4000046E1071E61100247A7A001F005602210B
1536+:100B5000816E0409818100018EFA81800056022194
1537+:100B60000B6A046904801859E60F00247A7A001F82
1538+:100B7000005602218E81802E1D1D011D026E00C9AE
1539+:100B80001D1D011F8E33B88100560221E60200248C
1540+:100B90007A7A001F00560221E1000024C4100024CC
1541+:100BA0008E87802E8403002F02EB01C88EF4C18053
1542+:100BB00001010101C1C11001FA011E6700560221A5
1543+:100BC0008A83802E04000024C41800248403002F8C
1544+:100BD000194A0151E1000024026A00518101FF2EEF
1545+:100BE000812C0C8183000F2486E28380C2040024C0
1546+:100BF00082804F24E120602486E100F786E200E74E
1547+:100C00008483FF2E2440002404370024E5E2E21010
1548+:100C10008403002FE1E14001E2E2400186E100F7B8
1549+:100C200086E200E7E5E2E2108403002F86E283908B
1550+:100C300000560221086A00518E8FFF2EE200082420
1551+:100C4000E1000824E1E1E2008EE0E282E2E220013C
1552+:100C5000FEE2E16E0056022104000024C4100024CC
1553+:100C60008403002F240C0024043300248403002F69
1554+:100C70008EB700918E85002F00560221C0540024AB
1555+:100C80000480C058E60F00248681002F0056022100
1556+:100C90008A81802E046A2071E60E00248681002F4E
1557+:100CA000005602218E8FFF2EC26A0609144A00697F
1558+:100CB00004000024C41400248403002F60200024B6
1559+:100CC000022A0459602A03098EBF802E8EF6C28242
1560+:100CD0008E8FFF2EC2C22001072A04710400002457
1561+:100CE000C42000248403002F602A040560600309E7
1562+:100CF0008EBF802E8EF6C28200560221054A0169FF
1563+:100D00008EF6C282C2C220018EF6C2820056022135
1564+:100D10000C4A026904000024C41400248403002F38
1565+:100D20008483FF2E2440002404470024C5040024AB
1566+:100D300085006624E5E5C2008403002F00560221E9
1567+:100D4000E60F00248681002F00560221C0140024E3
1568+:100D50000480C058E60F00248681002F005602212F
1569+:100D60008A81802E8B33B091048ACB70E6130024E5
1570+:100D70008681002F00560221086A00C982000424DF
1571+:100D8000C20008248100A024C100A0248120828008
1572+:100D900082820401FE82C26E04000024C414002476
1573+:100DA0008403002FC404002482000424EB8A00552D
1574+:100DB0008E81802EC2CE0109C2C28200CE00C280C6
1575+:100DC0008A8A01058403002F006B0321C058002488
1576+:100DD0000480C058E60F00248681002F00560221AF
1577+:100DE0008A83802E246A6A10E5EBEB1004630024EA
1578+:100DF0008403002F04000024C41800248403002F5F
1579+:100E00008E8F802E240000240462002401380024E8
1580+:100E1000E501222C8403002F010104012424010197
1581+:100E2000FC24086704000024C42000248403002F4D
1582+:100E30008E8F802E240800240462002401380024B0
1583+:100E4000E501222C8403002F010104012424010167
1584+:100E5000FC24106700560221C09000240480C05872
1585+:100E6000E60F00248681002F005602218A81802E01
1586+:100E70008B33AC91046A6B60E61200248681002FEC
1587+:100E800000560221816A0609024B806981810109AD
1588+:100E90008A2181808181040104000024C41400247B
1589+:100EA0008403002FC4200024404B04058E8F802E25
1590+:100EB0008EE181828403002F404020058181200142
1591+:100EC000FB40204F0EBF802E0EE1818E0056022186
1592+:100ED0000037030B3737071176761F1156560F115F
1593+:100EE0001683002FC0000609000000248E76C090F3
1594+:100EF000046E07D1042100248403002F00009E20EB
1595+:100F0000056E00C9040C00248403002F0411002482
1596+:100F10008403002F036E01C900FF06D18F271881BB
1597+:100F20008483FF2E24F0002404220024440600249D
1598+:100F3000C58E8E10054E4E108403002FC0C00801D0
1599+:100F40000000010100FF04C9040800248403002FED
1600+:100F5000E900085700BB032190D7D7101566026936
1601+:100F60000E4700516107269101010711212703094E
1602+:100F70000101211261072681C1072C918181E011B5
1603+:100F800003470151C116002400E40321C10D0024D0
1604+:100F90008181C112C1072C81E420502464180024EF
1605+:100FA000446767108403002F6E69035100009E2080
1606+:100FB0002766006987271881050800516207099193
1607+:100FC00002020F11020208126207098158690151D9
1608+:100FD0005769045108690269244949100430002402
1609+:100FE000C58989108403002F97072491D7D749001A
1610+:100FF0009707248109680069E420F024641800241C
1611+:1010000044060024C5868610054646108403002F3A
1612+:101010005469035100009E20966720917676A013B4
1613+:101020005656071F37370711024803093737021290
1614+:1010300096672081E4205024641800244428281056
1615+:101040008403002F4769035100009E201466016944
1616+:101050008767188136690151356904510869026949
1617+:101060002449491004300024C58989108403002FC5
1618+:1010700097072491D7D7490097072481E420F024CB
1619+:101080006418002444060024C586861005464610D0
1620+:101090008403002F3369035100009E200E6604690B
1621+:1010A00087672081620708910202071122690309FC
1622+:1010B0000202221262070881E420F024640800245E
1623+:1010C00044060024C5868610054646108403002F7A
1624+:1010D00000009E200B6603696207099102020F114E
1625+:1010E0000202671262070981E42050246400002490
1626+:1010F000440700248403002F1A69035100009E2036
1627+:1011000006660551FBFB151F04FC14C98281FF2EE6
1628+:10111000E2E2141F822D0081FBFBE3120421002474
1629+:101120008403002F0F69035100009E2096672091D1
1630+:101130007676A0135656061F290730819607208120
1631+:1011400026070B81C6071281E4205024641800246E
1632+:10115000440400248403002F0269045100009E20EF
1633+:10116000D08989108F198091014F040101011F114D
1634+:10117000036F0168FBFB151F00009E20C14F90010B
1635+:0C1180009039C1806119818100009E201F
1636+:00000001FF
1637diff --git a/firmware/keystone/pa_pdsp45_1_2_1_2.fw.ihex b/firmware/keystone/pa_pdsp45_1_2_1_2.fw.ihex
1638deleted file mode 100644
1639index b46bdfc..0000000
1640--- a/firmware/keystone/pa_pdsp45_1_2_1_2.fw.ihex
1641+++ /dev/null
1642@@ -1,357 +0,0 @@
1643-:100000000079002184505024C4848410E5E4E41075
1644-:10001000E6E4E410E7E4E410E8E4E410E9E4E410E2
1645-:10002000EAE4E410EBE4E41084E3008384E3208357
1646-:1000300084E3408384E3608384E3808384E3A08358
1647-:1000400084E3C08384E3E0830443002464030481E5
1648-:100050000444002464032981040A002464033281D7
1649-:10006000040C0024640333810409002464032F81F9
1650-:100070000453002464030681040500246403008102
1651-:100080000406002464032B810407002464032C81EC
1652-:100090000408002464033C8104510024640311819A
1653-:1000A0000452002464038881040F002464038481C3
1654-:1000B00080A7FF2E80F3008980F3508980FA0087A3
1655-:1000C00080FA408780FA808780FAC087E5000024A4
1656-:1000D000E1E001248887FF2E6805002488F4E5808C
1657-:1000E000E5E51001FEE5E16EC800812488A88824BA
1658-:1000F000C900082489DD8624CA4788248A488824C0
1659-:10010000CB6488248B63882488F54081E500002433
1660-:1001100085356081899FFF2E85000024C500082455
1661-:1001200089F6858685854001FE85C56E040000241C
1662-:100130006418008104010024641820810402002452
1663-:1001400064184081040300246418608104040024BE
1664-:1001500064188081040500246418A081E001002453
1665-:10016000E1640024806A0481828DFF2E82B3A08323
1666-:100170006202002442020024220200248233A08171
1667-:1001800065400024454000248533AC81F4000424FC
1668-:10019000F50008248000A024C000A0248020F48062
1669-:1001A000F4F40401FEF4F56EF4000824F5001024C4
1670-:1001B000809FFF2E80E0F486F4F44001FEF4F56E9B
1671-:1001C000F480002480E0F480F480012480E0F48056
1672-:1001D000F480022480E0F480F480032480E0F48042
1673-:1001E00000009E209E8B05238285FF2E82A4048121
1674-:1001F000E20100248224008100FF00C900FF00D139
1675-:1002000004FF01C99E010023E2000024822404812E
1676-:100210001D1700915D0000249B81FF2E03FB005100
1677-:100220009B2C08819B81FF2E137D05516E040024B9
1678-:100230004E5D5D100F6E00518E4E0809CF8E9001FD
1679-:100240008E8E8001CF008E904E4E01014E4E0311D6
1680-:100250006E6E0105F80F2F56812FCF0090208190F0
1681-:100260002F2F04012F2F1F114F008E809E4A032332
1682-:100270005D4E4E10EAFF04CF81240091E1E10101BF
1683-:10028000812400819483FF2EF8000024868F802E25
1684-:1002900003CA0ED1CA920E1F868F002F0BC90069A8
1685-:1002A00004FC13C98081FF2EE0E0131F802D008124
1686-:1002B000DEB0002486F4DE908381FF2EE3E31E1F70
1687-:1002C0009E87002400F60421040800248403002FE4
1688-:1002D00004310024242000248403002F9689802EDA
1689-:1002E0000176050B100100514E0103512F010251FF
1690-:1002F0001F010151A5010553A301045342010651F9
1691-:10030000900107518483FF2E042100248403002FD1
1692-:10031000C3FC13CF8081FF2EE0E0131F802D0081EE
1693-:10032000008700210C7502598685802EE20000248A
1694-:1003300002750051E2E20C0186B9E2807575010197
1695-:1003400004010024C40C00248403002FE43506CFEC
1696-:100350000000F420FBFB1E1FE1FC13CF8081FF2E69
1697-:10036000E0E0131F802D008100B70021093507D17F
1698-:100370008685802E86B9C0813535071F040100248B
1699-:10038000C40C00248403002FD53506CF0000F420D0
1700-:10039000FBFB1E1FD2FC13CF8081FF2EE0E0131F5A
1701-:1003A000802D008100B700210E5504598689802ECA
1702-:1003B0000046040B00000209C3550509C3C34001F0
1703-:1003C00006D9C38E04010024C446040BC4C4020928
1704-:1003D0008403002F55550101C13506CF0000F420DC
1705-:1003E000FBFB1E1F04FC13C98081FF2EE0E0131FDE
1706-:1003F000802D00818483FF2E042100248403002F9C
1707-:10040000008700218E83802E8E79E0813535031F91
1708-:1004100004010024C40800248403002F00B7002135
1709-:100420008687802EC40C0024176603C9C4C4040147
1710-:10043000426607110D4200696666F811666606138A
1711-:1004400062070891020207112269030902022212BF
1712-:10045000620708811502021087672081C4100024FA
1713-:100460003535051F002201216207099102020F1193
1714-:100470000202691262070981150202103535041F54
1715-:100480000242075187671881F3E6E610ECE7E710B0
1716-:10049000EDE8E810040100248401002F056604C97A
1717-:1004A0003535061F942C0124D400002400B7002108
1718-:1004B000383502D19E0102238483FF2E04200024BC
1719-:1004C0004473071124F00024C5939310055353106F
1720-:1004D000023505C964080024183503C98E79E091F6
1721-:1004E000042200248403002FE1003024802108F13D
1722-:1004F000C0FFFF2480C080048015629100FF04C902
1723-:100500008B83802EEBE0E010ECEFEF108B83002F5D
1724-:10051000040C00248403002F041100248403002F02
1725-:100520008483FF2E042000244406002424F00024A9
1726-:10053000C58E8E10054E4E108403002F00870021BB
1727-:1005400004010024C40400248401002F01761F113B
1728-:10055000630100570B0102696175025F7602002496
1729-:1005600003960FC97604002496960F1DC3750209E1
1730-:10057000C3C3F8019639C3807575010100B7002126
1731-:10058000063506D13535021F9639F08100B70021B6
1732-:100590009639F0918279F8918E85FF2ECE9696103D
1733-:1005A0002E565610040C00248403002F040000244F
1734-:1005B000C42E2E108403002F8689802E0066F01131
1735-:1005C00003004051CFC7280100D50121CF868610F6
1736-:1005D0000E660F110E0E02095FCECF585E870ED148
1737-:1005E0008F878710D0CE0E045050F811E190030B86
1738-:1005F000878FE100E090D000E1CF0E0403E1E048F6
1739-:10060000D0E190040083012187870D1F86D00E0062
1740-:10061000880000248685002F1175005104430024B2
1741-:1006200024626210C442421003240251E582860013
1742-:10063000008E0121C58286008403002F08750151B8
1743-:1006400024636310C443431003240251E5838600EE
1744-:1006500000960121C58386008403002F8483FF2E2A
1745-:1006600004510024C40E0E10850A00248403002FB8
1746-:1006700004000024C40E0E108401002F4A90005183
1747-:1006800004010024C49090108401002F81000024F4
1748-:1006900004000024C4D081048401002F9090D00075
1749-:1006A000E1900E0024E1CF58041100248401002FB2
1750-:1006B0008483FF2E042200244473071124F20024B3
1751-:1006C000C593931005535310023505C964080024DF
1752-:1006D0008403002F00FF04C9033505C968151510F0
1753-:1006E0000880002F033504C9481515102880002FF5
1754-:1006F0008C83002F040800248401002F073505C9CE
1755-:100700000431002424040024E5ECEC108403002FC1
1756-:10071000E5EDED108403002F040D00248401002F6B
1757-:1007200004000024C42E2E108401002F8689802E00
1758-:10073000007B0121E0862E0060E03C5F84100024F5
1759-:100740008401002F8433002424E03C0D8401002F19
1760-:10075000002E01211175005104430024246262100F
1761-:10076000C442421003240251E582CF0000DD012182
1762-:10077000C582CF008403002F0875015124636310E4
1763-:10078000C443431003240251E583CF0000E5012157
1764-:10079000C583CF008403002F822E2E109E2E0124AD
1765-:1007A000003B022181000024BA55016F804470246F
1766-:1007B000C0040024027D056920200101414000247D
1767-:1007C00086394190C10E2E00B286C166B14603CF74
1768-:1007D000C486C10481C4C4108403002F0401002412
1769-:1007E000C4661F118403002F8181C40004370024D4
1770-:1007F00024661F11C4000024E5E0E0108403002FEC
1771-:1008000000A40121040C00248403002F8200002492
1772-:100810002275005186B9009104000024C486861018
1773-:100820008403002F82C4C41004510024C4C7C7101D
1774-:10083000C5C8C810858787102446070B8403002F7E
1775-:100840001675017186B90C910A868258FBFB1E1F32
1776-:10085000042100248403002FFBFB1E1F70FC13CD1A
1777-:100860008081FF2EE0E0131F802D00810087002192
1778-:1008700004000024C48682048282C4008403002F02
1779-:1008800004530024C4C7C710C5C8C8108587871083
1780-:100890002446070B8403002F153507C986B9C0917C
1781-:1008A00009868258FBFB1E1F042100248403002FAD
1782-:1008B0005BFC13CD8081FF2EE0E0131F802D0081B3
1783-:1008C0000087002104000024C48682048282C400C0
1784-:1008D0008403002F04610024C4C7C710C5C8C81012
1785-:1008E0008587871024460F118403002F255500515A
1786-:1008F000030000242340002480447024C00400240A
1787-:10090000027D0569202001011E5503708639239060
1788-:1009100009868258FBFB1E1F042100248403002F3C
1789-:100920003FFC13CD8081FF2EE0E0131F802D00815E
1790-:100930000087002104000024C48682048282C4004F
1791-:100940008403002F054603C904010024C4661F1157
1792-:100950008403002F8282C400064602D1043700249B
1793-:1009600024661F11C4000024E5E0E0108403002F7A
1794-:100970000303010123232001E0E0200100420221C2
1795-:1009800000009E20006703219E870024025607C9AD
1796-:1009900000D40421D15605D1025606D100C1002150
1797-:1009A000040D00248403002F007A7A108C83FF2E1C
1798-:1009B0002D1800248B33AC918C000609024B806902
1799-:1009C0008C8C01098C018C908C8C04014E6C006C19
1800-:1009D0004D4C0A4D0C4C005186218C908C8C04019E
1801-:1009E0000B660B5125660C5155660D5166660E510E
1802-:1009F000A1660F51A8661051B6661151B066035139
1803-:100A000000C100216767001D0084022187218C90AE
1804-:100A1000080D07D1030D06C9D7D796049600002408
1805-:100A2000010D3F11D7D7010000FF07C9962720838A
1806-:100A30004406002424500024642D2D10046700D1A6
1807-:100A4000042000248403002F00009E2004220024A0
1808-:100A50008403002F040800248403002F04310024A1
1809-:100A6000242000248403002F040D00248403002F7D
1810-:100A70003747030900D4042187A18C908C8C0C018A
1811-:100A80004C4C010581C8C81041000024878796009E
1812-:100A9000898996000B6707C9046704C9CE88964EFA
1813-:100AA0008896880400AB022188889600C0883801A7
1814-:100AB00000FF06D18E06C09081CEC9108181470407
1815-:100AC000126705C9C087380100FF06D18E26C09085
1816-:100AD00061670F11046100692E2E030B410600248B
1817-:100AE00000BB02212E0E030B410400244E2E0109EF
1818-:100AF0006E2E010B4E4E6E0041414E00022E00C97B
1819-:100B00004141010187874100B3CD874E0400002495
1820-:100B1000C487CD048403002FCD8787108483FF2EE4
1821-:100B2000036706D12424001F8589870404600024FC
1822-:100B3000C48141048403002F0075022187218C9019
1823-:100B40008C8C04014C4C0105036700D1474796008B
1824-:100B500000D6022147D70704C047380100FF06D15D
1825-:100B60008EE6C0902D2707009B2D204F0227145999
1826-:100B70000D0D071F00070710202720010EC7208E2C
1827-:100B8000007502210046040507C18C9EC08C04013B
1828-:100B90008C8C00004C4C0105096701C98ECD006F9B
1829-:100BA000027800697896961004010024C4787810C1
1830-:100BB0008403002FCD787810000103214747960069
1831-:100BC00085CD474E04000024C447CD048403002F84
1832-:100BD000CD474710076702C904010024C427271026
1833-:100BE0008403002FCDCD2700D7D72704007502211D
1834-:100BF000056700D1002727100EC1C09E0EBE002F32
1835-:100C000000750221C5040024850020240437002437
1836-:100C100024272710C40000248585C0008403002FEA
1837-:100C2000106701C9D7D72700D7D7780403580051D8
1838-:100C3000585827005858780403380051383827008E
1839-:100C40003838780403180051181827001818780449
1840-:100C5000969627009696780478272710007502212B
1841-:100C6000010D3F11010127000D0DC0110D0D0100F7
1842-:100C7000007502214C4C010557CD006FCD969610A2
1843-:100C80000D0D061F04010024C49696108403002F46
1844-:100C9000007502214C4C01054FCDD74E04000024B5
1845-:100CA000C4D7CD048403002FCDD7D710040100246E
1846-:100CB000C489D7048403002F007502214C4C010520
1847-:100CC000D086861090D7D7109E4A03230075022144
1848-:100CD0003726030900D404218B83802E040D0024C1
1849-:100CE0008403002F04000024C4CCCC108403002F04
1850-:100CF0008E81802E06EBEE50EEEBEB108E81002FF6
1851-:100D0000610709910101021F61070981962720836C
1852-:100D100044060024245000246418002404200024E5
1853-:100D20008403002F00009E208A33B091878A030934
1854-:100D300086D00109861C869018C60DD10AD08A5823
1855-:100D4000C7D00309887DC79003C60ED1E9E9010128
1856-:100D500000560321E9E99000E8E80003887DC78098
1857-:100D60000062032181D08A04C7810209C7C78700B6
1858-:100D7000883DC79003C60ED1E8E801010061032158
1859-:100D8000E8E89000883DC78004C60FD1D0C6C610E1
1860-:100D900070700F11004C032100009E20DA00002427
1861-:100DA00080898910040D00248403002F8687802EFB
1862-:100DB00000FF07C9882718810447CE51E6010024A7
1863-:100DC0008681002F008603215A0000240F670151FD
1864-:100DD0000F6702510F6703510F670451996706515E
1865-:100DE00057670C513D670A53C5670851F8670B51A7
1866-:100DF0001767095324670551B8670751E6020024B5
1867-:100E00008681002F008603210088052100880521A6
1868-:100E10000083052100880521152906698124089190
1869-:100E2000E1E1010181240881067A00C9044300241C
1870-:100E3000C45A5A1024040024E5E6E6108403002F67
1871-:100E40006400002444292910C5C9C91005090910E6
1872-:100E50000420002424F000246117009102000359AB
1873-:100E60009E8D05238403002F00870021E4210024A8
1874-:100E70008401002F81240C91E1E1010181240C8186
1875-:100E80000087002104803459E60F00248681002F5A
1876-:100E900000860321E60000248681002F8A87802EA9
1877-:100EA00004000024C42000248403002F8E87802E99
1878-:100EB000026A00C98B33A081056A01C98C33A48101
1879-:100EC00061010024E2100024812204E1056A02C9C4
1880-:100ED0008D33A88161010024E2200024812204E1F5
1881-:100EE000026A03C98E33AC81026A04C98F33B081B0
1882-:100EF000026A05C99033B4810E6A06C9C100012493
1883-:100F000081000024027100C981010024E200002454
1884-:100F100081220CE181000024027101C981010024B9
1885-:100F2000E210002481220CE1E220002481220CE165
1886-:100F3000BA6A07CFFCF2F21000860321E600002413
1887-:100F40008681002F8A83802E04000024096A0069AC
1888-:100F5000C0F801240480C058E60F00248681002FC9
1889-:100F600000860321C41800248403002F00060421F6
1890-:100F7000C41400248403002F176A016904803C59BB
1891-:100F8000E60F00247A7A001F008603218E83802ECC
1892-:100F9000046E0471E61000247A7A001F0086032193
1893-:100FA000816E0509C16E03098181C1008181000143
1894-:100FB0008E738180C40800248403002F8E8F802EBE
1895-:100FC000818108018EF38182C42000248403002FD4
1896-:100FD000008603210E6A026904802459E60F00246A
1897-:100FE0007A7A001F008603218E87802E046E10718E
1898-:100FF000E61100247A7A001F00860321816E04091D
1899-:10100000818100018EFA818000860321E60200249E
1900-:101010007A7A001F00860321E1000024C410002416
1901-:101020008E87802E8403002F02EB01C88EF4C180CE
1902-:1010300001010101C1C11001FA011E6700860321EF
1903-:101040008A83802E04000024C41800248403002F07
1904-:10105000194A0151E1000024026A00518101FF2E6A
1905-:10106000812C0C8183000F2486E28380C20400243B
1906-:1010700082804F24E120602486E100F786E200E7C9
1907-:101080008483FF2E2440002404370024E5E2E2108C
1908-:101090008403002FE1E14001E2E2400186E100F734
1909-:1010A00086E200E7E5E2E2108403002F86E2839007
1910-:1010B00000860321086A00518E8FFF2EE20008246B
1911-:1010C000E1000824E1E1E2008EE0E282E2E22001B8
1912-:1010D000FEE2E16E0086032104000024C410002417
1913-:1010E0008403002F240C0024043300248403002FE5
1914-:1010F0008EB700918E85002F00860321C0540024F6
1915-:101100000480C058E60F00248681002F008603214A
1916-:101110008A81802E046A2071E60E00248681002FC9
1917-:10112000008603218E8FFF2EC26A0609144A0069C9
1918-:1011300004000024C41400248403002F6020002431
1919-:10114000022A0459602A03098EBF802E8EF6C282BD
1920-:101150008E8FFF2EC2C22001072A047104000024D2
1921-:10116000C42000248403002F602A04056060030962
1922-:101170008EBF802E8EF6C28200860321054A016949
1923-:101180008EF6C282C2C220018EF6C2820086032180
1924-:101190000C4A026904000024C41400248403002FB4
1925-:1011A0008483FF2E2440002404470024C504002427
1926-:1011B00085006624E5E5C2008403002F0086032134
1927-:1011C000E60F00248681002F00860321C01400242E
1928-:1011D0000480C058E60F00248681002F008603217A
1929-:1011E0008A81802E8B33B091048ACB70E613002461
1930-:1011F0008681002F00860321086A00C9820004242A
1931-:10120000C20008248100A024C100A0248120828083
1932-:1012100082820401FE82C26E04000024C4140024F1
1933-:101220008403002FC404002482000424FB8A005598
1934-:101230008E81802EC2CE0109C2C28200CE00C28041
1935-:101240008A8A01058403002F008B0421C0580024E2
1936-:101250000480C058E60F00248681002F00860321F9
1937-:101260008A83802E246A6A10E5EBEB100463002465
1938-:101270008403002F04000024C41800248403002FDA
1939-:101280008E8F802E24000024046200240138002464
1940-:10129000E501222C8403002F010104012424010113
1941-:1012A000FC24086704000024C42000248403002FC9
1942-:1012B0008E8F802E2408002404620024013800242C
1943-:1012C000E501222C8403002F0101040124240101E3
1944-:1012D000FC24106700860321C09000240480C058BD
1945-:1012E000E60F00248681002F008603218A81802E4C
1946-:1012F0008B33AC91046A6B60E61200248681002F68
1947-:1013000000860321816A0609024B806981810109F7
1948-:101310008A2181808181040104000024C4140024F6
1949-:101320008403002FC4200024404B04058E8F802EA0
1950-:101330008EE181828403002F4040200581812001BD
1951-:10134000FB40204F0EBF802E0EE1818E00860321D0
1952-:101350000037030B3737071176761F1156560F11DA
1953-:101360001683002FC0000609000000248E76C0906E
1954-:10137000046E07D1042100248403002F00009E2066
1955-:10138000056E00C9040C00248403002F04110024FE
1956-:101390008403002F036E01C900FF06D18F27188137
1957-:1013A0008483FF2E24F00024042200244406002419
1958-:1013B000C58E8E10054E4E108403002FC0C008014C
1959-:1013C0000000010100FF04C9040800248403002F69
1960-:1013D000E900085700DB042190D7D7101566026991
1961-:1013E0000E470051610726910101071121270309CA
1962-:1013F0000101211261072681C1072C918181E01131
1963-:1014000003470151C116002400040521C10D002429
1964-:101410008181C112C1072C81E4205024641800246A
1965-:10142000446767108403002F6E69035100009E20FB
1966-:10143000276600698727188105080051620709910E
1967-:1014400002020F1102020812620709815869015154
1968-:10145000576904510869026924494910043000247D
1969-:10146000C58989108403002F97072491D7D7490095
1970-:101470009707248109680069E420F0246418002497
1971-:1014800044060024C5868610054646108403002FB6
1972-:101490005469035100009E20966720917676A01330
1973-:1014A0005656071F3737071102480309373702120C
1974-:1014B00096672081E42050246418002444282810D2
1975-:1014C0008403002F4769035100009E2014660169C0
1976-:1014D00087671881366901513569045108690269C5
1977-:1014E0002449491004300024C58989108403002F41
1978-:1014F00097072491D7D7490097072481E420F02447
1979-:101500006418002444060024C5868610054646104B
1980-:101510008403002F3369035100009E200E66046986
1981-:101520008767208162070891020207112269030977
1982-:101530000202221262070881E420F02464080024D9
1983-:1015400044060024C5868610054646108403002FF5
1984-:1015500000009E200B6603696207099102020F11C9
1985-:101560000202671262070981E4205024640000240B
1986-:10157000440700248403002F1A69035100009E20B1
1987-:1015800006660551FBFB141F04FC14C98281FF2E63
1988-:10159000E2E2141F822D0081FBFBE31204210024F0
1989-:1015A0008403002F0F69035100009E20966720914D
1990-:1015B0007676A0135656061F29073081960720819C
1991-:1015C00026070B81C6071281E420502464180024EA
1992-:1015D000440400248403002F0269045100009E206B
1993-:1015E000D08989108F198091014F040101011F11C9
1994-:1015F000036F0168FBFB141F00009E20C14F900188
1995-:101600009039C1806119818100009E208A83802EDB
1996-:10161000042A02C9E1000024812134E1008603216B
1997-:10162000E60C00248681002F008603219C81FF2E7A
1998-:0816300000009E2000009E2036
1999-:00000001FF
2000diff --git a/firmware/keystone/pa_pdsp45_1_3_0_2.fw.ihex b/firmware/keystone/pa_pdsp45_1_3_0_2.fw.ihex
2001new file mode 100755
2002index 0000000..c2900b3
2003--- /dev/null
2004+++ b/firmware/keystone/pa_pdsp45_1_3_0_2.fw.ihex
2005@@ -0,0 +1,445 @@
2006+:10000000007B00210300BEBA02000301845050248B
2007+:10001000C4848410E5E4E410E6E4E410E7E4E410CA
2008+:10002000E8E4E410E9E4E410EAE4E410EBE4E410CA
2009+:1000300084E3008384E3208384E3408384E3608358
2010+:1000400084E3808384E3A08384E3C08384E3E08348
2011+:1000500004430024640304810444002464032981CC
2012+:10006000040A002464033281040C002464033381F5
2013+:100070000409002464032F810453002464030681CF
2014+:1000800004050024640300810406002464032B811A
2015+:100090000407002464032C810408002464033C81C9
2016+:1000A00004510024640311810452002464038881F4
2017+:1000B000040F00246403848180A7FF2E80F300894D
2018+:1000C00080F3508980FA008780FA408780FA808721
2019+:1000D00080FAC087E5000024E1E001248887FF2E34
2020+:1000E0006805002488F4E580E5E51001FEE5E16E91
2021+:1000F000C800812488A88824C900082489DD8624B2
2022+:10010000CA4788248A488824CB6488248B6388243F
2023+:1001100088F54081E500002485356081899FFF2EA8
2024+:1001200085000024C500082489F685868585400160
2025+:10013000FE85C56E040000246418008104010024BB
2026+:100140006418208104020024641840810403002400
2027+:10015000641860810404002464188081040500246C
2028+:100160006418A081E0010024E1640024806A048115
2029+:10017000828FFF2E82F3A0836202002442020024B9
2030+:10018000220200248233A0816540002445400024DF
2031+:100190008533AC81F4000424F50008248000A024F9
2032+:1001A000C000A0248020F480F4F40401FEF4F56E75
2033+:1001B000F4000824F5001024809FFF2E80E0F486D0
2034+:1001C000F4F44001FEF4F56EF480002480E0F48045
2035+:1001D000F480012480E0F480F480022480E0F48044
2036+:1001E000F480032480E0F48000009E209EEA062331
2037+:1001F0008285FF2E82A40481E201002482240081F2
2038+:1002000000FF00C900FF00D104FF01C99E030023C5
2039+:10021000E2000024822404811D1700915D00002467
2040+:1002200082020024C2030124823704818087FF2ECA
2041+:1002300080F710819B81FF2E03FB00519B2C0881CE
2042+:100240009B81FF2E137D05516E0400244E5D5D10D1
2043+:100250000F6E00518E4E0809CF8E90018E8E800158
2044+:10026000CF008E904E4E01014E4E03116E6E010571
2045+:10027000F80F2F56812FCF00902081902F2F04014F
2046+:100280002F2F1F114F008E809EA404235D4E4E1011
2047+:10029000EAFF04CF81240091E1E101018124008182
2048+:1002A0009483FF2EF80000243D0000248037109135
2049+:1002B000096000518483FF2E24B00024042200240E
2050+:1002C00044060024C5808010054040108403002FA0
2051+:1002D00000FF04C9868F802E9489891003CA0ED12D
2052+:1002E000CA920E1F868F002F0BC9006904FC13C928
2053+:1002F0008081FF2EE0E0131F802D0081DEB00024FE
2054+:1003000086F4DE908381FF2EE3E31E1F9E8E002481
2055+:1003100000550621040800248403002F0431002422
2056+:10032000242000248403002F9689802E0176050B5B
2057+:1003300014010051520103513301025123010151B3
2058+:100340000201055100D3002100490321020104519B
2059+:1003500000D600210048032142010651A1010751A6
2060+:100360008483FF2E042100248403002FB3FC13CFC9
2061+:100370008081FF2EE0E0131F802D0081008E002180
2062+:100380000C7502598685802EE2000024027500510A
2063+:10039000E2E20C0186B9E2807575010104010024D6
2064+:1003A000C40C00248403002FE03506CF0000D420C5
2065+:1003B000FBFB1E1FDDFC13CF8081FF2EE0E0131F2F
2066+:1003C000802D008100CA0021093507D18685802E45
2067+:1003D00086B9C0813535071F04010024C40C0024F0
2068+:1003E0008403002FD13506CF0000D420FBFB1E1F55
2069+:1003F000CEFC13CF8081FF2EE0E0131F802D008103
2070+:1004000000CA00210E5504598689802E0046040B2F
2071+:1004100000000209C3550509C3C3400106D9C38EB4
2072+:1004200004010024C446040BC4C402098403002F41
2073+:1004300055550101BD3506CF0000D420FBFB1E1F22
2074+:1004400004FC13C98081FF2EE0E0131F802D008182
2075+:100450008483FF2E042100248403002F008E0021BA
2076+:100460008E83802E8E79E0813535031F04010024B0
2077+:10047000C40800248403002F00CA00218687802E30
2078+:10048000C40C002400FF07C9196603C9C4C40401D1
2079+:10049000020900C93535011F426607110D42006986
2080+:1004A0006666F81166660613620708910202071174
2081+:1004B0002269030902022212620708811502021052
2082+:1004C00087672081C41000243535051F003C0121B9
2083+:1004D0006207099102020F11020269126207098183
2084+:1004E000150202103535041F024207518767188133
2085+:1004F000F3E6E610ECE7E710EDE8E810040100246D
2086+:100500008401002F046604C93535061FD445012433
2087+:1005100000CA0021483502D19EE60223083501C9F0
2088+:1005200007943C59841000248401002F8433002454
2089+:1005300024943C0D8401002F3D3D0101063D0051F6
2090+:100540009013BE91900100249EA404233D3D01051B
2091+:10055000004F01218483FF2E0420002444730711DF
2092+:1005600024F00024C593931005535310023505C998
2093+:1005700064080024193503C98E79E091042200240F
2094+:100580008403002FE1003024802108F1C0FFFF2404
2095+:1005900080C0800481356091C0818110EDC1C1109F
2096+:1005A00000FF04C9EBE0E010ECEFEF108B85002FAB
2097+:1005B000040C00248403002F041100248403002F62
2098+:1005C0008483FF2E042000244406002424F0002409
2099+:1005D000C58E8E10054E4E108403002F008E002114
2100+:1005E00004010024C40400248401002F01761F119B
2101+:1005F0004E0100570B0102694C75025F7602002420
2102+:1006000003960FC97604002496960F1DC375020940
2103+:10061000C3C3F8019639C3807575010100CA002172
2104+:10062000073506D13535021F3535011F9639F08162
2105+:1006300000CA00219639F0918279F8918E85FF2EBB
2106+:10064000CE9696102E565610040C00248403002FCC
2107+:1006500004000024C42E2E108403002F8689802ECF
2108+:100660000066F01103004051920060510000022129
2109+:10067000CF8686100E660F110E0E020961CECF587E
2110+:1006800060870ED18F878710D0CE0E045050F8119E
2111+:10069000E190030B878FE100E090D000E1CF0E04E2
2112+:1006A00003E1E048D0E1900400AC012187870D1FF1
2113+:1006B00086D00E00880000248685002F94862E00A8
2114+:1006C000FBFB111F9B2C08819B81FF2E1175005194
2115+:1006D0000443002424626210C442421003240251E5
2116+:1006E000E582860000BB0121C58286008403002FBD
2117+:1006F0000875015124636310C4434310032402515D
2118+:10070000E583860000C30121C58386008403002F92
2119+:100710008483FF2E04510024C40E0E10850A002489
2120+:100720008403002F04000024C40E0E108401002F47
2121+:100730004890005104010024C49090108401002FBF
2122+:100740008100002404000024C4D081048401002F0F
2123+:100750009090D000E1900E0029E1CF5804110024C0
2124+:100760008401002F05943C598433002424943C0DCB
2125+:100770008401002F3D3D01018483FF2E04220024CB
2126+:100780004473071124F20024C593931005535310AA
2127+:10079000023505C9640800248403002F00FF04C942
2128+:1007A000033505C9681515100880002F033504C9E5
2129+:1007B000481515102880002F8C83002F0408002472
2130+:1007C0008401002F073505C90431002424040024C6
2131+:1007D000E5ECEC108403002FE5EDED108403002F11
2132+:1007E000040D00248401002F04000024C42E2E10C8
2133+:1007F0008401002F8689802E00A401210047012159
2134+:10080000117500510443002424626210C442421056
2135+:1008100003240251E582CF0000080221C582CF00E7
2136+:100820008403002F0875015124636310C4434310EF
2137+:1008300003240251E583CF0000100221C583CF00BD
2138+:100840008403002F822E2E109E47012400200321B6
2139+:1008500081000024BC55016F80447024C004002432
2140+:10086000027D056920200101414000248639419024
2141+:10087000C10E2E00B486C166B34603CFC486C10440
2142+:1008800081C4C4108403002F04010024C4661F1116
2143+:100890008403002F8181C4000437002424661F11C3
2144+:1008A000C4000024E5E0E0108403002F00D1012102
2145+:1008B0008683802ECFC728010E2800248BCECF58E8
2146+:1008C0008083FF2E07272B510627005107273B5116
2147+:1008D00006273C5105272C516161001F003A022177
2148+:1008E0006161011F6161021F196100D1C02E2801E1
2149+:1008F000C006C090046102C94120201081C0C01010
2150+:100900006161021D07202B510620005107203B5139
2151+:1009100006203C5105202C516161001F004A022134
2152+:100920006161011F6161021FC0C00000026100D14E
2153+:10093000003C0221066101C9C0068190202C0024E0
2154+:100940000E810000C0068180005602214127271039
2155+:10095000272C00248683002F0E0E0801D0CE0E0413
2156+:100960005050F8119683FF2E7641411097356491CF
2157+:10097000F7F7010197356481E1909010968F81001F
2158+:10098000E090D000E1CF0E04E1E1080103E1E0488E
2159+:10099000D0E19004006702219696001FC7D00E0098
2160+:1009A00094C72E00C7C728058683002FFBFB111FA5
2161+:1009B0009B2C08819B81FF2E11750051044300245C
2162+:1009C00024626210C442421003240251E582C7002F
2163+:1009D00000760221C582C7008403002F08750151EB
2164+:1009E00024636310C443431003240251E583C7000A
2165+:1009F000007E0221C583C7008403002F0400002469
2166+:100A0000C40E08058401002FC104002481804F24F6
2167+:100A1000966100E10437002424080024C400002467
2168+:100A2000E5E1E1108403002F44900051040100240B
2169+:100A3000C49090108401002F810000240400002441
2170+:100A4000C4D081048401002F9090D000E1900E006A
2171+:100A5000E1E1080524E1CF58041100248401002FAE
2172+:100A60008483FF2E042200244473071124F0002401
2173+:100A7000C593931005535310023505C9640800242B
2174+:100A80008403002F00FF04C9033505C9681515103C
2175+:100A90000880002F033504C9481515102880002F41
2176+:100AA0008C83002F040800248401002F073505C91A
2177+:100AB0000431002424040024E5ECEC108403002F0E
2178+:100AC000E5EDED108403002F040D00248401002FB8
2179+:100AD00004000024C42E2E108401002F8683802E53
2180+:100AE000005E0221004701211175005104430024DA
2181+:100AF00024626210C442421003240251E582CF00F6
2182+:100B000000C20221C582CF008403002F0875015165
2183+:100B100024636310C443431003240251E583CF00D0
2184+:100B200000CA0221C583CF008403002F822E2E101D
2185+:100B30009E4701240020032181000024C055016F3D
2186+:100B400080447024C0040024027D05692020010136
2187+:100B50004140002486394190C10E2E00B886C166FE
2188+:100B6000B74603CFC486C10481C4C4108403002FD8
2189+:100B700004010024C4661F118403002F8181C40076
2190+:100B80000437002424661F11C4000024E5E0E010AF
2191+:100B90008403002F008F0221040C00248403002F03
2192+:100BA000820000242275005186B9009104000024BF
2193+:100BB000C48686108403002F82C4C410045100240C
2194+:100BC000C4C7C710C5C8C810858787102446070B3F
2195+:100BD0008403002F1675017186B90C910A8682581C
2196+:100BE000FBFB1E1F042100248403002FFBFB1E1FA0
2197+:100BF00019FC13C98081FF2EE0E0131F802D0081B6
2198+:100C0000008E002104000024C48682048282C40075
2199+:100C10008403002F04530024C4C7C710C5C8C810DC
2200+:100C2000858787102446070B8403002F153507C9D5
2201+:100C300086B9C09109868258FBFB1E1F042100243F
2202+:100C40008403002F04FC13C98081FF2EE0E0131FF2
2203+:100C5000802D0081008E002104000024C4868204BF
2204+:100C60008282C4008403002F04610024C4C7C7101B
2205+:100C7000C5C8C8108587871024460F118403002F2C
2206+:100C80002755005103000024234000248044702491
2207+:100C9000C0040024027D0569202001012055037055
2208+:100CA0008639239009868258FBFB1E1F04210024ED
2209+:100CB0008403002FE8FC13CF8081FF2EE0E0131F98
2210+:100CC000802D0081008E002104000024C48682044F
2211+:100CD0008282C4008403002F064603C90401002455
2212+:100CE000C4661F118403002F8282C4009494C4043C
2213+:100CF000074602D10437002424661F11C4000024D3
2214+:100D0000E5E0E0108403002F949424000303010124
2215+:100D100023232001E0E020010027032100009E2082
2216+:100D200000C104219E8E0024025607C9003306210B
2217+:100D3000035605D1045606D100D80021377D05534E
2218+:100D400000710421040D00248403002F5656061D53
2219+:100D5000007A7A108C83FF2E2D180024741800243A
2220+:100D60008B33AC918C000609024B80698C8C010995
2221+:100D70008C018C908C8C0401036C0068024C0A4935
2222+:100D80000062032100D800210E4C005186218C9076
2223+:100D90008C8C04010D660B5131660C517C660D5133
2224+:100DA00093660E51D2660F51D9661051E766115104
2225+:100DB000E1660351E76612515A66135100D80021CB
2226+:100DC0006767001D0073032187218C90035406C9B7
2227+:100DD000D7D796049600002481000024020D07C98D
2228+:100DE00021FF0024010D0D10D7D781007676E01188
2229+:100DF000767674000074040500FF07C916C7208FBB
2230+:100E00004406002424500024642D2D10096700D1CD
2231+:100E1000055605C900741C0100FF07C9952700800D
2232+:100E200044050024042000248403002F00009E2099
2233+:100E3000042200248403002F040800248403002FCC
2234+:100E400004310024242000248403002F040D0024F6
2235+:100E50008403002F374703090033062187A18C90B4
2236+:100E60008C8C0C014C4C010581C8C8104100002439
2237+:100E700087879600898996000B6707C9046704C9AC
2238+:100E8000C288964E8896880400A40321888896001C
2239+:100E9000C088380100FF06D18E06C09081CEC910EF
2240+:100EA00081814704126705C9C087380100FF06D158
2241+:100EB0008E26C09061670F11046100692E2E030B0E
2242+:100EC0004106002400B403212E0E030B410400242C
2243+:100ED0004E2E01096E2E010B4E4E6E0041414E000A
2244+:100EE000022E00C94141010187874100A7CD874EED
2245+:100EF00004000024C487CD048403002FCD8787100D
2246+:100F00008483FF2E036706D12424001F858987046C
2247+:100F100004600024C48141048403002F0062032183
2248+:100F200087618C908C8C08014C4C010575479600AC
2249+:100F3000116707C9C075380100FF06D18E26C09021
2250+:100F4000042700692E2E030B4106002400D603213E
2251+:100F50002E0E030B410400244E2E01096E2E010BB0
2252+:100F60004E4E6E0041414E00022E00C9414101012A
2253+:100F7000757541005656051F0274085974080024FF
2254+:100F800095888810554848100062032187218C906D
2255+:100F90008C8C04014C4C0105036700D14747960037
2256+:100FA00000EA032147D70704C047380100FF06D1F4
2257+:100FB0008EE6C090002707007400204F032D0058D4
2258+:100FC0002D0003012D2DFC11025605C96F2708675E
2259+:100FD000022774587427FC110007071020272001EE
2260+:100FE00000FF07C90EC7208E0062032100460405DA
2261+:100FF00007C18C9EC08C04018C8C00004C4C0105F8
2262+:10100000096701C961CD006F027800697896961072
2263+:1010100004010024C47878108403002FCD78781060
2264+:10102000002104214747960058CD474E0400002474
2265+:10103000C447CD048403002FCD4747100D6702C974
2266+:1010400004010024C42727108403002F0675CD70E7
2267+:101050000075CD040300277075752704001904215D
2268+:1010600075750004CDCD27000D0D27040062032106
2269+:10107000056700D1002727100EC1C09E0EBE002FAD
2270+:1010800000620321C50400248500202404370024C5
2271+:1010900024272710C40000248585C0008403002F66
2272+:1010A0000F6701C90D2778040358005158582700CD
2273+:1010B00058587804033800513838270038387804F5
2274+:1010C000031800511818270018187804969627005E
2275+:1010D0009696780478272710006203210275CD6068
2276+:1010E000757527000D0D2700006203214C4C01058A
2277+:1010F00026CD006FCD9696105454061F040100248F
2278+:10110000C49696108403002F006203214C4C010505
2279+:101110001ECDD74E04000024C4D7CD048403002F75
2280+:10112000CDD7D71004010024C489D7048403002F2D
2281+:10113000006203214C4C0105D086861090D7D71051
2282+:101140009EA40423006203213726030900330621ED
2283+:1011500087A18C908C8C0C014C4C01056006099188
2284+:1011600000006710090000571447006900FF07C915
2285+:1011700089271881035406C9D7D7960496000024FE
2286+:1011800081000024020D07C921FF0024010D0D106C
2287+:10119000D7D781000074040516C7208FE420F024FF
2288+:1011A000642D2D1044060024C5C8C810052727103B
2289+:1011B0008403002F00009E20042100248403002FBC
2290+:1011C00000009E208B83802E040D00248403002FBA
2291+:1011D00004000024C4CCCC108403002F8E81802E08
2292+:1011E00006EBEE50EEEBEB108E81002F61070991BC
2293+:1011F0000101021F610709815656051D96272083AC
2294+:1012000044060024245000246418002404200024F0
2295+:101210008403002F00009E2000761F1100001C0197
2296+:1012200000FF06D18B260090040C00248403002FBD
2297+:1012300004000024C46B6B108403002F04110024ED
2298+:101240008401002F4406002424500024640000245C
2299+:10125000042200248403002F00FF04C9040C00248E
2300+:101260008403002F04010024C46B6B108403002F3F
2301+:101270008483FF2E24F0002404200024440600244C
2302+:10128000C58B8B10054B4B108403002F00009E2054
2303+:101290008A33B091878A030986D00109861C86901B
2304+:1012A00018C60DD10AD08A58C7D00309887DC790C7
2305+:1012B00003C60ED1E9E9010100B00421E9E990007B
2306+:1012C000E8E80003887DC78000BC042181D08A043F
2307+:1012D000C7810209C7C78700883DC79003C60ED1E2
2308+:1012E000E8E8010100BB0421E8E89000883DC780E0
2309+:1012F00004C60FD1D0C6C61070700F1100A604210D
2310+:1013000000009E20DA00002480898910040D00244A
2311+:101310008403002F8687802E00FF07C98827188145
2312+:101320000447CE51E60100248681002F00E004210D
2313+:101330005A0000240F6701510F6702510F670351D4
2314+:101340000F6704519E6706515C670C5142670A5350
2315+:10135000CA670851FD670B511C6709532467055183
2316+:10136000BD670751E60200248681002F00E00421BA
2317+:1013700000E7062100E7062100E2062100E706213A
2318+:101380001529066981240891E1E101018124088180
2319+:10139000067A00C904430024C45A5A1024040024C5
2320+:1013A000E5E6E6108403002F640000244429291098
2321+:1013B000C5C9C910050909100420002424F000241F
2322+:1013C00061170091020003599EEC06238403002F4D
2323+:1013D000008E0021E42100248401002F81240C913F
2324+:1013E000E1E1010181240C81008E00210480385943
2325+:1013F000E60F00248681002F00E00421E60000248F
2326+:101400008681002F8A87802E04000024C4200024B7
2327+:101410008403002F8E8B802E026A00C98B33A0813B
2328+:10142000056A01C98C33A48161010024E210002403
2329+:10143000812204E1056A02C98D33A881610100247B
2330+:10144000E2200024812204E1026A03C98E33AC81C8
2331+:10145000026A04C98F33B081026A05C99033B4812E
2332+:10146000136A06C99233BC81C100012481000024A3
2333+:10147000027100C90101071F027102C90101061FA3
2334+:10148000E200002481220CE181000024027101C9E4
2335+:101490000101071F027103C90101061FE2100024A8
2336+:1014A00081220CE1E220002481220CE1B56A07CF01
2337+:1014B000FCF3F31000E00421E60000248681002FF5
2338+:1014C0008A83802E04000024096A0069C0F8012480
2339+:1014D0000480C058E60F00248681002F00E004211C
2340+:1014E000C41800248403002F00650521C4140024BF
2341+:1014F0008403002F176A016904803C59E60F002419
2342+:101500007A7A001F00E004218E83802E046E04711D
2343+:10151000E61000247A7A001F00E00421816E05099C
2344+:10152000C16E03098181C100818100018E738180B8
2345+:10153000C40800248403002F8E8F802E818108012F
2346+:101540008EF38182C42000248403002F00E0042154
2347+:101550000E6A026904802459E60F00247A7A001F7B
2348+:1015600000E004218E87802E046E1071E6110024A5
2349+:101570007A7A001F00E00421816E04098181000154
2350+:101580008EFA818000E00421E60200247A7A001FAE
2351+:1015900000E00421E1000024C41000248E87802E86
2352+:1015A0008403002F02EB01C88EF4C1800101010108
2353+:1015B000C1C11001FA011E6700E004218A83802E58
2354+:1015C00004000024C41800248403002F194A015188
2355+:1015D000E1000024026A00518101FF2E812C0C8160
2356+:1015E00083000F2486E28380C204002482804F247B
2357+:1015F000E120602486E100F786E200E78483FF2E85
2358+:101600002440002404370024E5E2E2108403002F84
2359+:10161000E1E14001E2E2400186E100F786E200E715
2360+:10162000E5E2E2108403002F86E2839000E00421CB
2361+:10163000086A00518E8FFF2EE2000824E100082482
2362+:10164000E1E1E2008EE0E282E2E22001FEE2E16E10
2363+:1016500000E0042104000024C41000248403002FAF
2364+:10166000240C0024043300248403002F8EB700913F
2365+:101670008E85002F00E00421C05400240480C0584F
2366+:10168000E60F00248681002F00E004218A81802E4D
2367+:10169000046A2071E60E00248681002F00E00421F8
2368+:1016A0008E8FFF2EC26A0609144A006904000024C6
2369+:1016B000C41400248403002F60200024022A04594B
2370+:1016C000602A03098EBF802E8EF6C2828E8FFF2E77
2371+:1016D000C2C22001072A047104000024C42000248F
2372+:1016E0008403002F602A0405606003098EBF802EEA
2373+:1016F0008EF6C28200E00421054A01698EF6C2829C
2374+:10170000C2C220018EF6C28200E004210C4A0269A6
2375+:1017100004000024C41400248403002F8483FF2EBB
2376+:101720002440002404470024C504002485006624C6
2377+:10173000E5E5C2008403002F00E00421E60F002449
2378+:101740008681002F00E00421C01400240480C058CA
2379+:10175000E60F00248681002F00E004218A81802E7C
2380+:101760008B33B091048ACB70E61300248681002F5E
2381+:1017700000E00421086A00C982000424C200082491
2382+:101780008100A024C100A0248120828082820401E3
2383+:10179000FE82C26E04000024C41400248403002FBF
2384+:1017A000C404002482000424F68A00558E81802E11
2385+:1017B000C2CE0109C2C28200CE00C2808A8A01055F
2386+:1017C0008403002F00EA0521C05800240480C0587B
2387+:1017D000E60F00248681002F00E004218A83802EFA
2388+:1017E000246A6A10E5EBEB10046300248403002FE5
2389+:1017F00004000024C41800248403002F8E8F802E40
2390+:10180000240000240462002401380024E501222C75
2391+:101810008403002F0101040124240101FC24086732
2392+:1018200004000024C42000248403002F8E8F802E07
2393+:10183000240800240462002401380024E501222C3D
2394+:101840008403002F0101040124240101FC241067FA
2395+:1018500000E00421C09000240480C058E60F00245A
2396+:101860008681002F00E004218A81802E8B33AC9189
2397+:10187000046A6B60E61200248681002F00E00421D8
2398+:10188000816A0609024B8069818101098A21818070
2399+:101890008181040104000024C41400248403002F67
2400+:1018A000C4200024404B04058E8F802E8EE181825F
2401+:1018B0008403002F4040200581812001FB40204F00
2402+:1018C0000EBF802E0EE1818E00E004210037030B55
2403+:1018D0003737071176761F1156560F111683002FD2
2404+:1018E000C0000609000000248E76C090046E07D167
2405+:1018F000042100248403002F00009E20056E00C9EF
2406+:10190000040C00248403002F041100248403002FFE
2407+:10191000036E01C900FF06D18F2718818483FF2E33
2408+:1019200024F000240422002444060024C58E8E10D6
2409+:10193000054E4E108403002FC0C0080100000101B5
2410+:1019400000FF04C9040800248403002FE90008579D
2411+:10195000003A062190D7D710156602690E4700514C
2412+:1019600061072691010107112127030901012112B5
2413+:1019700061072681C1072C918181E0110347015144
2414+:10198000C116002400630621C10D00248181C1120B
2415+:10199000C1072C81E4205024641800244467671098
2416+:1019A0008403002F6E69035100009E2027660069A2
2417+:1019B00087271881050800516207099102020F115B
2418+:1019C00002020812620709815869015157690451DE
2419+:1019D000086902692449491004300024C589891026
2420+:1019E0008403002F97072491D7D7490097072481B4
2421+:1019F00009680069E420F0246418002444060024E7
2422+:101A0000C5868610054646108403002F546903518D
2423+:101A100000009E20966720917676A0135656071FE9
2424+:101A200037370711024803093737021296672081BA
2425+:101A3000E420502464180024442828108403002F34
2426+:101A40004769035100009E20146601698767188169
2427+:101A50003669015135690451086902692449491000
2428+:101A600004300024C58989108403002F970724912E
2429+:101A7000D7D7490097072481E420F0246418002474
2430+:101A800044060024C5868610054646108403002FB0
2431+:101A90003369035100009E200E6604698767208128
2432+:101AA0006207089102020711226903090202221249
2433+:101AB00062070881E420F02464080024440600241E
2434+:101AC000C5868610054646108403002F00009E2020
2435+:101AD0000B6603696207099102020F110202671285
2436+:101AE00062070981E4205024640000244407002494
2437+:101AF0008403002F1A69035100009E2006660551D9
2438+:101B0000FBFB151F04FC14C98281FF2EE2E2141FA7
2439+:101B1000822D0081FBFBE312042100248403002FAB
2440+:101B20000F69035100009E20966720917676A013DE
2441+:101B30005656061F290730819607208126070B81FC
2442+:101B4000C6071281E42050246418002444040024B1
2443+:101B50008403002F0269045100009E20D08989105F
2444+:101B60008F198091014F040101011F11036F01685A
2445+:101B7000FBFB151F00009E20C14F90019039C180D2
2446+:101B80006119818100009E208A83802E042A02C967
2447+:101B9000E1000024812134E100E00421E60C00246E
2448+:101BA0008681002F00E004219C81FF2E00009E20F2
2449+:041BB00000009E2073
2450+:00000001FF
2451--
24521.6.0.4
2453
diff --git a/ti/runtime/netapi/tools/kernel_patches/README.txt b/ti/runtime/netapi/tools/kernel_patches/README.txt
new file mode 100644
index 0000000..910b461
--- /dev/null
+++ b/ti/runtime/netapi/tools/kernel_patches/README.txt
@@ -0,0 +1,4 @@
1This directory contains patches to be applied to SC-MCSDK 2.0.0.8 Linux kernel distribution.
2
3dma_patch_2.0.0.8.txt: patch to enable allocation of cacheable physically contiguous memory from CMA.
4
diff --git a/ti/runtime/netapi/tools/kernel_patches/dma_patch_2.0.0.8.txt b/ti/runtime/netapi/tools/kernel_patches/dma_patch_2.0.0.8.txt
new file mode 100644
index 0000000..fae177f
--- /dev/null
+++ b/ti/runtime/netapi/tools/kernel_patches/dma_patch_2.0.0.8.txt
@@ -0,0 +1,13 @@
1diff --git arch/arm/include/asm/pgtable.h arch/arm/include/asm/pgtable.h
2index f66626d..95bd431 100644
3--- arch/arm/include/asm/pgtable.h
4+++ arch/arm/include/asm/pgtable.h
5@@ -105,7 +105,7 @@ extern pgprot_t pgprot_kernel;
6
7 #ifdef CONFIG_ARM_DMA_MEM_BUFFERABLE
8 #define pgprot_dmacoherent(prot) \
9- __pgprot_modify(prot, L_PTE_MT_MASK, L_PTE_MT_BUFFERABLE | L_PTE_XN)
10+ __pgprot_modify(prot, L_PTE_MT_MASK, L_PTE_MT_WRITEBACK| L_PTE_XN)
11 #define __HAVE_PHYS_MEM_ACCESS_PROT
12 struct file;
13 extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
diff --git a/ti/runtime/netapi/tools/net_test_loopback_setup.sh b/ti/runtime/netapi/tools/net_test_loopback_setup.sh
new file mode 100644
index 0000000..b1016ab
--- /dev/null
+++ b/ti/runtime/netapi/tools/net_test_loopback_setup.sh
@@ -0,0 +1,20 @@
1#!/bin/sh
2
3if [ -z "$1"]
4 then
5 echo "Need to supply device type, either k2h, k2k, k2l, k2e"
6 exit 1
7fi
8
9# start up RM server
10/usr/bin/rmServer.out /usr/bin/device/$1/global-resource-list.dtb /usr/bin/device/$1/policy_dsp_arm.dtb
11export KERNEL_VER=$(uname -r)
12#install kernel module
13echo $KERNEL_VER
14insmod /lib/modules/$KERNEL_VER/extra/hplibmod.ko
15# disable vlan aware mode in switch
16devmem2 0x2090804 w 0x4
17#
18# run net_test_loopback applicaton, default location of config file is in /etc/transportnetlib/test,
19# default config file name is net_test_config.txt
20/usr/bin/net_test_loopback_$1 /etc/transportnetlib/test/net_test_config.txt
diff --git a/ti/runtime/netapi/tools/net_test_router_setup.sh b/ti/runtime/netapi/tools/net_test_router_setup.sh
new file mode 100644
index 0000000..766bd37
--- /dev/null
+++ b/ti/runtime/netapi/tools/net_test_router_setup.sh
@@ -0,0 +1,24 @@
1#!/bin/sh
2
3if [ -z "$1"]
4 then
5 echo "Need to supply device type, either k2h, k2k, k2l, k2e"
6 exit 1
7fi
8
9# start up RM server
10/usr/bin/rmServer.out /usr/bin/device/$1/global-resource-list.dtb /usr/bin/device/$1/policy_dsp_arm.dtb
11export KERNEL_VER=$(uname -r)
12#install kernel module
13echo $KERNEL_VER
14insmod /lib/modules/$KERNEL_VER/extra/hplibmod.ko
15#
16ifconfig eth1 up
17# any ip address ok here
18ifconfig eth1 10.0.2.100
19# disable vlan aware mode in switch
20devmem2 0x2090804 w 0x4
21#
22# run net_test_router applicaton, default location of config file is in /etc/transportnetlib/test,
23# default config file name is net_test_config.txt
24/usr/bin/net_test_router_$1 /etc/transportnetlib/test/net_test_config.txt
diff --git a/ti/runtime/netapi/tools/nt_bridge_setup.sh b/ti/runtime/netapi/tools/nt_bridge_setup.sh
new file mode 100755
index 0000000..eba7784
--- /dev/null
+++ b/ti/runtime/netapi/tools/nt_bridge_setup.sh
@@ -0,0 +1,21 @@
1#!/bin/sh
2
3if [ -z "$1"]
4 then
5 echo "Need to supply device type, either k2h, k2k"
6 exit 1
7fi
8
9# start up RM server
10/usr/bin/rmServer.out /usr/bin/device/$1/global-resource-list.dtb /usr/bin/device/$1/policy_dsp_arm.dtb
11export KERNEL_VER=$(uname -r)
12#install kernel module
13echo $KERNEL_VER
14insmod /lib/modules/$KERNEL_VER/extra/hplibmod.ko
15#
16#reprogram qos tree shaper rates
17echo "312500000" > /sys/devices/soc.0/hwqueue.6/qos-inputs-2/qos-tree-2/output_rate
18echo "312500000" > /sys/devices/soc.0/hwqueue.6/qos-inputs-2/qos-tree-3/output_rate
19
20# run nt_bridge applicaton
21/usr/bin/nt_bridge_$1 eqos_config1.txt eqos_config2.txt
diff --git a/ti/runtime/netapi/tools/parse_clocks.awk b/ti/runtime/netapi/tools/parse_clocks.awk
new file mode 100755
index 0000000..dc6a68f
--- /dev/null
+++ b/ti/runtime/netapi/tools/parse_clocks.awk
@@ -0,0 +1,3 @@
1BEGIN {}
2/main_div_chip_clk1/ {print $5;}
3END{}
diff --git a/ti/runtime/netapi/tools/pcsetupfornetapi.sh b/ti/runtime/netapi/tools/pcsetupfornetapi.sh
new file mode 100755
index 0000000..3c5657f
--- /dev/null
+++ b/ti/runtime/netapi/tools/pcsetupfornetapi.sh
@@ -0,0 +1,7 @@
1#add local ips
2ifconfig eth0:1 10.0.0.10
3ifconfig eth0:2 192.168.1.10
4
5#install netapi evm ip addresses into arp cache
6arp -v -n -s 10.0.0.100 00:01:02:03:05:05
7arp -v -n -s 192.168.1.100 00:01:02:03:05:05
diff --git a/ti/runtime/netapi/tools/udpif b/ti/runtime/netapi/tools/udpif
new file mode 100755
index 0000000..9e19b11
--- /dev/null
+++ b/ti/runtime/netapi/tools/udpif
Binary files differ
diff --git a/ti/runtime/netapi/tools/udpif.c b/ti/runtime/netapi/tools/udpif.c
new file mode 100644
index 0000000..e150062
--- /dev/null
+++ b/ti/runtime/netapi/tools/udpif.c
@@ -0,0 +1,272 @@
1/*
2 *
3 * udpIf.c - provides udp
4 *
5 */
6//#define BENCHMARK
7#include <sys/types.h>
8#include <sys/socket.h>
9#include <netinet/in.h>
10#include <arpa/inet.h>
11#include <fcntl.h>
12#include <stdio.h>
13#include <errno.h>
14#include <sys/time.h>
15
16int nSent=0;
17
18#ifdef BENCHMARK
19struct timeval stime,mtime,etime;
20#endif
21
22#define SENDSZ 1396
23int SendSize=SENDSZ;
24
25#define MAIN_NEEDED
26#ifdef MAIN_NEEDED
27/******************************************************************************
28 main
29*******************************************************************************/
30/* argv[1] = S for Send, R for Receive
31 argv[2] = fileName
32 argv[3] = port
33 argv[4] = ipAddress
34 argv[5] = send size
35*/
36main(argc,argv)
37int argc;
38char **argv;
39{
40int sending = 0;
41char fileName[256];
42int port;
43char ipAddress[64];
44 if (argc < 4)
45 {
46 printf ("usage:udpIf S|R fileName port [ipAddress] [send size]\n");
47 exit(-1);
48 }
49 sending = (*argv[1] == 'S') ? 1 : 0;
50 strcpy(fileName,argv[2]);
51 port = atoi(argv[3]);
52 if (argc >= 5)
53 strcpy(ipAddress,argv[4]);
54 else
55 strcpy(ipAddress,"");
56 if (argc ==6) SendSize=atoi(argv[5]);
57 if (SendSize > SENDSZ) SendSize=SENDSZ;
58 udpif(sending,fileName,port,ipAddress);
59}
60#endif
61char startstring[]="start";
62char endstring[]="done";
63/******************************************************************************
64 udpif
65*******************************************************************************/
66udpif(sending,fileName,port,ipAddress)
67int sending;
68char *fileName;
69int port;
70char *ipAddress;
71{
72struct sockaddr_in addr,fraddr;
73int addrlen, fd, cnt;
74socklen_t fraddrlen;
75char message[SENDSZ+3];
76int numTries = 0;
77#define MAX_TRIES 5
78int rc;
79int sstate=0;
80int total, rtotal;
81total=rtotal=0;
82 if (sending)
83 {
84 int inFile;
85 inFile = open(fileName,O_RDONLY);
86 if (inFile < 0)
87 {
88 printf ("Can't read %s in tcpIf\n",fileName);
89 exit(-1);
90 }
91 fd = socket(AF_INET, SOCK_DGRAM, 0);
92 printf ("socket is %d\n",fd);
93 if (fd < 0)
94 {
95 perror("socket");
96 exit(1);
97 }
98 bzero(&addr, sizeof(addr));
99 addr.sin_family = AF_INET;
100 addr.sin_addr.s_addr = INADDR_ANY;
101 addr.sin_port = 40000;
102 addrlen = sizeof(addr);
103 rc = bind(fd, &addr, sizeof(addr));
104 printf ("Sender:bind rc is %d\n",rc);
105 if (rc < 0)
106 {
107 perror("bind");
108 exit(1);
109 }
110 addr.sin_addr.s_addr = inet_addr(ipAddress);
111 addr.sin_port = htons(port);
112 printf("dbg: %x %x\n", addr.sin_addr.s_addr, addr.sin_port);
113#ifdef BENCHMARK
114 sendto(fd,
115 startstring,
116 strlen(startstring)+1,
117 0,&addr,sizeof(addr));
118#endif
119 while(1)
120 {
121 char *mPtr;
122 int len;
123 int count = read(inFile,message,/*4096*/ /*SENDSZ*/SendSize);
124#ifndef BENCHMARK
125 //printf ("Sender:in count is %d\n",count);
126#endif
127 if (count == 0)
128 {
129 close(inFile);
130#ifdef BENCHMARK
131 sendto(fd,
132 endstring,
133 strlen(endstring)+1,
134 0,&addr,sizeof(addr));
135
136 sendto(fd,
137 endstring,
138 strlen(endstring)+1,
139 0,&addr,sizeof(addr));
140 sendto(fd,
141 endstring,
142 strlen(endstring)+1,
143 0,&addr,sizeof(addr));
144 printf("sending done %d\n",nSent);
145 sleep(1);
146#endif
147 printf("sending done %d\n",nSent);
148
149 break;
150 }
151 mPtr = message;
152 len = count==-1 ? 5: count;
153 do {
154 cnt = sendto(fd,
155 mPtr,
156 len,
157 0,&addr,sizeof(addr));
158#ifndef BENCHMARK
159 // printf ("Sender:sendto count is %d\n",cnt);
160#endif
161 if (cnt < 0)
162 {
163 close(inFile);
164 perror("sendto");
165 exit(1);
166 }
167 nSent+=1;
168 mPtr += cnt;
169 len -= cnt;
170 } while(len > 0);
171 }
172 }
173 else
174 {
175 /* receive */
176 int outFile;
177 int newSocket;
178 int rc;
179 fd = socket(AF_INET, SOCK_DGRAM, 0);
180 printf ("socket is %d\n",fd);
181 if (fd < 0)
182 {
183 perror("socket");
184 exit(1);
185 }
186 bzero(&addr, sizeof(addr));
187 addr.sin_family = AF_INET;
188 addr.sin_addr.s_addr = htonl(INADDR_ANY);
189 addr.sin_port = htons(port);
190 addrlen = sizeof(addr);
191 rc = bind(fd, &addr, sizeof(addr));
192 printf ("Receiver:bind is %d\n",rc);
193 if (rc < 0)
194 {
195 perror("bind");
196 exit(1);
197 }
198 /*outFile = open(fileName,O_WRONLY | O_CREAT);
199 if (outFile < 0)
200 {
201 printf ("Can't write to %s in tcpIf\n",fileName);
202 exit(-1);
203 }*/
204 memset(&fraddr,0,sizeof(fraddr));
205 fraddr.sin_family= AF_INET;
206 fraddrlen = sizeof(fraddr);
207#ifdef BENCHMARK
208 gettimeofday(&stime, 0 );
209 printf("rcv start @ %d: %d\n",stime.tv_sec, stime.tv_usec);
210
211#endif
212 while(1)
213 {
214#ifdef BENCHMARK
215
216 gettimeofday(&mtime, 0 );
217 if(rtotal >= 10000000)
218 {
219 printf("rcv mtime @ %d: %d %d %d\n",mtime.tv_sec, mtime.tv_usec,total, rtotal);
220 rtotal=0;
221 }
222#endif
223 cnt = recvfrom(fd,
224 message,
225 sizeof(message),
226 0,
227 NULL,
228 &fraddrlen);
229 //printf ("Receiver:recv count = %d\n",cnt);
230 if (cnt == 0)
231 {
232 /*close(outFile);*/
233 continue;
234 }
235 if (cnt < 0)
236 {
237 /*close(outFile);*/
238 perror("recvfrom");
239 exit(1);
240 }
241 rtotal+=cnt;
242 total+=cnt;
243
244 message[cnt+1] = '\0';
245#ifndef BENCHMARK
246 printf("rcvd %s\n",message);
247#else
248 if (strcmp("done",message)==0)
249 {
250 time_t blah1;
251 suseconds_t blah2;
252 gettimeofday(&etime, 0 );
253 blah1= (etime.tv_usec>stime.tv_usec) ?
254 etime.tv_sec-stime.tv_sec :
255 etime.tv_sec-stime.tv_sec-1;
256 blah2 = (etime.tv_usec>stime.tv_usec) ?
257 etime.tv_usec-stime.tv_usec :
258 1000000-stime.tv_usec+etime.tv_usec;
259 printf("DONE @ %d: %d {%d %d}\n",etime.tv_sec, etime.tv_usec,
260 blah1, blah2 );
261 gettimeofday(&etime, 0 );
262 }
263 if (strcmp("start",message)==0)
264 {
265 gettimeofday(&stime, 0 );
266 printf("START @ %d: %d\n",stime.tv_sec, stime.tv_usec);
267 }
268
269#endif
270 }
271 }
272}
diff --git a/ti/runtime/netapi/utils/netapi_util_rm.c b/ti/runtime/netapi/utils/netapi_util_rm.c
new file mode 100644
index 0000000..9d8dd61
--- /dev/null
+++ b/ti/runtime/netapi/utils/netapi_util_rm.c
@@ -0,0 +1,285 @@
1/**************************************************************
2 * FILE PURPOSE : NETAPI Resource Manager Configuration
3 *
4 **************************************************************
5 * @file netapi_rm.c
6 *
7 * @brief DESCRIPTION: netapi resource manager file used for user space
8 * transport library
9 *
10 * REVISION HISTORY:
11 *
12 * Copyright (c) Texas Instruments Incorporated 2014
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41*****************************************************************************/
42
43#include <stdlib.h>
44#include <stdio.h>
45#include <stdarg.h>
46
47#include "ti/runtime/netapi/netapi.h"
48
49/* Socket Includes */
50#include "sockutils.h"
51
52/* RM Includes */
53#include <ti/drv/rm/rm_server_if.h>
54#include <ti/drv/rm/rm.h>
55#include <ti/drv/rm/rm_transport.h>
56#include <ti/drv/rm/rm_services.h>
57
58/* Socket timeout */
59#define CLIENT_SOCK_TIMEOUT_USEC (500)
60
61/* Application's registered RM transport indices */
62#define SERVER_TO_CLIENT_MAP_ENTRY 0
63/* Maximum number of registered RM transports */
64#define MAX_MAPPING_ENTRIES 1
65
66/* Error checking macro */
67#define RM_ERROR_CHECK(checkVal, resultVal, rmInstName, printMsg) \
68 if (resultVal != checkVal) { \
69 char errorMsgToPrint[] = printMsg; \
70 printf("RM Inst : %s : ", rmInstName); \
71 printf("%s with error code : %d, exiting\n", errorMsgToPrint, resultVal); \
72 return(-1); \
73 }
74
75/* RM registered transport mapping structure */
76typedef struct trans_map_entry_s {
77 /* Registered RM transport handle */
78 Rm_TransportHandle transportHandle;
79 /* Remote socket tied to the transport handle */
80 sock_name_t *remote_sock;
81} Transport_MapEntry;
82
83
84
85
86
87/* RM Client Vars */
88Rm_Handle rmClientHandle = NULL;
89Rm_ServiceHandle *rmClientServiceHandle = NULL;
90sock_h rmClientSocket;
91
92/* Client instance name (must match with RM Global Resource List (GRL) and policies */
93char rmClientName[RM_NAME_MAX_CHARS] = "RM_Client_NETAPI";
94
95/* Client socket name */
96char rmClientSockName[] = "/tmp/var/run/rm/rm_client_netapi";
97
98/* Transport map stores the RM transport handle to IPC MessageQ queue mapping */
99Transport_MapEntry rmTransportMap[MAX_MAPPING_ENTRIES];
100
101
102hplib_spinLock_T net_test_rm_lock;
103
104Rm_Packet *transportAlloc(Rm_AppTransportHandle appTransport, uint32_t pktSize, Rm_PacketHandle *pktHandle)
105{
106 Rm_Packet *rm_pkt = NULL;
107
108 rm_pkt = calloc(1, sizeof(*rm_pkt));
109 if (!rm_pkt) {
110 printf("can't malloc for RM send message (err: %s)\n", strerror(errno));
111 return (NULL);
112 }
113 rm_pkt->pktLenBytes = pktSize;
114 *pktHandle = rm_pkt;
115
116 return(rm_pkt);
117}
118
119void transportFree (Rm_Packet *rm_pkt)
120{
121 if (rm_pkt) {
122 free (rm_pkt);
123 }
124}
125
126void transportReceive (void)
127{
128 int32_t rm_result;
129 int retval;
130 int length = 0;
131 sock_name_t server_sock_addr;
132 Rm_Packet *rm_pkt = NULL;
133 struct sockaddr_un server_addr;
134
135 retval = sock_wait(rmClientSocket, &length, NULL, -1);
136 if (retval == -2) {
137 /* Timeout */
138 printf("Error socket timeout\n");
139 return;
140 }
141 else if (retval < 0) {
142 printf("Error in reading from socket, error %d\n", retval);
143 return;
144 }
145
146 if (length < sizeof(*rm_pkt)) {
147 printf("invalid RM message length %d\n", length);
148 return;
149 }
150 rm_pkt = calloc(1, length);
151 if (!rm_pkt) {
152 printf("can't malloc for recv'd RM message (err: %s)\n",
153 strerror(errno));
154 return;
155 }
156
157 server_sock_addr.type = sock_addr_e;
158 server_sock_addr.s.addr = &server_addr;
159 retval = sock_recv(rmClientSocket, (char *)rm_pkt, length, &server_sock_addr);
160 if (retval != length) {
161 printf("recv RM pkt failed from socket, received = %d, expected = %d\n",
162 retval, length);
163 return;
164 }
165
166
167 /* Provide packet to RM Client for processing */
168 if ((rm_result = Rm_receivePacket(rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].transportHandle, rm_pkt))) {
169 printf("RM failed to process received packet !!: %d\n", rm_result);
170 }
171
172 transportFree(rm_pkt);
173}
174
175int32_t transportSendRcv (Rm_AppTransportHandle appTransport, Rm_PacketHandle pktHandle)
176{
177 sock_name_t *server_sock_name = (sock_name_t *)appTransport;
178 Rm_Packet *rm_pkt = (Rm_Packet *)pktHandle;
179
180 hplib_mSpinLockLock(&net_test_rm_lock);
181 if (sock_send(rmClientSocket, (char *)rm_pkt, (int) rm_pkt->pktLenBytes, server_sock_name))
182 {
183 hplib_mSpinLockUnlock(&net_test_rm_lock);
184 return (-1);
185 }
186 /* Wait for response from Server */
187 transportReceive();
188 hplib_mSpinLockUnlock(&net_test_rm_lock);
189
190 return (0);
191}
192
193int connection_setup(void)
194{
195 Rm_TransportCfg rmTransCfg;
196 int32_t rm_result;
197 int i;
198 sock_name_t sock_name;
199 char server_sock_name[] = RM_SERVER_SOCKET_NAME;
200
201 /* Initialize the transport map */
202 for (i = 0; i < MAX_MAPPING_ENTRIES; i++) {
203 rmTransportMap[i].transportHandle = NULL;
204 }
205
206 sock_name.type = sock_name_e;
207 sock_name.s.name = rmClientSockName;
208
209 rmClientSocket = sock_open(&sock_name);
210 if (!rmClientSocket) {
211 printf("connection_setup: Client socket open failed\n");
212 return (-1);
213 }
214
215 rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].remote_sock = calloc(1, sizeof(sock_name_t));
216 rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].remote_sock->type = sock_name_e;
217 rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].remote_sock->s.name = calloc(1, strlen(server_sock_name)+1);
218 strncpy(rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].remote_sock->s.name, server_sock_name, strlen(server_sock_name)+1);
219
220 /* Register the Server with the Client instance */
221 rmTransCfg.rmHandle = rmClientHandle;
222 rmTransCfg.appTransportHandle = (Rm_AppTransportHandle) rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].remote_sock;
223 rmTransCfg.remoteInstType = Rm_instType_SERVER;
224 rmTransCfg.transportCallouts.rmAllocPkt = transportAlloc;
225 rmTransCfg.transportCallouts.rmSendPkt = transportSendRcv;
226 rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].transportHandle = Rm_transportRegister(&rmTransCfg, &rm_result);
227 printf("connection_setup: complete !!!!!!!!!!!!!!!!!!!!!!!!!!\n");
228 return(0);
229}
230
231/** ============================================================================
232 * @n@b initRm
233 *
234 * @b Description
235 * @n This API initializes the RM Client for the QMSS test establishing
236 * a socket connection with the RM Server
237 *
238 * @return int32_t
239 * -1 - Error
240 * 0 - Success
241 * =============================================================================
242 */
243int initRm (void)
244{
245 Rm_InitCfg rmInitCfg;
246 int32_t result;
247
248
249 hplib_mSpinLockInit(&net_test_rm_lock );
250
251 /* Initialize the RM Client - RM must be initialized before anything else in the system */
252 memset(&rmInitCfg, 0, sizeof(rmInitCfg));
253 rmInitCfg.instName = rmClientName;
254 rmInitCfg.instType = Rm_instType_CLIENT;
255 rmClientHandle = Rm_init(&rmInitCfg, &result);
256 RM_ERROR_CHECK(RM_OK, result, rmClientName, "Initialization failed");
257
258
259 /* Open Client service handle */
260 rmClientServiceHandle = Rm_serviceOpenHandle(rmClientHandle, &result);
261 RM_ERROR_CHECK(RM_OK, result, rmClientName, "Service handle open failed");
262
263 return(connection_setup());
264}
265
266int32_t closeRm(void)
267{
268 int32_t result = 0;
269
270 if(rmClientHandle)
271 {
272 result = Rm_serviceCloseHandle(rmClientServiceHandle);
273 RM_ERROR_CHECK(RM_OK, result, rmClientName, "Service handle close failed");
274
275 result = Rm_transportUnregister(rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].transportHandle);
276 RM_ERROR_CHECK(RM_OK, result, rmClientName, "Unregister of CD transport failed");
277
278 result = Rm_delete(rmClientHandle, 1);
279 RM_ERROR_CHECK(RM_OK, result, rmClientName, "Instance delete failed");
280 }
281 return (result);
282}
283
284
285
diff --git a/ti/runtime/netapi/utils/sockutils.c b/ti/runtime/netapi/utils/sockutils.c
new file mode 100644
index 0000000..13933b8
--- /dev/null
+++ b/ti/runtime/netapi/utils/sockutils.c
@@ -0,0 +1,260 @@
1/*
2 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
3 *
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
15 * distribution.
16 *
17 * Neither the name of Texas Instruments Incorporated nor the names of
18 * its contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 */
34
35#include <string.h>
36#include <unistd.h>
37#include <errno.h>
38#include <malloc.h>
39#include <sys/stat.h>
40#include <sys/types.h>
41#include <sys/ioctl.h>
42
43#include "sockutils.h"
44
45#define error_msg printf
46
47typedef struct sock_data {
48 struct sockaddr_un addr;
49 fd_set readfds;
50 int fd;
51} sock_data_t;
52
53int check_and_create_path (char *path)
54{
55 char *d = path;
56 if (!d)
57 return -1;
58
59 while ((d = strchr(d + 1, '/'))) {
60 *d = 0;
61 if (mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) {
62 if (errno != EEXIST) {
63 *d = '/';
64 error_msg("can't create path %s (error: %s)",
65 path, strerror(errno));
66 return -1;
67 }
68 }
69 *d = '/';
70 }
71 return 0;
72}
73
74sock_h sock_open (sock_name_t *sock_name)
75{
76 sock_data_t *sd = 0;
77 int retval = 0;
78
79 if (!sock_name) {
80 return 0;
81 }
82
83 sd = calloc (1, sizeof(sock_data_t));
84
85 if (sock_name->type == sock_addr_e) {
86 memcpy (&sd->addr, sock_name->s.addr, sizeof(struct sockaddr_un));
87 } else {
88 if (check_and_create_path(sock_name->s.name) < 0) {
89 goto check_n_return;
90 }
91 sd->addr.sun_family = AF_UNIX;
92 strncpy(sd->addr.sun_path, sock_name->s.name, UNIX_PATH_MAX);
93 }
94
95 sd->fd = socket(AF_UNIX, SOCK_DGRAM, 0);
96 if (sd->fd < 0) {
97 error_msg("can't open socket %s (error: %s)",
98 sd->addr.sun_path, strerror(errno));
99 goto check_n_return;
100 }
101
102 unlink(sd->addr.sun_path);
103 if (bind(sd->fd, (struct sockaddr *) &sd->addr, sizeof(struct sockaddr_un)) < 0) {
104 error_msg("can't bind socket %s (error: %s)",
105 sd->addr.sun_path, strerror(errno));
106 goto check_n_return;
107 }
108
109 FD_ZERO(&sd->readfds);
110 FD_SET(sd->fd, &sd->readfds);
111
112 retval = (int) sd;
113
114check_n_return:
115 if (!retval) {
116 sock_close ((sock_h) &sd);
117 }
118
119 return ((sock_h) retval);
120}
121
122int sock_close (sock_h handle)
123{
124 sock_data_t *sd = (sock_data_t *) handle;
125
126 if (!sd) {
127 return -1;
128 }
129
130 if (sd->fd)
131 close (sd->fd);
132 free (sd);
133
134 return 0;
135}
136
137int sock_send (sock_h handle, const char *data, int length,
138 sock_name_t *to)
139{
140 int fd;
141 sock_data_t *sd = (sock_data_t *) handle;
142 struct sockaddr_un to_addr;
143
144 if (!to) {
145 return -1;
146 }
147
148 if (to->type == sock_addr_e) {
149 memcpy (&to_addr, to->s.addr, sizeof(struct sockaddr_un));
150 } else {
151 to_addr.sun_family = AF_UNIX;
152 strncpy(to_addr.sun_path, to->s.name, UNIX_PATH_MAX);
153 }
154
155 if (sd) {
156 fd = sd->fd;
157 } else {
158 fd = socket(AF_UNIX, SOCK_DGRAM, 0);
159 if (fd < 0) {
160 error_msg("can't open socket %s (error: %s)",
161 to_addr.sun_path, strerror(errno));
162 return -1;
163 }
164 }
165
166 if (sendto (fd, data, length, 0, (struct sockaddr *) &to_addr,
167 sizeof(struct sockaddr_un)) < 0) {
168 error_msg("can't send data to %s (error: %s)",
169 to_addr.sun_path, strerror(errno));
170 return -1;
171
172 }
173
174 if (!sd) {
175 close(fd);
176 }
177
178 return 0;
179}
180
181int sock_wait (sock_h handle, int *size, struct timeval *timeout, int extern_fd)
182{
183 sock_data_t *sd = (sock_data_t *) handle;
184 int retval;
185 fd_set fds;
186
187 if (!sd) {
188 error_msg("invalid hanlde");
189 return -1;
190 }
191
192 fds = sd->readfds;
193
194 if (extern_fd != -1) {
195 FD_SET(extern_fd, &fds);
196 }
197
198 retval = select(FD_SETSIZE, &fds, NULL, NULL, timeout);
199 if (retval == -1) {
200 error_msg("select failed for %s (error: %s)",
201 sd->addr.sun_path, strerror(errno));
202 return -1;
203 }
204
205 if ((extern_fd != -1) && (FD_ISSET(extern_fd, &fds))) {
206 return 1;
207 }
208
209 if (!FD_ISSET(sd->fd, &fds)) {
210 /* Wait timedout */
211 return -2;
212 }
213
214 if (!retval) {
215 return 0;
216 }
217
218 if (size != 0) {
219 retval = ioctl(sd->fd, FIONREAD, size);
220 if (retval == -1) {
221 error_msg("can't read datagram size for %s (error: %s)",
222 sd->addr.sun_path, strerror(errno));
223 return -1;
224 }
225 }
226
227 return 0;
228}
229
230int sock_recv (sock_h handle, char *data, int length, sock_name_t *from)
231{
232 int size;
233 sock_data_t *sd = (sock_data_t *) handle;
234 socklen_t from_length = 0;
235
236 if (!sd) {
237 error_msg("invalid hanlde");
238 return -1;
239 }
240
241 if (from) {
242 if((from->type == sock_addr_e) && (from->s.addr))
243 from_length = sizeof(struct sockaddr_un);
244 else {
245 error_msg("invalid from parameter");
246 return -1;
247 }
248 }
249
250 size = recvfrom(sd->fd, data, length, 0, (struct sockaddr *)((from_length) ? from->s.addr : NULL), &from_length);
251 if (size < 1) {
252 error_msg("can't read datagram from socket for %s (error: %s), size %d",
253 sd->addr.sun_path, strerror(errno), size);
254 return -1;
255 }
256
257 return size;
258
259}
260
diff --git a/ti/runtime/netapi/utils/sockutils.h b/ti/runtime/netapi/utils/sockutils.h
new file mode 100644
index 0000000..ad83e08
--- /dev/null
+++ b/ti/runtime/netapi/utils/sockutils.h
@@ -0,0 +1,74 @@
1/*
2 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
3 *
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
15 * distribution.
16 *
17 * Neither the name of Texas Instruments Incorporated nor the names of
18 * its contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33*/
34
35#ifndef __SOCKUTILS_H__
36#define __SOCKUTILS_H__
37
38#include <sys/socket.h>
39#include <sys/un.h>
40
41#ifndef UNIX_PATH_MAX
42#define UNIX_PATH_MAX 108
43#endif
44
45
46typedef enum {
47 sock_name_e,
48 sock_addr_e
49} sock_name_type;
50
51typedef struct {
52 sock_name_type type;
53 union sock {
54 char *name;
55 struct sockaddr_un *addr;
56 } s;
57} sock_name_t;
58
59#define sock_h void *
60
61int check_and_create_path (char *path);
62sock_h sock_open (sock_name_t *sock_name);
63
64int sock_close (sock_h handle);
65
66int sock_send (sock_h handle, const char *data, int length,
67 sock_name_t *to);
68
69/* Returns: 1 => success (external FD), 0 => success, -1 => error, -2 => timeout */
70int sock_wait (sock_h handle, int *size, struct timeval *timeout, int extern_fd);
71
72int sock_recv (sock_h handle, char *data, int length, sock_name_t *from);
73
74#endif