├── .gitignore ├── DLBZoo └── README.md ├── DSAZoo ├── README.md ├── benchmark_guide_for_PoC.pdf ├── build.txt ├── dsa+mtcp PoC SPR-Tuning-Guide-PRC-proposal.pdf ├── dsa_userlib │ ├── CMakeLists.txt │ ├── README.md │ ├── config_dsa │ │ ├── configs │ │ │ ├── 1e1w-d.conf │ │ │ ├── 1e1w-s.conf │ │ │ ├── 4e1w-d.conf │ │ │ ├── 4e4w-d.conf │ │ │ └── 4e8w-d.conf │ │ └── setup_dsa.sh │ ├── dsa.gif │ ├── include │ │ ├── accfg │ │ │ ├── .libs │ │ │ │ └── accel-config │ │ │ ├── accfg.h │ │ │ ├── config.h │ │ │ ├── idxd.h │ │ │ └── libaccel_config.h │ │ ├── accfg_test.h │ │ ├── bitops.h │ │ ├── ccan │ │ │ ├── array_size │ │ │ │ └── array_size.h │ │ │ ├── build_assert │ │ │ │ └── build_assert.h │ │ │ ├── check_type │ │ │ │ └── check_type.h │ │ │ ├── container_of │ │ │ │ └── container_of.h │ │ │ ├── endian │ │ │ │ └── endian.h │ │ │ ├── list │ │ │ │ ├── .dirstamp │ │ │ │ └── list.h │ │ │ ├── minmax │ │ │ │ └── minmax.h │ │ │ ├── short_types │ │ │ │ └── short_types.h │ │ │ └── str │ │ │ │ ├── .dirstamp │ │ │ │ ├── str.h │ │ │ │ └── str_debug.h │ │ ├── config.h │ │ ├── dsa.h │ │ ├── test.h │ │ └── util │ │ │ ├── .dirstamp │ │ │ ├── bitmap.h │ │ │ ├── filter.h │ │ │ ├── json.h │ │ │ ├── list.h │ │ │ ├── log.h │ │ │ ├── log.lo │ │ │ ├── main.h │ │ │ ├── parse-options.h │ │ │ ├── size.h │ │ │ ├── strbuf.h │ │ │ ├── sysfs.h │ │ │ ├── sysfs.lo │ │ │ └── util.h │ ├── src │ │ ├── CMakeLists.txt │ │ ├── core.c │ │ ├── dsa.c │ │ ├── log.c │ │ └── prep.c │ └── test │ │ ├── CMakeLists.txt │ │ ├── dsa_memcpy_single.c │ │ ├── dsa_mt_async.c │ │ ├── dsa_mt_single.c │ │ ├── dsa_mt_vector.c │ │ ├── dsa_test.c │ │ ├── dsa_test_async.c │ │ ├── dsa_test_batch.c │ │ └── dsa_test_vector.c ├── example_mtcp │ ├── .buildtest_dpdk.sh │ ├── .buildtest_netmap.sh │ ├── .buildtest_psio.sh │ ├── .check_hyperthreading.sh │ ├── .pre_dpdk2203.sh.swp │ ├── .travis.yml │ ├── CHANGELOG │ ├── LICENSE │ ├── Makefile │ ├── Makefile.am │ ├── Makefile.in │ ├── README │ ├── README.config │ ├── README.devel │ ├── README.md │ ├── README.netmap │ ├── TODOS │ ├── aclocal.m4 │ ├── apps │ │ ├── example │ │ │ ├── .gitignore │ │ │ ├── Makefile.in │ │ │ ├── Makefile.old │ │ │ ├── README │ │ │ ├── config │ │ │ │ ├── arp.conf │ │ │ │ └── route.conf │ │ │ ├── epping.c │ │ │ ├── epping.conf │ │ │ ├── epserver-multiprocess.conf │ │ │ ├── epserver.c │ │ │ ├── epserver.conf │ │ │ ├── epwget-multiprocess.conf │ │ │ ├── epwget.c │ │ │ └── epwget.conf │ │ └── perf │ │ │ ├── .gitignore │ │ │ ├── Makefile │ │ │ ├── Makefile.in │ │ │ ├── README.md │ │ │ ├── add-delay-bw.sh │ │ │ ├── add-delay.sh │ │ │ ├── client.c │ │ │ ├── client.conf │ │ │ ├── recv.py │ │ │ └── rm-delay.sh │ ├── autom4te.cache │ │ ├── output.0 │ │ ├── output.1 │ │ ├── output.2 │ │ ├── requests │ │ ├── traces.0 │ │ ├── traces.1 │ │ └── traces.2 │ ├── compile │ ├── compile_prepare.sh │ ├── config.guess │ ├── config.h │ ├── config.h.in │ ├── config.h.in~ │ ├── config.log │ ├── config.status │ ├── config.sub │ ├── config │ │ ├── affinity-netmap.py │ │ ├── sample_arp.conf │ │ ├── sample_mtcp.conf │ │ └── sample_route.conf │ ├── configure │ ├── configure.ac │ ├── docs │ │ ├── html │ │ │ ├── mtcp_accept.html │ │ │ ├── mtcp_bind.html │ │ │ ├── mtcp_close.html │ │ │ ├── mtcp_connect.html │ │ │ ├── mtcp_create_context.html │ │ │ ├── mtcp_destroy.html │ │ │ ├── mtcp_destroy_context.html │ │ │ ├── mtcp_getpeername.html │ │ │ ├── mtcp_getsockname.html │ │ │ ├── mtcp_getsockopt.html │ │ │ ├── mtcp_init.html │ │ │ ├── mtcp_init_rss.html │ │ │ ├── mtcp_listen.html │ │ │ ├── mtcp_read.html │ │ │ ├── mtcp_recv.html │ │ │ ├── mtcp_setsockopt.html │ │ │ ├── mtcp_socket.html │ │ │ └── mtcp_write.html │ │ └── man │ │ │ ├── mtcp_accept │ │ │ ├── mtcp_bind │ │ │ ├── mtcp_close │ │ │ ├── mtcp_connect │ │ │ ├── mtcp_create_context │ │ │ ├── mtcp_destroy │ │ │ ├── mtcp_destroy_context │ │ │ ├── mtcp_getpeername │ │ │ ├── mtcp_getsockname │ │ │ ├── mtcp_getsockopt │ │ │ ├── mtcp_init │ │ │ ├── mtcp_init_rss │ │ │ ├── mtcp_listen │ │ │ ├── mtcp_read │ │ │ ├── mtcp_recv │ │ │ ├── mtcp_setsockopt │ │ │ ├── mtcp_socket │ │ │ └── mtcp_write │ ├── install-sh │ ├── io_engine │ │ ├── COPYING │ │ ├── driver │ │ │ ├── Makefile │ │ │ ├── affinity.py │ │ │ ├── affinity_numa0.py │ │ │ ├── affinity_numa1.py │ │ │ ├── install.py │ │ │ ├── ixgbe.h │ │ │ ├── ixgbe_82598.c │ │ │ ├── ixgbe_82599.c │ │ │ ├── ixgbe_api.c │ │ │ ├── ixgbe_api.h │ │ │ ├── ixgbe_common.c │ │ │ ├── ixgbe_common.h │ │ │ ├── ixgbe_dcb.c │ │ │ ├── ixgbe_dcb.h │ │ │ ├── ixgbe_dcb_82598.c │ │ │ ├── ixgbe_dcb_82598.h │ │ │ ├── ixgbe_dcb_82599.c │ │ │ ├── ixgbe_dcb_82599.h │ │ │ ├── ixgbe_dcb_nl.c │ │ │ ├── ixgbe_ethtool.c │ │ │ ├── ixgbe_fcoe.c │ │ │ ├── ixgbe_fcoe.h │ │ │ ├── ixgbe_main.c │ │ │ ├── ixgbe_osdep.h │ │ │ ├── ixgbe_param.c │ │ │ ├── ixgbe_phy.c │ │ │ ├── ixgbe_phy.h │ │ │ ├── ixgbe_sysfs.c │ │ │ ├── ixgbe_type.h │ │ │ ├── kcompat.c │ │ │ ├── kcompat.h │ │ │ └── kcompat_ethtool.c │ │ ├── include │ │ │ └── ps.h │ │ ├── lib │ │ │ ├── Makefile │ │ │ ├── Makefile.in │ │ │ └── pslib.c │ │ └── samples │ │ │ ├── echo │ │ │ ├── Makefile │ │ │ ├── echo.c │ │ │ └── echo_new.c │ │ │ ├── list_devices │ │ │ ├── Makefile │ │ │ └── list_devices.c │ │ │ ├── packet_generator │ │ │ ├── Makefile │ │ │ └── packet_generator.c │ │ │ └── rxdump │ │ │ ├── Makefile │ │ │ └── rxdump.c │ ├── missing │ ├── mtcp │ │ ├── include │ │ │ └── .gitignore │ │ ├── lib │ │ │ └── .gitignore │ │ └── src │ │ │ ├── Makefile │ │ │ ├── Makefile.in │ │ │ ├── Makefile.old │ │ │ ├── addr_pool.c │ │ │ ├── api.c │ │ │ ├── arp.c │ │ │ ├── ccp.c │ │ │ ├── clock.c │ │ │ ├── config.c │ │ │ ├── core.c │ │ │ ├── cpu.c │ │ │ ├── debug.c │ │ │ ├── dpdk_module.c │ │ │ ├── eth_in.c │ │ │ ├── eth_out.c │ │ │ ├── eventpoll.c │ │ │ ├── fhash.c │ │ │ ├── icmp.c │ │ │ ├── include │ │ │ ├── addr_pool.h │ │ │ ├── arp.h │ │ │ ├── ccp.h │ │ │ ├── clock.h │ │ │ ├── config.h │ │ │ ├── cpu.h │ │ │ ├── debug.h │ │ │ ├── eth_in.h │ │ │ ├── eth_out.h │ │ │ ├── eventpoll.h │ │ │ ├── fhash.h │ │ │ ├── icmp.h │ │ │ ├── io_module.h │ │ │ ├── ip_in.h │ │ │ ├── ip_out.h │ │ │ ├── logger.h │ │ │ ├── memory_mgt.h │ │ │ ├── mtcp.h │ │ │ ├── mtcp_api.h │ │ │ ├── mtcp_epoll.h │ │ │ ├── netmap.h │ │ │ ├── netmap_user.h │ │ │ ├── pacing.h │ │ │ ├── pipe.h │ │ │ ├── rss.h │ │ │ ├── rte_common.h │ │ │ ├── rte_config.h │ │ │ ├── rte_os.h │ │ │ ├── sfifo.h │ │ │ ├── socket.h │ │ │ ├── stat.h │ │ │ ├── tcp_in.h │ │ │ ├── tcp_out.h │ │ │ ├── tcp_rb_frag_queue.h │ │ │ ├── tcp_ring_buffer.h │ │ │ ├── tcp_sb_queue.h │ │ │ ├── tcp_send_buffer.h │ │ │ ├── tcp_stream.h │ │ │ ├── tcp_stream_queue.h │ │ │ ├── tcp_util.h │ │ │ ├── timer.h │ │ │ ├── virtio_ring.h │ │ │ └── virtqueue.h │ │ │ ├── io_module.c │ │ │ ├── ip_in.c │ │ │ ├── ip_out.c │ │ │ ├── libccp │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── BUILD.gn │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── ccp.c │ │ │ ├── ccp.h │ │ │ ├── ccp_priv.c │ │ │ ├── ccp_priv.h │ │ │ ├── integration_test.py │ │ │ ├── machine.c │ │ │ ├── serialize.c │ │ │ ├── serialize.h │ │ │ └── test.c │ │ │ ├── logger.c │ │ │ ├── memory_mgt.c │ │ │ ├── netmap_module.c │ │ │ ├── onvm_module.c │ │ │ ├── pacing.c │ │ │ ├── pipe.c │ │ │ ├── psio_module.c │ │ │ ├── rss.c │ │ │ ├── sfifo.c │ │ │ ├── socket.c │ │ │ ├── tcp_in.c │ │ │ ├── tcp_out.c │ │ │ ├── tcp_rb_frag_queue.c │ │ │ ├── tcp_ring_buffer.c │ │ │ ├── tcp_sb_queue.c │ │ │ ├── tcp_send_buffer.c │ │ │ ├── tcp_stream.c │ │ │ ├── tcp_stream_queue.c │ │ │ ├── tcp_util.c │ │ │ ├── timer.c │ │ │ └── virtqueue.c │ ├── pre_compile.sh │ ├── pre_dpdk2203.sh │ ├── setup_linux_env.sh │ ├── setup_mtcp_dpdk_env.sh │ ├── setup_mtcp_onvm_env.sh │ ├── stamp-h1 │ ├── util │ │ ├── Makefile │ │ ├── Makefile.in │ │ ├── cpu.c │ │ ├── http_parsing.c │ │ ├── include │ │ │ ├── cpu.h │ │ │ ├── debug.h │ │ │ ├── http_parsing.h │ │ │ ├── netlib.h │ │ │ ├── ring_buffer.h │ │ │ ├── rss.h │ │ │ └── tdate_parse.h │ │ ├── netlib.c │ │ ├── ring_buffer.c │ │ ├── rss.c │ │ └── tdate_parse.c │ └── ww-set-hp.sh └── kernel_build_and_iax_enable_v1.0.pdf ├── IAAZoo ├── Arrow_Parquet_Reader_with_IAA │ ├── README.md │ ├── arrow_rledecode_with_iaa.patch │ └── img │ │ ├── IAA.png │ │ ├── NoIAA.png │ │ └── RleDeocder.png └── README.md ├── Intel-Sapphire-Rapids-accelerators.jpg ├── QATZoo └── README.md ├── README.md ├── benchmark_guide_for_PoC.pdf ├── intel-accelerator-zoo.jpeg └── kernel_build_and_iax_enable_v1.0.pdf /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.d 3 | 4 | # ignore default build directory, and directories from test-meson-builds.sh 5 | build 6 | build-* 7 | # ignore other build directory patterns 8 | 9 | -------------------------------------------------------------------------------- /DLBZoo/README.md: -------------------------------------------------------------------------------- 1 | # Intel DLB Zoo 2 | 3 | -------------------------------------------------------------------------------- /DSAZoo/README.md: -------------------------------------------------------------------------------- 1 | # Intel DSA Zoo 2 | Intel DSA(Data streaming accelerator), [specification link](https://www.intel.com/content/www/us/en/content-details/671116/intel-data-streaming-accelerator-architecture-specification.html?wapkw=data%20streaming%20accelerator%20specification),DSA is a high-performance data copy and transformation accelerator that will be integrated in future Intel® processors, targeted for optimizing streaming data movement and transformation operations common with applications for high-performance storage, networking, persistent memory, and various data processing applications. 3 | The project is to propagate the usage to illustrate vector data streaming with DSA (Data Streaming Accelerator) feature introduced in the Intel® Sapphire Rapids platform. It provides an effective data manipulation to demonstrate data move and transforms which can be used by networking, service mesh, message queue, or image distribution. 4 | Here we provide a reference example to use our library in user space network implementation mTCP. The users can use this library into their own network protocal stack. 5 | -------------------------------------------------------------------------------- /DSAZoo/benchmark_guide_for_PoC.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/accelerator-solution-zoo/36b95b6854aa43f2da6b07cc70bf703fe4ef0669/DSAZoo/benchmark_guide_for_PoC.pdf -------------------------------------------------------------------------------- /DSAZoo/build.txt: -------------------------------------------------------------------------------- 1 | 1 Build libary: 2 | 1.1 Go into dsa_userlib directory. 3 | 1.2 Use mkdir command to create a new directory such as named with "build" for building. 4 | 1.3 Go into build directory, and run "cmake .." to generate building files such as Makefile. 5 | 1.4 Run "make" command to build the library. 6 | 7 | 2 Build example(user space network protocol mTCP) 8 | 2.1 Go into example_mtcp directory 9 | 2.2 Run script pre_dpdk2203.sh to git clone dpdk v22.03, and then build and install it, command like: ./pre_dpdk2203.sh ~/dpdk2203 10 | 2.3 Run script pre_compile.sh to prepare the environment before you building this project: ./pre_compile.sh 11 | 2.4 Set environments 12 | export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:~/dpdk2203/lib64/pkgconfig 13 | export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:~/dpdk2203/lib64 14 | 2.5 Run make command to build the mtcp and sample workload epping. 15 | -------------------------------------------------------------------------------- /DSAZoo/dsa+mtcp PoC SPR-Tuning-Guide-PRC-proposal.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/accelerator-solution-zoo/36b95b6854aa43f2da6b07cc70bf703fe4ef0669/DSAZoo/dsa+mtcp PoC SPR-Tuning-Guide-PRC-proposal.pdf -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #Author: william.wu@intel.com 2 | #Date: 2021/11/10 3 | #History: Created this file for cmake build. 4 | 5 | cmake_minimum_required(VERSION 3.8) 6 | project(vector-data-streaming-library) 7 | 8 | #SET(CMAKE_BUILD_TYPE "Debug") 9 | set(CMAKE_C_FLAGS_Release "${CMAKE_C_FLAGS_Release} -O3") 10 | 11 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 12 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 13 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 14 | 15 | #add_compile_options(-D__REMOTE_HOST__) 16 | MESSAGE(${CMAKE_SOURCE_DIR}) 17 | include_directories(${CMAKE_SOURCE_DIR}/include) 18 | 19 | add_subdirectory(src) 20 | 21 | #Todo: to add a validation directory which to do unit test 22 | add_subdirectory(test) 23 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/README.md: -------------------------------------------------------------------------------- 1 | DSA user library 2 | ========== 3 | ![](dsa.gif) 4 | 5 | 6 | Dependency 7 | ==== 8 | - You need firstly build and install accel-config from: 9 | https://github.com/intel/idxd-config 10 | 11 | Build 12 | ===== 13 | - To build the project with steps are following: 14 | ``` 15 | - cd build 16 | - cmake .. 17 | - make 18 | ``` 19 | 20 | Configure dsa 21 | ===== 22 | - Make sure you have installed accel-config library and tools before doing this step 23 | ``` 24 | - cd config_dsa 25 | - ./setup_dsa.sh configs/4e1w-d.conf 26 | ``` 27 | 28 | Run test 29 | ===== 30 | - To run dsa_test for single mode, run dsa_test_batch for batch mode 31 | ``` 32 | - cd build/bin 33 | - ./dsa_test -w 0 -l 4096 -o 3 34 | - ./dsa_test_batch -w 0 -l 4096 -c 16 35 | - ./dsa_test_vector -w0 -o3 -l 4096 -n128 36 | - ./dsa_test_vector -w0 -o3 -l 4096 -m -n128 37 | ``` 38 | 39 | 40 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/config_dsa/configs/1e1w-d.conf: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "dev":"dsa0", 4 | "token_limit":0, 5 | "groups":[ 6 | { 7 | "dev":"group0.0", 8 | "tokens_reserved":0, 9 | "use_token_limit":0, 10 | "grouped_workqueues":[ 11 | { 12 | "dev":"wq0.0", 13 | "mode":"dedicated", 14 | "size":128, 15 | "group_id":0, 16 | "priority":10, 17 | "block_on_fault":0, 18 | "type":"user", 19 | "name":"app1", 20 | "threshold":15 21 | } 22 | ], 23 | "grouped_engines":[ 24 | { 25 | "dev":"engine0.0", 26 | "group_id":0 27 | } 28 | ] 29 | } 30 | ] 31 | } 32 | ] 33 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/config_dsa/configs/1e1w-s.conf: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "dev":"dsa0", 4 | "token_limit":0, 5 | "groups":[ 6 | { 7 | "dev":"group0.0", 8 | "tokens_reserved":0, 9 | "use_token_limit":0, 10 | "grouped_workqueues":[ 11 | { 12 | "dev":"wq0.0", 13 | "mode":"shared", 14 | "size":128, 15 | "group_id":0, 16 | "priority":10, 17 | "block_on_fault":0, 18 | "type":"user", 19 | "name":"app1", 20 | "threshold":128 21 | } 22 | ], 23 | "grouped_engines":[ 24 | { 25 | "dev":"engine0.0", 26 | "group_id":0 27 | } 28 | ] 29 | } 30 | ] 31 | } 32 | ] 33 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/config_dsa/configs/4e1w-d.conf: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "dev":"dsa0", 4 | "token_limit":0, 5 | "groups":[ 6 | { 7 | "dev":"group0.0", 8 | "tokens_reserved":0, 9 | "use_token_limit":0, 10 | "grouped_workqueues":[ 11 | { 12 | "dev":"wq0.0", 13 | "mode":"dedicated", 14 | "size":128, 15 | "group_id":0, 16 | "priority":10, 17 | "block_on_fault":0, 18 | "type":"user", 19 | "name":"app1", 20 | "threshold":15 21 | } 22 | ], 23 | "grouped_engines":[ 24 | { 25 | "dev":"engine0.0", 26 | "group_id":0 27 | }, 28 | { 29 | "dev":"engine0.1", 30 | "group_id":0 31 | }, 32 | { 33 | "dev":"engine0.2", 34 | "group_id":0 35 | }, 36 | { 37 | "dev":"engine0.3", 38 | "group_id":0 39 | } 40 | ] 41 | } 42 | ] 43 | } 44 | ] 45 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/config_dsa/configs/4e4w-d.conf: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "dev":"dsa0", 4 | "token_limit":0, 5 | "groups":[ 6 | { 7 | "dev":"group0.0", 8 | "tokens_reserved":0, 9 | "use_token_limit":0, 10 | "grouped_workqueues":[ 11 | { 12 | "dev":"wq0.0", 13 | "mode":"dedicated", 14 | "size":32, 15 | "group_id":0, 16 | "priority":10, 17 | "block_on_fault":0, 18 | "type":"user", 19 | "name":"app1", 20 | "threshold":15 21 | }, 22 | { 23 | "dev":"wq0.1", 24 | "mode":"dedicated", 25 | "size":32, 26 | "group_id":0, 27 | "priority":10, 28 | "block_on_fault":0, 29 | "type":"user", 30 | "name":"app2", 31 | "threshold":15 32 | }, 33 | { 34 | "dev":"wq0.2", 35 | "mode":"dedicated", 36 | "size":32, 37 | "group_id":0, 38 | "priority":10, 39 | "block_on_fault":0, 40 | "type":"user", 41 | "name":"app3", 42 | "threshold":15 43 | }, 44 | { 45 | "dev":"wq0.3", 46 | "mode":"dedicated", 47 | "size":32, 48 | "group_id":0, 49 | "priority":10, 50 | "block_on_fault":0, 51 | "type":"user", 52 | "name":"app1", 53 | "threshold":15 54 | } 55 | ], 56 | "grouped_engines":[ 57 | { 58 | "dev":"engine0.0", 59 | "group_id":0 60 | }, 61 | { 62 | "dev":"engine0.1", 63 | "group_id":0 64 | }, 65 | { 66 | "dev":"engine0.2", 67 | "group_id":0 68 | }, 69 | { 70 | "dev":"engine0.3", 71 | "group_id":0 72 | } 73 | ] 74 | } 75 | ] 76 | } 77 | ] 78 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/dsa.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/accelerator-solution-zoo/36b95b6854aa43f2da6b07cc70bf703fe4ef0669/DSAZoo/dsa_userlib/dsa.gif -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/accfg/.libs/accel-config: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/accelerator-solution-zoo/36b95b6854aa43f2da6b07cc70bf703fe4ef0669/DSAZoo/dsa_userlib/include/accfg/.libs/accel-config -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/accfg/accfg.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* Copyright(c) 2019 Intel Corporation. All rights reserved. */ 3 | 4 | #ifndef __ACCFG_H__ 5 | #define __ACCFG_H__ 6 | 7 | #ifndef ARRAY_SIZE 8 | #include 9 | #endif 10 | #include 11 | #include 12 | #include 13 | 14 | #endif /* __ACCFG_H__ */ 15 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/accfg/config.h: -------------------------------------------------------------------------------- 1 | /* Autogenerated by accfg/Makefile.am */ 2 | #define ACCFG_CONF_FILE "/etc/accel-config/accel-config.conf" 3 | #define ACCFG_CONF_DIR "/etc/accel-config" 4 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/accfg_test.h: -------------------------------------------------------------------------------- 1 | #ifndef _DSA_TEST_H_ 2 | #define _DSA_TEST_H_ 3 | 4 | static inline void movdir64b(volatile void *portal, void *desc) 5 | { 6 | asm volatile("sfence\t\n" 7 | ".byte 0x66, 0x0f, 0x38, 0xf8, 0x02\t\n" : 8 | : "a" (portal), "d" (desc)); 9 | } 10 | 11 | static inline unsigned char enqcmd(volatile void *portal, void *desc) 12 | { 13 | unsigned char retry; 14 | asm volatile("sfence\t\n" 15 | ".byte 0xf2, 0x0f, 0x38, 0xf8, 0x02\t\n" 16 | "setz %0\t\n" 17 | : "=r"(retry): "a" (portal), "d" (desc)); 18 | return retry; 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/ccan/array_size/array_size.h: -------------------------------------------------------------------------------- 1 | /* CC0 (Public domain) - see LICENSE file for details */ 2 | #ifndef CCAN_ARRAY_SIZE_H 3 | #define CCAN_ARRAY_SIZE_H 4 | #include "config.h" 5 | #include 6 | 7 | /** 8 | * ARRAY_SIZE - get the number of elements in a visible array 9 | * @arr: the array whose size you want. 10 | * 11 | * This does not work on pointers, or arrays declared as [], or 12 | * function parameters. With correct compiler support, such usage 13 | * will cause a build error (see build_assert). 14 | */ 15 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + _array_size_chk(arr)) 16 | 17 | #if HAVE_BUILTIN_TYPES_COMPATIBLE_P && HAVE_TYPEOF 18 | /* Two gcc extensions. 19 | * &a[0] degrades to a pointer: a different type from an array */ 20 | #define _array_size_chk(arr) \ 21 | BUILD_ASSERT_OR_ZERO(!__builtin_types_compatible_p(typeof(arr), \ 22 | typeof(&(arr)[0]))) 23 | #else 24 | #define _array_size_chk(arr) 0 25 | #endif 26 | #endif /* CCAN_ALIGNOF_H */ 27 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/ccan/build_assert/build_assert.h: -------------------------------------------------------------------------------- 1 | /* CC0 (Public domain) - see LICENSE file for details */ 2 | #ifndef CCAN_BUILD_ASSERT_H 3 | #define CCAN_BUILD_ASSERT_H 4 | 5 | /** 6 | * BUILD_ASSERT - assert a build-time dependency. 7 | * @cond: the compile-time condition which must be true. 8 | * 9 | * Your compile will fail if the condition isn't true, or can't be evaluated 10 | * by the compiler. This can only be used within a function. 11 | * 12 | * Example: 13 | * #include 14 | * ... 15 | * static char *foo_to_char(struct foo *foo) 16 | * { 17 | * // This code needs string to be at start of foo. 18 | * BUILD_ASSERT(offsetof(struct foo, string) == 0); 19 | * return (char *)foo; 20 | * } 21 | */ 22 | #define BUILD_ASSERT(cond) \ 23 | do { (void) sizeof(char [1 - 2*!(cond)]); } while(0) 24 | 25 | /** 26 | * BUILD_ASSERT_OR_ZERO - assert a build-time dependency, as an expression. 27 | * @cond: the compile-time condition which must be true. 28 | * 29 | * Your compile will fail if the condition isn't true, or can't be evaluated 30 | * by the compiler. This can be used in an expression: its value is "0". 31 | * 32 | * Example: 33 | * #define foo_to_char(foo) \ 34 | * ((char *)(foo) \ 35 | * + BUILD_ASSERT_OR_ZERO(offsetof(struct foo, string) == 0)) 36 | */ 37 | #define BUILD_ASSERT_OR_ZERO(cond) \ 38 | (sizeof(char [1 - 2*!(cond)]) - 1) 39 | 40 | #endif /* CCAN_BUILD_ASSERT_H */ 41 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/ccan/check_type/check_type.h: -------------------------------------------------------------------------------- 1 | /* CC0 (Public domain) - see LICENSE file for details */ 2 | #ifndef CCAN_CHECK_TYPE_H 3 | #define CCAN_CHECK_TYPE_H 4 | #include "config.h" 5 | 6 | /** 7 | * check_type - issue a warning or build failure if type is not correct. 8 | * @expr: the expression whose type we should check (not evaluated). 9 | * @type: the exact type we expect the expression to be. 10 | * 11 | * This macro is usually used within other macros to try to ensure that a macro 12 | * argument is of the expected type. No type promotion of the expression is 13 | * done: an unsigned int is not the same as an int! 14 | * 15 | * check_type() always evaluates to 0. 16 | * 17 | * If your compiler does not support typeof, then the best we can do is fail 18 | * to compile if the sizes of the types are unequal (a less complete check). 19 | * 20 | * Example: 21 | * // They should always pass a 64-bit value to _set_some_value! 22 | * #define set_some_value(expr) \ 23 | * _set_some_value((check_type((expr), uint64_t), (expr))) 24 | */ 25 | 26 | /** 27 | * check_types_match - issue a warning or build failure if types are not same. 28 | * @expr1: the first expression (not evaluated). 29 | * @expr2: the second expression (not evaluated). 30 | * 31 | * This macro is usually used within other macros to try to ensure that 32 | * arguments are of identical types. No type promotion of the expressions is 33 | * done: an unsigned int is not the same as an int! 34 | * 35 | * check_types_match() always evaluates to 0. 36 | * 37 | * If your compiler does not support typeof, then the best we can do is fail 38 | * to compile if the sizes of the types are unequal (a less complete check). 39 | * 40 | * Example: 41 | * // Do subtraction to get to enclosing type, but make sure that 42 | * // pointer is of correct type for that member. 43 | * #define container_of(mbr_ptr, encl_type, mbr) \ 44 | * (check_types_match((mbr_ptr), &((encl_type *)0)->mbr), \ 45 | * ((encl_type *) \ 46 | * ((char *)(mbr_ptr) - offsetof(enclosing_type, mbr)))) 47 | */ 48 | #if HAVE_TYPEOF 49 | #define check_type(expr, type) \ 50 | ((typeof(expr) *)0 != (type *)0) 51 | 52 | #define check_types_match(expr1, expr2) \ 53 | ((typeof(expr1) *)0 != (typeof(expr2) *)0) 54 | #else 55 | #include 56 | /* Without typeof, we can only test the sizes. */ 57 | #define check_type(expr, type) \ 58 | BUILD_ASSERT_OR_ZERO(sizeof(expr) == sizeof(type)) 59 | 60 | #define check_types_match(expr1, expr2) \ 61 | BUILD_ASSERT_OR_ZERO(sizeof(expr1) == sizeof(expr2)) 62 | #endif /* HAVE_TYPEOF */ 63 | 64 | #endif /* CCAN_CHECK_TYPE_H */ 65 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/ccan/list/.dirstamp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/accelerator-solution-zoo/36b95b6854aa43f2da6b07cc70bf703fe4ef0669/DSAZoo/dsa_userlib/include/ccan/list/.dirstamp -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/ccan/minmax/minmax.h: -------------------------------------------------------------------------------- 1 | /* CC0 (Public domain) - see LICENSE file for details */ 2 | #ifndef CCAN_MINMAX_H 3 | #define CCAN_MINMAX_H 4 | 5 | #include "config.h" 6 | 7 | #include 8 | 9 | #if !HAVE_STATEMENT_EXPR || !HAVE_TYPEOF 10 | /* 11 | * Without these, there's no way to avoid unsafe double evaluation of 12 | * the arguments 13 | */ 14 | #error Sorry, minmax module requires statement expressions and typeof 15 | #endif 16 | 17 | #if HAVE_BUILTIN_TYPES_COMPATIBLE_P 18 | #define MINMAX_ASSERT_COMPATIBLE(a, b) \ 19 | BUILD_ASSERT(__builtin_types_compatible_p(a, b)) 20 | #else 21 | #define MINMAX_ASSERT_COMPATIBLE(a, b) \ 22 | do { } while (0) 23 | #endif 24 | 25 | #define min(a, b) \ 26 | ({ \ 27 | typeof(a) _a = (a); \ 28 | typeof(b) _b = (b); \ 29 | MINMAX_ASSERT_COMPATIBLE(typeof(_a), typeof(_b)); \ 30 | _a < _b ? _a : _b; \ 31 | }) 32 | 33 | #define max(a, b) \ 34 | ({ \ 35 | typeof(a) __a = (a); \ 36 | typeof(b) __b = (b); \ 37 | MINMAX_ASSERT_COMPATIBLE(typeof(__a), typeof(__b)); \ 38 | __a > __b ? __a : __b; \ 39 | }) 40 | 41 | #define clamp(v, f, c) (max(min((v), (c)), (f))) 42 | 43 | 44 | #define min_t(t, a, b) \ 45 | ({ \ 46 | t _ta = (a); \ 47 | t _tb = (b); \ 48 | min(_ta, _tb); \ 49 | }) 50 | #define max_t(t, a, b) \ 51 | ({ \ 52 | t _ta = (a); \ 53 | t _tb = (b); \ 54 | max(_ta, _tb); \ 55 | }) 56 | 57 | #define clamp_t(t, v, f, c) \ 58 | ({ \ 59 | t _tv = (v); \ 60 | t _tf = (f); \ 61 | t _tc = (c); \ 62 | clamp(_tv, _tf, _tc); \ 63 | }) 64 | 65 | #endif /* CCAN_MINMAX_H */ 66 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/ccan/short_types/short_types.h: -------------------------------------------------------------------------------- 1 | /* CC0 (Public domain) - see LICENSE file for details */ 2 | #ifndef CCAN_SHORT_TYPES_H 3 | #define CCAN_SHORT_TYPES_H 4 | #include 5 | 6 | /** 7 | * u64/s64/u32/s32/u16/s16/u8/s8 - short names for explicitly-sized types. 8 | */ 9 | typedef uint64_t u64; 10 | typedef int64_t s64; 11 | typedef uint32_t u32; 12 | typedef int32_t s32; 13 | typedef uint16_t u16; 14 | typedef int16_t s16; 15 | typedef uint8_t u8; 16 | typedef int8_t s8; 17 | 18 | /* Whichever they include first, they get these definitions. */ 19 | #ifdef CCAN_ENDIAN_H 20 | /** 21 | * be64/be32/be16 - 64/32/16 bit big-endian representation. 22 | */ 23 | typedef beint64_t be64; 24 | typedef beint32_t be32; 25 | typedef beint16_t be16; 26 | 27 | /** 28 | * le64/le32/le16 - 64/32/16 bit little-endian representation. 29 | */ 30 | typedef leint64_t le64; 31 | typedef leint32_t le32; 32 | typedef leint16_t le16; 33 | #endif 34 | 35 | #endif /* CCAN_SHORT_TYPES_H */ 36 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/ccan/str/.dirstamp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/accelerator-solution-zoo/36b95b6854aa43f2da6b07cc70bf703fe4ef0669/DSAZoo/dsa_userlib/include/ccan/str/.dirstamp -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/ccan/str/str_debug.h: -------------------------------------------------------------------------------- 1 | /* CC0 (Public domain) - see LICENSE file for details */ 2 | #ifndef CCAN_STR_DEBUG_H 3 | #define CCAN_STR_DEBUG_H 4 | 5 | /* #define CCAN_STR_DEBUG 1 */ 6 | 7 | #ifdef CCAN_STR_DEBUG 8 | /* Because we mug the real ones with macros, we need our own wrappers. */ 9 | int str_isalnum(int i); 10 | int str_isalpha(int i); 11 | int str_isascii(int i); 12 | #if HAVE_ISBLANK 13 | int str_isblank(int i); 14 | #endif 15 | int str_iscntrl(int i); 16 | int str_isdigit(int i); 17 | int str_isgraph(int i); 18 | int str_islower(int i); 19 | int str_isprint(int i); 20 | int str_ispunct(int i); 21 | int str_isspace(int i); 22 | int str_isupper(int i); 23 | int str_isxdigit(int i); 24 | 25 | char *str_strstr(const char *haystack, const char *needle); 26 | char *str_strchr(const char *s, int c); 27 | char *str_strrchr(const char *s, int c); 28 | #endif /* CCAN_STR_DEBUG */ 29 | 30 | #endif /* CCAN_STR_DEBUG_H */ 31 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2015-2019 Intel Corporation. All rights reserved. 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms of version 2 of the GNU General Public License as 6 | * published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | */ 13 | #ifndef __TEST_H__ 14 | #define __TEST_H__ 15 | #include 16 | 17 | #define EXIT_SKIP 77 18 | struct accfg_test; 19 | struct accfg_ctx; 20 | struct util_filter_ctx; 21 | struct accfg_test *accfg_test_new(unsigned int kver); 22 | int accfg_test_result(struct accfg_test *test, int rc); 23 | int accfg_test_get_skipped(struct accfg_test *test); 24 | int accfg_test_get_attempted(struct accfg_test *test); 25 | int __accfg_test_attempt(struct accfg_test *test, unsigned int kver, 26 | const char *caller, int line); 27 | #define accfg_test_attempt(t, v) __accfg_test_attempt(t, v, __func__, __LINE__) 28 | void __accfg_test_skip(struct accfg_test *test, const char *caller, int line); 29 | #define accfg_test_skip(t) __accfg_test_skip(t, __func__, __LINE__) 30 | int test_libaccfg(int loglevel, struct accfg_test *test, struct accfg_ctx *ctx); 31 | int device_enum(struct accfg_ctx *ctx, struct util_filter_ctx *fctx); 32 | #endif /* __TEST_H__ */ 33 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/util/.dirstamp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/accelerator-solution-zoo/36b95b6854aa43f2da6b07cc70bf703fe4ef0669/DSAZoo/dsa_userlib/include/util/.dirstamp -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/util/bitmap.h: -------------------------------------------------------------------------------- 1 | 2 | /* SPDX-License-Identifier: GPL-2.0 */ 3 | /* Copyright(c) 2015-2019 Intel Corporation. All rights reserved. */ 4 | #ifndef _ACCFG_BITMAP_H_ 5 | #define _ACCFG_BITMAP_H_ 6 | 7 | #include 8 | #include 9 | 10 | #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) 11 | 12 | #define BIT(nr) (1UL << (nr)) 13 | #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) 14 | #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) 15 | #define BITS_PER_BYTE 8 16 | #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) 17 | 18 | #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1))) 19 | #define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1))) 20 | 21 | #define small_const_nbits(nbits) \ 22 | (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) 23 | 24 | uint64_t *bitmap_alloc(uint64_t nbits); 25 | void bitmap_set(uint64_t *map, unsigned int start, int len); 26 | void bitmap_clear(uint64_t *map, unsigned int start, int len); 27 | int test_bit(unsigned int nr, const volatile uint64_t *addr); 28 | uint64_t find_next_bit(const uint64_t *addr, uint64_t size, 29 | uint64_t offset); 30 | uint64_t find_next_zero_bit(const uint64_t *addr, uint64_t size, 31 | uint64_t offset); 32 | int bitmap_full(const uint64_t *src, unsigned int nbits); 33 | 34 | 35 | #endif /* _ACCFG_BITMAP_H_ */ 36 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/util/json.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* Copyright(c) 2015-2019 Intel Corporation. All rights reserved. */ 3 | #ifndef __ACCFG_JSON_H__ 4 | #define __ACCFG_JSON_H__ 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | enum util_json_flags { 11 | UTIL_JSON_IDLE = (1 << 0), 12 | UTIL_JSON_HUMAN = (1 << 1), 13 | UTIL_JSON_VERBOSE = (1 << 2), 14 | UTIL_JSON_SAVE = (1 << 3), 15 | }; 16 | 17 | struct json_object; 18 | void util_display_json_array(FILE *f_out, struct json_object *jarray, 19 | uint64_t flags); 20 | struct json_object *util_device_to_json(struct accfg_device *device, 21 | uint64_t flags); 22 | struct json_object *util_wq_to_json(struct accfg_wq *accfg_wq, 23 | uint64_t flags); 24 | struct json_object *util_engine_to_json(struct accfg_engine *accfg_engine, 25 | uint64_t flags); 26 | struct json_object *util_json_object_size(uint64_t size, 27 | uint64_t flags); 28 | struct json_object *util_json_object_hex(uint64_t val, 29 | uint64_t flags); 30 | #endif /* __ACCFG_JSON_H__ */ 31 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/util/list.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* Copyright(c) 2015-2019 Intel Corporation. All rights reserved. */ 3 | 4 | #ifndef _ACCFG_LIST_H_ 5 | #define _ACCFG_LIST_H_ 6 | 7 | #include 8 | 9 | /** 10 | * list_add_after - add an entry after the given node in the linked list. 11 | * @h: the list_head to add the node to 12 | * @l: the list_node after which to add to 13 | * @n: the list_node to add to the list. 14 | * 15 | * The list_node does not need to be initialized; it will be overwritten. 16 | * Example: 17 | * struct child *child = malloc(sizeof(*child)); 18 | * 19 | * child->name = "geoffrey"; 20 | * list_add_after(&parent->children, &child1->list, &child->list); 21 | * parent->num_children++; 22 | */ 23 | #define list_add_after(h, l, n) list_add_after_(h, l, n, LIST_LOC) 24 | static inline void list_add_after_(struct list_head *h, 25 | struct list_node *l, 26 | struct list_node *n, 27 | const char *abortstr) 28 | { 29 | if (l->next == &h->n) { 30 | /* l is the last element, this becomes a list_add_tail */ 31 | list_add_tail(h, n); 32 | return; 33 | } 34 | n->next = l->next; 35 | n->prev = l; 36 | l->next->prev = n; 37 | l->next = n; 38 | (void)list_debug(h, abortstr); 39 | } 40 | 41 | #endif /* _ACCFG_LIST_H_ */ 42 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/util/log.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* Copyright(c) 2015-2019 Intel Corporation. All rights reserved. */ 3 | 4 | #ifndef __UTIL_LOG_H__ 5 | #define __UTIL_LOG_H__ 6 | #include 7 | #include 8 | #include 9 | 10 | struct log_ctx; 11 | typedef void (*log_fn)(struct log_ctx *ctx, int priority, const char *file, 12 | int line, const char *fn, const char *format, va_list args); 13 | 14 | struct log_ctx { 15 | log_fn log_fn; 16 | const char *owner; 17 | int log_priority; 18 | }; 19 | 20 | 21 | void do_log(struct log_ctx *ctx, int priority, const char *file, int line, 22 | const char *fn, const char *format, ...) 23 | __attribute__((format(printf, 6, 7))); 24 | void log_init(struct log_ctx *ctx, const char *owner, const char *log_env); 25 | static inline void __attribute__((always_inline, format(printf, 2, 3))) 26 | log_null(struct log_ctx *ctx, const char *format, ...) {} 27 | 28 | #define log_cond(ctx, prio, arg...) \ 29 | do { \ 30 | if ((ctx)->log_priority >= prio) \ 31 | do_log(ctx, prio, __FILE__, __LINE__, __FUNCTION__, ## arg); \ 32 | } while (0) 33 | 34 | #ifdef ENABLE_LOGGING 35 | # ifdef ENABLE_DEBUG 36 | # define log_dbg(ctx, arg...) log_cond(ctx, LOG_DEBUG, ## arg) 37 | # else 38 | # define log_dbg(ctx, arg...) log_null(ctx, ## arg) 39 | # endif 40 | # define log_info(ctx, arg...) log_cond(ctx, LOG_INFO, ## arg) 41 | # define log_err(ctx, arg...) log_cond(ctx, LOG_ERR, ## arg) 42 | # define log_notice(ctx, arg...) log_cond(ctx, LOG_NOTICE, ## arg) 43 | #else 44 | # define log_dbg(ctx, arg...) log_null(ctx, ## arg) 45 | # define log_info(ctx, arg...) log_null(ctx, ## arg) 46 | # define log_err(ctx, arg...) log_null(ctx, ## arg) 47 | # define log_notice(ctx, arg...) log_null(ctx, ## arg) 48 | #endif 49 | 50 | #define dbg(x, arg...) log_dbg(&(x)->ctx, ## arg) 51 | #define info(x, arg...) log_info(&(x)->ctx, ## arg) 52 | #define err(x, arg...) log_err(&(x)->ctx, ## arg) 53 | #define notice(x, arg...) log_notice(&(x)->ctx, ## arg) 54 | 55 | #ifndef HAVE_SECURE_GETENV 56 | # ifdef HAVE___SECURE_GETENV 57 | # define secure_getenv __secure_getenv 58 | # else 59 | //# warning neither secure_getenv nor __secure_getenv is available. 60 | # define secure_getenv getenv 61 | # endif 62 | #endif 63 | 64 | #endif /* __UTIL_LOG_H__ */ 65 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/util/log.lo: -------------------------------------------------------------------------------- 1 | # ../../util/log.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/log.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/util/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright(c) 2015-2017 Intel Corporation. All rights reserved. 3 | * Copyright(c) 2006 Linus Torvalds. All rights reserved. 4 | * 5 | * This program is free software; you can redistribute it and/or modify it 6 | * under the terms of version 2 of the GNU General Public License as 7 | * published by the Free Software Foundation. 8 | * 9 | * This program is distributed in the hope that it will be useful, but 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | */ 14 | 15 | /* originally copied from perf and git */ 16 | 17 | #ifndef __MAIN_H__ 18 | #define __MAIN_H__ 19 | struct cmd_struct; 20 | int main_handle_options(const char ***argv, int *argc, const char *usage_msg, 21 | struct cmd_struct *cmds, int num_cmds); 22 | int main_handle_internal_command(int argc, const char **argv, void *ctx, 23 | struct cmd_struct *cmds, int num_cmds); 24 | int help_show_man_page(const char *cmd, const char *util_name, 25 | const char *viewer); 26 | #endif /* __MAIN_H__ */ 27 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/util/size.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* Copyright(c) 2015-2019 Intel Corporation. All rights reserved. */ 3 | 4 | #ifndef _ACCFG_SIZE_H_ 5 | #define _ACCFG_SIZE_H_ 6 | 7 | #include 8 | 9 | #define SZ_1K 0x00000400 10 | #define SZ_4K 0x00001000 11 | #define SZ_1M 0x00100000 12 | #define SZ_2M 0x00200000 13 | #define SZ_4M 0x00400000 14 | #define SZ_16M 0x01000000 15 | #define SZ_64M 0x04000000 16 | #define SZ_1G 0x40000000 17 | #define SZ_1T 0x10000000000ULL 18 | 19 | uint64_t parse_size64(const char *str); 20 | uint64_t __parse_size64(const char *str, uint64_t *units); 21 | 22 | #define ALIGN(x, a) ((((uint64_t) x) + (a - 1)) & ~(a - 1)) 23 | #define ALIGN_DOWN(x, a) (((((uint64_t) x) + a) & ~(a - 1)) - a) 24 | #define BITS_PER_LONG (sizeof(uint64_t) * 8) 25 | #define HPAGE_SIZE (2 << 20) 26 | 27 | #endif /* _ACCFG_SIZE_H_ */ 28 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/util/sysfs.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* Copyright(c) 2015-2019 Intel Corporation. All rights reserved. */ 3 | 4 | #ifndef __UTIL_SYSFS_H__ 5 | #define __UTIL_SYSFS_H__ 6 | 7 | #include 8 | #include 9 | 10 | typedef void *(*add_dev_fn)(void *parent, int id, const char *dev_path, 11 | char *dev_prefix, char *bus_type); 12 | 13 | #define SYSFS_ATTR_SIZE 1024 14 | 15 | struct log_ctx; 16 | int __sysfs_read_attr(struct log_ctx *ctx, const char *path, char *buf); 17 | int __sysfs_write_attr(struct log_ctx *ctx, const char *path, const char *buf); 18 | int __sysfs_write_attr_quiet(struct log_ctx *ctx, const char *path, 19 | const char *buf); 20 | int __sysfs_device_parse(struct log_ctx *ctx, const char *base_path, 21 | char *dev_prefix, char *bus_type, 22 | int (*filter)(const struct dirent *), 23 | void *parent, add_dev_fn add_dev); 24 | 25 | #define sysfs_read_attr(c, p, b) __sysfs_read_attr(&(c)->ctx, (p), (b)) 26 | #define sysfs_write_attr(c, p, b) __sysfs_write_attr(&(c)->ctx, (p), (b)) 27 | #define sysfs_write_attr_quiet(c, p, b) __sysfs_write_attr_quiet(&(c)->ctx, (p), (b)) 28 | #define sysfs_device_parse(c, b, d, bt, m, p, fn) __sysfs_device_parse(&(c)->ctx, \ 29 | (b), (d), (bt), (m), (p), (fn)) 30 | 31 | static inline const char *devpath_to_devname(const char *devpath) 32 | { 33 | return strrchr(devpath, '/') + 1; 34 | } 35 | #endif /* __UTIL_SYSFS_H__ */ 36 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/include/util/sysfs.lo: -------------------------------------------------------------------------------- 1 | # ../../util/sysfs.lo - a libtool object file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | # 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Name of the PIC object. 8 | pic_object='.libs/sysfs.o' 9 | 10 | # Name of the non-PIC object 11 | non_pic_object=none 12 | 13 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(vector_data_streaming VERSION 1.0.0) 2 | 3 | add_compile_options(-Wall) 4 | 5 | include_directories(CMAKE_SOURCE_DIR/include) 6 | 7 | #set(DSA_SRCS core.c dsa.c libaccfg.c prep.c) 8 | file (GLOB LIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.c) 9 | 10 | add_library (${PROJECT_NAME} SHARED ${LIB_SRCS} ) 11 | 12 | set(STATIC_LIB "vector_data_streaming_static") 13 | add_library (${STATIC_LIB} STATIC ${LIB_SRCS} ) 14 | 15 | target_link_libraries(${PROJECT_NAME} PUBLIC accel-config) 16 | 17 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/src/core.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* Copyright(c) 2015-2019 Intel Corporation. All rights reserved. */ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #define KVER_STRLEN 20 17 | 18 | struct accfg_test { 19 | unsigned int kver; 20 | int attempt; 21 | int skip; 22 | }; 23 | 24 | static unsigned int get_system_kver(void) 25 | { 26 | const char *kver = getenv("KVER"); 27 | struct utsname utsname; 28 | int a, b, c; 29 | 30 | if (!kver) { 31 | uname(&utsname); 32 | kver = utsname.release; 33 | } 34 | 35 | if (sscanf(kver, "%d.%d.%d", &a, &b, &c) != 3) 36 | return LINUX_VERSION_CODE; 37 | 38 | return KERNEL_VERSION(a,b,c); 39 | } 40 | 41 | struct accfg_test *accfg_test_new(unsigned int kver) 42 | { 43 | struct accfg_test *test = calloc(1, sizeof(*test)); 44 | 45 | if (!test) 46 | return NULL; 47 | 48 | if (!kver) 49 | test->kver = get_system_kver(); 50 | else 51 | test->kver = kver; 52 | 53 | return test; 54 | } 55 | 56 | int accfg_test_result(struct accfg_test *test, int rc) 57 | { 58 | if (accfg_test_get_skipped(test)) 59 | fprintf(stderr, "attempted: %d skipped: %d\n", 60 | accfg_test_get_attempted(test), 61 | accfg_test_get_skipped(test)); 62 | if (rc && rc != EXIT_SKIP) 63 | return rc; 64 | if (accfg_test_get_skipped(test) >= accfg_test_get_attempted(test)) 65 | return EXIT_SKIP; 66 | /* return success if no failures and at least one test not skipped */ 67 | return 0; 68 | } 69 | 70 | static char *kver_str(char *buf, unsigned int kver) 71 | { 72 | snprintf(buf, KVER_STRLEN, "%d.%d.%d", (kver >> 16) & 0xffff, 73 | (kver >> 8) & 0xff, kver & 0xff); 74 | return buf; 75 | } 76 | 77 | int __accfg_test_attempt(struct accfg_test *test, unsigned int kver, 78 | const char *caller, int line) 79 | { 80 | char requires[KVER_STRLEN], current[KVER_STRLEN]; 81 | 82 | test->attempt++; 83 | if (kver <= test->kver) 84 | return 1; 85 | fprintf(stderr, "%s: skip %s:%d requires: %s current: %s\n", 86 | __func__, caller, line, kver_str(requires, kver), 87 | kver_str(current, test->kver)); 88 | test->skip++; 89 | return 0; 90 | } 91 | 92 | void __accfg_test_skip(struct accfg_test *test, const char *caller, int line) 93 | { 94 | test->skip++; 95 | test->attempt = test->skip; 96 | fprintf(stderr, "%s: explicit skip %s:%d\n", __func__, caller, line); 97 | } 98 | 99 | int accfg_test_get_attempted(struct accfg_test *test) 100 | { 101 | return test->attempt; 102 | } 103 | 104 | int accfg_test_get_skipped(struct accfg_test *test) 105 | { 106 | return test->skip; 107 | } 108 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/src/log.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | /* Copyright(c) 2015-2019 Intel Corporation. All rights reserved. */ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | void do_log(struct log_ctx *ctx, int priority, const char *file, 12 | int line, const char *fn, const char *format, ...) 13 | { 14 | va_list args; 15 | int errno_save = errno; 16 | 17 | va_start(args, format); 18 | ctx->log_fn(ctx, priority, file, line, fn, format, args); 19 | va_end(args); 20 | errno = errno_save; 21 | } 22 | 23 | static void log_stderr(struct log_ctx *ctx, int priority, const char *file, 24 | int line, const char *fn, const char *format, va_list args) 25 | { 26 | fprintf(stderr, "%s: %s: ", ctx->owner, fn); 27 | vfprintf(stderr, format, args); 28 | } 29 | 30 | static int log_priority(const char *priority) 31 | { 32 | char *endptr; 33 | int prio; 34 | 35 | prio = strtol(priority, &endptr, 10); 36 | if (endptr[0] == '\0' || isspace(endptr[0])) 37 | return prio; 38 | if (strncmp(priority, "err", 3) == 0) 39 | return LOG_ERR; 40 | if (strncmp(priority, "info", 4) == 0) 41 | return LOG_INFO; 42 | if (strncmp(priority, "debug", 5) == 0) 43 | return LOG_DEBUG; 44 | if (strncmp(priority, "notice", 6) == 0) 45 | return LOG_NOTICE; 46 | return 0; 47 | } 48 | 49 | void log_init(struct log_ctx *ctx, const char *owner, const char *log_env) 50 | { 51 | const char *env; 52 | 53 | ctx->owner = owner; 54 | ctx->log_fn = log_stderr; 55 | ctx->log_priority = LOG_ERR; 56 | 57 | /* environment overwrites config */ 58 | env = secure_getenv(log_env); 59 | if (env != NULL) 60 | ctx->log_priority = log_priority(env); 61 | } 62 | -------------------------------------------------------------------------------- /DSAZoo/dsa_userlib/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(dsa_test) 2 | 3 | include_directories("${CMAKE_SOURCE_DIR}/include") 4 | 5 | set(TEST_SRC dsa_test.c) 6 | add_executable(${PROJECT_NAME} ${TEST_SRC}) 7 | target_link_libraries(${PROJECT_NAME} vector_data_streaming) 8 | 9 | project(dsa_mt_single) 10 | set(TEST_SRC1 dsa_mt_single.c) 11 | add_executable(${PROJECT_NAME} ${TEST_SRC1}) 12 | target_link_libraries(${PROJECT_NAME} vector_data_streaming pthread) 13 | 14 | project(dsa_test_batch) 15 | set(TEST_SRC2 dsa_test_batch.c) 16 | add_executable(${PROJECT_NAME} ${TEST_SRC2}) 17 | target_link_libraries(${PROJECT_NAME} vector_data_streaming) 18 | 19 | 20 | project(dsa_test_vector) 21 | set(TEST_SRC3 dsa_test_vector.c) 22 | add_executable(${PROJECT_NAME} ${TEST_SRC3}) 23 | target_link_libraries(${PROJECT_NAME} vector_data_streaming) 24 | 25 | project(dsa_mt_vector) 26 | set(TEST_SRC3 dsa_mt_vector.c) 27 | add_executable(${PROJECT_NAME} ${TEST_SRC3}) 28 | target_link_libraries(${PROJECT_NAME} vector_data_streaming pthread) 29 | 30 | 31 | project(dsa_mt_async) 32 | set(TEST_SRC3 dsa_mt_async.c) 33 | add_executable(${PROJECT_NAME} ${TEST_SRC3}) 34 | target_link_libraries(${PROJECT_NAME} vector_data_streaming pthread) 35 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/.buildtest_dpdk.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | git submodule init 3 | git submodule update 4 | export RTE_SDK=`echo $PWD`/dpdk 5 | export RTE_TARGET=x86_64-native-linuxapp-gcc 6 | export MTCP_TARGET=`echo $PWD`/mtcp 7 | sed -i -e 's/O_TO_EXE_STR =/\$(shell if [ \! -d \${RTE_SDK}\/\${RTE_TARGET}\/lib ]\; then mkdir \${RTE_SDK}\/\${RTE_TARGET}\/lib\; fi)\nLINKER_FLAGS = \$(call linkerprefix,\$(LDLIBS))\n\$(shell echo \${LINKER_FLAGS} \> \${RTE_SDK}\/\${RTE_TARGET}\/lib\/ldflags\.txt)\nO_TO_EXE_STR =/g' $RTE_SDK/mk/rte.app.mk 8 | cd dpdk/ 9 | make install T=x86_64-native-linuxapp-gcc 10 | cd .. 11 | autoreconf -ivf 12 | ./configure --with-dpdk-lib=$RTE_SDK/$RTE_TARGET 13 | make 14 | cd apps/lighttpd-1.4.32/ 15 | autoreconf -ivf 16 | ./configure --without-bzip2 CFLAGS="-g -O3" --with-libmtcp=$MTCP_TARGET --with-libdpdk=$RTE_SDK/$RTE_TARGET 17 | make 18 | cd ../apache_benchmark 19 | ./configure --with-libmtcp=$MTCP_TARGET --with-libdpdk=$RTE_SDK/$RTE_TARGET 20 | make 21 | 22 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/.buildtest_netmap.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | export MTCP_TARGET=`echo $PWD`/mtcp 3 | autoreconf -ivf 4 | ./configure --enable-netmap 5 | make 6 | cd apps/lighttpd-1.4.32/ 7 | autoreconf -ivf 8 | ./configure --without-bzip2 CFLAGS="-g -O3" --with-libmtcp=$MTCP_TARGET --enable-netmap 9 | make 10 | cd ../apache_benchmark 11 | ./configure --with-libmtcp=$MTCP_TARGET --enable-netmap 12 | make 13 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/.buildtest_psio.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | export PSIO_TARGET=`echo $PWD`/io_engine 3 | export MTCP_TARGET=`echo $PWD`/mtcp 4 | autoreconf -ivf 5 | ./configure --with-psio-lib=`echo $PWD`/io_engine 6 | make 7 | cd apps/lighttpd-1.4.32/ 8 | autoreconf -ivf 9 | ./configure --without-bzip2 CFLAGS="-g -O3" --with-libmtcp=$MTCP_TARGET --with-libpsio=$PSIO_TARGET 10 | make 11 | cd ../apache_benchmark 12 | ./configure --with-libmtcp=$MTCP_TARGET --with-libpsio=$PSIO_TARGET 13 | make 14 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/.check_hyperthreading.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | RED='\033[0;31m' 4 | CYAN='\033[0;36m' 5 | YELLOW='\033[1;33m' 6 | LIGHTRED='\033[1;31m' 7 | NC='\033[0m' # No Color 8 | #str=$(grep -o '^flags\b.*: .*\bht\b' /proc/cpuinfo | tail -1) 9 | nproc=$(grep -i "processor" /proc/cpuinfo | sort -u | wc -l) 10 | phycore=$(cat /proc/cpuinfo | egrep "core id|physical id" | tr -d "\n" | sed s/physical/\\nphysical/g | grep -v ^$ | sort | uniq | wc -l) 11 | 12 | if [ -z "$(echo "$phycore *2" | bc | grep $nproc)" ] 13 | then 14 | str="" 15 | else 16 | str="ht-enabled" 17 | fi 18 | 19 | 20 | if [ "$str" ] 21 | then 22 | printf "${RED}mTCP works best when hyperthreading is DISABLED. Please disable this feature from BIOS.${NC}\n" 23 | fi 24 | 25 | printf "${CYAN}Type ${YELLOW}make${CYAN} to compile mTCP ${LIGHTRED}src/${CYAN} and ${LIGHTRED}apps/${CYAN}.${NC}\n" 26 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/.pre_dpdk2203.sh.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/accelerator-solution-zoo/36b95b6854aa43f2da6b07cc70bf703fe4ef0669/DSAZoo/example_mtcp/.pre_dpdk2203.sh.swp -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | dist: trusty 3 | language: c 4 | 5 | notifications: 6 | email: 7 | on_success: change 8 | on_failure: change 9 | 10 | matrix: 11 | include: 12 | - env: COMPILER=gcc VERSION=6 13 | - env: COMPILER=gcc VERSION=5 14 | - env: COMPILER=gcc VERSION=4.8 15 | 16 | before_install: 17 | - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test 18 | - sudo apt-get update -qq 19 | - | 20 | if [ "$VERSION" = "6" ]; then 21 | sudo apt-get install -qq -y gcc-6 22 | elif [ "$VERSION" = "5" ]; then 23 | sudo apt-get install -qq -y gcc-5 24 | elif [ "$VERSION" = "4.8" ]; then 25 | sudo apt-get install -qq -y gcc-4.8 26 | fi 27 | 28 | before_script: 29 | - | 30 | if [ "$VERSION" = "6" ]; then 31 | export CC=gcc-6 32 | elif [ "$VERSION" = "5" ]; then 33 | export CC=gcc-5 34 | elif [ "$VERSION" = "4.8" ]; then 35 | export CC=gcc-4.8 36 | fi 37 | 38 | install: 39 | - sudo apt-get -qq update 40 | - sudo apt-get install -y linux-headers-$(uname -r) 41 | - sudo apt-get install libnuma-dev 42 | - sudo apt-get install bash 43 | - sudo apt-get install libgmp3-dev 44 | 45 | script: 46 | - bash .buildtest_dpdk.sh 47 | - bash .buildtest_psio.sh 48 | - bash .buildtest_netmap.sh -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/CHANGELOG: -------------------------------------------------------------------------------- 1 | 2015-02-04 Muhammad Asim Jamshed 2 | mTCPv3 3 | * Updated the I/O abstraction layer. 4 | * Added DPDK support 5 | 6 | 7 | 2014-02-04 Eunyoung Jeong 8 | mTCPv2 9 | * First stable version of mTCP released 10 | 11 | * Please see README & http://shader.kaist.edu/mtcp/ 12 | for more details. 13 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/LICENSE: -------------------------------------------------------------------------------- 1 | mTCP source code is distributed under the Modified BSD Licence. 2 | 3 | Copyright (C) 2015 EunYoung Jeong, Shinae Woo, Muhammad Jamshed, Haewon Jeong, 4 | Sunghwan Ihm, Dongsu Han, KyoungSoo Park 5 | 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 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 the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of the nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | SUBDIRS = mtcp/src util io_engine/lib apps/example 3 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/README.config: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | README for mTCP configuration files 3 | ======================================================================== 4 | 5 | Before starting mTCP applications, please go through the config/*.conf 6 | files. mTCP requires three startup configuration files for correct 7 | execution: 8 | 9 | - mtcp.conf (e.g. apps/example/epserver.conf, 10 | apps/example/epwget.conf) 11 | -- This file contains the mtcp configuration parameters for 12 | mtcp-detected Ethernet interfaces & mtcp-specific buffer 13 | sizes etc. Please go through config/sample_mtcp.conf for 14 | more details. By default, an mtcp application searches for 15 | this file in the same directory where the binary lies. 16 | 17 | 18 | - arp.conf 19 | -- This file contains the static arp table entries for 20 | mtcp. Please see config/sample_arp.conf file for more 21 | details. By default, an mtcp application searches for 22 | config/arp.conf file in the same directory where the 23 | binary lies. An mTCP ARP module (that manages dynamic 24 | ARP table entries) is under development. 25 | 26 | 27 | - route.conf 28 | -- This file contains the static route table entries for 29 | mtcp. Please browse through config/sample_route.conf 30 | file for more details. By default, an mtcp application 31 | searches for config/route.conf file in the same directory 32 | where the binary lies. 33 | 34 | ======================================================================== 35 | 36 | Contact: mtcp-user at list.ndsl.kaist.edu 37 | April 2, 2015. 38 | EunYoung Jeong 39 | M. Asim Jamshed -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/README.devel: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | README for mTCP development 3 | ======================================================================== 4 | 5 | This file will be updated in coming revisions. In the mean time please 6 | have a look @: 7 | 8 | 1 - http://www.ndsl.kaist.edu/~kyoungsoo/papers/mtcp.pdf 9 | 10 | 2 - apps/example/epserver.c OR apps/example/epwget.c example 11 | applications 12 | 13 | to see how to use mTCP API. 14 | 15 | ======================================================================== 16 | 17 | Contact: mtcp-user at list.ndsl.kaist.edu 18 | April 2, 2015. 19 | EunYoung Jeong 20 | M. Asim Jamshed -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/TODOS: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | TODOs list for mTCP 3 | ======================================================================== 4 | 5 | See https://github.com/eunyoung14/mtcp/wiki/Supported-Features for details. 6 | 7 | ** This is only a small list of ideas that we have in our mind. Please 8 | contact the authors if you want to help develop mTCP even further. 9 | 10 | ======================================================================== 11 | 12 | Contact: mtcp-user at list.ndsl.kaist.edu 13 | April 2, 2015. 14 | EunYoung Jeong 15 | M. Asim Jamshed -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/apps/example/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | epserver 3 | epwget 4 | log_* 5 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/apps/example/Makefile.in: -------------------------------------------------------------------------------- 1 | # TODO: Make this Makefile.in pretty 2 | 3 | TARGETS = epserver epwget 4 | CC=@CC@ -g -O3 -Wall -Werror -fgnu89-inline 5 | DPDK=@DPDK@ 6 | PS=@PSIO@ 7 | NETMAP=@NETMAP@ 8 | ONVM=@ONVM@ 9 | CCP=@CCP@ 10 | CFLAGS=@CFLAGS@ 11 | 12 | # Add arch-specific optimization 13 | ifeq ($(shell uname -m),x86_64) 14 | LIBS += -m64 15 | endif 16 | 17 | # mtcp library and header 18 | MTCP_FLD =../../mtcp/ 19 | MTCP_INC =-I${MTCP_FLD}/include 20 | MTCP_LIB =-L${MTCP_FLD}/lib 21 | MTCP_TARGET = ${MTCP_LIB}/libmtcp.a 22 | 23 | UTIL_FLD = ../../util 24 | UTIL_INC = -I${UTIL_FLD}/include 25 | UTIL_OBJ = ${UTIL_FLD}/http_parsing.o ${UTIL_FLD}/tdate_parse.o ${UTIL_FLD}/netlib.o 26 | 27 | DSA_FLD = ../../../dsa_userlib 28 | DSA_INC = -I${DSA_FLD}/include 29 | DSA_LIB=${DSA_FLD}/build/lib 30 | LIBS += -L${DSA_LIB} -lvector_data_streaming 31 | 32 | 33 | # util library and header 34 | INC = -I./include/ ${UTIL_INC} ${MTCP_INC} -I${UTIL_FLD}/include -I${MTCP_FLD}/src/include 35 | LIBS = ${MTCP_LIB} 36 | 37 | # psio-specific variables 38 | ifeq ($(PS),1) 39 | PS_DIR = ../../io_engine/ 40 | PS_INC = ${PS_DIR}/include 41 | INC += -I{PS_INC} 42 | LIBS += -lmtcp -L${PS_DIR}/lib -lps -lpthread -lnuma -lrt 43 | endif 44 | 45 | # netmap-specific variables 46 | ifeq ($(NETMAP),1) 47 | LIBS += -lmtcp -lpthread -lnuma -lrt 48 | endif 49 | 50 | # dpdk-specific variables 51 | ifeq ($(DPDK),1) 52 | 53 | PKGCONF ?= pkg-config 54 | CFLAGS += $(shell $(PKGCONF) --cflags libdpdk) 55 | LIBS += $(shell $(PKGCONF) --static --libs libdpdk) 56 | LIBS += -g -O3 -lpthread -lrt ${MTCP_FLD}/lib/libmtcp.a -lnuma -lmtcp -ldl -lgmp 57 | 58 | endif 59 | 60 | # onvm-specific variables 61 | ifeq ($(ONVM),1) 62 | ifeq ($(RTE_TARGET),) 63 | $(error "Please define RTE_TARGET environment variable") 64 | endif 65 | 66 | INC += -I@ONVMLIBPATH@/onvm_nflib 67 | INC += -I@ONVMLIBPATH@/lib 68 | INC += -DENABLE_ONVM 69 | LIBS += @ONVMLIBPATH@/onvm_nflib/$(RTE_TARGET)/libonvm.a 70 | LIBS += @ONVMLIBPATH@/lib/$(RTE_TARGET)/lib/libonvmhelper.a -lm 71 | endif 72 | 73 | ifeq ($V,) # no echo 74 | export MSG=@echo 75 | export HIDE=@ 76 | else 77 | export MSG=@\# 78 | export HIDE= 79 | endif 80 | 81 | ifeq ($(CCP), 1) 82 | # LIBCCP 83 | LIBCCP = $(MTCP_FLD)/src/libccp 84 | LIBS += -L$(LIBCCP) -lccp -lstartccp 85 | INC += -I$(LIBCCP) 86 | endif 87 | 88 | all: epserver epwget epping 89 | 90 | epserver.o: epserver.c 91 | $(MSG) " CC $<" 92 | $(HIDE) ${CC} -c $< ${CFLAGS} ${INC} 93 | 94 | epserver: epserver.o ${MTCP_FLD}/lib/libmtcp.a 95 | $(MSG) " LD $<" 96 | $(HIDE) ${CC} $< ${LIBS} ${UTIL_OBJ} -o $@ 97 | 98 | epwget.o: epwget.c 99 | $(MSG) " CC $<" 100 | $(HIDE) ${CC} -c $< ${CFLAGS} ${INC} 101 | 102 | epwget: epwget.o ${MTCP_FLD}/lib/libmtcp.a 103 | $(MSG) " LD $<" 104 | $(HIDE) ${CC} $< ${LIBS} ${UTIL_OBJ} -o $@ 105 | 106 | epping.o: epping.c 107 | $(MSG) " CC $<" 108 | $(HIDE) ${CC} -c $< ${CFLAGS} ${INC} 109 | 110 | epping: epping.o ${MTCP_FLD}/lib/libmtcp.a 111 | $(MSG) " LD $<" 112 | $(HIDE) ${CC} $< ${LIBS} ${UTIL_OBJ} -o $@ 113 | 114 | clean: 115 | $(MSG) " CLEAN $(TARGETS)" 116 | $(HIDE) rm -f *~ *.o ${TARGETS} log_* 117 | 118 | distclean: clean 119 | rm -rf Makefile 120 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/apps/example/Makefile.old: -------------------------------------------------------------------------------- 1 | TARGETS = epserver epwget 2 | CC = gcc -g -O3 3 | DPDK=0 4 | PS=0 5 | 6 | # DPDK LIBRARY and HEADER 7 | DPDK_INC=../../dpdk/include 8 | DPDK_LIB=../../dpdk/lib/ 9 | 10 | # mtcp library and header 11 | MTCP_FLD =../../mtcp/ 12 | MTCP_INC =-I${MTCP_FLD}/include 13 | MTCP_LIB =-L${MTCP_FLD}/lib 14 | MTCP_TARGET = ${MTCP_LIB}/libmtcp.a 15 | 16 | UTIL_FLD = ../../util 17 | UTIL_INC = -I${UTIL_FLD}/include 18 | UTIL_OBJ = ${UTIL_FLD}/http_parsing.o ${UTIL_FLD}/tdate_parse.o 19 | 20 | 21 | PS_DIR = ../../io_engine/ 22 | PS_INC = ${PS_DIR}/include 23 | INC = -I./include/ ${UTIL_INC} ${MTCP_INC} -I${UTIL_FLD}/include 24 | LIBS = ${MTCP_LIB} 25 | ifeq ($(PS),1) 26 | INC += -I{PS_INC} 27 | LIBS += -lmtcp -L${PS_DIR}/lib -lps -lpthread -lnuma -lrt 28 | endif 29 | 30 | # CFLAGS for DPDK-related compilation 31 | INC += ${MTCP_INC} 32 | ifeq ($(DPDK),1) 33 | INC += -DENABLE_DPDK -DRTE_MACHINE_CPUFLAG_SSE -DRTE_MACHINE_CPUFLAG_SSE2 -DRTE_MACHINE_CPUFLAG_SSE3 \ 34 | -DRTE_MACHINE_CPUFLAG_SSSE3 -DRTE_MACHINE_CPUFLAG_SSE4_1 -DRTE_MACHINE_CPUFLAG_SSE4_2 \ 35 | -DRTE_MACHINE_CPUFLAG_AES -DRTE_MACHINE_CPUFLAG_PCLMULQDQ -DRTE_MACHINE_CPUFLAG_AVX \ 36 | -DRTE_COMPILE_TIME_CPUFLAGS=RTE_CPUFLAG_SSE,RTE_CPUFLAG_SSE2,RTE_CPUFLAG_SSE3,RTE_CPUFLAG_SSSE3,RTE_CPUFLAG_SSE4_1,RTE_CPUFLAG_SSE4_2,RTE_CPUFLAG_AES,RTE_CPUFLAG_PCLMULQDQ,RTE_CPUFLAG_AVX -I${DPDK_INC} \ 37 | -include ${DPDK_INC}/rte_config.h 38 | endif 39 | 40 | ifeq ($(DPDK),1) 41 | LIBS += -m64 -g -O3 -pthread -lrt -march=native -Wl,-export-dynamic ${MTCP_FLD}/lib/libmtcp.a -L../../dpdk/lib -Wl,-lnuma -Wl,-lmtcp -Wl,-lpthread -Wl,-lrt -Wl,-ldl -Wl,--whole-archive -Wl,-lrte_distributor -Wl,-lrte_kni -Wl,-lrte_pipeline -Wl,-lrte_table -Wl,-lrte_port -Wl,-lrte_timer -Wl,-lrte_hash -Wl,-lrte_lpm -Wl,-lrte_power -Wl,-lrte_acl -Wl,-lrte_meter -Wl,-lrte_sched -Wl,-lm -Wl,-lrt -Wl,--start-group -Wl,-lrte_kvargs -Wl,-lrte_mbuf -Wl,-lrte_ip_frag -Wl,-lethdev -Wl,-lrte_malloc -Wl,-lrte_mempool -Wl,-lrte_ring -Wl,-lrte_eal -Wl,-lrte_cmdline -Wl,-lrte_cfgfile -Wl,-lrte_pmd_bond -Wl,-lrte_pmd_vmxnet3_uio -Wl,-lrte_pmd_i40e -Wl,-lrte_pmd_ixgbe -Wl,-lrte_pmd_e1000 -Wl,-lrte_pmd_ring -Wl,-lrt -Wl,-lm -Wl,-ldl -Wl,--end-group -Wl,--no-whole-archive 42 | endif 43 | 44 | all: epserver epwget 45 | 46 | epserver.o: epserver.c 47 | ${CC} -c $< ${CFLAGS} ${INC} 48 | 49 | epserver: epserver.o 50 | ${CC} $< ${LIBS} ${UTIL_OBJ} -o $@ 51 | 52 | epwget.o: epwget.c 53 | ${CC} -c $< ${CFLAGS} ${INC} 54 | 55 | epwget: epwget.o 56 | ${CC} $< ${LIBS} ${UTIL_OBJ} -o $@ 57 | 58 | clean: 59 | rm -f *~ *.o ${TARGETS} log_* 60 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/apps/example/config/arp.conf: -------------------------------------------------------------------------------- 1 | # This file is to configure static arp tables. 2 | # Rename this file to arp.conf and set the appropriate values. 3 | # Please save this file as config/arp.conf. Put the config/ 4 | # directory in the same directory where the binary lies. 5 | # 6 | # (Destination IP address/IP_prefix) (Destination MAC address) 7 | 8 | ARP_ENTRY 1 9 | #192.168.18.123/24 B4:96:91:AA:9B:81 10 | 192.168.18.124/24 b4:96:91:ad:85:b1 11 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/apps/example/config/route.conf: -------------------------------------------------------------------------------- 1 | # This file is routing table example of our testbed machine 2 | # Copy this file to route.conf and give appropriate routes 3 | # Please save this file as config/route.conf. Put the config/ 4 | # directory in the same directory where the binary lies. 5 | # 6 | # (Destination address)/(Prefix) (Device name) 7 | # 8 | # 9 | # Add entry for default gateway route as: 10 | # w.x.y.z/0 dpdk0 11 | # Always put the default gateway route as the last entry. 12 | # Make sure that the mask (Prefix) is set to 0. For example, 13 | # if the default gateway IP address is 10.0.0.10, then the 14 | # entry will be: 15 | # 10.0.0.10/0 dpdk0 16 | # 17 | 18 | ROUTES 1 19 | 192.168.18.124/24 0000:4b:00.1 20 | 192.168.18.1/24 0000:4b:00.1 21 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/apps/example/epping.conf: -------------------------------------------------------------------------------- 1 | ############### mtcp configuration file ############### 2 | 3 | # The underlying I/O module you want to use. Please 4 | # enable only one out of the four. 5 | #io = psio 6 | #io = netmap 7 | #io = onvm 8 | io = dpdk 9 | 10 | # No. of cores setting (enabling this option will override 11 | # the `cpu' config for those applications that accept 12 | # num_cores as command line arguments) 13 | # 14 | # e.g. in case ./epserver is executed with `-N 4', the 15 | # mtcp core will still invoke 8 mTCP threads if the 16 | # following line is uncommented. 17 | num_cores = 8 18 | 19 | # Core mask 20 | core_mask = f 21 | 22 | # Number of memory channels per processor socket (dpdk-only) 23 | num_mem_ch = 2 24 | 25 | #--- ONVM specific args ---# 26 | # Service id (required) 27 | #onvm_serv = 1 28 | # Instance id (optional) 29 | #onvm_inst = 1 30 | # Destination id (will forward to another NF) 31 | # If not set will send packets out 32 | #onvm_dest = 2 33 | 34 | # Sample ONVM configurations 35 | # Single node epserver <-> epwget 36 | #onvm_serv = 1 37 | #onvm_dest = 2 38 | 39 | # Simple endpoint server multi node setup 40 | #onvm_serv = 1 41 | #--------------------------# 42 | 43 | # Enable multi-process support 44 | #multiprocess = 1 45 | 46 | # Used port (please adjust accordingly) 47 | #------ PSIO ports -------# 48 | #port = xge0 xge1 49 | #port = xge1 50 | #------ DPDK ports -------# 51 | port=0000:29:00.0 52 | #port = dpdk1 53 | #port = dpdk0 dpdk1 54 | local_ip=192.168.14.112 55 | # Congestion control algorithm 56 | # (only available when configured with --enable-ccp) 57 | # cc = reno 58 | # cc = cubic 59 | 60 | # Maximum concurrency per core (default = 10000) 61 | #max_concurrency = 10000 62 | 63 | # Maximum number of socket buffers per core (default = 10000) 64 | # Set this to small value if there are many idle connections 65 | max_num_buffers = 1 66 | 67 | 68 | # Receive buffer size of sockets,1500*7=10500; if not set: rcvbuf = sndbuf 69 | rcvbuf = 10500 70 | 71 | # Send buffer size of sockets; if not set: sndbuf = rcvbuf 72 | 73 | #sndbuf = 4096 74 | #sndbuf = 8192 75 | #sndbuf = 16384 76 | #sndbuf = 32768 77 | #sndbuf = 65536 78 | #sndbuf = 131072 79 | #sndbuf = 262144 80 | #sndbuf = 524288 81 | #sndbuf = 1048576 82 | #sndbuf = 2097152 83 | #sndbuf = 4194304 84 | #sndbuf = 8388608 85 | #sndbuf = 16777216 86 | #sndbuf = 33554432 87 | #sndbuf = 67108864 88 | #sndbuf = 268435456 89 | # if sndbuf & rcvbuf not set: sndbuf = rcvbuf = 8192 90 | 91 | # TCP timeout seconds 92 | # (tcp_timeout = -1 can disable the timeout check) 93 | tcp_timeout = 30 94 | 95 | # TCP timewait seconds 96 | tcp_timewait = 0 97 | 98 | # Interface to print stats (please adjust accordingly) 99 | # You can enable multiple ports in a line 100 | #------ PSIO ports -------# 101 | #stat_print = xge0 102 | #stat_print = xge1 103 | #------ DPDK ports -------# 104 | stat_print=0000:29:00.0 105 | #stat_print=0000:c8:00.0 106 | #stat_print = dpdk0 dpdk1 107 | 108 | ####################################################### 109 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/apps/example/epserver-multiprocess.conf: -------------------------------------------------------------------------------- 1 | ############### mtcp configuration file ############### 2 | 3 | # The underlying I/O module you want to use. Please 4 | # enable only one out of the three. 5 | #io = psio 6 | #io = netmap 7 | io = dpdk 8 | 9 | # No. of cores setting (enabling this option will override 10 | # the `cpu' config for those applications that accept 11 | # num_cores as command line arguments) 12 | # 13 | # e.g. in case ./epserver is executed with `-N 4', the 14 | # mtcp core will still invoke 8 mTCP threads if the 15 | # following line is uncommented. 16 | #num_cores = 8 17 | 18 | # Number of memory channels per processor socket (dpdk-only) 19 | num_mem_ch = 4 20 | 21 | # Enable multi-process support 22 | multiprocess = 1 23 | 24 | # Used port (please adjust accordingly) 25 | #------ PSIO ports -------# 26 | #port = xge0 xge1 27 | #port = xge1 28 | #------ DPDK ports -------# 29 | port = dpdk0 30 | #port = dpdk1 31 | #port = dpdk0 dpdk1 32 | 33 | # Maximum concurrency per core (default = 10000) 34 | #max_concurrency = 10000 35 | 36 | # Maximum number of socket buffers per core (default = 10000) 37 | # Set this to small value if there are many idle connections 38 | #max_num_buffers = 10000 39 | 40 | # Receive buffer size of sockets; if not set: rcvbuf = sndbuf 41 | rcvbuf = 8192 42 | 43 | # Send buffer size of sockets; if not set: sndbuf = rcvbuf 44 | sndbuf = 8192 45 | 46 | # if sndbuf & rcvbuf not set: sndbuf = rcvbuf = 8192 47 | 48 | # TCP timeout seconds 49 | # (tcp_timeout = -1 can disable the timeout check) 50 | tcp_timeout = 30 51 | 52 | # TCP timewait seconds 53 | tcp_timewait = 0 54 | 55 | # Interface to print stats (please adjust accordingly) 56 | # You can enable multiple ports in separate lines 57 | #------ PSIO ports -------# 58 | #stat_print = xge0 59 | #stat_print = xge1 60 | #------ DPDK ports -------# 61 | stat_print = dpdk0 62 | #stat_print = dpdk1 63 | 64 | ####################################################### -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/apps/example/epserver.conf: -------------------------------------------------------------------------------- 1 | ############### mtcp configuration file ############### 2 | 3 | # The underlying I/O module you want to use. Please 4 | # enable only one out of the four. 5 | #io = psio 6 | #io = netmap 7 | #io = onvm 8 | io = dpdk 9 | 10 | # No. of cores setting (enabling this option will override 11 | # the `cpu' config for those applications that accept 12 | # num_cores as command line arguments) 13 | # 14 | # e.g. in case ./epserver is executed with `-N 4', the 15 | # mtcp core will still invoke 8 mTCP threads if the 16 | # following line is uncommented. 17 | #num_cores = 8 18 | 19 | # Core mask 20 | #core_mask = 0000000F0 21 | 22 | # Number of memory channels per processor socket (dpdk-only) 23 | num_mem_ch = 4 24 | 25 | #--- ONVM specific args ---# 26 | # Service id (required) 27 | #onvm_serv = 1 28 | # Instance id (optional) 29 | #onvm_inst = 1 30 | # Destination id (will forward to another NF) 31 | # If not set will send packets out 32 | #onvm_dest = 2 33 | 34 | # Sample ONVM configurations 35 | # Single node epserver <-> epwget 36 | #onvm_serv = 1 37 | #onvm_dest = 2 38 | 39 | # Simple endpoint server multi node setup 40 | #onvm_serv = 1 41 | #--------------------------# 42 | 43 | # Enable multi-process support 44 | #multiprocess = 1 45 | 46 | # Used port (please adjust accordingly) 47 | #------ PSIO ports -------# 48 | #port = xge0 xge1 49 | #port = xge1 50 | #------ DPDK ports -------# 51 | port = dpdk0 52 | #port = dpdk1 53 | #port = dpdk0 dpdk1 54 | 55 | local_ip = "192.168.18.124" 56 | # Congestion control algorithm 57 | # (only available when configured with --enable-ccp) 58 | # cc = reno 59 | # cc = cubic 60 | 61 | # Maximum concurrency per core (default = 10000) 62 | #max_concurrency = 10000 63 | 64 | # Maximum number of socket buffers per core (default = 10000) 65 | # Set this to small value if there are many idle connections 66 | #max_num_buffers = 10000 67 | 68 | # Receive buffer size of sockets; if not set: rcvbuf = sndbuf 69 | rcvbuf = 8192 70 | 71 | # Send buffer size of sockets; if not set: sndbuf = rcvbuf 72 | sndbuf = 8192 73 | 74 | # if sndbuf & rcvbuf not set: sndbuf = rcvbuf = 8192 75 | 76 | # TCP timeout seconds 77 | # (tcp_timeout = -1 can disable the timeout check) 78 | tcp_timeout = 30 79 | 80 | # TCP timewait seconds 81 | tcp_timewait = 0 82 | 83 | # Interface to print stats (please adjust accordingly) 84 | # You can enable multiple ports in a line 85 | #------ PSIO ports -------# 86 | #stat_print = xge0 87 | #stat_print = xge1 88 | #------ DPDK ports -------# 89 | stat_print = dpdk0 90 | #stat_print = dpdk0 dpdk1 91 | 92 | ####################################################### 93 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/apps/example/epwget-multiprocess.conf: -------------------------------------------------------------------------------- 1 | ############### mtcp configuration file ############### 2 | # The underlying I/O module you want to use. Please 3 | # enable only one out of the three. 4 | #io = psio 5 | #io = netmap 6 | io = dpdk 7 | 8 | # No. of cores setting (enabling this option will override 9 | # the `cpu' config for those applications that accept 10 | # num_cores as command line arguments) 11 | # 12 | # e.g. in case ./epserver is executed with `-N 4', the 13 | # mtcp core will still invoke 8 mTCP threads if the 14 | # following line is uncommented. 15 | #num_cores = 8 16 | 17 | # Number of memory channels per processor socket (dpdk-only) 18 | num_mem_ch = 4 19 | 20 | # Enable multi-process support 21 | multiprocess = 1 22 | 23 | # Used port (please adjust accordingly) 24 | #------ PSIO ports -------# 25 | #port = xge0 xge1 26 | #port = xge1 27 | #------ DPDK ports -------# 28 | port = dpdk0 29 | #port = dpdk1 30 | #port = dpdk0 dpdk1 31 | 32 | # Maximum concurrency per core (default = 10000) 33 | #max_concurrency = 10000 34 | 35 | # Maximum number of socket buffers per core (default = 10000) 36 | # Set this to small value if there are many idle connections 37 | #max_num_buffers = 10000 38 | 39 | # Receive buffer size of sockets; if not set: rcvbuf = sndbuf 40 | rcvbuf = 8192 41 | 42 | # Send buffer size of sockets; if not set: sndbuf = rcvbuf 43 | sndbuf = 8192 44 | 45 | # if sndbuf & rcvbuf not set: sndbuf = rcvbuf = 8192 46 | 47 | # TCP timeout seconds 48 | # (tcp_timeout = -1 can disable the timeout check) 49 | tcp_timeout = 30 50 | 51 | # TCP timewait seconds 52 | tcp_timewait = 0 53 | 54 | # Interface to print stats (please adjust accordingly) 55 | # You can enable multiple ports in separate lines 56 | #------ PSIO ports -------# 57 | #stat_print = xge0 58 | #stat_print = xge1 59 | #------ DPDK ports -------# 60 | stat_print = dpdk0 61 | #stat_print = dpdk1 62 | 63 | ####################################################### -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/apps/example/epwget.conf: -------------------------------------------------------------------------------- 1 | ############### mtcp configuration file ############### 2 | 3 | # The underlying I/O module you want to use. Please 4 | # enable only one out of the four. 5 | #io = psio 6 | #io = onvm 7 | #io = netmap 8 | io = dpdk 9 | 10 | # No. of cores setting (enabling this option will override 11 | # the `cpu' config for those applications that accept 12 | # num_cores as command line arguments) 13 | # 14 | # e.g. in case ./epwget is executed with `-N 4', the 15 | # mtcp core will still invoke 8 mTCP threads if the 16 | # following line is uncommented. 17 | #num_cores = 8 18 | 19 | # Number of memory channels per processor socket (dpdk-only) 20 | num_mem_ch = 4 21 | 22 | #--- ONVM specific args ---# 23 | # Service id (required) 24 | #onvm_serv = 2 25 | # Dest id (used to forward traffic to specific NF) 26 | #onvm_dest = 1 27 | 28 | # Sample ONVM configurations 29 | # Single node epserver <-> epwget 30 | #onvm_serv = 2 31 | #onvm_dest = 1 32 | 33 | # Simple client for multi node setup 34 | #onvm_serv = 1 35 | #--------------------------# 36 | 37 | # Used port (please adjust accordingly) 38 | #------ PSIO ports -------# 39 | #port = xge0 xge1 40 | #port = xge1 41 | #------ DPDK ports -------# 42 | port = dpdk0 43 | #port = dpdk1 44 | #port = dpdk0 dpdk1 45 | 46 | # Enable multi-process support 47 | #multiprocess = 1 48 | 49 | # Congestion control algorithm 50 | # (only available when configured with --enable-ccp) 51 | # cc = reno 52 | # cc = cubic 53 | 54 | # Receive buffer size of sockets; if not set: rcvbuf = sndbuf 55 | rcvbuf = 8192 56 | 57 | # Send buffer size of sockets; if not set: sndbuf = rcvbuf 58 | sndbuf = 8192 59 | 60 | # if sndbuf & rcvbuf not set: sndbuf = rcvbuf = 8192 61 | 62 | # Maximum concurrency per core (default = 10000) 63 | #max_concurrency = 10000 64 | 65 | # Maximum number of socket buffers per core (default = 10000) 66 | # Set this to small value if there are many idle connections 67 | #max_num_buffers = 10000 68 | 69 | # TCO timeout seconds 70 | # (tcp_timeout = -1 can disable the timeout check) 71 | tcp_timeout = 30 72 | 73 | # TCP timewait seconds 74 | tcp_timewait = 0 75 | 76 | # Interface to print stats (please adjust accordingly) 77 | # You can enable multiple ports in a line 78 | #------ PSIO ports -------# 79 | #stat_print = xge0 80 | #stat_print = xge1 81 | #------ DPDK ports -------# 82 | stat_print = dpdk0 83 | #stat_print = dpdk0 dpdk1 84 | 85 | ####################################################### 86 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/apps/perf/.gitignore: -------------------------------------------------------------------------------- 1 | logs/ 2 | client 3 | run 4 | log_* 5 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/apps/perf/Makefile: -------------------------------------------------------------------------------- 1 | # TODO: Make this Makefile.in pretty 2 | 3 | TARGETS = epserver epwget 4 | CC=gcc -g -O3 -Wall -Werror -fgnu89-inline 5 | DPDK=1 6 | PS=0 7 | NETMAP=0 8 | ONVM=0 9 | CCP= 10 | CFLAGS=-DMAX_CPUS=8 11 | 12 | # Add arch-specific optimization 13 | ifeq ($(shell uname -m),x86_64) 14 | LIBS += -m64 15 | endif 16 | 17 | # mtcp library and header 18 | MTCP_FLD =../../mtcp/ 19 | MTCP_INC =-I${MTCP_FLD}/include 20 | MTCP_LIB =-L${MTCP_FLD}/lib 21 | MTCP_TARGET = ${MTCP_LIB}/libmtcp.a 22 | 23 | UTIL_FLD = ../../util 24 | UTIL_INC = -I${UTIL_FLD}/include 25 | UTIL_OBJ = ${UTIL_FLD}/http_parsing.o ${UTIL_FLD}/tdate_parse.o ${UTIL_FLD}/netlib.o 26 | 27 | # util library and header 28 | INC = -I./include/ ${UTIL_INC} ${MTCP_INC} -I${UTIL_FLD}/include 29 | LIBS = ${MTCP_LIB} 30 | 31 | # psio-specific variables 32 | ifeq ($(PS),1) 33 | PS_DIR = ../../io_engine/ 34 | PS_INC = ${PS_DIR}/include 35 | INC += -I{PS_INC} 36 | LIBS += -lmtcp -L${PS_DIR}/lib -lps -lpthread -lnuma -lrt 37 | endif 38 | 39 | # netmap-specific variables 40 | ifeq ($(NETMAP),1) 41 | LIBS += -lmtcp -lpthread -lnuma -lrt 42 | endif 43 | 44 | # dpdk-specific variables 45 | ifeq ($(DPDK),1) 46 | DPDK_MACHINE_LINKER_FLAGS=$${RTE_SDK}/$${RTE_TARGET}/lib/ldflags.txt 47 | DPDK_MACHINE_LDFLAGS=$(shell cat ${DPDK_MACHINE_LINKER_FLAGS}) 48 | LIBS += -g -O3 -pthread -lrt -march=native ${MTCP_FLD}/lib/libmtcp.a -lnuma -lmtcp -lpthread -lrt -ldl -lgmp -L${RTE_SDK}/${RTE_TARGET}/lib ${DPDK_MACHINE_LDFLAGS} 49 | endif 50 | 51 | # onvm-specific variables 52 | ifeq ($(ONVM),1) 53 | ifeq ($(RTE_TARGET),) 54 | $(error "Please define RTE_TARGET environment variable") 55 | endif 56 | 57 | INC += -I/onvm_nflib 58 | INC += -DENABLE_ONVM 59 | LIBS += /onvm_nflib/$(RTE_TARGET)/libonvm.a 60 | endif 61 | 62 | ifeq ($V,) # no echo 63 | export MSG=@echo 64 | export HIDE=@ 65 | else 66 | export MSG=@\# 67 | export HIDE= 68 | endif 69 | 70 | ifeq ($(CCP), 1) 71 | # LIBCCP 72 | LIBCCP = $(MTCP_FLD)/src/libccp 73 | LIBS += -L$(LIBCCP) -lccp -lstartccp 74 | INC += -I$(LIBCCP) 75 | endif 76 | 77 | 78 | all: client 79 | 80 | client.o: client.c 81 | $(MSG) " CC $<" 82 | ${CC} -g -c $< ${CFLAGS} ${INC} 83 | 84 | client: client.o 85 | $(MSG) " LD $<" 86 | ${CC} $< ${INC} ${UTIL_OBJ} -g -o $@ ${LIBS} 87 | 88 | clean: 89 | rm -f *~ *.o ${TARGETS} log_* 90 | 91 | distclean: clean 92 | rm -rf Makefile 93 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/apps/perf/Makefile.in: -------------------------------------------------------------------------------- 1 | # TODO: Make this Makefile.in pretty 2 | 3 | TARGETS = epserver epwget 4 | CC=@CC@ -g -O3 -Wall -Werror -fgnu89-inline 5 | DPDK=@DPDK@ 6 | PS=@PSIO@ 7 | NETMAP=@NETMAP@ 8 | ONVM=@ONVM@ 9 | CCP=@CCP@ 10 | CFLAGS=@CFLAGS@ 11 | 12 | # Add arch-specific optimization 13 | ifeq ($(shell uname -m),x86_64) 14 | LIBS += -m64 15 | endif 16 | 17 | # mtcp library and header 18 | MTCP_FLD =../../mtcp/ 19 | MTCP_INC =-I${MTCP_FLD}/include 20 | MTCP_LIB =-L${MTCP_FLD}/lib 21 | MTCP_TARGET = ${MTCP_LIB}/libmtcp.a 22 | 23 | UTIL_FLD = ../../util 24 | UTIL_INC = -I${UTIL_FLD}/include 25 | UTIL_OBJ = ${UTIL_FLD}/http_parsing.o ${UTIL_FLD}/tdate_parse.o ${UTIL_FLD}/netlib.o 26 | 27 | # util library and header 28 | INC = -I./include/ ${UTIL_INC} ${MTCP_INC} -I${UTIL_FLD}/include 29 | LIBS = ${MTCP_LIB} 30 | 31 | # psio-specific variables 32 | ifeq ($(PS),1) 33 | PS_DIR = ../../io_engine/ 34 | PS_INC = ${PS_DIR}/include 35 | INC += -I{PS_INC} 36 | LIBS += -lmtcp -L${PS_DIR}/lib -lps -lpthread -lnuma -lrt 37 | endif 38 | 39 | # netmap-specific variables 40 | ifeq ($(NETMAP),1) 41 | LIBS += -lmtcp -lpthread -lnuma -lrt 42 | endif 43 | 44 | # dpdk-specific variables 45 | ifeq ($(DPDK),1) 46 | DPDK_MACHINE_LINKER_FLAGS=$${RTE_SDK}/$${RTE_TARGET}/lib/ldflags.txt 47 | DPDK_MACHINE_LDFLAGS=$(shell cat ${DPDK_MACHINE_LINKER_FLAGS}) 48 | LIBS += -g -O3 -pthread -lrt -march=native ${MTCP_FLD}/lib/libmtcp.a -lnuma -lmtcp -lpthread -lrt -ldl -lgmp -L${RTE_SDK}/${RTE_TARGET}/lib ${DPDK_MACHINE_LDFLAGS} 49 | endif 50 | 51 | # onvm-specific variables 52 | ifeq ($(ONVM),1) 53 | ifeq ($(RTE_TARGET),) 54 | $(error "Please define RTE_TARGET environment variable") 55 | endif 56 | 57 | INC += -I@ONVMLIBPATH@/onvm_nflib 58 | INC += -DENABLE_ONVM 59 | LIBS += @ONVMLIBPATH@/onvm_nflib/$(RTE_TARGET)/libonvm.a 60 | endif 61 | 62 | ifeq ($V,) # no echo 63 | export MSG=@echo 64 | export HIDE=@ 65 | else 66 | export MSG=@\# 67 | export HIDE= 68 | endif 69 | 70 | ifeq ($(CCP), 1) 71 | # LIBCCP 72 | LIBCCP = $(MTCP_FLD)/src/libccp 73 | LIBS += -L$(LIBCCP) -lccp -lstartccp 74 | INC += -I$(LIBCCP) 75 | endif 76 | 77 | 78 | all: client 79 | 80 | client.o: client.c 81 | $(MSG) " CC $<" 82 | ${CC} -g -c $< ${CFLAGS} ${INC} 83 | 84 | client: client.o 85 | $(MSG) " LD $<" 86 | ${CC} $< ${INC} ${UTIL_OBJ} -g -o $@ ${LIBS} 87 | 88 | clean: 89 | rm -f *~ *.o ${TARGETS} log_* 90 | 91 | distclean: clean 92 | rm -rf Makefile 93 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/apps/perf/README.md: -------------------------------------------------------------------------------- 1 | Throughput Measurement Application 2 | ================================== 3 | 4 | As the name suggests, this application is an iperf-like application which 5 | attempts to measure throughput with mTCP by measuring the time it takes to 6 | complete a bulk transfer. 7 | 8 | The client uses mTCP sockets, while the receiver is written in Python using 9 | traditional sockets so that it can be run on a machine that does not have 10 | DPDK/mTCP installed. 11 | 12 | The traffic always flows from client to receiver, but there are two different 13 | modes that allow you to specify whether the client or receiver should initiate 14 | the connection: 15 | 16 | 1. Client initiates connection (receiver listens on `port` and client sends to 17 | `ip:port` for `length` seconds) 18 | - `python recv.py wait [ip] [port]` 19 | - `./client send [ip] [port] [length (seconds)]` 20 | 21 | 2. Receiver initiates connection (client listens on `port`, receiver sends a 22 | start message to `ip:port`, and then client sends back to receiver for `length` 23 | seconds) 24 | - `./client wait [ip] [port] [length (seconds)]` 25 | - `python recv.py send [ip] [port]` 26 | 27 | *NOTE*: If using CCP with mTCP, you will need to ensure that `LD_LIBRARY_PATH` 28 | includes the path to libccp: 29 | 30 | `export LD_LIBRARY_PATH=/path/to/mtcp/src/libccp:$LD_LIBRARY_PATH` 31 | 32 | Even once this is in your user's local environment, you will probably need to 33 | make sure it persists when running with sudo: 34 | 35 | `sudo env LD_LIBRARY_PATH=$LD_LIBRARY_PATH ./client ...` 36 | 37 | 38 | Setup Notes 39 | =========== 40 | 41 | 0. Ensure the ARP table and routing table are populated correctly and located inside ./config/ 42 | 43 | 1. Build this application by simply running make in this directory (apps/perf) 44 | 45 | 2. Assuming sender and receiver are on the same network and/or have a very low 46 | delay between them, add a netem qdisc for ingress traffic at the receiver 47 | (who is not running mTCP/DPDK) to simulate a reasonable delay for the link. 48 | To add 20 ms delay to interface ETH, use the included script as follows: 49 | 50 | ./add-delay.sh IFACE 20 51 | 52 | (you can also easily remove the qdiscs later with ./rm-delay.sh ETH) 53 | 54 | 3. Start mTCP perf client in wait mode, listening on, e.g., port 9000 and 55 | sending for 30 seconds: 56 | 57 | `sudo env LD_LIBRARY_PATH=$LD_LIBRARY_PATH ./client wait 10.1.1.5 9000 30` 58 | 59 | 4. Start python receiver in send mode, where client ip is e.g. 10.1.1.5 60 | 61 | `sudo python recv.py send 10.1.1.5 9000` 62 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/apps/perf/add-delay-bw.sh: -------------------------------------------------------------------------------- 1 | ETH=10gp1 2 | DELAY=$1 3 | BW=$2 4 | BURST=400 #$2 #`expr $2 \* 5` 5 | #LAT=$5 6 | 7 | sudo modprobe ifb 8 | ip link set dev ifb0 up 9 | sudo tc qdisc add dev ${ETH} ingress 10 | sudo tc filter add dev ${ETH} parent ffff: protocol ip u32 match u32 0 0 flowid 1:1 action mirred egress redirect dev ifb0 11 | 12 | sudo tc qdisc add dev ifb0 root handle 1: netem limit 10000000 delay ${DELAY}ms 13 | sudo tc qdisc add dev ifb0 parent 1: handle 2: tbf rate ${BW}mbit burst ${BURST}kbit latency ${DELAY}ms 14 | 15 | #sudo tc qdisc add dev ifb0 root handle 1: tbf rate ${BW}mbit burst ${BURST}kbit latency 20ms 16 | #sudo tc qdisc add dev ifb0 parent 1: handle 2: netem delay ${DELAY}ms 17 | 18 | echo "Created a" $BW "mbps link with 1BDP buffering and" $DELAY "ms delay." 19 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/apps/perf/add-delay.sh: -------------------------------------------------------------------------------- 1 | ETH=$1 2 | DELAY=$2 3 | 4 | sudo modprobe ifb 5 | ip link set dev ifb0 up 6 | sudo tc qdisc add dev ${ETH} ingress 7 | sudo tc filter add dev ${ETH} parent ffff: protocol ip u32 match u32 0 0 flowid 1:1 action mirred egress redirect dev ifb0 8 | sudo tc qdisc add dev ifb0 root netem delay ${DELAY}ms 9 | 10 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/apps/perf/client.conf: -------------------------------------------------------------------------------- 1 | ############### mtcp configuration file ############### 2 | 3 | # The underlying I/O module you want to use. Please 4 | # enable only one out of the two. 5 | #io = psio 6 | io = dpdk 7 | 8 | # No. of cores setting (enabling this option will override 9 | # the `cpu' config for those applications that accept 10 | # num_cores as command line arguments) 11 | # 12 | # e.g. in case ./epwget is executed with `-N 4', the 13 | # mtcp core will still invoke 8 mTCP threads if the 14 | # following line is uncommented. 15 | #num_cores = 8 16 | 17 | # Number of memory channels per processor socket (dpdk-only) 18 | num_mem_ch = 4 19 | 20 | # Used port (please adjust accordingly) 21 | #------ PSIO ports -------# 22 | #port = xge0 xge1 23 | #port = xge 24 | #------ DPDK ports -------# 25 | port = 10gp1 26 | #port = dpdk0:0 27 | #port = dpdk0:1 28 | 29 | # Enable multi-process support (under development) 30 | #multiprocess = 0 master 31 | #multiprocess = 1 32 | 33 | # Congestion control algorithm 34 | # (only available when configured with --enable-ccp) 35 | # cc = reno 36 | # cc = cubic 37 | 38 | # Receive buffer size of sockets 39 | rcvbuf = 6291456 40 | #rcvbuf = 16384 41 | 42 | # Send buffer size of sockets 43 | #sndbuf = 2048 44 | sndbuf = 4194304 45 | #sndbuf = 41943040 46 | #sndbuf = 146000 47 | 48 | # Maximum concurrency per core 49 | max_concurrency = 10000 50 | 51 | # Maximum number of socket buffers per core 52 | # Set this to small value if there are many idle connections 53 | max_num_buffers = 10000 54 | 55 | # TCO timeout seconds 56 | # (tcp_timeout = -1 can disable the timeout check) 57 | tcp_timeout = 30 58 | 59 | # TCP timewait seconds 60 | tcp_timewait = 0 61 | 62 | # Interface to print stats (please adjust accordingly) 63 | # You can enable multiple ports in a line 64 | #------ PSIO ports -------# 65 | #stat_print = xge0 66 | #stat_print = xge1 67 | #------ DPDK ports -------# 68 | #stat_print = dpdk0 69 | #stat_print = p2p1 70 | #stat_print = 10gp1 71 | 72 | ####################################################### 73 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/apps/perf/recv.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | # Test network throughput. 4 | # 5 | # Usage: 6 | # 1) on host_A: throughput -s [port] # start a server 7 | # 2) on host_B: throughput -c count host_A [port] # start a client 8 | # 9 | # The server will service multiple clients until it is killed. 10 | 11 | import sys, time 12 | from socket import * 13 | 14 | BUFSIZE = 8192 15 | 16 | REPORT_INTERVAL = 0.5 # seconds 17 | 18 | def bulk_recv(conn, host, remoteport): 19 | bytes_rcvd = 0 20 | bytes_interval = 0 21 | start = time.time() 22 | last_report = time.time() 23 | i = 0 24 | while 1: 25 | data = conn.recv(BUFSIZE) 26 | n = len(data) 27 | bytes_rcvd += n 28 | bytes_interval += n 29 | 30 | now = time.time() 31 | elapsed = now - last_report 32 | if elapsed > REPORT_INTERVAL: 33 | thru_interval = ((bytes_interval / elapsed) * 8) / 1000000 34 | print "{} {:06.3f} Mbps".format((i * REPORT_INTERVAL), thru_interval) 35 | i += 1 36 | last_report = now 37 | bytes_interval = 0 38 | 39 | # print bytes_rcvd, data[-1] == 0x96 if len(data) > 0 else "" 40 | if (not data) or (n <= 0) or (data[-1] == '\x96'): 41 | break 42 | del data 43 | print "Received END from client" 44 | conn.send('OK\n') 45 | #conn.close() 46 | end = time.time() 47 | thru = ((bytes_rcvd / (end-start)) * 8) / 1000000 48 | print "Done with {}:{}, bytes_rcvd: {}, time: {}, thru: {}Mbps".format(host,remoteport,bytes_rcvd,(end-start),thru) 49 | 50 | def server(mode): 51 | ip = None 52 | port = None 53 | 54 | if mode == "wait": 55 | port = eval(sys.argv[3]) 56 | s = socket(AF_INET, SOCK_STREAM) 57 | s.bind((sys.argv[2], port)) 58 | s.listen(1) 59 | print 'Server ready...' 60 | while 1: 61 | conn, (host, remoteport) = s.accept() 62 | print 'Connected!' 63 | bulk_recv(conn, host, remoteport) 64 | elif mode == "send": 65 | ip = sys.argv[2] 66 | port = eval(sys.argv[3]) 67 | s = socket(AF_INET, SOCK_STREAM) 68 | #s.setsockopt(SOL_SOCKET, SO_RCVBUF, 450000) 69 | s.connect((ip, port)) 70 | print 'Connected' 71 | #while True: 72 | bulk_recv(s, ip, port) 73 | 74 | 75 | 76 | def usage(): 77 | sys.stdout = sys.stderr 78 | print "usage: python recv.py wait [port]" 79 | print "usage: python recv.py send [ip] [port]" 80 | sys.exit(2) 81 | 82 | def main(): 83 | if len(sys.argv) < 3: 84 | usage() 85 | else: 86 | mode = sys.argv[1] 87 | if mode == "wait": 88 | if len(sys.argv) != 4: 89 | usage() 90 | elif mode == "send": 91 | if len(sys.argv) != 4: 92 | usage() 93 | else: 94 | print "Unknown mode", mode 95 | server(mode) 96 | 97 | main() 98 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/apps/perf/rm-delay.sh: -------------------------------------------------------------------------------- 1 | ETH=$1 2 | 3 | sudo tc qdisc del dev $ETH ingress 4 | sudo tc qdisc del dev ifb0 parent 1: handle 2: netem 5 | sudo tc qdisc del dev ifb0 root 6 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/config/affinity-netmap.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #### -NOTE- This script only works for ixgbe driver #### 3 | 4 | import os 5 | import sys 6 | import subprocess 7 | 8 | def execute(cmd): 9 | try: 10 | proc = subprocess.Popen(cmd, shell = True, stdout = subprocess.PIPE) 11 | return proc.communicate()[0] 12 | except: 13 | pass 14 | return None 15 | 16 | if os.getuid() != 0: 17 | print 'You must be root!' 18 | sys.exit(1) 19 | 20 | num_cpus = len(execute('cat /proc/cpuinfo | grep processor').strip().split('\n')) 21 | 22 | if len(sys.argv) < 2: 23 | print 'usage: %s ' % sys.argv[0] 24 | sys.exit(1) 25 | 26 | ifname = sys.argv[1] 27 | 28 | intrmap = execute('cat /proc/interrupts | grep %s-TxRx-' % ifname).strip().split('\n') 29 | 30 | for intr in intrmap: 31 | irq = int(intr.split()[0][:-1]) 32 | name = intr.split()[-1] 33 | queue = int(name[name.rfind('-') + 1:]) 34 | 35 | cpu = queue 36 | 37 | print 'echo %x > /proc/irq/%d/smp_affinity' % (1 << cpu, irq) 38 | execute('echo %x > /proc/irq/%d/smp_affinity' % (1 << cpu, irq)) 39 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/config/sample_arp.conf: -------------------------------------------------------------------------------- 1 | # This file is to configure static arp tables. 2 | # Rename this file to arp.conf and set the appropriate values. 3 | # Please save this file as config/arp.conf. Put the config/ 4 | # directory in the same directory where the binary lies. 5 | # 6 | # (Destination IP address/IP_prefix) (Destination MAC address) 7 | 8 | ARP_ENTRY 2 9 | 10.0.0.1/32 00:00:00:00:00:01 10 | 10.0.1.1/32 00:00:00:00:00:02 -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/config/sample_mtcp.conf: -------------------------------------------------------------------------------- 1 | ############### mtcp configuration file ############### 2 | 3 | # The underlying I/O module you want to use. Please 4 | # enable only one out of the four. 5 | #io = psio 6 | #io = netmap 7 | #io = onvm 8 | io = dpdk 9 | 10 | # No. of cores setting (enabling this option will override 11 | # the `cpu' config for those applications that accept 12 | # num_cores as command line arguments) 13 | # 14 | # e.g. in case ./epserver is executed with `-N 4', the 15 | # mtcp core will still invoke 8 mTCP threads if the 16 | # following line is uncommented. 17 | #num_cores = 8 18 | 19 | # Enable multi-process support 20 | #multiprocess = 1 21 | 22 | # Number of memory channels per processor socket (dpdk-only!) 23 | num_mem_ch = 4 24 | 25 | #--- ONVM specific args ---# 26 | # Service id (required) 27 | #onvm_serv = 1 28 | # Instance id (optional) 29 | #onvm_inst = 1 30 | # Destination id (will forward to another NF) 31 | # If not set will send packets out 32 | #onvm_dest = 2 33 | #--------------------------# 34 | 35 | # Used port (please adjust accordingly) 36 | #------ PSIO ports -------# 37 | #port = xge0 xge1 38 | #port = xge1 39 | #------ DPDK ports -------# 40 | port = dpdk0 41 | #port = dpdk1 42 | #port = dpdk0 dpdk1 43 | 44 | # Congestion control algorithm 45 | # (only available when configured with --enable-ccp) 46 | # cc = reno 47 | # cc = cubic 48 | 49 | # Maximum concurrency per core (default = 10000) 50 | #max_concurrency = 10000 51 | 52 | # Maximum number of socket buffers per core (default = 10000) 53 | # Set this to small value if there are many idle connections 54 | #max_num_buffers = 10000 55 | 56 | # Receive buffer size of sockets; if not set: rcvbuf = sndbuf 57 | rcvbuf = 8192 58 | #rcvbuf = 16384 59 | 60 | # Send buffer size of sockets; if not set: sndbuf = rcvbuf 61 | sndbuf = 8192 62 | #sndbuf = 2048 63 | 64 | local_ip = "192.168.18.124" 65 | # if sndbuf & rcvbuf not set: sndbuf = rcvbuf = 8192 66 | 67 | # TCP timeout seconds 68 | # (tcp_timeout = -1 can disable the timeout check) 69 | tcp_timeout = 30 70 | 71 | # TCP timewait seconds 72 | tcp_timewait = 0 73 | 74 | # Interface to print stats (please adjust accordingly) 75 | # You can enable multiple ports in a line 76 | #------ PSIO ports -------# 77 | #stat_print = xge0 78 | #stat_print = xge1 79 | #------ DPDK ports -------# 80 | stat_print = dpdk0 81 | #stat_print = dpdk0 dpdk1 82 | 83 | ####################################################### 84 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/config/sample_route.conf: -------------------------------------------------------------------------------- 1 | # This file is routing table example of our testbed machine 2 | # Copy this file to route.conf and give appropriate routes 3 | # Please save this file as config/route.conf. Put the config/ 4 | # directory in the same directory where the binary lies. 5 | # 6 | # (Destination address)/(Prefix) (Device name) 7 | # 8 | # 9 | # Add entry for default gateway route as: 10 | # w.x.y.z/0 dpdk0 11 | # Always put the default gateway route as the last entry. 12 | # Make sure that the mask (Prefix) is set to 0. For example, 13 | # if the default gateway IP address is 10.0.0.10, then the 14 | # entry will be: 15 | # 10.0.0.10/0 dpdk0 16 | # 17 | 18 | ROUTES 2 19 | 10.0.0.1/24 dpdk0 20 | 10.0.1.1/24 dpdk1 21 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/docs/html/mtcp_destroy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 16 | mtcp_destroy 17 | 18 | 19 | 20 | 21 |

mtcp_destroy

22 | 23 | NAME
24 | SYNOPSIS
25 | DESCRIPTION
26 | RETURN VALUE
27 | NOTES
28 | AUTHORS
29 | SEE ALSO
30 | COLOPHON
31 | 32 |
33 | 34 | 35 |

NAME 36 | 37 |

38 | 39 | 40 |

mtcp_destroy 41 | − clean up the mTCP stack.

42 | 43 |

SYNOPSIS 44 | 45 |

46 | 47 | 48 |

#include 49 | <mtcp_api.h>

50 | 51 |

void 52 | mtcp_destroy();

53 | 54 |

DESCRIPTION 55 | 56 |

57 | 58 | 59 | 60 |

mtcp_destroy() 61 | call is used to clean up the networking stack for the mTCP 62 | application. This is usually the last call the application 63 | makes before terminating.

64 | 65 |

RETURN VALUE 66 | 67 |

68 | 69 | 70 |

Nothing is 71 | returned.

72 | 73 |

NOTES 74 | 75 |

76 | 77 | 78 |

This function 79 | only needs to be called once in an mTCP application.

80 | 81 |

AUTHORS 82 | 83 |

84 | 85 | 86 |

mTCP 87 | development team <mtcp-user@list.ndsl.kaist.edu>

88 | 89 |

SEE ALSO 90 | 91 |

92 | 93 | 94 | 95 |

mtcp_init()

96 | 97 |

COLOPHON 98 | 99 |

100 | 101 | 102 |

This page is 103 | part of mTCP release 3.0 docs section. A description 104 | of the project, and information about reporting bugs, can be 105 | found at http://shader.kaist.edu/mtcp/.

106 |
107 | 108 | 109 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/docs/html/mtcp_destroy_context.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 16 | mtcp_destroy_context 17 | 18 | 19 | 20 | 21 |

mtcp_destroy_context

22 | 23 | NAME
24 | SYNOPSIS
25 | DESCRIPTION
26 | RETURN VALUE
27 | AUTHORS
28 | SEE ALSO
29 | COLOPHON
30 | 31 |
32 | 33 | 34 |

NAME 35 | 36 |

37 | 38 | 39 | 40 |

mtcp_destroy_context 41 | − destroy mTCP context

42 | 43 |

SYNOPSIS 44 | 45 |

46 | 47 | 48 |

#include 49 | <mtcp_api.h>

50 | 51 |

void 52 | mtcp_destroy_context(mctx_t mctx);

53 | 54 |

DESCRIPTION 55 | 56 |

57 | 58 | 59 | 60 |

mtcp_destroy_context() 61 | cleans up the per-thread (with CPU core-id as specified in 62 | the mctx structure) mTCP context in the process. This 63 | is usually the last function called (specific to mTCP API) 64 | before the mTCP application thread is terminated from the 65 | process address space.

66 | 67 |

RETURN VALUE 68 | 69 |

70 | 71 | 72 | 73 |

mtcp_destroy_context() 74 | returns nothing.

75 | 76 |

AUTHORS 77 | 78 |

79 | 80 | 81 |

mTCP 82 | development team <mtcp-user@list.ndsl.kaist.edu>

83 | 84 |

SEE ALSO 85 | 86 |

87 | 88 | 89 | 90 |

mtcp_create_context(), 91 | mtcp_init(), mtcp_destroy()

92 | 93 |

COLOPHON 94 | 95 |

96 | 97 | 98 |

This page is 99 | part of mTCP release 3.0 docs section. A description 100 | of the project, and information about reporting bugs, can be 101 | found at http://shader.kaist.edu/mtcp/.

102 |
103 | 104 | 105 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/docs/man/mtcp_bind: -------------------------------------------------------------------------------- 1 | .TH mtcp_bind 2 2016-05-02 "Linux" "mTCP Programmer's Manual" 2 | .SH NAME 3 | mtcp_bind \- bind an IP address to an mTCP socket 4 | .SH SYNOPSIS 5 | .B #include 6 | .sp 7 | .BI "int mtcp_bind(mctx_t " mctx ", int " sockid ", const struct sockaddr *" addr ", socklen_t " addrlen ); 8 | 9 | .SH DESCRIPTION 10 | .BR mtcp_bind () 11 | can be used to bind an IPv4 address (assigning a 12 | name) to an mTCP socket. This socket is referred to by the 13 | .I "sockid" 14 | argument. 15 | The 16 | .I "addr" 17 | structure contains the address and the port number 18 | (both in network byte order) to be bound while the 19 | .I "addrlen" 20 | specifies the size of the address structure pointing to 21 | .I "addr." 22 | The actual structure passed for the 23 | .I "addr" 24 | argument is defined as: 25 | .in +4n 26 | .nf 27 | 28 | struct sockaddr { 29 | sa_family_t sa_family; /* AF_INET */ 30 | char sa_data[14]; /* IPv4 address + TCP port */ 31 | } 32 | 33 | .fi 34 | .in 35 | 36 | It is necessary to assign a local address using 37 | .BR mtcp_bind() 38 | on a passive socket before it can be used to receive 39 | connections using 40 | .BR mtcp_accept(). 41 | 42 | The 43 | .BR mtcp_bind () 44 | call takes an additional argument named 45 | .I "mctx" 46 | that represents the per-core mTCP context in an application 47 | (see 48 | .BR mtcp_create_context() 49 | for details). 50 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 51 | .SH RETURN VALUE 52 | Returns 0 on success; -1 on failure. In case 53 | of failure, 54 | .I "errno" 55 | is set appropriately. 56 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 57 | .SH ERRORS 58 | .TP 10 59 | .B "EBADF" 60 | .I "sockid" 61 | is not a valid socket descriptor for binding to an address. 62 | 63 | .TP 10 64 | .B "EINVAL" 65 | The 66 | .I "addr" 67 | argument is NULL. This may also mean that an address is already bound 68 | to the current 69 | .I "sockid" 70 | descriptor. 71 | 72 | .TP 10 73 | .B "ENOTSOCK" 74 | The socket referred to by 75 | .I "sockid" 76 | has an invalid type. 77 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 78 | .\""""".SH CONFORMING TO 79 | .\"""""POSIX.1-2001. 80 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 81 | .SH AUTHORS 82 | mTCP development team 83 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 84 | .SH SEE ALSO 85 | .BR mtcp_socket (), 86 | .BR mtcp_listen (), 87 | .BR mtcp_accept (), 88 | .BR mtcp_connect (), 89 | .BR mtcp_read (), 90 | .BR mtcp_write () 91 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 92 | .SH COLOPHON 93 | This page is part of mTCP release 3.0 94 | .I "docs" 95 | section. A description of the project, and information 96 | about reporting bugs, can be found at 97 | \%http://shader.kaist.edu/mtcp/. 98 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 99 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/docs/man/mtcp_close: -------------------------------------------------------------------------------- 1 | .TH mtcp_close 2 2016-05-02 "Linux" "mTCP Programmer's Manual" 2 | .SH NAME 3 | mtcp_close \- close an mTCP socket descriptor 4 | .SH SYNOPSIS 5 | .B #include 6 | .sp 7 | .BI "int mtcp_close(mctx_t " mctx ", int " sockid ); 8 | 9 | .SH DESCRIPTION 10 | .BR mtcp_close () 11 | closes the socket associated with 12 | .I "sockid" 13 | descriptor. This call can be used to gracefully terminate 14 | the underlying connection for active sockets. All the 15 | underlying resources pertaining to the connection are also 16 | destroyed. 17 | .BR "mtcp_close()" 18 | can also be used to shut down a passive listening socket. In both 19 | cases, the socket ID is made available for re-use for a future 20 | incoming connection request. 21 | .\""""""after a mandatory 22 | .\"""""".BR "TCP_TIMEOUT" 23 | .\""""""threshold period passes. 24 | 25 | .BR mtcp_close () 26 | call takes an additional argument named 27 | .I "mctx" 28 | that represents the per-core mTCP context in an application 29 | (see 30 | .BR mtcp_create_context() 31 | for details). 32 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 33 | .SH RETURN VALUE 34 | Returns 0 on success; -1 on failure and 35 | .I "errno" 36 | is set appropriately. 37 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 38 | .SH ERRORS 39 | .TP 10 40 | .B "EAGAIN" 41 | The request to close the connection was refused. 42 | 43 | .TP 10 44 | .B "EBADF" 45 | .I "sockid" 46 | is not a valid socket descriptor for closing. 47 | 48 | .TP 10 49 | .B "EINVAL" 50 | The socket specific to 51 | .I "sockid" 52 | has invalid type. 53 | 54 | .TP 10 55 | .B "ENOTCONN" 56 | The connection referred to by 57 | .I "sockid" 58 | is already terminated. 59 | 60 | .TP 10 61 | .B "ENOTSOCK" 62 | The socket referred to by 63 | .I "sockid" 64 | is not valid. 65 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 66 | .\""""".SH CONFORMING TO 67 | .\"""""POSIX.1-2001. 68 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 69 | .SH NOTES 70 | Please note that the same 71 | .I "mctx" 72 | context should be used to destroy the socket that created 73 | the socket via 74 | .BR "mtcp_socket ()" 75 | call in the first place. The user may experience unpredictable 76 | behavior if this practice is not followed. 77 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 78 | .SH AUTHORS 79 | mTCP development team 80 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 81 | .SH SEE ALSO 82 | .BR mtcp_socket () 83 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 84 | .SH COLOPHON 85 | This page is part of mTCP release 3.0 86 | .I "docs" 87 | section. A description of the project, and information 88 | about reporting bugs, can be found at 89 | \%http://shader.kaist.edu/mtcp/. 90 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 91 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/docs/man/mtcp_create_context: -------------------------------------------------------------------------------- 1 | .TH mtcp_create_context 2 2016-05-02 "Linux" "mTCP Programmer's Manual" 2 | .SH NAME 3 | mtcp_create_context \- create mTCP context for network communication 4 | .SH SYNOPSIS 5 | .B #include 6 | .sp 7 | .BI "mctx_t mtcp_create_context(int " cpu ); 8 | 9 | .SH DESCRIPTION 10 | .BR mtcp_create_context () 11 | creates the underlying mTCP stack based on the 12 | parameters passed by the 13 | .BR mtcp_init() 14 | function call. 15 | Each mTCP thread requires its own exclusive invocation 16 | of the 17 | .BR mtcp_create_context() 18 | routine before the stack can be used for network 19 | communication. The function requires a sole 20 | .I "cpu" 21 | integer argument that passes the CPU core-id of the 22 | system on which the stack is instantiated. 23 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 24 | .SH RETURN VALUE 25 | Returns 26 | .I "mctx" 27 | on success; NULL on failure. Please see the 28 | .BR "NOTES" 29 | section for details. 30 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 31 | .\""""".SH CONFORMING TO 32 | .\"""""POSIX.1-2001. 33 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 34 | .SH NOTES 35 | The user cannot call 36 | .BR mtcp_create_context() 37 | function more than once using the same cpu-id in a 38 | process. 39 | 40 | Passing an invalid CPU core-id (value < 0 or value > max_cpus) 41 | will prevent the creation of the mTCP stack. 42 | 43 | It is suggested that the user creates only 1 mTCP context thread 44 | per core for performance reasons. 45 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 46 | .SH AUTHORS 47 | mTCP development team 48 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 49 | .SH SEE ALSO 50 | .BR mtcp_destroy_context (), 51 | .BR mtcp_init (), 52 | .BR mtcp_destroy () 53 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 54 | .SH COLOPHON 55 | This page is part of mTCP release 3.0 56 | .I "docs" 57 | section. A description of the project, and information 58 | about reporting bugs, can be found at 59 | \%http://shader.kaist.edu/mtcp/. 60 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 61 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/docs/man/mtcp_destroy: -------------------------------------------------------------------------------- 1 | .TH mtcp_destroy 2 2016-05-02 "Linux" "mTCP Programmer's Manual" 2 | .SH NAME 3 | mtcp_destroy \- clean up the mTCP stack. 4 | .SH SYNOPSIS 5 | .B #include 6 | .sp 7 | .BI "void mtcp_destroy();" 8 | 9 | .SH DESCRIPTION 10 | .BR mtcp_destroy () 11 | call is used to clean up the networking stack for the mTCP 12 | application. This is usually the last call the application 13 | makes before terminating. 14 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 15 | .SH RETURN VALUE 16 | Nothing is returned. 17 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 18 | .SH NOTES 19 | This function only needs to be called once in an mTCP 20 | application. 21 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 22 | .\""""".SH CONFORMING TO 23 | .\"""""POSIX.1-2001. 24 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 25 | .SH AUTHORS 26 | mTCP development team 27 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 28 | .SH SEE ALSO 29 | .BR mtcp_init () 30 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 31 | .SH COLOPHON 32 | This page is part of mTCP release 3.0 33 | .I "docs" 34 | section. A description of the project, and information 35 | about reporting bugs, can be found at 36 | \%http://shader.kaist.edu/mtcp/. 37 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 38 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/docs/man/mtcp_destroy_context: -------------------------------------------------------------------------------- 1 | .TH mtcp_destroy_context 2 2016-05-02 "Linux" "mTCP Programmer's Manual" 2 | .SH NAME 3 | mtcp_destroy_context \- destroy mTCP context 4 | .SH SYNOPSIS 5 | .B #include 6 | .sp 7 | .BI "void mtcp_destroy_context(mctx_t " mctx ); 8 | 9 | .SH DESCRIPTION 10 | .BR mtcp_destroy_context () 11 | cleans up the per-thread (with CPU core-id as specified 12 | in the 13 | .I "mctx" 14 | structure) mTCP context in the process. 15 | This is usually the last function called (specific to 16 | mTCP API) before the mTCP application thread is 17 | terminated from the process address space. 18 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 19 | .SH RETURN VALUE 20 | .BR mtcp_destroy_context() 21 | returns nothing. 22 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 23 | .\""""".SH CONFORMING TO 24 | .\"""""POSIX.1-2001. 25 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 26 | .SH AUTHORS 27 | mTCP development team 28 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 29 | .SH SEE ALSO 30 | .BR mtcp_create_context (), 31 | .BR mtcp_init (), 32 | .BR mtcp_destroy () 33 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 34 | .SH COLOPHON 35 | This page is part of mTCP release 3.0 36 | .I "docs" 37 | section. A description of the project, and information 38 | about reporting bugs, can be found at 39 | \%http://shader.kaist.edu/mtcp/. 40 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 41 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/docs/man/mtcp_getsockname: -------------------------------------------------------------------------------- 1 | .TH mtcp_getsockname 2 2016-05-02 "Linux" "mTCP Programmer's Manual" 2 | .SH NAME 3 | mtcp_getsockname \- get socket name 4 | .SH SYNOPSIS 5 | .B #include 6 | .sp 7 | .BI "int mtcp_getsockname(mctx_t " mctx ", int " sockfd ", struct sockaddr *" addr ", socklen_t *" addrlen ); 8 | 9 | .SH DESCRIPTION 10 | .BR mtcp_getsockname () 11 | returns the current address to which the socket 12 | .I "sockfd" 13 | is bound, in the buffer pointed to by 14 | .I "addr." 15 | The 16 | .I "addrlen" 17 | argument should be initialized to indicate the amount of space 18 | (in bytes) pointed to by 19 | .I "addr." 20 | On return it contains the actual size of the socket address. 21 | 22 | An 23 | .BR mtcp_getsockname () 24 | call takes an additional argument named 25 | .I "mctx" 26 | that represents the per-core mTCP context in an application 27 | (see 28 | .BR mtcp_create_context() 29 | for details). 30 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 31 | .SH RETURN VALUE 32 | Returns zero on success; -1 on failure. In case 33 | of failure, 34 | .I "errno" 35 | is set appropriately. 36 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 37 | .SH ERRORS 38 | .TP 10 39 | .B "EBADF" 40 | The argument 41 | .I "sockfd" 42 | is not a valid socket descriptor. 43 | 44 | .TP 10 45 | .B "EINVAL" 46 | .I "addrlen" 47 | argument is invalid (e.g., is negative). 48 | 49 | .TP 10 50 | .B "ENOTSOCK" 51 | The argument 52 | .I "sockfd" 53 | is pointing to an invalid mTCP socket. 54 | 55 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 56 | .\""""".SH CONFORMING TO 57 | .\"""""POSIX.1-2001. 58 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 59 | .SH NOTES 60 | The third argument of 61 | .BR mtcp_getsockname() 62 | is in reality an 63 | .I "int *" 64 | (and this is what 4.x BSD and libc4 and libc5 have). Some 65 | POSIX confusion resulted in the present 66 | .I "socklen_t", 67 | also used by glibc. 68 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 69 | .SH AUTHORS 70 | mTCP development team 71 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 72 | .SH SEE ALSO 73 | .BR mtcp_bind (), 74 | .BR mtcp_socket () 75 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 76 | .SH COLOPHON 77 | This page is part of mTCP release 3.0 78 | .I "docs" 79 | section. A description of the project, and information 80 | about reporting bugs, can be found at 81 | \%http://shader.kaist.edu/mtcp/. 82 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 83 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/docs/man/mtcp_listen: -------------------------------------------------------------------------------- 1 | .TH mtcp_listen 2 2016-05-02 "Linux" "mTCP Programmer's Manual" 2 | .SH NAME 3 | mtcp_listen \- listen for connections on an mTCP socket 4 | .SH SYNOPSIS 5 | .B #include 6 | .sp 7 | .BI "int mtcp_listen(mctx_t " mctx ", int " sockid ", int " backlog ); 8 | 9 | .SH DESCRIPTION 10 | .BR mtcp_listen () 11 | marks the mTCP socket referred to by 12 | .I "sockid" 13 | as a passive socket of type 14 | .BR SOCK_STREAM. 15 | Once this function is called on a 16 | mTCP socket, it is ready to start accepting incoming 17 | connection requests. 18 | 19 | The 20 | .I "backlog" 21 | argument is used to set the maximum length of the 22 | queue that the passive socket, referred to by 23 | .I "sockid" 24 | can accomodate for pending connections requests. 25 | 26 | .BR mtcp_listen () 27 | call takes an additional argument named 28 | .I "mctx" 29 | that represents the per-core mTCP context in an application 30 | (see 31 | .BR mtcp_create_context() 32 | for details). 33 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 34 | .SH RETURN VALUE 35 | Returns 0 on success; -1 on failure. In case 36 | of failure, 37 | .I "errno" 38 | is set appropriately. 39 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 40 | .SH ERRORS 41 | 42 | .TP 15 43 | .B "EADDRINUSE" 44 | Another socket is already listening on the same port. 45 | 46 | .TP 15 47 | .B "EBADF" 48 | .I "sockid" 49 | is not a valid socket descriptor. 50 | 51 | .TP 15 52 | .B "EINVAL" 53 | The 54 | .I "backlog" 55 | argument is either <= 0 or exceeds the maximum conneciton concurrency 56 | limit as set by the mTCP startup configuration file (see 57 | .BR mtcp_init() 58 | for details). 59 | 60 | .TP 15 61 | .B "ENOMEM" 62 | There is not enough available memory to create the listening 63 | .I "backlog" 64 | queue. 65 | 66 | .TP 15 67 | .B "ENOTSOCK" 68 | The socket referred to by 69 | .I "sockid" 70 | is not valid. 71 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 72 | .\""""".SH CONFORMING TO 73 | .\"""""POSIX.1-2001. 74 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 75 | .SH AUTHORS 76 | mTCP development team 77 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 78 | .SH SEE ALSO 79 | .BR mtcp_bind (), 80 | .BR mtcp_socket (), 81 | .BR mtcp_accept (), 82 | .BR mtcp_connect (), 83 | .BR mtcp_read (), 84 | .BR mtcp_write () 85 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 86 | .SH COLOPHON 87 | This page is part of mTCP release 3.0 88 | .I "docs" 89 | section. A description of the project, and information 90 | about reporting bugs, can be found at 91 | \%http://shader.kaist.edu/mtcp/. 92 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 93 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/docs/man/mtcp_read: -------------------------------------------------------------------------------- 1 | .TH mtcp_read 2 2016-05-02 "Linux" "mTCP Programmer's Manual" 2 | .SH NAME 3 | mtcp_read \- read bytestream from an mTCP socket 4 | .SH SYNOPSIS 5 | .B #include 6 | .sp 7 | .BI "ssize_t mtcp_read(mctx_t " mctx ", int " sockid ", char *" buf ", size_t " len ); 8 | 9 | .SH DESCRIPTION 10 | .BR mtcp_read () 11 | can be used to read up to 12 | .I "len" 13 | number of bytes from mTCP socket via socket descriptor 14 | .I "sockid" 15 | into the buffer starting at 16 | .I "buf." 17 | It is the responsibility of the user to allocate memory for 18 | .I "buf" 19 | array. 20 | 21 | For cases when the total number of buffered unread bytes 22 | in the socket are less than 23 | .I "len," 24 | .BR "mtcp_read()" 25 | copies entire data to 26 | .I "buf" 27 | and returns the actual number of bytes that can be used 28 | by the application. 29 | 30 | An 31 | .BR mtcp_read () 32 | call takes an additional argument named 33 | .I "mctx" 34 | that represents the per-core mTCP context in an application 35 | (see 36 | .BR mtcp_create_context() 37 | for details). 38 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 39 | .SH RETURN VALUE 40 | On success, the number of bytes read is returned. It is not 41 | an error if this number is smaller than the number of bytes 42 | requested; this may happen when the socket has fewer number of 43 | bytes buffered at that moment. On all errors, -1 is returned and 44 | .I "errno" 45 | is set appropriately. 46 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 47 | .SH ERRORS 48 | .TP 10 49 | .B "EBADF" 50 | The socket descriptor 51 | .I "sockid" 52 | is invalid. 53 | 54 | .TP 10 55 | .B "ENOTSOCK" 56 | The socket referred to by 57 | .I "sockid" 58 | has invalid 59 | .I "type" 60 | 61 | .TP 10 62 | .B "ENOTCONN" 63 | Th socket referred to by 64 | .I "sockid" 65 | is in a TCP state that disallows read operations. 66 | 67 | .TP 10 68 | .B "EAGAIN" 69 | The socket referred to by 70 | .I "sockid" 71 | does not have any available bytes in its buffer 72 | for reading. 73 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 74 | .\""""".SH CONFORMING TO 75 | .\"""""POSIX.1-2001. 76 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 77 | .SH AUTHORS 78 | mTCP development team 79 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 80 | .SH SEE ALSO 81 | .BR mtcp_bind (), 82 | .BR mtcp_listen (), 83 | .BR mtcp_accept (), 84 | .BR mtcp_connect (), 85 | .BR mtcp_socket (), 86 | .BR mtcp_write () 87 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 88 | .SH COLOPHON 89 | This page is part of mTCP release 3.0 90 | .I "docs" 91 | section. A description of the project, and information 92 | about reporting bugs, can be found at 93 | \%http://shader.kaist.edu/mtcp/. 94 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 95 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/docs/man/mtcp_write: -------------------------------------------------------------------------------- 1 | .TH mtcp_write 2 2016-05-02 "Linux" "mTCP Programmer's Manual" 2 | .SH NAME 3 | mtcp_write \- send bytestream to an mTCP socket 4 | .SH SYNOPSIS 5 | .B #include 6 | .sp 7 | .BI "ssize_t mtcp_write(mctx_t " mctx ", int " sockid ", char *" buf ", size_t " len ); 8 | 9 | .SH DESCRIPTION 10 | .BR mtcp_write () 11 | sends up to 12 | .I "len" 13 | number of bytes from the buffer that is being pointed by 14 | .I "buf." 15 | The bytestream is sent to the mTCP socket using the 16 | .I "sockid" 17 | descriptor. 18 | 19 | An 20 | .BR mtcp_write() 21 | function call may write less number of bytes than 22 | .I "len" 23 | if there is insufficient space in the write buffer of the 24 | socket. In such a case, the return value is considered the 25 | actual number of bytes successfully written. 26 | 27 | .BR mtcp_write () 28 | call takes an additional argument named 29 | .I "mctx" 30 | that represents the per-core mTCP context in an application 31 | (see 32 | .BR mtcp_create_context() 33 | for details). 34 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 35 | .SH RETURN VALUE 36 | On success, the number of bytes dispatched via the socket 37 | are returned. The number of bytes sent can be less than 38 | .I "count" 39 | if there is insufficient space in the write buffer of 40 | the socket. On error, -1 is returned and 41 | .I "errno" 42 | is set appropriately. 43 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 44 | .SH ERRORS 45 | .TP 10 46 | .B "EAGAIN" 47 | The write buffer of the socket is currently full. The user should 48 | call the write function again once the write buffer has space 49 | available. 50 | 51 | .TP 10 52 | .B "EBADF" 53 | .I "sockid" 54 | is not a valid socket descriptor for writing. 55 | 56 | .TP 10 57 | .B "ENOTCONN" 58 | The underlying connection is not in a TCP state that allows data 59 | transmission (i.e. the TCP flow is neither in 60 | .BR "ESTABLISHED" 61 | or 62 | .BR "CLOSE_WAIT" 63 | state). 64 | 65 | .TP 10 66 | .B "ENOTSOCK" 67 | The socket referred to by 68 | .I "sockid" 69 | is not valid. 70 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 71 | .\""""".SH CONFORMING TO 72 | .\"""""POSIX.1-2001. 73 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 74 | .SH AUTHORS 75 | mTCP development team 76 | .\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 77 | .SH SEE ALSO 78 | .BR mtcp_bind (), 79 | .BR mtcp_listen (), 80 | .BR mtcp_accept (), 81 | .BR mtcp_connect (), 82 | .BR mtcp_read (), 83 | .BR mtcp_socket () 84 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 85 | .SH COLOPHON 86 | This page is part of mTCP release 3.0 87 | .I "docs" 88 | section. A description of the project, and information 89 | about reporting bugs, can be found at 90 | \%http://shader.kaist.edu/mtcp/. 91 | .\"""""""""""""""""""""""""""""""""""""""""""""""""""""" 92 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/io_engine/driver/affinity.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import sys 5 | import subprocess 6 | 7 | def execute(cmd): 8 | try: 9 | proc = subprocess.Popen(cmd, shell = True, stdout = subprocess.PIPE) 10 | return proc.communicate()[0] 11 | except: 12 | pass 13 | return None 14 | 15 | if os.getuid() != 0: 16 | print 'You must be root!' 17 | sys.exit(1) 18 | 19 | num_cpus = len(execute('cat /proc/cpuinfo | grep processor').strip().split('\n')) 20 | 21 | if len(sys.argv) < 2: 22 | print 'usage: %s ' % sys.argv[0] 23 | sys.exit(1) 24 | 25 | ifname = sys.argv[1] 26 | 27 | intrmap = execute('cat /proc/interrupts | grep %s-rx-' % ifname).strip().split('\n') 28 | 29 | for intr in intrmap: 30 | irq = int(intr.split()[0][:-1]) 31 | name = intr.split()[-1] 32 | queue = int(name[name.rfind('-') + 1:]) 33 | 34 | cpu = queue 35 | 36 | print 'echo %x > /proc/irq/%d/smp_affinity' % (1 << cpu, irq) 37 | execute('echo %x > /proc/irq/%d/smp_affinity' % (1 << cpu, irq)) 38 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/io_engine/driver/affinity_numa0.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import sys 5 | import subprocess 6 | 7 | def execute(cmd): 8 | try: 9 | proc = subprocess.Popen(cmd, shell = True, stdout = subprocess.PIPE) 10 | return proc.communicate()[0] 11 | except: 12 | pass 13 | return None 14 | 15 | if os.getuid() != 0: 16 | print 'You must be root!' 17 | sys.exit(1) 18 | 19 | num_cpus = len(execute('cat /proc/cpuinfo | grep processor').strip().split('\n')) 20 | 21 | if len(sys.argv) < 2: 22 | print 'usage: %s ' % sys.argv[0] 23 | sys.exit(1) 24 | 25 | ifname = sys.argv[1] 26 | 27 | intrmap = execute('cat /proc/interrupts | grep %s-rx-' % ifname).strip().split('\n') 28 | 29 | for intr in intrmap: 30 | irq = int(intr.split()[0][:-1]) 31 | name = intr.split()[-1] 32 | queue = int(name[name.rfind('-') + 1:]) 33 | 34 | cpu = queue 35 | 36 | print 'echo %x > /proc/irq/%d/smp_affinity' % (1 << cpu, irq) 37 | execute('echo %x > /proc/irq/%d/smp_affinity' % (1 << cpu, irq)) 38 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/io_engine/driver/affinity_numa1.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import sys 5 | import subprocess 6 | 7 | def execute(cmd): 8 | try: 9 | proc = subprocess.Popen(cmd, shell = True, stdout = subprocess.PIPE) 10 | return proc.communicate()[0] 11 | except: 12 | pass 13 | return None 14 | 15 | if os.getuid() != 0: 16 | print 'You must be root!' 17 | sys.exit(1) 18 | 19 | num_cpus = len(execute('cat /proc/cpuinfo | grep processor').strip().split('\n')) 20 | 21 | if len(sys.argv) < 2: 22 | print 'usage: %s ' % sys.argv[0] 23 | sys.exit(1) 24 | 25 | ifname = sys.argv[1] 26 | 27 | intrmap = execute('cat /proc/interrupts | grep %s-rx-' % ifname).strip().split('\n') 28 | 29 | for intr in intrmap: 30 | irq = int(intr.split()[0][:-1]) 31 | name = intr.split()[-1] 32 | queue = int(name[name.rfind('-') + 1:]) 33 | 34 | cpu = queue + 6 35 | 36 | print 'echo %x > /proc/irq/%d/smp_affinity' % (1 << cpu, irq) 37 | execute('echo %x > /proc/irq/%d/smp_affinity' % (1 << cpu, irq)) 38 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/io_engine/driver/install.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys 4 | import os 5 | import subprocess 6 | import time 7 | 8 | #ITR = 12500 #956 # interrupt throttling rate 9 | ITR = 956 10 | 11 | def execute(cmd): 12 | try: 13 | proc = subprocess.Popen(cmd, shell = True, stdout = subprocess.PIPE) 14 | return proc.communicate()[0] 15 | except: 16 | pass 17 | return None 18 | 19 | def get_num_interfaces(): 20 | output_82598 = execute('lspci | grep 82598').strip() 21 | num_82598 = len(output_82598.split('\n')) 22 | if output_82598 == '': 23 | num_82598 = 0 24 | 25 | output_82599 = execute('lspci | grep 82599').strip() 26 | num_82599 = len(output_82599.split('\n')) 27 | if output_82599 == '': 28 | num_82599 = 0 29 | 30 | return num_82598 + num_82599 31 | 32 | def get_num_cpus(): 33 | output = execute('cat /proc/cpuinfo | grep processor') 34 | return len(output.strip().split('\n')) 35 | 36 | if os.getuid() != 0: 37 | print 'You must be root!' 38 | sys.exit(1) 39 | 40 | if len(sys.argv) < 3: 41 | print 'usage: %s <# of RX queues> <# of TX queues>' % sys.argv[0] 42 | print ' You can specify 0 instead of the number of queues (one queue for each core)' 43 | sys.exit(1) 44 | 45 | num_rx_queues = int(sys.argv[1]) 46 | num_tx_queues = int(sys.argv[2]) 47 | postfix = '3' 48 | 49 | assert 0 <= num_rx_queues <= 16 50 | 51 | num_ifs = get_num_interfaces() 52 | num_cpus = get_num_cpus() 53 | 54 | execute('lsmod | grep ps_ixgbe > /dev/null && sudo rmmod ps_ixgbe') 55 | execute('insmod ./ps_ixgbe.ko RXQ=%s TXQ=%s InterruptThrottleRate=%s' % 56 | (','.join([str(num_rx_queues)] * num_ifs), 57 | ','.join([str(num_tx_queues)] * num_ifs), 58 | ','.join([str(ITR)] * num_ifs)) 59 | ) 60 | 61 | time.sleep(3) 62 | #for i in range(num_ifs): 63 | for i in range(2): 64 | ifname = 'xge%d' % i 65 | print 'setting %s...' % ifname 66 | 67 | execute('ethtool -A %s autoneg off rx off tx off' % ifname) 68 | execute('ifconfig %s 10.0.%d.%s mtu 1500 netmask 255.255.255.0' % (ifname, i, postfix)) 69 | 70 | print 'OK' 71 | print execute('./affinity.py %s' % ifname).strip() 72 | 73 | execute('rm -f /dev/packet_shader') 74 | execute('mknod /dev/packet_shader c 1010 0') 75 | execute('chmod 666 /dev/packet_shader') 76 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/io_engine/driver/ixgbe_fcoe.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | Intel 10 Gigabit PCI Express Linux driver 4 | Copyright(c) 1999 - 2009 Intel Corporation. 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms and conditions of the GNU General Public License, 8 | version 2, as published by the Free Software Foundation. 9 | 10 | This program is distributed in the hope it will be useful, but WITHOUT 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | more details. 14 | 15 | You should have received a copy of the GNU General Public License along with 16 | this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18 | 19 | The full GNU General Public License is included in this distribution in 20 | the file called "COPYING". 21 | 22 | Contact Information: 23 | e1000-devel Mailing List 24 | Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 | 26 | *******************************************************************************/ 27 | 28 | #include "ixgbe.h" 29 | 30 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/io_engine/driver/ixgbe_fcoe.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | Intel 10 Gigabit PCI Express Linux driver 4 | Copyright(c) 1999 - 2009 Intel Corporation. 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms and conditions of the GNU General Public License, 8 | version 2, as published by the Free Software Foundation. 9 | 10 | This program is distributed in the hope it will be useful, but WITHOUT 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | more details. 14 | 15 | You should have received a copy of the GNU General Public License along with 16 | this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18 | 19 | The full GNU General Public License is included in this distribution in 20 | the file called "COPYING". 21 | 22 | Contact Information: 23 | e1000-devel Mailing List 24 | Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 | 26 | *******************************************************************************/ 27 | 28 | #ifndef _IXGBE_FCOE_H 29 | #define _IXGBE_FCOE_H 30 | 31 | 32 | #endif /* _IXGBE_FCOE_H */ 33 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/io_engine/driver/ixgbe_sysfs.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | Intel 10 Gigabit PCI Express Linux driver 4 | Copyright(c) 1999 - 2009 Intel Corporation. 5 | 6 | This program is free software; you can redistribute it and/or modify it 7 | under the terms and conditions of the GNU General Public License, 8 | version 2, as published by the Free Software Foundation. 9 | 10 | This program is distributed in the hope it will be useful, but WITHOUT 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 | more details. 14 | 15 | You should have received a copy of the GNU General Public License along with 16 | this program; if not, write to the Free Software Foundation, Inc., 17 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18 | 19 | The full GNU General Public License is included in this distribution in 20 | the file called "COPYING". 21 | 22 | Contact Information: 23 | e1000-devel Mailing List 24 | Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 25 | 26 | *******************************************************************************/ 27 | 28 | #include "ixgbe.h" 29 | 30 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/io_engine/lib/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean 2 | 3 | CC=gcc 4 | PS=0 5 | 6 | ifeq ($(PS),1) 7 | all: pslib.a 8 | 9 | pslib.a: pslib.c 10 | $(CC) -O3 -c -g -Wall -fPIC -o pslib.o pslib.c 11 | ar rcs libps.a pslib.o 12 | 13 | clean: 14 | rm -f *.o *.a 15 | else 16 | all: 17 | 18 | clean: 19 | 20 | endif 21 | 22 | distclean: clean 23 | rm -f Makefile 24 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/io_engine/lib/Makefile.in: -------------------------------------------------------------------------------- 1 | .PHONY: clean 2 | 3 | CC=@CC@ 4 | PS=@PSIO@ 5 | 6 | ifeq ($(PS),1) 7 | all: pslib.a 8 | 9 | pslib.a: pslib.c 10 | $(CC) -O3 -c -g -Wall -fPIC -o pslib.o pslib.c 11 | ar rcs libps.a pslib.o 12 | 13 | clean: 14 | rm -f *.o *.a 15 | else 16 | all: 17 | 18 | clean: 19 | 20 | endif 21 | 22 | distclean: clean 23 | rm -f Makefile 24 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/io_engine/samples/echo/Makefile: -------------------------------------------------------------------------------- 1 | LIBS = -lps -lnuma 2 | LIB_DIR = -L../../lib 3 | 4 | .PHONY: clean 5 | 6 | all: echo echo_new 7 | 8 | echo: echo.c 9 | gcc -O3 -Wall -o echo echo.c $(LIB_DIR) $(LIBS) 10 | 11 | echo_new: echo_new.c 12 | gcc -O3 -Wall -o echo_new echo_new.c $(LIB_DIR) $(LIBS) 13 | 14 | clean: 15 | rm -f echo echo_new 16 | 17 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/io_engine/samples/list_devices/Makefile: -------------------------------------------------------------------------------- 1 | LIBS = -lps 2 | LIB_DIR = -L../../lib 3 | 4 | .PHONY: clean 5 | 6 | all: list_devices 7 | 8 | list_devices: list_devices.c 9 | gcc -O2 -g -Wall -o list_devices list_devices.c $(LIB_DIR) $(LIBS) 10 | 11 | clean: 12 | rm -f list_devices 13 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/io_engine/samples/list_devices/list_devices.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "../../include/ps.h" 4 | 5 | int main() 6 | { 7 | int num_devices; 8 | struct ps_device devices[MAX_DEVICES]; 9 | 10 | int i; 11 | 12 | num_devices = ps_list_devices(devices); 13 | if (num_devices == -1) { 14 | perror("ps_list_devices"); 15 | return 1; 16 | } 17 | 18 | printf("found %d device(s).\n", num_devices); 19 | 20 | for (i = 0; i < num_devices; i++) { 21 | struct ps_device *dev = &devices[i]; 22 | char *t = (char *)&dev->ip_addr; 23 | 24 | printf("%d: %s ", 25 | dev->ifindex, 26 | dev->name); 27 | 28 | printf("(%02hhX:%02hhX:%02hhX:%02hhX:%02hhX:%02hhX) ", 29 | dev->dev_addr[0], 30 | dev->dev_addr[1], 31 | dev->dev_addr[2], 32 | dev->dev_addr[3], 33 | dev->dev_addr[4], 34 | dev->dev_addr[5]); 35 | 36 | printf("%u.%u.%u.%u ", t[0], t[1], t[2], t[3]); 37 | 38 | printf("%d RX, %d TX queues\n", 39 | dev->num_rx_queues, 40 | dev->num_tx_queues); 41 | } 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/io_engine/samples/packet_generator/Makefile: -------------------------------------------------------------------------------- 1 | LIBS = -lps -lnuma 2 | LIB_DIR = -L../../lib 3 | 4 | .PHONY: clean 5 | 6 | all: packet_generator 7 | 8 | packet_generator: packet_generator.c 9 | gcc -O2 -g -Wall -o packet_generator packet_generator.c $(LIB_DIR) $(LIBS) 10 | 11 | clean: 12 | rm -f packet_generator 13 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/io_engine/samples/rxdump/Makefile: -------------------------------------------------------------------------------- 1 | LIBS = -lps 2 | LIB_DIR = -L../../lib 3 | 4 | .PHONY: clean 5 | 6 | all: rxdump 7 | 8 | rxdump: rxdump.c 9 | gcc -O2 -g -Wall -o rxdump rxdump.c $(LIB_DIR) $(LIBS) 10 | 11 | clean: 12 | rm -f rxdump 13 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/include/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/lib/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | 6 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/Makefile.old: -------------------------------------------------------------------------------- 1 | 2 | .PHONY: clean 3 | 4 | PS=0 5 | DPDK=0 6 | 7 | ### TARGET ### 8 | MTCP_LIB_DIR=../lib 9 | MTCP_LIB=libmtcp.a 10 | 11 | MTCP_HDR_DIR=../include 12 | MTCP_HDR = mtcp_api.h mtcp_epoll.h 13 | 14 | 15 | ### GCC ### 16 | GCC = gcc 17 | GCC_OPT = -m64 -Wall -fPIC 18 | 19 | #DBG_OPT = -DDBGMSG -DDBGFUNC -DSTREAM -DSTATE -DTSTAT -DAPP -DEPOLL 20 | #DBG_OPT = -DDBGMSG -DDBGFUNC -DSTREAM -DSTATE 21 | #DBG_OPT += -DPKTDUMP 22 | #DBG_OPT += -DDUMP_STREAM 23 | #GCC_OPT += -g -DNETSTAT -DINFO -DDBGERR -DDBGCERR 24 | GCC_OPT += -DNDEBUG -O3 -DNETSTAT -DINFO -DDBGERR -DDBGCERR 25 | #GCC_OPT += -DNDEBUG -g -DNETSTAT -DINFO -DDBGERR -DDBGCERR 26 | GCC_OPT += $(DBG_OPT) 27 | 28 | 29 | ### LIBRARIES AND INCLUDES ### 30 | INC_DIR=./include 31 | INC= -I$(INC_DIR) 32 | 33 | LIBS = -lnuma -lpthread -lrt 34 | ifeq ($(PS),1) 35 | LIBS += -lps 36 | else 37 | INC += -DDISABLE_PSIO 38 | endif 39 | 40 | # PacketShader LIBRARY and HEADER 41 | PS_DIR=../../io_engine 42 | INC += -I$(PS_DIR)/include 43 | 44 | # DPDK LIBRARY and HEADER 45 | DPDK_INC=../../dpdk/include 46 | DPDK_LIB=../../dpdk/lib/ 47 | # CFLAGS for DPDK-related compilation 48 | ifeq ($(DPDK), 1) 49 | INC += -DRTE_MACHINE_CPUFLAG_SSE -DRTE_MACHINE_CPUFLAG_SSE2 -DRTE_MACHINE_CPUFLAG_SSE3 \ 50 | -DRTE_MACHINE_CPUFLAG_SSSE3 -DRTE_MACHINE_CPUFLAG_SSE4_1 -DRTE_MACHINE_CPUFLAG_SSE4_2 \ 51 | -DRTE_MACHINE_CPUFLAG_AES -DRTE_MACHINE_CPUFLAG_PCLMULQDQ -DRTE_MACHINE_CPUFLAG_AVX \ 52 | -DRTE_COMPILE_TIME_CPUFLAGS=RTE_CPUFLAG_SSE,RTE_CPUFLAG_SSE2,RTE_CPUFLAG_SSE3,RTE_CPUFLAG_SSSE3,RTE_CPUFLAG_SSE4_1,RTE_CPUFLAG_SSE4_2,RTE_CPUFLAG_AES,RTE_CPUFLAG_PCLMULQDQ,RTE_CPUFLAG_AVX -I$(DPDK_INC) \ 53 | -include $(DPDK_INC)/rte_config.h 54 | LIBS += -export-dynamic -L$(DPDK_LIB) 55 | else 56 | INC += -DDISABLE_DPDK 57 | endif 58 | 59 | ifeq ($(wildcard /usr/lib/libhugetlbfs.so),) 60 | else 61 | GCC_OPT += -DHUGEPAGE 62 | endif 63 | 64 | 65 | ### SOURCE CODE ### 66 | SRCS = core.c tcp_stream.c config.c api.c eventpoll.c socket.c pipe.c \ 67 | tcp_util.c eth_in.c ip_in.c tcp_in.c eth_out.c ip_out.c tcp_out.c \ 68 | arp.c timer.c cpu.c rss.c addr_pool.c fhash.c memory_mgt.c logger.c debug.c \ 69 | tcp_rb_frag_queue.c tcp_ring_buffer.c tcp_send_buffer.c tcp_sb_queue.c tcp_stream_queue.c \ 70 | psio_module.c io_module.c dpdk_module.c 71 | 72 | OBJS = $(patsubst %.c,%.o,$(SRCS)) 73 | DEPS = $(patsubst %.c,.%.d,$(SRCS)) 74 | 75 | 76 | ### GOALS ### 77 | default: $(OBJS) $(MTCP_HDR) 78 | mkdir -p $(MTCP_LIB_DIR) 79 | ar rvs $(MTCP_LIB_DIR)/$(MTCP_LIB) $(OBJS) 80 | 81 | $(OBJS): %.o: %.c Makefile 82 | $(GCC) $(GCC_OPT) $(INC) -c $< -o $@ 83 | $(DEPS): .%.d: %.c Makefile 84 | $(GCC) $(GCC_OPT) $(INC) -MM $(CFLAGS) $< > $@ 85 | 86 | -include $(DEPS) 87 | 88 | $(MTCP_HDR): 89 | cp $(INC_DIR)/$@ $(MTCP_HDR_DIR)/$@ 90 | 91 | clean: clean-library 92 | rm -f *.o *~ core 93 | rm -f .*.d 94 | 95 | clean-library: 96 | rm -f $(MTCP_LIB_DIR)/* 97 | rm -f $(MTCP_HDR_DIR)/* 98 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/clock.c: -------------------------------------------------------------------------------- 1 | #include "clock.h" 2 | /*----------------------------------------------------------------------------*/ 3 | uint64_t init_time_ns = 0; 4 | uint32_t last_print = 0; 5 | /*----------------------------------------------------------------------------*/ 6 | uint64_t 7 | now_usecs() 8 | { 9 | struct timespec now; 10 | uint64_t now_ns, now_us; 11 | 12 | clock_gettime(CLOCK_MONOTONIC, &now); 13 | 14 | now_ns = (1000000000L * now.tv_sec) + now.tv_nsec; 15 | if (init_time_ns == 0) { 16 | init_time_ns = now_ns; 17 | } 18 | 19 | now_us = ((now_ns - init_time_ns) / 1000) & 0xffffffff; 20 | return now_us; 21 | } 22 | /*----------------------------------------------------------------------------*/ 23 | uint64_t 24 | time_since_usecs(uint64_t then) { 25 | return now_usecs() - then; 26 | } 27 | /*----------------------------------------------------------------------------*/ 28 | uint64_t 29 | time_after_usecs(uint64_t usecs) { 30 | return now_usecs() + usecs; 31 | } 32 | /*----------------------------------------------------------------------------*/ 33 | #define SAMPLE_FREQ_US 10000 34 | 35 | void 36 | log_cwnd_rtt(void *vs) { 37 | tcp_stream *stream = (tcp_stream *)vs; 38 | unsigned long now = (unsigned long)(now_usecs()); 39 | if (time_since_usecs(last_print) > SAMPLE_FREQ_US) { 40 | fprintf(stderr, "%lu %d %d/%d\n", 41 | now / 1000, 42 | stream->rcvvar->srtt * 125, 43 | stream->sndvar->cwnd / stream->sndvar->mss, 44 | stream->sndvar->peer_wnd / stream->sndvar->mss 45 | ); 46 | #if RATE_LIMIT_ENABLED 47 | PrintBucket(stream->bucket); 48 | #endif 49 | #if PACING_ENABLED 50 | PrintPacer(stream->pacer); 51 | #endif 52 | last_print = now; 53 | } 54 | } 55 | /*----------------------------------------------------------------------------*/ 56 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/cpu.c: -------------------------------------------------------------------------------- 1 | #ifndef _GNU_SOURCE 2 | #define _GNU_SOURCE 3 | #endif 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "mtcp_api.h" 14 | #ifndef DISABLE_DPDK 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #endif 22 | 23 | #define MAX_FILE_NAME 1024 24 | 25 | /*----------------------------------------------------------------------------*/ 26 | inline int 27 | GetNumCPUs() 28 | { 29 | return sysconf(_SC_NPROCESSORS_ONLN); 30 | } 31 | /*----------------------------------------------------------------------------*/ 32 | pid_t 33 | Gettid() 34 | { 35 | return syscall(__NR_gettid); 36 | } 37 | /*----------------------------------------------------------------------------*/ 38 | inline int 39 | whichCoreID(int thread_no) 40 | { 41 | #ifndef DISABLE_DPDK 42 | int i, cpu_id; 43 | if (mpz_get_ui(CONFIG._cpumask) == 0) 44 | return thread_no; 45 | else { 46 | int limit = mpz_popcount(CONFIG._cpumask); 47 | 48 | for (cpu_id = 0, i = 0; i < limit; cpu_id++) 49 | if (mpz_tstbit(CONFIG._cpumask, cpu_id)) { 50 | if (thread_no == i) 51 | return cpu_id; 52 | i++; 53 | } 54 | } 55 | #endif 56 | return thread_no; 57 | } 58 | /*----------------------------------------------------------------------------*/ 59 | int 60 | mtcp_core_affinitize(int cpu) 61 | { 62 | cpu_set_t cpus; 63 | size_t n; 64 | int ret; 65 | 66 | n = GetNumCPUs(); 67 | 68 | cpu = whichCoreID(cpu); 69 | 70 | if (cpu < 0 || cpu >= (int) n) { 71 | errno = -EINVAL; 72 | return -1; 73 | } 74 | 75 | CPU_ZERO(&cpus); 76 | CPU_SET((unsigned)cpu, &cpus); 77 | 78 | #ifndef DISABLE_DPDK 79 | return rte_thread_set_affinity(&cpus); 80 | #else 81 | struct bitmask *bmask; 82 | FILE *fp; 83 | char sysfname[MAX_FILE_NAME]; 84 | int phy_id; 85 | 86 | ret = sched_setaffinity(Gettid(), sizeof(cpus), &cpus); 87 | 88 | if (numa_max_node() == 0) 89 | return ret; 90 | 91 | bmask = numa_bitmask_alloc(numa_max_node() + 1); 92 | assert(bmask); 93 | 94 | /* read physical id of the core from sys information */ 95 | snprintf(sysfname, MAX_FILE_NAME - 1, 96 | "/sys/devices/system/cpu/cpu%d/topology/physical_package_id", cpu); 97 | fp = fopen(sysfname, "r"); 98 | if (!fp) { 99 | perror(sysfname); 100 | errno = EFAULT; 101 | return -1; 102 | } 103 | ret = fscanf(fp, "%d", &phy_id); 104 | if (ret != 1) { 105 | fclose(fp); 106 | perror("Fail to read core id"); 107 | errno = EFAULT; 108 | return -1; 109 | } 110 | 111 | numa_bitmask_setbit(bmask, phy_id); 112 | numa_set_membind(bmask); 113 | numa_bitmask_free(bmask); 114 | 115 | fclose(fp); 116 | #endif 117 | return ret; 118 | } 119 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/eth_in.c: -------------------------------------------------------------------------------- 1 | #include "ps.h" 2 | #include "ip_in.h" 3 | #include "eth_in.h" 4 | #include "arp.h" 5 | #include "debug.h" 6 | 7 | /*----------------------------------------------------------------------------*/ 8 | int 9 | ProcessPacket(mtcp_manager_t mtcp, const int ifidx, 10 | uint32_t cur_ts, unsigned char *pkt_data, int len) 11 | { 12 | struct ethhdr *ethh = (struct ethhdr *)pkt_data; 13 | u_short ip_proto = ntohs(ethh->h_proto); 14 | int ret; 15 | 16 | //#ifdef PKTDUMP 17 | // DumpPacket(mtcp, (char *)pkt_data, len, "IN", ifidx); 18 | //#endif 19 | 20 | #ifdef NETSTAT 21 | mtcp->nstat.rx_packets[ifidx]++; 22 | mtcp->nstat.rx_bytes[ifidx] += len + 24; 23 | //if(mtcp->nstat.rx_packets[ifidx] % 100 == 0) 24 | // printf("rx pkt num: %ld\n", mtcp->nstat.rx_packets[ifidx]); 25 | #endif /* NETSTAT */ 26 | 27 | #if 0 28 | /* ignore mac address which is not for current interface */ 29 | int i; 30 | for (i = 0; i < 6; i ++) { 31 | if (ethh->h_dest[i] != CONFIG.eths[ifidx].haddr[i]) { 32 | return FALSE; 33 | } 34 | } 35 | #endif 36 | 37 | if (ip_proto == ETH_P_IP) { 38 | /* process ipv4 packet */ 39 | ret = ProcessIPv4Packet(mtcp, cur_ts, ifidx, pkt_data, len); 40 | 41 | } else if (ip_proto == ETH_P_ARP) { 42 | ProcessARPPacket(mtcp, cur_ts, ifidx, pkt_data, len); 43 | return TRUE; 44 | 45 | } else { 46 | //DumpPacket(mtcp, (char *)pkt_data, len, "??", ifidx); 47 | mtcp->iom->release_pkt(mtcp->ctx, ifidx, pkt_data, len); 48 | return TRUE; 49 | } 50 | 51 | #ifdef NETSTAT 52 | if (ret < 0) { 53 | mtcp->nstat.rx_errors[ifidx]++; 54 | } 55 | #endif 56 | 57 | return ret; 58 | } 59 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/eth_out.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include "mtcp.h" 13 | #include "arp.h" 14 | #include "eth_out.h" 15 | #include "debug.h" 16 | 17 | #ifndef TRUE 18 | #define TRUE (1) 19 | #endif 20 | 21 | #ifndef FALSE 22 | #define FALSE (0) 23 | #endif 24 | 25 | #ifndef ERROR 26 | #define ERROR (-1) 27 | #endif 28 | 29 | #define MAX(a, b) ((a)>(b)?(a):(b)) 30 | #define MIN(a, b) ((a)<(b)?(a):(b)) 31 | 32 | #define MAX_WINDOW_SIZE 65535 33 | 34 | /*----------------------------------------------------------------------------*/ 35 | uint8_t * 36 | EthernetOutput(struct mtcp_manager *mtcp, uint16_t h_proto, 37 | int nif, unsigned char* dst_haddr, uint16_t iplen) 38 | { 39 | uint8_t *buf; 40 | struct ethhdr *ethh; 41 | int i, eidx; 42 | 43 | /* 44 | * -sanity check- 45 | * return early if no interface is set (if routing entry does not exist) 46 | */ 47 | if (nif < 0) { 48 | TRACE_INFO("No interface set!\n"); 49 | return NULL; 50 | } 51 | 52 | eidx = CONFIG.nif_to_eidx[nif]; 53 | if (eidx < 0) { 54 | TRACE_INFO("No interface selected!\n"); 55 | return NULL; 56 | } 57 | 58 | buf = mtcp->iom->get_wptr(mtcp->ctx, eidx, iplen + ETHERNET_HEADER_LEN); 59 | if (!buf) { 60 | //TRACE_DBG("Failed to get available write buffer\n"); 61 | return NULL; 62 | } 63 | //memset(buf, 0, ETHERNET_HEADER_LEN + iplen); 64 | 65 | #if 0 66 | TRACE_DBG("dst_hwaddr: %02X:%02X:%02X:%02X:%02X:%02X\n", 67 | dst_haddr[0], dst_haddr[1], 68 | dst_haddr[2], dst_haddr[3], 69 | dst_haddr[4], dst_haddr[5]); 70 | #endif 71 | 72 | ethh = (struct ethhdr *)buf; 73 | for (i = 0; i < ETH_ALEN; i++) { 74 | ethh->h_source[i] = CONFIG.eths[eidx].haddr[i]; 75 | ethh->h_dest[i] = dst_haddr[i]; 76 | } 77 | ethh->h_proto = htons(h_proto); 78 | 79 | return (uint8_t *)(ethh + 1); 80 | } 81 | /*----------------------------------------------------------------------------*/ 82 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/addr_pool.h: -------------------------------------------------------------------------------- 1 | #ifndef ADDR_POOL_H 2 | #define ADDR_POOL_H 3 | 4 | #include 5 | #include 6 | 7 | #define MIN_PORT (1025) 8 | #define MAX_PORT (65535 + 1) 9 | /*----------------------------------------------------------------------------*/ 10 | typedef struct addr_pool *addr_pool_t; 11 | /*----------------------------------------------------------------------------*/ 12 | /* CreateAddressPool() */ 13 | /* Create address pool for given address range. */ 14 | /* addr_base: the base address in network order. */ 15 | /* num_addr: number of addresses to use as source IP */ 16 | /*----------------------------------------------------------------------------*/ 17 | addr_pool_t 18 | CreateAddressPool(in_addr_t addr_base, int num_addr); 19 | /*----------------------------------------------------------------------------*/ 20 | /* CreateAddressPoolPerCore() */ 21 | /* Create address pool only for the given core number. */ 22 | /* All addresses and port numbers should be in network order. */ 23 | /*----------------------------------------------------------------------------*/ 24 | addr_pool_t 25 | CreateAddressPoolPerCore(int core, int num_queues, 26 | in_addr_t saddr_base, int num_addr, in_addr_t daddr, in_port_t dport); 27 | /*----------------------------------------------------------------------------*/ 28 | void 29 | DestroyAddressPool(addr_pool_t ap); 30 | /*----------------------------------------------------------------------------*/ 31 | int 32 | FetchAddress(addr_pool_t ap, int core, int num_queues, 33 | const struct sockaddr_in *daddr, struct sockaddr_in *saddr); 34 | /*----------------------------------------------------------------------------*/ 35 | int 36 | FetchAddressPerCore(addr_pool_t ap, int core, int num_queues, 37 | const struct sockaddr_in *daddr, struct sockaddr_in *saddr); 38 | /*----------------------------------------------------------------------------*/ 39 | int 40 | FreeAddress(addr_pool_t ap, const struct sockaddr_in *addr); 41 | /*----------------------------------------------------------------------------*/ 42 | 43 | #endif /* ADDR_POOL_H */ 44 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/arp.h: -------------------------------------------------------------------------------- 1 | #ifndef ARP_H 2 | #define ARP_H 3 | 4 | #define MAX_ARPENTRY 1024 5 | 6 | int 7 | InitARPTable(); 8 | 9 | unsigned char * 10 | GetHWaddr(uint32_t ip); 11 | 12 | unsigned char * 13 | GetDestinationHWaddr(uint32_t dip, uint8_t is_gateway); 14 | 15 | void 16 | RequestARP(mtcp_manager_t mtcp, uint32_t ip, int nif, uint32_t cur_ts); 17 | 18 | int 19 | ProcessARPPacket(mtcp_manager_t mtcp, uint32_t cur_ts, 20 | const int ifidx, unsigned char* pkt_data, int len); 21 | 22 | void 23 | ARPTimer(mtcp_manager_t mtcp, uint32_t cur_ts); 24 | 25 | void 26 | PrintARPTable(); 27 | 28 | #endif /* ARP_H */ 29 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/ccp.h: -------------------------------------------------------------------------------- 1 | #ifndef __CCP_H_ 2 | #define __CCP_H_ 3 | 4 | #include 5 | 6 | #include "tcp_stream.h" 7 | #include "tcp_in.h" 8 | #include "debug.h" 9 | 10 | // CCP currently only supports a single global datapath and CCP instance, but 11 | // this ID exists in case there is a need for supporting multiple 12 | // If this change is made in the future CCP_UNIX_BASE_ID will need to be 13 | // generated dynamically based on the CCP/datapath ID. For now, we always use 0. 14 | #define CCP_UNIX_BASE "/tmp/ccp/" 15 | #define CCP_ID "0/" 16 | #define FROM_CCP "out" 17 | #define TO_CCP "in" 18 | #define FROM_CCP_PATH CCP_UNIX_BASE CCP_ID FROM_CCP 19 | #define TO_CCP_PATH CCP_UNIX_BASE CCP_ID TO_CCP 20 | #define CCP_MAX_MSG_SIZE 32678 21 | 22 | #define MIN(a, b) ((a)<(b)?(a):(b)) 23 | #define MAX(a, b) ((a)>(b)?(a):(b)) 24 | 25 | #define EVENT_DUPACK 1 26 | #define EVENT_TRI_DUPACK 2 27 | #define EVENT_TIMEOUT 3 28 | #define EVENT_ECN 4 29 | 30 | void setup_ccp_connection(mtcp_manager_t mtcp); 31 | void setup_ccp_send_socket(mtcp_manager_t mtcp); 32 | void destroy_ccp_connection(mtcp_manager_t mtcp); 33 | void ccp_create(mtcp_manager_t mtcp, tcp_stream *stream); 34 | void ccp_cong_control(mtcp_manager_t mtcp, tcp_stream *stream, uint32_t ack, uint64_t bytes_delivered, uint64_t packets_delivered); 35 | void ccp_record_event(mtcp_manager_t mtcp, tcp_stream *stream, uint8_t event_type, uint32_t val); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/clock.h: -------------------------------------------------------------------------------- 1 | #ifndef __CLOCK__H_ 2 | #define __CLOCK__H_ 3 | 4 | #include 5 | #include 6 | #include "tcp_stream.h" 7 | 8 | uint64_t now_usecs(); 9 | uint64_t time_since_usecs(); 10 | uint64_t time_after_usecs(); 11 | void log_cwnd_rtt(void *stream); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/config.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_H 2 | #define CONFIG_H 3 | 4 | #include "ps.h" 5 | 6 | extern int num_cpus; 7 | extern int num_queues; 8 | extern int num_devices; 9 | 10 | extern int num_devices_attached; 11 | extern int devices_attached[MAX_DEVICES]; 12 | 13 | int 14 | LoadConfiguration(const char *fname); 15 | 16 | /* set configurations from the setted 17 | interface information */ 18 | int 19 | SetInterfaceInfo(); 20 | 21 | /* set configurations from the files */ 22 | int 23 | SetRoutingTable(); 24 | 25 | int 26 | LoadARPTable(); 27 | 28 | /* print setted configuration */ 29 | void 30 | PrintConfiguration(); 31 | 32 | void 33 | PrintInterfaceInfo(); 34 | 35 | void 36 | PrintRoutingTable(); 37 | 38 | /* fetch mask from prefix */ 39 | uint32_t 40 | MaskFromPrefix(int prefix); 41 | 42 | void 43 | ParseMACAddress(unsigned char *haddr, char *haddr_str); 44 | 45 | int 46 | ParseIPAddress(uint32_t *ip_addr, char *ip_str); 47 | 48 | #endif /* CONFIG_H */ 49 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/cpu.h: -------------------------------------------------------------------------------- 1 | #ifndef CPU_H 2 | #define CPU_H 3 | 4 | inline int GetNumCPUs(); 5 | 6 | inline int whichCoreID(int thread_no); 7 | 8 | #endif /* CPU_H */ 9 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/eth_in.h: -------------------------------------------------------------------------------- 1 | #ifndef ETH_IN_H 2 | #define ETH_IN_H 3 | 4 | #include "mtcp.h" 5 | 6 | int 7 | ProcessPacket(mtcp_manager_t mtcp, const int ifidx, 8 | uint32_t cur_ts, unsigned char *pkt_data, int len); 9 | 10 | #endif /* ETH_IN_H */ 11 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/eth_out.h: -------------------------------------------------------------------------------- 1 | #ifndef ETH_OUT_H 2 | #define ETH_OUT_H 3 | 4 | #include 5 | 6 | #include "mtcp.h" 7 | #include "tcp_stream.h" 8 | #include "ps.h" 9 | 10 | #define MAX_SEND_PCK_CHUNK 64 11 | 12 | uint8_t * 13 | EthernetOutput(struct mtcp_manager *mtcp, uint16_t h_proto, 14 | int nif, unsigned char* dst_haddr, uint16_t iplen); 15 | 16 | #endif /* ETH_OUT_H */ 17 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/eventpoll.h: -------------------------------------------------------------------------------- 1 | #ifndef EVENTPOLL_H 2 | #define EVENTPOLL_H 3 | 4 | #include "mtcp_api.h" 5 | #include "mtcp_epoll.h" 6 | 7 | /*----------------------------------------------------------------------------*/ 8 | struct mtcp_epoll_stat 9 | { 10 | uint64_t calls; 11 | uint64_t waits; 12 | uint64_t wakes; 13 | 14 | uint64_t issued; 15 | uint64_t registered; 16 | uint64_t invalidated; 17 | uint64_t handled; 18 | }; 19 | /*----------------------------------------------------------------------------*/ 20 | struct mtcp_epoll_event_int 21 | { 22 | struct mtcp_epoll_event ev; 23 | int sockid; 24 | }; 25 | /*----------------------------------------------------------------------------*/ 26 | enum event_queue_type 27 | { 28 | USR_EVENT_QUEUE = 0, 29 | USR_SHADOW_EVENT_QUEUE = 1, 30 | MTCP_EVENT_QUEUE = 2 31 | }; 32 | /*----------------------------------------------------------------------------*/ 33 | struct event_queue 34 | { 35 | struct mtcp_epoll_event_int *events; 36 | int start; // starting index 37 | int end; // ending index 38 | 39 | int size; // max size 40 | int num_events; // number of events 41 | }; 42 | /*----------------------------------------------------------------------------*/ 43 | struct mtcp_epoll 44 | { 45 | struct event_queue *usr_queue; 46 | struct event_queue *usr_shadow_queue; 47 | struct event_queue *mtcp_queue; 48 | 49 | uint8_t waiting; 50 | struct mtcp_epoll_stat stat; 51 | 52 | pthread_cond_t epoll_cond; 53 | pthread_mutex_t epoll_lock; 54 | }; 55 | /*----------------------------------------------------------------------------*/ 56 | 57 | int 58 | CloseEpollSocket(mctx_t mctx, int epid); 59 | 60 | #endif /* EVENTPOLL_H */ 61 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/fhash.h: -------------------------------------------------------------------------------- 1 | #ifndef FHASH_H 2 | #define FHASH_H 3 | 4 | #include 5 | #include "tcp_stream.h" 6 | 7 | #define NUM_BINS_FLOWS (131072) /* 132 K entries per thread*/ 8 | #define NUM_BINS_LISTENERS (1024) /* assuming that chaining won't happen excessively */ 9 | #define TCP_AR_CNT (3) 10 | 11 | typedef struct hash_bucket_head { 12 | tcp_stream *tqh_first; 13 | tcp_stream **tqh_last; 14 | } hash_bucket_head; 15 | 16 | typedef struct list_bucket_head { 17 | struct tcp_listener *tqh_first; 18 | struct tcp_listener **tqh_last; 19 | } list_bucket_head; 20 | 21 | /* hashtable structure */ 22 | struct hashtable { 23 | uint32_t bins; 24 | 25 | union { 26 | hash_bucket_head *ht_table; 27 | list_bucket_head *lt_table; 28 | }; 29 | 30 | // functions 31 | unsigned int (*hashfn) (const void *); 32 | int (*eqfn) (const void *, const void *); 33 | }; 34 | 35 | /*functions for hashtable*/ 36 | struct hashtable *CreateHashtable(unsigned int (*hashfn) (const void *), 37 | int (*eqfn) (const void *, 38 | const void *), 39 | int bins); 40 | void DestroyHashtable(struct hashtable *ht); 41 | 42 | 43 | int StreamHTInsert(struct hashtable *ht, void *); 44 | void* StreamHTRemove(struct hashtable *ht, void *); 45 | void *StreamHTSearch(struct hashtable *ht, const void *); 46 | unsigned int HashListener(const void *hbo_port_ptr); 47 | int EqualListener(const void *hbo_port_ptr1, const void *hbo_port_ptr2); 48 | int ListenerHTInsert(struct hashtable *ht, void *); 49 | void *ListenerHTRemove(struct hashtable *ht, void *); 50 | void *ListenerHTSearch(struct hashtable *ht, const void *); 51 | 52 | #endif /* FHASH_H */ 53 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/icmp.h: -------------------------------------------------------------------------------- 1 | #ifndef ICMP_H 2 | #define ICMP_H 3 | /*----------------------------------------------------------------------------*/ 4 | struct icmphdr { 5 | uint8_t icmp_type; 6 | uint8_t icmp_code; 7 | uint16_t icmp_checksum; 8 | union { 9 | struct { 10 | uint16_t icmp_id; 11 | uint16_t icmp_sequence; 12 | } echo; // ECHO | ECHOREPLY 13 | struct { 14 | uint16_t unused; 15 | uint16_t nhop_mtu; 16 | } dest; // DEST_UNREACH 17 | } un; 18 | }; 19 | /*----------------------------------------------------------------------------*/ 20 | /* getters and setters for ICMP fields */ 21 | #define ICMP_ECHO_GET_ID(icmph) (icmph->un.echo.icmp_id) 22 | #define ICMP_ECHO_GET_SEQ(icmph) (icmph->un.echo.icmp_sequence) 23 | #define ICMP_DEST_UNREACH_GET_MTU(icmph) (icmph->un.dest.nhop_mtu) 24 | 25 | #define ICMP_ECHO_SET_ID(icmph, id) (icmph->un.echo.icmp_id = id) 26 | #define ICMP_ECHO_SET_SEQ(icmph, seq) (icmph->un.echo.icmp_sequence = seq) 27 | 28 | void 29 | RequestICMP(mtcp_manager_t mtcp, uint32_t saddr, uint32_t daddr, 30 | uint16_t icmp_id, uint16_t icmp_seq, 31 | uint8_t *icmpd, uint16_t len); 32 | 33 | int 34 | ProcessICMPPacket(mtcp_manager_t mtcp, struct iphdr *iph, int len); 35 | 36 | /* ICMP types */ 37 | #define ICMP_ECHOREPLY 0 /* Echo Reply */ 38 | #define ICMP_DEST_UNREACH 3 /* Destination Unreachable */ 39 | #define ICMP_SOURCE_QUENCH 4 /* Source Quench */ 40 | #define ICMP_REDIRECT 5 /* Redirect (change route) */ 41 | #define ICMP_ECHO 8 /* Echo Request */ 42 | #define ICMP_TIME_EXCEEDED 11 /* Time Exceeded */ 43 | #define ICMP_PARAMETERPROB 12 /* Parameter Problem */ 44 | #define ICMP_TIMESTAMP 13 /* Timestamp Request */ 45 | #define ICMP_TIMESTAMPREPLY 14 /* Timestamp Reply */ 46 | #define ICMP_INFO_REQUEST 15 /* Information Request */ 47 | #define ICMP_INFO_REPLY 16 /* Information Reply */ 48 | #define ICMP_ADDRESS 17 /* Address Mask Request */ 49 | #define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */ 50 | /*----------------------------------------------------------------------------*/ 51 | #endif /* ICMP_H */ 52 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/ip_in.h: -------------------------------------------------------------------------------- 1 | #ifndef IP_IN_H 2 | #define IP_IN_H 3 | 4 | #include "mtcp.h" 5 | 6 | int 7 | ProcessIPv4Packet(mtcp_manager_t mtcp, uint32_t cur_ts, 8 | const int ifidx, unsigned char* pkt_data, int len); 9 | 10 | #endif /* IP_IN_H */ 11 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/ip_out.h: -------------------------------------------------------------------------------- 1 | #ifndef IP_OUT_H 2 | #define IP_OUT_H 3 | 4 | #include 5 | #include "tcp_stream.h" 6 | 7 | extern inline int 8 | GetOutputInterface(uint32_t daddr, uint8_t *is_external); 9 | 10 | void 11 | ForwardIPv4Packet(mtcp_manager_t mtcp, int nif_in, char *buf, int len); 12 | 13 | uint8_t * 14 | IPOutputStandalone(struct mtcp_manager *mtcp, uint8_t protocol, 15 | uint16_t ip_id, uint32_t saddr, uint32_t daddr, uint16_t tcplen); 16 | 17 | uint8_t * 18 | IPOutput(struct mtcp_manager *mtcp, tcp_stream *stream, uint16_t tcplen); 19 | 20 | #endif /* IP_OUT_H */ 21 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/logger.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGGER_H 2 | #define LOGGER_H 3 | 4 | #include 5 | 6 | #define LOG_BUFF_SIZE (256*1024) 7 | #define NUM_LOG_BUFF (100) 8 | 9 | enum { 10 | IDLE_LOGT, 11 | ACTIVE_LOGT 12 | } log_thread_state; 13 | 14 | typedef struct log_buff 15 | { 16 | int tid; 17 | FILE* fid; 18 | int buff_len; 19 | char buff[LOG_BUFF_SIZE]; 20 | TAILQ_ENTRY(log_buff) buff_link; 21 | } log_buff; 22 | 23 | typedef struct log_thread_context { 24 | pthread_t thread; 25 | int cpu; 26 | int done; 27 | int sp_fd; 28 | int pair_sp_fd; 29 | int free_buff_cnt; 30 | int job_buff_cnt; 31 | 32 | uint8_t state; 33 | 34 | pthread_mutex_t mutex; 35 | pthread_mutex_t free_mutex; 36 | 37 | TAILQ_HEAD(, log_buff) working_queue; 38 | TAILQ_HEAD(, log_buff) free_queue; 39 | 40 | } log_thread_context; 41 | 42 | log_buff* DequeueFreeBuffer (log_thread_context *ctx); 43 | void EnqueueJobBuffer(log_thread_context *ctx, log_buff* working_bp); 44 | void InitLogThreadContext (log_thread_context *ctx, int cpu); 45 | void *ThreadLogMain(void* arg); 46 | 47 | #endif /* LOGGER_H */ 48 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/memory_mgt.h: -------------------------------------------------------------------------------- 1 | #ifndef MEMORY_MGT_H 2 | #define MEMORY_MGT_H 3 | /*----------------------------------------------------------------------------*/ 4 | #if ! defined(DISABLE_DPDK) && !defined(ENABLE_ONVM) 5 | #include 6 | #include 7 | /* for rte_versions retrieval */ 8 | #include 9 | /*----------------------------------------------------------------------------*/ 10 | typedef struct rte_mempool mem_pool; 11 | typedef struct rte_mempool* mem_pool_t; 12 | /* create a memory pool with a chunk size and total size 13 | an return the pointer to the memory pool */ 14 | mem_pool_t 15 | MPCreate(char *name, int chunk_size, size_t total_size); 16 | /*----------------------------------------------------------------------------*/ 17 | #else 18 | struct mem_pool; 19 | typedef struct mem_pool* mem_pool_t; 20 | 21 | /* create a memory pool with a chunk size and total size 22 | an return the pointer to the memory pool */ 23 | mem_pool_t MPCreate(int chunk_size, size_t total_size); 24 | #endif /* DISABLE_DPDK */ 25 | /*----------------------------------------------------------------------------*/ 26 | /* allocate one chunk */ 27 | void * 28 | MPAllocateChunk(mem_pool_t mp); 29 | 30 | /* free one chunk */ 31 | void 32 | MPFreeChunk(mem_pool_t mp, void *p); 33 | 34 | /* destroy the memory pool */ 35 | void 36 | MPDestroy(mem_pool_t mp); 37 | 38 | /* retrun the number of free chunks */ 39 | int 40 | MPGetFreeChunks(mem_pool_t mp); 41 | /*----------------------------------------------------------------------------*/ 42 | #endif /* MEMORY_MGT_H */ 43 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/mtcp_epoll.h: -------------------------------------------------------------------------------- 1 | #ifndef MTCP_EPOLL_H 2 | #define MTCP_EPOLL_H 3 | 4 | #include "mtcp_api.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | /*----------------------------------------------------------------------------*/ 11 | enum mtcp_epoll_op 12 | { 13 | MTCP_EPOLL_CTL_ADD = 1, 14 | MTCP_EPOLL_CTL_DEL = 2, 15 | MTCP_EPOLL_CTL_MOD = 3, 16 | }; 17 | /*----------------------------------------------------------------------------*/ 18 | enum mtcp_event_type 19 | { 20 | MTCP_EPOLLNONE = 0x000, 21 | MTCP_EPOLLIN = 0x001, 22 | MTCP_EPOLLPRI = 0x002, 23 | MTCP_EPOLLOUT = 0x004, 24 | MTCP_EPOLLRDNORM = 0x040, 25 | MTCP_EPOLLRDBAND = 0x080, 26 | MTCP_EPOLLWRNORM = 0x100, 27 | MTCP_EPOLLWRBAND = 0x200, 28 | MTCP_EPOLLMSG = 0x400, 29 | MTCP_EPOLLERR = 0x008, 30 | MTCP_EPOLLHUP = 0x010, 31 | MTCP_EPOLLRDHUP = 0x2000, 32 | MTCP_EPOLLONESHOT = (1 << 30), 33 | MTCP_EPOLLET = (1 << 31) 34 | }; 35 | /*----------------------------------------------------------------------------*/ 36 | typedef union mtcp_epoll_data 37 | { 38 | void *ptr; 39 | int sockid; 40 | uint32_t u32; 41 | uint64_t u64; 42 | } mtcp_epoll_data_t; 43 | /*----------------------------------------------------------------------------*/ 44 | struct mtcp_epoll_event 45 | { 46 | uint32_t events; 47 | mtcp_epoll_data_t data; 48 | }; 49 | /*----------------------------------------------------------------------------*/ 50 | int 51 | mtcp_epoll_create(mctx_t mctx, int size); 52 | /*----------------------------------------------------------------------------*/ 53 | int 54 | mtcp_epoll_create1(mctx_t mctx, int flags); 55 | /*----------------------------------------------------------------------------*/ 56 | int 57 | mtcp_epoll_ctl(mctx_t mctx, int epid, 58 | int op, int sockid, struct mtcp_epoll_event *event); 59 | /*----------------------------------------------------------------------------*/ 60 | int 61 | mtcp_epoll_wait(mctx_t mctx, int epid, 62 | struct mtcp_epoll_event *events, int maxevents, int timeout); 63 | /*----------------------------------------------------------------------------*/ 64 | char * 65 | EventToString(uint32_t event); 66 | /*----------------------------------------------------------------------------*/ 67 | 68 | #ifdef __cplusplus 69 | }; 70 | #endif 71 | 72 | #endif /* MTCP_EPOLL_H */ 73 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/pacing.h: -------------------------------------------------------------------------------- 1 | #ifndef __PACING_H_ 2 | #define __PACING_H_ 3 | 4 | #include "tcp_stream.h" 5 | #include "clock.h" 6 | 7 | #if RATE_LIMIT_ENABLED 8 | typedef struct token_bucket { 9 | double tokens; 10 | uint32_t rate; 11 | uint32_t burst; 12 | uint32_t last_fill_t; 13 | } token_bucket; 14 | 15 | token_bucket* NewTokenBucket(); 16 | int SufficientTokens(token_bucket *bucket, uint64_t new_bits); 17 | void PrintBucket(token_bucket *bucket); 18 | #endif 19 | 20 | #if PACING_ENABLED 21 | typedef struct packet_pacer { 22 | uint32_t rate_bps; 23 | uint32_t extra_packets; 24 | uint32_t next_send_time; 25 | } packet_pacer; 26 | 27 | packet_pacer* NewPacketPacer(); 28 | int CanSendNow(packet_pacer *pacer); 29 | void PrintPacer(packet_pacer *pacer); 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/pipe.h: -------------------------------------------------------------------------------- 1 | #ifndef MTCP_PIPE_H 2 | #define MTCP_PIPE_H 3 | 4 | #include 5 | 6 | int 7 | PipeRead(mctx_t mctx, int pipeid, char *buf, int len); 8 | 9 | int 10 | PipeWrite(mctx_t mctx, int pipeid, const char *buf, int len); 11 | 12 | int 13 | RaisePendingPipeEvents(mctx_t mctx, int epid, int pipeid); 14 | 15 | int 16 | PipeClose(mctx_t mctx, int pipeid); 17 | 18 | #endif /* MTCP_PIPE_H */ 19 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/rss.h: -------------------------------------------------------------------------------- 1 | #ifndef RSS_H 2 | #define RSS_H 3 | 4 | #include 5 | 6 | /* sip, dip, sp, dp: in network byte order */ 7 | int GetRSSCPUCore(in_addr_t sip, in_addr_t dip, 8 | in_port_t sp, in_port_t dp, int num_queues, 9 | uint8_t endian_check); 10 | 11 | #endif /* RSS_H */ 12 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/rte_os.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: BSD-3-Clause 2 | * Copyright(c) 2010-2019 Intel Corporation 3 | */ 4 | 5 | #ifndef _RTE_OS_H_ 6 | #define _RTE_OS_H_ 7 | 8 | /** 9 | * This header should contain any definition 10 | * which is not supported natively or named differently in Linux. 11 | */ 12 | 13 | #include 14 | 15 | #ifdef CPU_SETSIZE /* may require _GNU_SOURCE */ 16 | typedef cpu_set_t rte_cpuset_t; 17 | #define RTE_HAS_CPUSET 18 | #define RTE_CPU_AND(dst, src1, src2) CPU_AND(dst, src1, src2) 19 | #define RTE_CPU_OR(dst, src1, src2) CPU_OR(dst, src1, src2) 20 | #define RTE_CPU_FILL(set) do \ 21 | { \ 22 | unsigned int i; \ 23 | CPU_ZERO(set); \ 24 | for (i = 0; i < CPU_SETSIZE; i++) \ 25 | CPU_SET(i, set); \ 26 | } while (0) 27 | #define RTE_CPU_NOT(dst, src) do \ 28 | { \ 29 | cpu_set_t tmp; \ 30 | RTE_CPU_FILL(&tmp); \ 31 | CPU_XOR(dst, &tmp, src); \ 32 | } while (0) 33 | #endif 34 | 35 | #endif /* _RTE_OS_H_ */ 36 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/sfifo.h: -------------------------------------------------------------------------------- 1 | #ifndef __SFIFO_H 2 | #define __SFIFO_H 3 | 4 | #define MAX_ENTRY 16 5 | 6 | #ifndef smp_wmb 7 | #define smp_wmb __sync_synchronize 8 | #endif 9 | 10 | struct entry { 11 | void *pdata; //pdata == NULL means this entry is empty 12 | int size; //size of pdata 13 | }; 14 | 15 | struct sfifo { 16 | struct entry entry_arr[MAX_ENTRY]; 17 | int tail; 18 | int head; 19 | int freen; 20 | }; 21 | 22 | struct sfifo *sfifo_create(); 23 | void sfifo_free(struct sfifo *ps); 24 | int sfifo_in(struct sfifo *ps, void *buff, int sz); 25 | int sfifo_out(struct sfifo *sf, struct entry *ep); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/socket.h: -------------------------------------------------------------------------------- 1 | #ifndef SOCKET_H 2 | #define SOCKET_H 3 | 4 | #include "mtcp_api.h" 5 | #include "mtcp_epoll.h" 6 | 7 | /*----------------------------------------------------------------------------*/ 8 | enum socket_opts 9 | { 10 | MTCP_NONBLOCK = 0x01, 11 | MTCP_ADDR_BIND = 0x02, 12 | }; 13 | /*----------------------------------------------------------------------------*/ 14 | struct socket_map 15 | { 16 | int id; 17 | int socktype; 18 | uint32_t opts; 19 | 20 | struct sockaddr_in saddr; 21 | 22 | union { 23 | struct tcp_stream *stream; 24 | struct tcp_listener *listener; 25 | struct mtcp_epoll *ep; 26 | struct pipe *pp; 27 | }; 28 | 29 | uint32_t epoll; /* registered events */ 30 | uint32_t events; /* available events */ 31 | mtcp_epoll_data_t ep_data; 32 | 33 | TAILQ_ENTRY (socket_map) free_smap_link; 34 | 35 | }; 36 | /*----------------------------------------------------------------------------*/ 37 | typedef struct socket_map * socket_map_t; 38 | /*----------------------------------------------------------------------------*/ 39 | socket_map_t 40 | AllocateSocket(mctx_t mctx, int socktype, int need_lock); 41 | /*----------------------------------------------------------------------------*/ 42 | void 43 | FreeSocket(mctx_t mctx, int sockid, int need_lock); 44 | /*----------------------------------------------------------------------------*/ 45 | socket_map_t 46 | GetSocket(mctx_t mctx, int sockid); 47 | /*----------------------------------------------------------------------------*/ 48 | struct tcp_listener 49 | { 50 | int sockid; 51 | socket_map_t socket; 52 | 53 | int backlog; 54 | stream_queue_t acceptq; 55 | 56 | pthread_mutex_t accept_lock; 57 | pthread_cond_t accept_cond; 58 | 59 | TAILQ_ENTRY(tcp_listener) he_link; /* hash table entry link */ 60 | }; 61 | /*----------------------------------------------------------------------------*/ 62 | 63 | #endif /* SOCKET_H */ 64 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/stat.h: -------------------------------------------------------------------------------- 1 | #ifndef STAT_H 2 | #define STAT_H 3 | 4 | struct run_stat 5 | { 6 | uint64_t rounds; 7 | uint64_t rounds_rx; 8 | uint64_t rounds_rx_try; 9 | uint64_t rounds_tx; 10 | uint64_t rounds_tx_try; 11 | uint64_t rounds_select; 12 | uint64_t rounds_select_rx; 13 | uint64_t rounds_select_tx; 14 | uint64_t rounds_select_intr; 15 | 16 | uint64_t rounds_accept; 17 | uint64_t rounds_read; 18 | uint64_t rounds_write; 19 | uint64_t rounds_epoll; 20 | uint64_t rounds_wndadv; 21 | 22 | uint64_t rounds_rtocheck; 23 | uint64_t rounds_twcheck; 24 | uint64_t rounds_tocheck; 25 | }; 26 | 27 | struct stat_counter 28 | { 29 | uint64_t cnt; 30 | uint64_t sum; 31 | uint64_t max; 32 | uint64_t min; 33 | }; 34 | 35 | struct time_stat 36 | { 37 | struct stat_counter round; 38 | struct stat_counter processing; 39 | struct stat_counter tcheck; 40 | struct stat_counter epoll; 41 | struct stat_counter handle; 42 | struct stat_counter xmit; 43 | struct stat_counter select; 44 | }; 45 | 46 | struct net_stat 47 | { 48 | uint64_t tx_packets[MAX_DEVICES]; 49 | uint64_t tx_bytes[MAX_DEVICES]; 50 | uint64_t tx_drops[MAX_DEVICES]; 51 | uint64_t rx_packets[MAX_DEVICES]; 52 | uint64_t rx_bytes[MAX_DEVICES]; 53 | uint64_t rx_errors[MAX_DEVICES]; 54 | #ifdef ENABLELRO 55 | uint64_t tx_gdptbytes; 56 | uint64_t rx_gdptbytes; 57 | #endif 58 | }; 59 | 60 | struct bcast_stat 61 | { 62 | uint64_t cycles; 63 | uint64_t write; 64 | uint64_t read; 65 | uint64_t epoll; 66 | uint64_t wnd_adv; 67 | uint64_t ack; 68 | }; 69 | 70 | struct timeout_stat 71 | { 72 | uint64_t cycles; 73 | uint64_t rto_try; 74 | uint64_t rto; 75 | uint64_t timewait_try; 76 | uint64_t timewait; 77 | }; 78 | 79 | #ifdef NETSTAT 80 | #define STAT_COUNT(stat) stat++ 81 | #else 82 | #define STAT_COUNT(stat) 83 | #endif 84 | 85 | #endif /* STAT_H */ 86 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/tcp_out.h: -------------------------------------------------------------------------------- 1 | #ifndef TCP_OUT_H 2 | #define TCP_OUT_H 3 | 4 | #include "mtcp.h" 5 | #include "tcp_stream.h" 6 | 7 | #define UNPACKING_SIZE 8192 8 | 9 | enum ack_opt 10 | { 11 | ACK_OPT_NOW, 12 | ACK_OPT_AGGREGATE, 13 | ACK_OPT_WACK 14 | }; 15 | 16 | int 17 | SendTCPPacketStandalone(struct mtcp_manager *mtcp, 18 | uint32_t saddr, uint16_t sport, uint32_t daddr, uint16_t dport, 19 | uint32_t seq, uint32_t ack_seq, uint16_t window, uint8_t flags, 20 | uint8_t *payload, uint16_t payloadlen, 21 | uint32_t cur_ts, uint32_t echo_ts); 22 | 23 | int 24 | SendTCPPacket(struct mtcp_manager *mtcp, tcp_stream *cur_stream, 25 | uint32_t cur_ts, uint8_t flags, uint8_t *payload, uint16_t payloadlen); 26 | 27 | extern inline int 28 | WriteTCPControlList(mtcp_manager_t mtcp, 29 | struct mtcp_sender *sender, uint32_t cur_ts, int thresh); 30 | 31 | extern inline int 32 | WriteTCPDataList(mtcp_manager_t mtcp, 33 | struct mtcp_sender *sender, uint32_t cur_ts, int thresh); 34 | 35 | extern inline int 36 | WriteTCPACKList(mtcp_manager_t mtcp, 37 | struct mtcp_sender *sender, uint32_t cur_ts, int thresh); 38 | 39 | extern inline void 40 | AddtoControlList(mtcp_manager_t mtcp, tcp_stream *cur_stream, uint32_t cur_ts); 41 | 42 | extern inline void 43 | AddtoSendList(mtcp_manager_t mtcp, tcp_stream *cur_stream); 44 | 45 | extern inline void 46 | RemoveFromControlList(mtcp_manager_t mtcp, tcp_stream *cur_stream); 47 | 48 | extern inline void 49 | RemoveFromSendList(mtcp_manager_t mtcp, tcp_stream *cur_stream); 50 | 51 | extern inline void 52 | RemoveFromACKList(mtcp_manager_t mtcp, tcp_stream *cur_stream); 53 | 54 | extern inline void 55 | EnqueueACK(mtcp_manager_t mtcp, 56 | tcp_stream *cur_stream, uint32_t cur_ts, uint8_t opt); 57 | 58 | extern inline void 59 | DumpControlList(mtcp_manager_t mtcp, struct mtcp_sender *sender); 60 | 61 | #endif /* TCP_OUT_H */ 62 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/tcp_rb_frag_queue.h: -------------------------------------------------------------------------------- 1 | #ifndef TCP_RB_FRAG_QUEUE 2 | #define TCP_RB_FRAG_QUEUE 3 | 4 | #include "tcp_ring_buffer.h" 5 | 6 | /*---------------------------------------------------------------------------*/ 7 | typedef struct rb_frag_queue* rb_frag_queue_t; 8 | /*---------------------------------------------------------------------------*/ 9 | rb_frag_queue_t 10 | CreateRBFragQueue(int capacity); 11 | /*---------------------------------------------------------------------------*/ 12 | void 13 | DestroyRBFragQueue(rb_frag_queue_t rb_fragq); 14 | /*---------------------------------------------------------------------------*/ 15 | int 16 | RBFragEnqueue(rb_frag_queue_t rb_fragq, struct fragment_ctx *frag); 17 | /*---------------------------------------------------------------------------*/ 18 | struct fragment_ctx * 19 | RBFragDequeue(rb_frag_queue_t rb_fragq); 20 | /*---------------------------------------------------------------------------*/ 21 | 22 | #endif /* TCP_RB_FRAG_QUEUE */ 23 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/tcp_ring_buffer.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * 2010.12.10 Shinae Woo 4 | * Ring buffer structure for managing dynamically allocating ring buffer 5 | * 6 | * put data to the tail 7 | * get/pop/remove data from the head 8 | * 9 | * always garantee physically continuous ready in-memory data from data_offset to the data_offset+len 10 | * automatically increase total buffer size when buffer is full 11 | * for efficiently managing packet payload and chunking 12 | * 13 | */ 14 | 15 | #ifndef NRE_RING_BUFFER 16 | #define NRE_RING_BUFFER 17 | 18 | #include 19 | #include 20 | 21 | /*----------------------------------------------------------------------------*/ 22 | enum rb_caller 23 | { 24 | AT_APP, 25 | AT_MTCP 26 | }; 27 | /*----------------------------------------------------------------------------*/ 28 | typedef struct mtcp_manager* mtcp_manager_t; 29 | typedef struct rb_manager* rb_manager_t; 30 | /*----------------------------------------------------------------------------*/ 31 | struct fragment_ctx 32 | { 33 | uint32_t seq; 34 | uint32_t len : 31; 35 | uint32_t is_calloc : 1; 36 | struct fragment_ctx *next; 37 | }; 38 | /*----------------------------------------------------------------------------*/ 39 | struct tcp_ring_buffer 40 | { 41 | u_char* data; /* buffered data */ 42 | u_char* head; /* pointer to the head */ 43 | 44 | uint32_t head_offset; /* offset for the head (head - data) */ 45 | uint32_t tail_offset; /* offset fot the last byte (null byte) */ 46 | 47 | int merged_len; /* contiguously merged length */ 48 | uint64_t cum_len; /* cummulatively merged length */ 49 | int last_len; /* currently saved data length */ 50 | int size; /* total ring buffer size */ 51 | 52 | /* TCP payload features */ 53 | uint32_t head_seq; 54 | uint32_t init_seq; 55 | 56 | struct fragment_ctx* fctx; 57 | }; 58 | /*----------------------------------------------------------------------------*/ 59 | uint32_t RBGetCurnum(rb_manager_t rbm); 60 | void RBPrintInfo(struct tcp_ring_buffer* buff); 61 | void RBPrintStr(struct tcp_ring_buffer* buff); 62 | void RBPrintHex(struct tcp_ring_buffer* buff); 63 | /*----------------------------------------------------------------------------*/ 64 | rb_manager_t RBManagerCreate(mtcp_manager_t mtcp, size_t chunk_size, uint32_t cnum); 65 | /*----------------------------------------------------------------------------*/ 66 | struct tcp_ring_buffer* RBInit(rb_manager_t rbm, uint32_t init_seq); 67 | void RBFree(rb_manager_t rbm, struct tcp_ring_buffer* buff); 68 | uint32_t RBIsDanger(rb_manager_t rbm); 69 | /*----------------------------------------------------------------------------*/ 70 | /* data manupulation functions */ 71 | int RBPut(rb_manager_t rbm, struct tcp_ring_buffer* buff, 72 | void* data, uint32_t len , uint32_t seq); 73 | size_t RBGet(rb_manager_t rbm, struct tcp_ring_buffer* buff, size_t len); 74 | size_t RBRemove(rb_manager_t rbm, struct tcp_ring_buffer* buff, 75 | size_t len, int option); 76 | /*----------------------------------------------------------------------------*/ 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/tcp_sb_queue.h: -------------------------------------------------------------------------------- 1 | #ifndef TCP_SB_QUEUE 2 | #define TCP_SB_QUEUE 3 | 4 | #include "tcp_send_buffer.h" 5 | 6 | /*---------------------------------------------------------------------------*/ 7 | typedef struct sb_queue* sb_queue_t; 8 | /*---------------------------------------------------------------------------*/ 9 | sb_queue_t 10 | CreateSBQueue(int capacity); 11 | /*---------------------------------------------------------------------------*/ 12 | void 13 | DestroySBQueue(sb_queue_t sq); 14 | /*---------------------------------------------------------------------------*/ 15 | int 16 | SBEnqueue(sb_queue_t sq, struct tcp_send_buffer *buf); 17 | /*---------------------------------------------------------------------------*/ 18 | struct tcp_send_buffer * 19 | SBDequeue(sb_queue_t sq); 20 | /*---------------------------------------------------------------------------*/ 21 | 22 | #endif /* TCP_SB_QUEUE */ 23 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/tcp_send_buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef TCP_SEND_BUFFER_H 2 | #define TCP_SEND_BUFFER_H 3 | 4 | #include 5 | #include 6 | 7 | /*----------------------------------------------------------------------------*/ 8 | typedef struct sb_manager* sb_manager_t; 9 | typedef struct mtcp_manager* mtcp_manager_t; 10 | /*----------------------------------------------------------------------------*/ 11 | struct tcp_send_buffer 12 | { 13 | unsigned char *data; 14 | unsigned char *head; 15 | 16 | uint32_t head_off; 17 | uint32_t tail_off; 18 | uint32_t len; 19 | uint64_t cum_len; 20 | uint32_t size; 21 | 22 | uint32_t head_seq; 23 | uint32_t init_seq; 24 | }; 25 | /*----------------------------------------------------------------------------*/ 26 | uint32_t 27 | SBGetCurnum(sb_manager_t sbm); 28 | /*----------------------------------------------------------------------------*/ 29 | sb_manager_t 30 | SBManagerCreate(mtcp_manager_t mtcp, size_t chunk_size, uint32_t cnum); 31 | /*----------------------------------------------------------------------------*/ 32 | struct tcp_send_buffer * 33 | SBInit(sb_manager_t sbm, uint32_t init_seq); 34 | /*----------------------------------------------------------------------------*/ 35 | void 36 | SBFree(sb_manager_t sbm, struct tcp_send_buffer *buf); 37 | /*----------------------------------------------------------------------------*/ 38 | size_t 39 | SBPut(sb_manager_t sbm, struct tcp_send_buffer *buf, const void *data, size_t len); 40 | /*----------------------------------------------------------------------------*/ 41 | size_t 42 | SBRemove(sb_manager_t sbm, struct tcp_send_buffer *buf, size_t len); 43 | /*----------------------------------------------------------------------------*/ 44 | 45 | #endif /* TCP_SEND_BUFFER_H */ 46 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/tcp_stream_queue.h: -------------------------------------------------------------------------------- 1 | #ifndef TCP_STREAM_QUEUE 2 | #define TCP_STREAM_QUEUE 3 | 4 | #include 5 | 6 | /* Lock definitions for stream queue */ 7 | #if LOCK_STREAM_QUEUE 8 | 9 | #if USE_SPIN_LOCK 10 | #define SQ_LOCK_INIT(lock, errmsg, action); \ 11 | if (pthread_spin_init(lock, PTHREAD_PROCESS_PRIVATE)) { \ 12 | perror("pthread_spin_init" errmsg); \ 13 | action; \ 14 | } 15 | #define SQ_LOCK_DESTROY(lock) pthread_spin_destroy(lock) 16 | #define SQ_LOCK(lock) pthread_spin_lock(lock) 17 | #define SQ_UNLOCK(lock) pthread_spin_unlock(lock) 18 | #else 19 | #define SQ_LOCK_INIT(lock, errmsg, action); \ 20 | if (pthread_mutex_init(lock, NULL)) { \ 21 | perror("pthread_mutex_init" errmsg); \ 22 | action; \ 23 | } 24 | #define SQ_LOCK_DESTROY(lock) pthread_mutex_destroy(lock) 25 | #define SQ_LOCK(lock) pthread_mutex_lock(lock) 26 | #define SQ_UNLOCK(lock) pthread_mutex_unlock(lock) 27 | #endif /* USE_SPIN_LOCK */ 28 | 29 | #else /* LOCK_STREAM_QUEUE */ 30 | #define SQ_LOCK_INIT(lock, errmsg, action) (void) 0 31 | #define SQ_LOCK_DESTROY(lock) (void) 0 32 | #define SQ_LOCK(lock) (void) 0 33 | #define SQ_UNLOCK(lock) (void) 0 34 | #endif /* LOCK_STREAM_QUEUE */ 35 | 36 | /*---------------------------------------------------------------------------*/ 37 | typedef struct stream_queue* stream_queue_t; 38 | /*---------------------------------------------------------------------------*/ 39 | typedef struct stream_queue_int 40 | { 41 | struct tcp_stream **array; 42 | int size; 43 | 44 | int first; 45 | int last; 46 | int count; 47 | 48 | } stream_queue_int; 49 | /*---------------------------------------------------------------------------*/ 50 | stream_queue_int * 51 | CreateInternalStreamQueue(int size); 52 | /*---------------------------------------------------------------------------*/ 53 | void 54 | DestroyInternalStreamQueue(stream_queue_int *sq); 55 | /*---------------------------------------------------------------------------*/ 56 | int 57 | StreamInternalEnqueue(stream_queue_int *sq, struct tcp_stream *stream); 58 | /*---------------------------------------------------------------------------*/ 59 | struct tcp_stream * 60 | StreamInternalDequeue(stream_queue_int *sq); 61 | /*---------------------------------------------------------------------------*/ 62 | stream_queue_t 63 | CreateStreamQueue(int size); 64 | /*---------------------------------------------------------------------------*/ 65 | void 66 | DestroyStreamQueue(stream_queue_t sq); 67 | /*---------------------------------------------------------------------------*/ 68 | int 69 | StreamEnqueue(stream_queue_t sq, struct tcp_stream *stream); 70 | /*---------------------------------------------------------------------------*/ 71 | struct tcp_stream * 72 | StreamDequeue(stream_queue_t sq); 73 | /*---------------------------------------------------------------------------*/ 74 | int 75 | StreamQueueIsEmpty(stream_queue_t sq); 76 | /*---------------------------------------------------------------------------*/ 77 | 78 | #endif /* TCP_STREAM_QUEUE */ 79 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/tcp_util.h: -------------------------------------------------------------------------------- 1 | #ifndef TCP_UTIL_H 2 | #define TCP_UTIL_H 3 | 4 | #include "mtcp.h" 5 | #include "tcp_stream.h" 6 | 7 | #define MSS 1448 8 | #define INIT_CWND_PKTS 10 9 | 10 | #define MAX(a, b) ((a)>(b)?(a):(b)) 11 | #define MIN(a, b) ((a)<(b)?(a):(b)) 12 | 13 | #define SECONDS_TO_USECS(seconds) ((seconds) / 1000000.0) 14 | #define USECS_TO_MS(us) ((us) / 1000) 15 | #define BYTES_TO_BITS(bytes) ((bytes) / 8.0) 16 | #define BPS_TO_MBPS(bps) ((bps) / 8000000.0) 17 | #define UNSHIFT_RTT(srtt) ((srtt) * 125.0) 18 | 19 | struct tcp_timestamp 20 | { 21 | uint32_t ts_val; 22 | uint32_t ts_ref; 23 | }; 24 | 25 | void ParseTCPOptions(tcp_stream *cur_stream, 26 | uint32_t cur_ts, uint8_t *tcpopt, int len); 27 | 28 | extern inline int 29 | ParseTCPTimestamp(tcp_stream *cur_stream, 30 | struct tcp_timestamp *ts, uint8_t *tcpopt, int len); 31 | 32 | #if TCP_OPT_SACK_ENABLED 33 | int 34 | SeqIsSacked(tcp_stream *cur_stream, uint32_t seq); 35 | 36 | void 37 | ParseSACKOption(tcp_stream *cur_stream, 38 | uint32_t ack_seq, uint8_t *tcpopt, int len); 39 | #endif 40 | 41 | uint16_t 42 | TCPCalcChecksum(uint16_t *buf, uint16_t len, uint32_t saddr, uint32_t daddr); 43 | 44 | void 45 | PrintTCPOptions(uint8_t *tcpopt, int len); 46 | 47 | #endif /* TCP_UTIL_H */ 48 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef TIMER_H 2 | #define TIMER_H 3 | 4 | #include "mtcp.h" 5 | #include "tcp_stream.h" 6 | 7 | #define RTO_HASH 3000 8 | 9 | struct rto_hashstore 10 | { 11 | uint32_t rto_now_idx; // pointing the hs_table_s index 12 | uint32_t rto_now_ts; // 13 | 14 | TAILQ_HEAD(rto_head , tcp_stream) rto_list[RTO_HASH+1]; 15 | }; 16 | 17 | struct rto_hashstore* 18 | InitRTOHashstore(); 19 | 20 | extern inline void 21 | AddtoRTOList(mtcp_manager_t mtcp, tcp_stream *cur_stream); 22 | 23 | extern inline void 24 | RemoveFromRTOList(mtcp_manager_t mtcp, tcp_stream *cur_stream); 25 | 26 | extern inline void 27 | AddtoTimewaitList(mtcp_manager_t mtcp, tcp_stream *cur_stream, uint32_t cur_ts); 28 | 29 | extern inline void 30 | RemoveFromTimewaitList(mtcp_manager_t mtcp, tcp_stream *cur_stream); 31 | 32 | extern inline void 33 | AddtoTimeoutList(mtcp_manager_t mtcp, tcp_stream *cur_stream); 34 | 35 | extern inline void 36 | RemoveFromTimeoutList(mtcp_manager_t mtcp, tcp_stream *cur_stream); 37 | 38 | extern inline void 39 | UpdateTimeoutList(mtcp_manager_t mtcp, tcp_stream *cur_stream); 40 | 41 | extern inline void 42 | UpdateRetransmissionTimer(mtcp_manager_t mtcp, 43 | tcp_stream *cur_stream, uint32_t cur_ts); 44 | 45 | void 46 | CheckRtmTimeout(mtcp_manager_t mtcp, uint32_t cur_ts, int thresh); 47 | 48 | void 49 | CheckTimewaitExpire(mtcp_manager_t mtcp, uint32_t cur_ts, int thresh); 50 | 51 | void 52 | CheckConnectionTimeout(mtcp_manager_t mtcp, uint32_t cur_ts, int thresh); 53 | 54 | #endif /* TIMER_H */ 55 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/include/virtqueue.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _VIRTQUEUE_H_ 3 | #define _VIRTQUEUE_H_ 4 | 5 | #include 6 | 7 | //#include 8 | //#include 9 | //#include 10 | //#include 11 | 12 | //#include "virtio.h" 13 | #include "virtio_ring.h" 14 | //#include "virtio_logs.h" 15 | //#include "virtio_rxtx.h" 16 | 17 | //#include "virtio_ring.h" 18 | struct virtqueue { 19 | struct vring ring; 20 | uint16_t vq_used_cons_idx; /**< last consumed descriptor */ 21 | uint16_t vq_nentries; /**< vring desc numbers */ 22 | uint16_t vq_free_cnt; /**< num of desc available */ 23 | uint16_t vq_avail_idx; /**< sync until needed */ 24 | uint16_t vq_free_thresh; /**< free threshold */ 25 | 26 | /** 27 | * Head of the free chain in the descriptor table. If 28 | * there are no free descriptors, this will be set to 29 | * VQ_RING_DESC_CHAIN_END. 30 | */ 31 | uint16_t vq_desc_head_idx; 32 | uint16_t vq_desc_tail_idx; 33 | uint16_t vq_queue_index; /**< PCI queue index */ 34 | 35 | void *vq_ring_virt_mem; /**< linear address of vring*/ 36 | unsigned int vq_ring_size; 37 | uint16_t mbuf_addr_offset; 38 | 39 | uint64_t vq_ring_mem; /* 40 | * or virtual address for virtio_user. */ 41 | 42 | uint16_t *notify_addr; 43 | struct rte_mbuf **sw_ring; /**< RX software ring. */ 44 | //struct vq_desc_extra vq_descx[0]; 45 | 46 | void *vq_desc_buf_virt_mem; /**< linear address of vring*/ 47 | uint16_t vhost_vq_used_cons_idx; /**< vhost last consumed descriptor */ 48 | int vhost_vq_used_cons_len; 49 | uint16_t vhost_vq_avail_idx; 50 | 51 | }; 52 | 53 | struct queue_context 54 | { 55 | // tx ctx 56 | int tx_queue_size; 57 | int tx_desc_buf_size; 58 | void* tx_virtqueue; 59 | 60 | // rx ctx 61 | int rx_queue_size; 62 | int rx_desc_buf_size; 63 | void* rx_virtqueue; 64 | 65 | // common context 66 | // int socket_id; 67 | //mctx_t mctx; 68 | 69 | volatile int stop_signal; 70 | }; 71 | 72 | struct virtqueue* init_virtqueue(int queue_size, int desc_buf_size); 73 | 74 | int deinit_virtqueue(void* ptr); 75 | 76 | int virtqueue_add_buf(char* p_data_send, int len, struct virtqueue * virtqueue); 77 | int virtqueue_add_buf2(char* p_data_send, int len, struct virtqueue * virtqueue); 78 | 79 | int virtqueue_get_buf(char** p_data_recv, int* len, struct virtqueue * virtqueue); 80 | 81 | int virtqueue_kick(struct virtqueue * virtqueue); 82 | 83 | int vhost_virtqueue_done(uint16_t idx, struct virtqueue * virtqueue); 84 | 85 | int vhost_get_req(char** p_data_recv, int* len, uint16_t* idx, struct virtqueue * virtqueue); 86 | 87 | int init_virtio(struct queue_context *pqctx); 88 | 89 | int deinit_virtio(struct queue_context *pqctx); 90 | 91 | #endif /* _VIRTQUEUE_H_ */ 92 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/ip_in.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "ip_in.h" 5 | #include "tcp_in.h" 6 | #include "mtcp_api.h" 7 | #include "ps.h" 8 | #include "debug.h" 9 | #include "icmp.h" 10 | 11 | #define ETH_P_IP_FRAG 0xF800 12 | #define ETH_P_IPV6_FRAG 0xF6DD 13 | 14 | /*----------------------------------------------------------------------------*/ 15 | inline int 16 | ProcessIPv4Packet(mtcp_manager_t mtcp, uint32_t cur_ts, 17 | const int ifidx, unsigned char* pkt_data, int len) 18 | { 19 | /* check and process IPv4 packets */ 20 | struct iphdr* iph = (struct iphdr *)(pkt_data + sizeof(struct ethhdr)); 21 | int ip_len = ntohs(iph->tot_len); 22 | int rc = -1; 23 | 24 | /* drop the packet shorter than ip header */ 25 | if (ip_len < sizeof(struct iphdr)) 26 | return ERROR; 27 | 28 | #ifndef DISABLE_HWCSUM 29 | if (mtcp->iom->dev_ioctl != NULL) 30 | rc = mtcp->iom->dev_ioctl(mtcp->ctx, ifidx, PKT_RX_IP_CSUM, iph); 31 | if (rc == -1 && ip_fast_csum(iph, iph->ihl)) 32 | return ERROR; 33 | #else 34 | UNUSED(rc); 35 | if (ip_fast_csum(iph, iph->ihl)) 36 | return ERROR; 37 | #endif 38 | 39 | #if !PROMISCUOUS_MODE 40 | /* if not promiscuous mode, drop if the destination is not myself */ 41 | if (iph->daddr != CONFIG.eths[ifidx].ip_addr) 42 | //DumpIPPacketToFile(stderr, iph, ip_len); 43 | return TRUE; 44 | #endif 45 | 46 | // see if the version is correct 47 | if (iph->version != 0x4 ) { 48 | mtcp->iom->release_pkt(mtcp->ctx, ifidx, pkt_data, len); 49 | return FALSE; 50 | } 51 | 52 | 53 | switch (iph->protocol) { 54 | case IPPROTO_TCP: 55 | return ProcessTCPPacket(mtcp, cur_ts, ifidx, iph, ip_len); 56 | case IPPROTO_ICMP: 57 | return ProcessICMPPacket(mtcp, iph, ip_len); 58 | default: 59 | /* currently drop other protocols */ 60 | return FALSE; 61 | } 62 | return FALSE; 63 | } 64 | /*----------------------------------------------------------------------------*/ 65 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/libccp/.gitignore: -------------------------------------------------------------------------------- 1 | **/*.d 2 | **/*.o 3 | libccp.so 4 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/libccp/.travis.yml: -------------------------------------------------------------------------------- 1 | language: rust 2 | rust: 3 | - nightly 4 | cache: cargo 5 | os: 6 | - linux 7 | - osx 8 | addons: 9 | apt: 10 | sources: 11 | - ubuntu-toolchain-r-test 12 | packages: 13 | - g++-6 14 | - llvm-dev 15 | - libclang-dev 16 | - clang 17 | 18 | matrix: 19 | # works on Precise and Trusty 20 | - os: linux 21 | env: 22 | - MATRIX_EVAL="CC=gcc-6 && CXX=g++-6" 23 | script: 24 | - make 25 | - python3 integration_test.py 26 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/libccp/BUILD.gn: -------------------------------------------------------------------------------- 1 | static_library("libccp") { 2 | sources = ["ccp.c", 3 | "machine.c", 4 | "serialize.c", 5 | "ccp_priv.c", 6 | ] 7 | cflags= ["-fPIC", 8 | "-Wall", 9 | "-Wextra", 10 | "-O2", 11 | "-g" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/libccp/Makefile: -------------------------------------------------------------------------------- 1 | #CC = ${CC} # C compiler 2 | DEBUG = n 3 | CFLAGS = -fPIC -Wall -Wextra -O2 -g # C flags 4 | CFLAGS += -std=gnu99 -Wno-declaration-after-statement -fgnu89-inline 5 | ifeq ($(DEBUG), y) 6 | CFLAGS += -D__DEBUG__ 7 | else 8 | endif 9 | RM = rm -f # rm command 10 | LIB_NAME = ccp 11 | TARGET_LIB = lib${LIB_NAME}.so # target lib 12 | 13 | TEST_TARGET = libccp-test 14 | SRCS = ccp.c machine.c serialize.c ccp_priv.c # source files 15 | OBJS = $(SRCS:.c=.o) 16 | 17 | TEST_SRCS = test.c 18 | TEST_OBJS = $(TEST_SRCS:.c=.o) 19 | 20 | .PHONY: all 21 | all: ${TARGET_LIB} test 22 | 23 | $(TARGET_LIB): $(OBJS) 24 | $(CC) -shared ${LDFLAGS} -o $@ $^ 25 | 26 | $(SRCS:.c=.d):%.d:%.c 27 | $(CC) $(CFLAGS) -MM $< >$@ 28 | 29 | -include $(SRCS:.c=.d) 30 | 31 | $(TEST_TARGET): ${TARGET_LIB} ${TEST_OBJS} 32 | $(CC) ${CFLAGS} -D__DEBUG__ ${TEST_SRCS} -L. ${LDFLAGS} -l${LIB_NAME} -o ${TEST_TARGET} 33 | 34 | test: $(TEST_TARGET) 35 | LD_LIBRARY_PATH=. ./libccp-test 36 | 37 | .PHONY: clean 38 | clean: 39 | -${RM} ${TARGET_LIB} ${OBJS} $(SRCS:.c=.d) ${TEST_TARGET} ${TEST_TARGET} 40 | -${RM} -r *.dSYM 41 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/libccp/ccp_priv.c: -------------------------------------------------------------------------------- 1 | #include "ccp_priv.h" 2 | 3 | #ifdef __KERNEL__ 4 | #include // kmalloc 5 | #include // memcpy,memset 6 | #else 7 | #include 8 | #include 9 | #endif 10 | 11 | extern struct ccp_datapath *datapath; 12 | 13 | int init_ccp_priv_state(struct ccp_connection *conn) { 14 | struct ccp_priv_state *state; 15 | conn->state = __CALLOC__(1, sizeof(struct ccp_priv_state)); 16 | state = (struct ccp_priv_state*) conn->state; 17 | 18 | state->sent_create = false; 19 | state->implicit_time_zero = datapath->time_zero; 20 | state->program_index = 0; 21 | state->staged_program_index = -1; 22 | return 0; 23 | } 24 | 25 | void free_ccp_priv_state(struct ccp_connection *conn) { 26 | struct ccp_priv_state *state = get_ccp_priv_state(conn); 27 | __FREE__(state); 28 | } 29 | 30 | __INLINE__ struct ccp_priv_state* get_ccp_priv_state(struct ccp_connection *conn) { 31 | return (struct ccp_priv_state*) conn->state; 32 | } 33 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/libccp/integration_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import subprocess 4 | 5 | curr_commit_cmd = "git rev-parse HEAD^@ | tail -n 1" 6 | clone_cmd = "git clone --recursive https://github.com/ccp-project/portus" 7 | checkout_libccp_commit = "cd ./portus/integration_tests/libccp_integration/libccp && git fetch && git checkout {}" 8 | run_integration_test = "cd ./portus && make libccp-integration" 9 | clean_cmd = "rm -rf portus" 10 | 11 | curr_commit = subprocess.check_output(curr_commit_cmd, shell=True).strip().decode('utf-8') 12 | print("libccp commit", curr_commit) 13 | print("===cloning portus===") 14 | subprocess.check_call(clone_cmd, shell=True) 15 | print("===checkout libccp commit===") 16 | subprocess.check_call(checkout_libccp_commit.format(curr_commit), shell=True) 17 | print("===run integration test===") 18 | subprocess.check_call(run_integration_test, shell=True) 19 | print("===clean up===") 20 | subprocess.check_call(clean_cmd, shell=True) 21 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/mtcp/src/socket.c: -------------------------------------------------------------------------------- 1 | #include "mtcp.h" 2 | #include "socket.h" 3 | #include "debug.h" 4 | 5 | /*---------------------------------------------------------------------------*/ 6 | socket_map_t 7 | AllocateSocket(mctx_t mctx, int socktype, int need_lock) 8 | { 9 | mtcp_manager_t mtcp = g_mtcp[mctx->cpu]; 10 | socket_map_t socket = NULL; 11 | 12 | if (need_lock) 13 | pthread_mutex_lock(&mtcp->ctx->smap_lock); 14 | 15 | while (socket == NULL) { 16 | socket = TAILQ_FIRST(&mtcp->free_smap); 17 | if (!socket) { 18 | if (need_lock) 19 | pthread_mutex_unlock(&mtcp->ctx->smap_lock); 20 | 21 | TRACE_ERROR("The concurrent sockets are at maximum.\n"); 22 | return NULL; 23 | } 24 | 25 | TAILQ_REMOVE(&mtcp->free_smap, socket, free_smap_link); 26 | 27 | /* if there is not invalidated events, insert the socket to the end */ 28 | /* and find another socket in the free smap list */ 29 | if (socket->events) { 30 | TRACE_INFO("There are still not invalidate events remaining.\n"); 31 | TRACE_DBG("There are still not invalidate events remaining.\n"); 32 | TAILQ_INSERT_TAIL(&mtcp->free_smap, socket, free_smap_link); 33 | socket = NULL; 34 | } 35 | } 36 | 37 | if (need_lock) 38 | pthread_mutex_unlock(&mtcp->ctx->smap_lock); 39 | 40 | socket->socktype = socktype; 41 | socket->opts = 0; 42 | socket->stream = NULL; 43 | socket->epoll = 0; 44 | socket->events = 0; 45 | 46 | /* 47 | * reset a few fields (needed for client socket) 48 | * addr = INADDR_ANY, port = INPORT_ANY 49 | */ 50 | memset(&socket->saddr, 0, sizeof(struct sockaddr_in)); 51 | memset(&socket->ep_data, 0, sizeof(mtcp_epoll_data_t)); 52 | 53 | return socket; 54 | } 55 | /*---------------------------------------------------------------------------*/ 56 | void 57 | FreeSocket(mctx_t mctx, int sockid, int need_lock) 58 | { 59 | mtcp_manager_t mtcp = g_mtcp[mctx->cpu]; 60 | socket_map_t socket = &mtcp->smap[sockid]; 61 | 62 | if (socket->socktype == MTCP_SOCK_UNUSED) { 63 | return; 64 | } 65 | 66 | socket->socktype = MTCP_SOCK_UNUSED; 67 | socket->epoll = MTCP_EPOLLNONE; 68 | socket->events = 0; 69 | 70 | if (need_lock) 71 | pthread_mutex_lock(&mtcp->ctx->smap_lock); 72 | 73 | /* insert into free stream map */ 74 | mtcp->smap[sockid].stream = NULL; 75 | TAILQ_INSERT_TAIL(&mtcp->free_smap, socket, free_smap_link); 76 | 77 | if (need_lock) 78 | pthread_mutex_unlock(&mtcp->ctx->smap_lock); 79 | } 80 | /*---------------------------------------------------------------------------*/ 81 | socket_map_t 82 | GetSocket(mctx_t mctx, int sockid) 83 | { 84 | if (sockid < 0 || sockid >= CONFIG.max_concurrency) { 85 | errno = EBADF; 86 | return NULL; 87 | } 88 | 89 | return &g_mtcp[mctx->cpu]->smap[sockid]; 90 | } 91 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/pre_compile.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | export RTE_SDK=`echo $PWD`/dpdk 3 | export RTE_TARGET=x86_64-native-linuxapp-gcc 4 | 5 | native_linuxapp_gcc_path=$RTE_SDK/x86_64-native-linuxapp-gcc 6 | current_pwd=`echo $PWD` 7 | # echo $native_linuxapp_gcc_path 8 | ./configure --with-dpdk-lib=$native_linuxapp_gcc_path CFLAGS=-DMAX_CPUS=152 9 | 10 | logger_h=`echo $PWD`/mtcp/src/include/logger.h 11 | n=12 12 | TMP="};" 13 | sed -i "$[ n ]c $TMP" $logger_h 14 | 15 | util_h=`echo $PWD`/util/include/netlib.h 16 | n=41 17 | TMP="};" 18 | sed -i "$[ n ]c $TMP" $util_h 19 | 20 | virtqueue_h=`echo $PWD`/mtcp/src/include/virtqueue.h 21 | n=39 22 | TMP="uint64_t vq_ring_mem; /*" 23 | sed -i "$[ n ]c $TMP" $virtqueue_h 24 | 25 | rm -rf apps/example/epping 26 | 27 | echo "start build dsa library..." 28 | dsa_so_dir=$PWD/../dsa_userlib/build/ 29 | echo $dsa_so_dir 30 | 31 | DSA_LIB_PATH=`find $dsa_so_dir -name "*.so"` 32 | echo $DSA_LIB_PATH 33 | if [ $DSA_LIB_PATH ];then 34 | echo "dsa user library already built" 35 | else 36 | mkdir $dsa_so_dir 37 | echo "start build dsa_userlib" 38 | cd $dsa_so_dir && cmake .. && make 39 | echo "start config dsa_userlib" 40 | #cd $dsa_so_dir/../config_dsa && ./setup_dsa.sh configs/4e1w-d.conf 41 | echo "dsa_userlib done" 42 | fi 43 | echo "done" 44 | cp $dsa_so_dir/lib/libvector_data_streaming.so $current_pwd/apps/example/ 45 | 46 | 47 | echo "prepare done" 48 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/pre_dpdk2203.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | 4 | #clone/build/install dpdk2203 5 | 6 | DPDK_INSTALL_DIR=$1 7 | DPDK_ID=${DPDK_INSTALL_DIR:-"~/dpdk_2203_install"} 8 | current_pwd=`pwd` 9 | 10 | if [ $# -eq 0 ]; then 11 | echo "Please input a directory to install DPDK v22.03" 12 | exit 0 13 | fi 14 | 15 | echo $DPDK_ID 16 | 17 | clone_and_build_dpdk() { 18 | git clone -b v22.03 http://dpdk.org/git/dpdk 19 | 20 | 21 | cd dpdk 22 | meson --prefix=${DPDK_ID} build 23 | ninja -C build 24 | meson install -C build 25 | ln -s build x86_64-native-linuxapp-gcc 26 | } 27 | 28 | if [ -d dpdk ]; then 29 | echo "there's already a dpdk dir here! check dpdk branch" 30 | cd dpdk 31 | Ver=`git branch -v | awk -F: '{print $2}'` 32 | if [ ! $Ver ]; then 33 | echo "not a dpdk repo, remove it and re-clone" 34 | rm -fr dpdk 35 | 36 | clone_and_build_dpdk 37 | else 38 | echo "$Ver" 39 | fi 40 | else 41 | clone_and_build_dpdk 42 | fi 43 | 44 | 45 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/setup_linux_env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | GREEN='\033[0;32m' 4 | NC='\033[0m' 5 | 6 | # Get to script directory 7 | cd $(dirname ${BASH_SOURCE[0]})/ 8 | 9 | # Remove dpdk_iface.ko module 10 | if [$# -ne 1]; 11 | then 12 | export RTE_SDK=$1 13 | else 14 | export RTE_SDK=$PWD/dpdk 15 | fi 16 | printf "${GREEN}Removing dpdk_iface module...\n $NC" 17 | if lsmod | grep dpdk_iface &> /dev/null ; then 18 | sudo rmmod dpdk_iface.ko 19 | else 20 | : 21 | fi 22 | 23 | # Compile dpdk and configure system 24 | if [ -f $RTE_SDK/usertools/dpdk-setup.sh ]; then 25 | bash $RTE_SDK/usertools/dpdk-setup.sh 26 | else 27 | bash $RTE_SDK/tools/setup.sh 28 | fi 29 | 30 | printf "${GREEN}Goodbye!$NC\n" 31 | 32 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/setup_mtcp_dpdk_env.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | GREEN='\033[0;32m' 4 | NC='\033[0m' 5 | 6 | # Get to script directory 7 | cd $(dirname ${BASH_SOURCE[0]})/ 8 | 9 | # First download dpdk 10 | if [ -z "$(ls -A $PWD/dpdk)" ]; then 11 | printf "${GREEN}Cloning dpdk...\n $NC" 12 | git submodule init 13 | git submodule update 14 | fi 15 | 16 | # Setup dpdk source for compilation 17 | if [ "$#" -ne 1 ]; 18 | then 19 | export RTE_SDK=$PWD/dpdk 20 | else 21 | export RTE_SDK=$1 22 | fi 23 | printf "${GREEN}Running dpdk_setup.sh...\n $NC" 24 | if grep "ldflags.txt" $RTE_SDK/mk/rte.app.mk > /dev/null 25 | then 26 | : 27 | else 28 | sed -i -e 's/O_TO_EXE_STR =/\$(shell if [ \! -d \${RTE_SDK}\/\${RTE_TARGET}\/lib ]\; then mkdir \${RTE_SDK}\/\${RTE_TARGET}\/lib\; fi)\nLINKER_FLAGS = \$(call linkerprefix,\$(LDLIBS))\n\$(shell echo \${LINKER_FLAGS} \> \${RTE_SDK}\/\${RTE_TARGET}\/lib\/ldflags\.txt)\nO_TO_EXE_STR =/g' $RTE_SDK/mk/rte.app.mk 29 | fi 30 | 31 | # Compile dpdk and configure system 32 | if [ -f $RTE_SDK/usertools/dpdk-setup.sh ]; then 33 | bash $RTE_SDK/usertools/dpdk-setup.sh 34 | else 35 | bash $RTE_SDK/tools/setup.sh 36 | fi 37 | 38 | # Print the user message 39 | cd $RTE_SDK 40 | CONFIG_NUM=1 41 | for cfg in config/defconfig_* ; do 42 | cfg=${cfg/config\/defconfig_/} 43 | if [ -d "$cfg" ]; then 44 | printf "Setting RTE_TARGET as $cfg\n" 45 | export RTE_TARGET=$cfg 46 | fi 47 | let "CONFIG_NUM+=1" 48 | done 49 | cd - 50 | printf "Set ${GREEN}RTE_SDK$NC env variable as $RTE_SDK\n" 51 | printf "Set ${GREEN}RTE_TARGET$NC env variable as $RTE_TARGET\n" 52 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/setup_mtcp_onvm_env.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | GREEN='\033[0;32m' 4 | NC='\033[0m' 5 | 6 | if [ -z "$RTE_SDK" ]; then 7 | echo "Please follow onvm install instructions to export \$RTE_SDK" 8 | exit 1 9 | fi 10 | 11 | if [ -z "$RTE_TARGET" ]; then 12 | echo "Please follow onvm install instructions to export \$RTE_TARGET" 13 | exit 1 14 | fi 15 | 16 | # Get to script directory 17 | cd $(dirname ${BASH_SOURCE[0]})/ 18 | 19 | printf "${GREEN}Checking ldflags.txt...\n$NC" 20 | if [ ! -f $RTE_SDK/$RTE_TARGET/lib/ldflags.txt ]; then 21 | echo "File $RTE_SDK/$RTE_TARGET/lib/ldflags.txt does not exist, please reinstall dpdk." 22 | sed -i -e 's/O_TO_EXE_STR =/\$(shell if [ \! -d \${RTE_SDK}\/\${RTE_TARGET}\/lib ]\; then mkdir \${RTE_SDK}\/\${RTE_TARGET}\/lib\; fi)\nLINKER_FLAGS = \$(call linkerprefix,\$(LDLIBS))\n\$(shell echo \${LINKER_FLAGS} \> \${RTE_SDK}\/\${RTE_TARGET}\/lib\/ldflags\.txt)\nO_TO_EXE_STR =/g' $RTE_SDK/mk/rte.app.mk 23 | exit 1 24 | fi 25 | 26 | printf "${GREEN}RTE_SDK$NC env variable is set to $RTE_SDK\n" 27 | printf "${GREEN}RTE_TARGET$NC env variable is set to $RTE_TARGET\n" 28 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/stamp-h1: -------------------------------------------------------------------------------- 1 | timestamp for config.h 2 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/util/Makefile: -------------------------------------------------------------------------------- 1 | ### GCC ### 2 | GCC=gcc 3 | 4 | ifeq ($(shell uname -m),x86_64) 5 | GCC_OPT = -m64 6 | else 7 | GCC_OPT = 8 | endif 9 | GCC_OPT += -Wall -fPIC -c 10 | GCC_OPT += -DNDEBUG -O3 -DNETSTAT -DINFO -DDBGERR -DDBGCERR 11 | 12 | 13 | ### LIBRARIES AND INCLUDES ### 14 | CFLAGS = -I./include/ 15 | 16 | ### SOURCE CODE ### 17 | SRCS = tdate_parse.c http_parsing.c netlib.c 18 | 19 | OBJS = $(patsubst %.c,%.o,$(SRCS)) 20 | 21 | ifeq ($V,) # no echo 22 | export MSG=@echo 23 | export HIDE=@ 24 | else 25 | export MSG=@\# 26 | export HIDE= 27 | endif 28 | 29 | ### COMPILE ### 30 | all: default 31 | 32 | default: $(OBJS) 33 | 34 | $(OBJS): %.o: %.c Makefile 35 | $(MSG) " CC $<" 36 | $(HIDE) ${CC} ${GCC_OPT} ${CFLAGS} $< 37 | 38 | clean: 39 | $(MSG) " CC *.o" 40 | $(HIDE) rm -rf *~ *.o 41 | 42 | distclean: clean 43 | rm -f Makefile 44 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/util/Makefile.in: -------------------------------------------------------------------------------- 1 | ### GCC ### 2 | GCC=@CC@ 3 | 4 | ifeq ($(shell uname -m),x86_64) 5 | GCC_OPT = -m64 6 | else 7 | GCC_OPT = 8 | endif 9 | GCC_OPT += -Wall -fPIC -c 10 | GCC_OPT += -DNDEBUG -O3 -DNETSTAT -DINFO -DDBGERR -DDBGCERR 11 | 12 | 13 | ### LIBRARIES AND INCLUDES ### 14 | CFLAGS = -I./include/ 15 | 16 | ### SOURCE CODE ### 17 | SRCS = tdate_parse.c http_parsing.c netlib.c 18 | 19 | OBJS = $(patsubst %.c,%.o,$(SRCS)) 20 | 21 | ifeq ($V,) # no echo 22 | export MSG=@echo 23 | export HIDE=@ 24 | else 25 | export MSG=@\# 26 | export HIDE= 27 | endif 28 | 29 | ### COMPILE ### 30 | all: default 31 | 32 | default: $(OBJS) 33 | 34 | $(OBJS): %.o: %.c Makefile 35 | $(MSG) " CC $<" 36 | $(HIDE) ${CC} ${GCC_OPT} ${CFLAGS} $< 37 | 38 | clean: 39 | $(MSG) " CC *.o" 40 | $(HIDE) rm -rf *~ *.o 41 | 42 | distclean: clean 43 | rm -f Makefile 44 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/util/cpu.c: -------------------------------------------------------------------------------- 1 | #ifndef _GNU_SOURCE 2 | #define _GNU_SOURCE 3 | #endif 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /*----------------------------------------------------------------------------*/ 13 | int GetNumCPUs() 14 | { 15 | return sysconf(_SC_NPROCESSORS_ONLN); 16 | } 17 | /*----------------------------------------------------------------------------*/ 18 | int 19 | CoreAffinitize(int cpu) 20 | { 21 | cpu_set_t *cmask; 22 | struct bitmask *bmask; 23 | size_t n; 24 | int ret; 25 | 26 | n = GetNumCPUs(); 27 | 28 | if (cpu < 0 || cpu >= (int) n) { 29 | errno = -EINVAL; 30 | return -1; 31 | } 32 | 33 | cmask = CPU_ALLOC(n); 34 | if (cmask == NULL) 35 | return -1; 36 | 37 | CPU_ZERO_S(n, cmask); 38 | CPU_SET_S(cpu, n, cmask); 39 | 40 | ret = sched_setaffinity(0, n, cmask); 41 | 42 | CPU_FREE(cmask); 43 | 44 | if (numa_max_node() == 0) 45 | return ret; 46 | 47 | bmask = numa_bitmask_alloc(16); 48 | assert(bmask); 49 | 50 | numa_bitmask_setbit(bmask, cpu %2); 51 | numa_set_membind(bmask); 52 | numa_bitmask_free(bmask); 53 | 54 | return ret; 55 | } 56 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/util/include/cpu.h: -------------------------------------------------------------------------------- 1 | #ifndef __CPU_H_ 2 | #define __CPU_H_ 3 | 4 | int GetNumCPUs(); 5 | int CoreAffinitize(int cpu); 6 | 7 | #endif /* __CPU_H_ */ 8 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/util/include/debug.h: -------------------------------------------------------------------------------- 1 | #ifndef __DEBUG_H_ 2 | #define __DEBUG_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define TRACE_CONFIG(f, m...) fprintf(stdout, f, ##m) 9 | 10 | #ifdef DBGERR 11 | 12 | #define TRACE_ERROR(f, m...) { \ 13 | fprintf(stdout, "[%10s:%4d] " f, __FUNCTION__, __LINE__, ##m); \ 14 | } 15 | 16 | #else 17 | 18 | #define TRACE_ERROR(f, m...) (void)0 19 | 20 | #endif /* DBGERR */ 21 | 22 | #ifdef DBGMSG 23 | 24 | #define TRACE_DBG(f, m...) {\ 25 | fprintf(stderr, "[%10s:%4d] " \ 26 | f, __FUNCTION__, __LINE__, ##m); \ 27 | } 28 | 29 | #else 30 | 31 | #define TRACE_DBG(f, m...) (void)0 32 | 33 | #endif /* DBGMSG */ 34 | 35 | #ifdef INFO 36 | 37 | #define TRACE_INFO(f, m...) { \ 38 | fprintf(stdout, "[%10s:%4d] " f,__FUNCTION__, __LINE__, ##m); \ 39 | } 40 | 41 | #else 42 | 43 | #define TRACE_INFO(f, m...) (void)0 44 | 45 | #endif /* INFO */ 46 | 47 | #ifdef EPOLL 48 | #define TRACE_EPOLL(f, m...) TRACE_FUNC("EPOLL", f, ##m) 49 | #else 50 | #define TRACE_EPOLL(f, m...) (void)0 51 | #endif 52 | 53 | #ifdef APP 54 | #define TRACE_APP(f, m...) TRACE_FUNC("APP", f, ##m) 55 | #else 56 | #define TRACE_APP(f, m...) (void)0 57 | #endif 58 | 59 | #ifdef DBGFUNC 60 | 61 | #define TRACE_FUNC(n, f, m...) { \ 62 | fprintf(stderr, "%6s: %10s:%4d] " \ 63 | f, n, __FUNCTION__, __LINE__, ##m); \ 64 | } 65 | 66 | #else 67 | 68 | #define TRACE_FUNC(f, m...) (void)0 69 | 70 | #endif /* DBGFUNC */ 71 | 72 | #endif /* __DEBUG_H_ */ 73 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/util/include/http_parsing.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __NRE_HTTP_PARSING 3 | #define __NRE_HTTP_PARSING 4 | 5 | #define HTTP_STR "HTTP" 6 | #define HTTPV0_STR "HTTP/1.0" 7 | #define HTTPV1_STR "HTTP/1.1" 8 | #define HTTP_GET "GET" 9 | #define HTTP_POST "POST" 10 | #define HTTP_CLOSE "Close" 11 | #define HTTP_KEEP_ALIVE "Keep-Alive" 12 | #define HOST_HDR "\nHost:" 13 | #define CONTENT_LENGTH_HDR "\nContent-Length:" 14 | #define CONTENT_TYPE_HDR "\nContent-Type:" 15 | #define CACHE_CONTROL_HDR "\nCache-Control:" 16 | #define CONNECTION_HDR "\nConnection:" 17 | #define DATE_HDR "\nDate:" 18 | #define EXPIRES_HDR "\nExpires:" 19 | #define AGE_HDR "\nAge:" 20 | #define LAST_MODIFIED_HDR "\nLast-Modified:" 21 | #define IF_MODIFIED_SINCE_HDR "\nIf-Modified_Since:" 22 | #define PRAGMA_HDR "\nPragma:" 23 | #define RANGE_HDR "\nRange:" 24 | #define IF_RANGE_HDR "\nIf-Range:" 25 | #define ETAG_HDR "\nETag:" 26 | 27 | enum { 28 | GET = 1, 29 | POST 30 | }; 31 | 32 | int find_http_header(char *data, int len); 33 | int is_http_response(char *data, int len); 34 | int is_http_request(char *data, int len); 35 | 36 | char* http_header_str_val(const char* buf, const char *key, const int key_len, char* value, int value_len); 37 | long int http_header_long_val(const char* buf, const char *key, int key_len); 38 | 39 | char* http_get_http_version_resp(char* data, int len, char* value, int value_len); 40 | char* http_get_url(char * data, int data_len, char* value, int value_len); 41 | int http_get_status_code(void *response); 42 | int http_get_maxage(char *cache_ctl, int len); 43 | 44 | time_t http_header_date(const char* data, const char* field, int len); 45 | 46 | enum {HTTP_09, HTTP_10, HTTP_11}; /* http version */ 47 | int http_parse_first_resp_line(const char* data, int len, int* scode, int* ver); 48 | int http_check_header_field(const char* data, const char* field); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/util/include/netlib.h: -------------------------------------------------------------------------------- 1 | #ifndef _NET_LIB_H_ 2 | #define _NET_LIB_H_ 3 | 4 | #include 5 | 6 | #ifndef TRUE 7 | #define TRUE 1 8 | #endif 9 | 10 | #ifndef FALSE 11 | #define FALSE 0 12 | #endif 13 | 14 | #ifndef MAX 15 | #define MAX(x, y) ((x) > (y) ? (x) : (y)) 16 | #endif 17 | 18 | #ifndef MIN 19 | #define MIN(x, y) ((x) < (y) ? (x) : (y)) 20 | #endif 21 | 22 | #ifndef VERIFY 23 | #define VERIFY(x) if (!(x)) {fprintf(stderr, "error: FILE:%s LINE:%d FUNC: %s", __FILE__, __LINE__, __FUNCTION__); assert(0);} 24 | #endif 25 | 26 | #ifndef FREE 27 | #define FREE(x) if (x) {free(x); (x) = NULL;} 28 | #endif 29 | 30 | int GetNumCPUCores(void); 31 | int AffinitizeThreadToCore(int core); 32 | int CreateServerSocket(int port, int isNonBlocking); 33 | int CreateConnectionSocket(in_addr_t addr, int port, int isNonBlocking); 34 | int mystrtol(const char *nptr, int base); 35 | 36 | /* processing options */ 37 | struct Options { 38 | char *op_name; 39 | char **op_varptr; 40 | char *op_comment; 41 | }; 42 | void ParseOptions(int argc, const char** argv, struct Options* ops); 43 | void PrintOptions(const struct Options* ops, int printVal); 44 | 45 | 46 | /* HTTP header processing */ 47 | char *GetHeaderString(const char *buf, const char* header, int hdrsize); 48 | int GetHeaderLong(const char* buf, const char* header, int hdrsize, long int *val); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/util/include/ring_buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef __APP_RELAYBUFFER 2 | #define __APP_RELAYBUFFER 3 | 4 | #include 5 | 6 | #define MAX_REP_LEN (10*1024) 7 | 8 | typedef struct ring_buffer ring_buffer; 9 | 10 | ring_buffer* InitBuffer(int size); 11 | 12 | int GetTotSizeRBuffer(ring_buffer* r_buff); 13 | int GetDataSizeRBuffer(ring_buffer* r_buff); 14 | int GetCumSizeRBuffer(ring_buffer* r_buff); 15 | int GetRemainBufferSize(ring_buffer *r_buff); 16 | int CheckAvailableSize(ring_buffer *r_buff, int size); 17 | 18 | u_char* GetDataPoint(ring_buffer* r_buff); 19 | u_char* GetInputPoint(ring_buffer *r_buff); 20 | 21 | int RemoveDataFromBuffer(ring_buffer *r_buff, int size); 22 | int AddDataLen(ring_buffer *r_buffer, int size); 23 | 24 | int CopyData(ring_buffer *dest_buff, ring_buffer *src_buff, int len); 25 | int MoveData(ring_buffer *dest_buff, ring_buffer *src_buff, int len); 26 | int MoveToREPData(ring_buffer *dest_buff, ring_buffer *src_buff, int len); 27 | 28 | int MtcpWriteFromBuffer(mctx_t mtcp, int fid, ring_buffer *r_buff); 29 | int MtcpReadFromBuffer(mctx_t mtcp, int fid, ring_buffer *r_buff); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/util/include/rss.h: -------------------------------------------------------------------------------- 1 | #ifndef _RSS_H_ 2 | #define _RSS_H_ 3 | 4 | #include 5 | 6 | /* return RSS hash value (32 bit) based on 4 tuple values */ 7 | uint32_t GetRSSHash(in_addr_t sip, in_addr_t dip, 8 | in_port_t sp, in_port_t dp); 9 | 10 | /* sip, dip, sp, dp: host-byte order */ 11 | int GetRSSCPUCore(in_addr_t sip, in_addr_t dip, 12 | in_port_t sp, in_port_t dp, int num_cpus); 13 | #endif 14 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/util/include/tdate_parse.h: -------------------------------------------------------------------------------- 1 | /* tdate_parse.h - parse string dates into internal form, stripped-down version 2 | ** 3 | ** Copyright (C) 1995 by Jef Poskanzer . All rights reserved. 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 | ** 1. Redistributions of source code must retain the above copyright 9 | ** notice, this list of conditions and the following disclaimer. 10 | ** 2. Redistributions in binary form must reproduce the above copyright 11 | ** notice, this list of conditions and the following disclaimer in the 12 | ** documentation and/or other materials provided with the distribution. 13 | ** 14 | ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 | ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | ** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | ** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | ** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | ** SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef _TDATE_PARSE_H_ 28 | #define _TDATE_PARSE_H_ 29 | 30 | /* convert a http date string to time_t format */ 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | # endif 35 | extern time_t httpdate_to_timet( const char* str ); 36 | 37 | 38 | /* 39 | Convert 't' (in time_t format) into a HTTP date string 40 | 41 | 42 | t: input (epoch-based time) 43 | str: output string that holds the HTTP date strinng 44 | strlen: the buffer size of str 45 | 46 | 0 : in case of successful conversion 47 | -1 : otherwise 48 | by KyoungSoo Park 49 | */ 50 | extern int timet_to_httpdate(time_t t, char* str, int strlen); 51 | 52 | #ifdef __cplusplus 53 | } 54 | # endif 55 | #endif /* _TDATE_PARSE_H_ */ 56 | -------------------------------------------------------------------------------- /DSAZoo/example_mtcp/ww-set-hp.sh: -------------------------------------------------------------------------------- 1 | HUGEPGSZ=`cat /proc/meminfo | grep Hugepagesize | cut -d : -f 2 | tr -d ' '` 2 | 3 | 4 | sudo mkdir -p /mnt/huge 5 | mount -t hugetlbfs nodev /mnt/huge 6 | echo 1024 > /sys/devices/system/node/node0/hugepages/hugepages-${HUGEPGSZ}/nr_hugepages 7 | echo 1024 > /sys/devices/system/node/node1/hugepages/hugepages-${HUGEPGSZ}/nr_hugepages 8 | -------------------------------------------------------------------------------- /DSAZoo/kernel_build_and_iax_enable_v1.0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/accelerator-solution-zoo/36b95b6854aa43f2da6b07cc70bf703fe4ef0669/DSAZoo/kernel_build_and_iax_enable_v1.0.pdf -------------------------------------------------------------------------------- /IAAZoo/Arrow_Parquet_Reader_with_IAA/img/IAA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/accelerator-solution-zoo/36b95b6854aa43f2da6b07cc70bf703fe4ef0669/IAAZoo/Arrow_Parquet_Reader_with_IAA/img/IAA.png -------------------------------------------------------------------------------- /IAAZoo/Arrow_Parquet_Reader_with_IAA/img/NoIAA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/accelerator-solution-zoo/36b95b6854aa43f2da6b07cc70bf703fe4ef0669/IAAZoo/Arrow_Parquet_Reader_with_IAA/img/NoIAA.png -------------------------------------------------------------------------------- /IAAZoo/Arrow_Parquet_Reader_with_IAA/img/RleDeocder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/accelerator-solution-zoo/36b95b6854aa43f2da6b07cc70bf703fe4ef0669/IAAZoo/Arrow_Parquet_Reader_with_IAA/img/RleDeocder.png -------------------------------------------------------------------------------- /IAAZoo/README.md: -------------------------------------------------------------------------------- 1 | # Intel IAA Zoo 2 | 3 | -------------------------------------------------------------------------------- /Intel-Sapphire-Rapids-accelerators.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/accelerator-solution-zoo/36b95b6854aa43f2da6b07cc70bf703fe4ef0669/Intel-Sapphire-Rapids-accelerators.jpg -------------------------------------------------------------------------------- /QATZoo/README.md: -------------------------------------------------------------------------------- 1 | # Intel QAT Zoo 2 | 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PROJECT NOT UNDER ACTIVE MANAGEMENT 2 | 3 | This project will no longer be maintained by Intel. 4 | 5 | Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project. 6 | 7 | Intel no longer accepts patches to this project. 8 | 9 | If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the open source software community, please create your own fork of this project. 10 | 11 | Contact: webadmin@linux.intel.com 12 | # Intel® Vector Data Streaming Library 13 | ![](intel-accelerator-zoo.jpeg) 14 | Intel Vector Data Streaming Library is a zoo of solutions based on accelerators in the die of Intel 4th Xeon Scalable processor,code-named [“Sapphire Rapids”](https://www.intel.com/content/www/us/en/newsroom/opinion/updates-next-gen-data-center-platform-sapphire-rapids.html?wapkw=Intel%20Sapphire%20Rapids%20Demos%20At%20Innovation%202022#gs.g4fsrh). Intel provide a boundle of powerful accelerators for different scenarios as below table. 15 | 16 | 17 | |Built-in Accelerator | Key Function | Accelerator Zoo | Solutions | Business Value | 18 | |:------------------------------------|:------------------------------------------- |:----------------|:----------------------------|:--------------------------------------| 19 | |Intel Data streaming accelerator(DSA)| Data copy and transformation accaleration |DSAZoo |User space network stack acceleration with DSA| improve efficiency for data transmission| 20 | |Intel In-memory Analytics(IAA) | Data compression/decompression acceleration |IAAZoo |Arrow parquet reader acceleration with IAA | Improve data access efficiency | 21 | |Intel QuickAssist Technology(QAT) | Compression/decompression/Crypto acceleraion|QATZoo | | | 22 | |Intel Dynamic Load Balance(DLB) | Improves performance related to handling network data|DLBZoo | | | 23 | 24 | Picture for referencing(To be updated, need source material input): 25 | ![](Intel-Sapphire-Rapids-accelerators.jpg) 26 | 27 | To expound how to utilize each powerful accelerator, we provide reference solutions. 28 | # Solution List 29 | - DSA 30 | User space network acceleration with DSA. 31 | - IAA 32 | - DLB 33 | - QAT 34 | -------------------------------------------------------------------------------- /benchmark_guide_for_PoC.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/accelerator-solution-zoo/36b95b6854aa43f2da6b07cc70bf703fe4ef0669/benchmark_guide_for_PoC.pdf -------------------------------------------------------------------------------- /intel-accelerator-zoo.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/accelerator-solution-zoo/36b95b6854aa43f2da6b07cc70bf703fe4ef0669/intel-accelerator-zoo.jpeg -------------------------------------------------------------------------------- /kernel_build_and_iax_enable_v1.0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/accelerator-solution-zoo/36b95b6854aa43f2da6b07cc70bf703fe4ef0669/kernel_build_and_iax_enable_v1.0.pdf --------------------------------------------------------------------------------