├── .gitattributes ├── .gitignore ├── .gitlab ├── issue_templates │ ├── bug-report.md │ └── feature.md └── merge_request_templates │ └── CONTRIBUTING.md ├── .gitmodules ├── KRdmaKit-syscall ├── Cargo.toml ├── Kbuild ├── Kbuild-DC ├── Kbuild-RC ├── Kbuild-hybrid ├── Kbuild-lite ├── Kbuild-meta-client ├── Kbuild-meta-rpc ├── Kbuild-meta-server ├── Makefile ├── build.rs ├── rust-toolchain.toml ├── src │ ├── bindings.rs │ ├── client.rs │ ├── consts.rs │ ├── core.rs │ ├── lib.rs │ ├── mem │ │ └── mod.rs │ ├── native │ │ ├── kernel_helper.c │ │ └── kernel_helper.h │ ├── rpc │ │ ├── mod.rs │ │ └── protocol.rs │ └── virtual_queue.rs ├── tests │ ├── CMakeLists.txt │ ├── test_bind.cc │ ├── test_connect.cc │ ├── test_nil.cc │ ├── test_poll_rpc.cc │ ├── test_rc.cc │ ├── test_reg_mr.cc │ └── test_two_sided_rc.cc └── two-sided-dc │ ├── KRdmaKit-syscall │ ├── Cargo.toml │ ├── Kbuild │ ├── Makefile │ ├── build.rs │ ├── src │ │ ├── bindings.rs │ │ ├── client.rs │ │ ├── core.rs │ │ ├── lib.rs │ │ └── virtual_queue.rs │ └── tests │ │ ├── CMakeLists.txt │ │ ├── test_bind.cc │ │ ├── test_connect.cc │ │ ├── test_nil.cc │ │ ├── test_rc.cc │ │ └── test_two_sided_rc.cc │ ├── KRdmaKit │ ├── Cargo.toml │ ├── src │ │ ├── cm │ │ │ ├── client.rs │ │ │ ├── mod.rs │ │ │ └── sidr.rs │ │ ├── consts.rs │ │ ├── ctrl.rs │ │ ├── device.rs │ │ ├── ib_path_explorer.rs │ │ ├── lib.rs │ │ ├── mem │ │ │ ├── mod.rs │ │ │ ├── phy.rs │ │ │ └── virt.rs │ │ ├── net_util.rs │ │ ├── qp │ │ │ ├── conn.rs │ │ │ ├── dc.rs │ │ │ ├── dc_op.rs │ │ │ ├── doorbell.rs │ │ │ ├── mod.rs │ │ │ ├── rc.rs │ │ │ ├── rc_op.rs │ │ │ ├── recv_helper.rs │ │ │ ├── statistics.rs │ │ │ ├── ud.rs │ │ │ └── ud_op.rs │ │ ├── random.rs │ │ └── thread_local.rs │ └── unitests │ │ ├── Kbuild │ │ ├── Makefile │ │ ├── dct │ │ ├── Cargo.toml │ │ ├── src │ │ │ ├── console_msgs.rs │ │ │ └── lib.rs │ │ └── tests │ │ │ └── test.rs │ │ ├── device │ │ ├── Cargo.toml │ │ ├── src │ │ │ ├── console_msgs.rs │ │ │ └── lib.rs │ │ └── tests │ │ │ └── test.rs │ │ ├── qp │ │ ├── Cargo.toml │ │ ├── src │ │ │ ├── console_msgs.rs │ │ │ └── lib.rs │ │ └── tests │ │ │ └── test.rs │ │ ├── qp_state │ │ ├── Cargo.toml │ │ ├── src │ │ │ ├── console_msgs.rs │ │ │ └── lib.rs │ │ └── tests │ │ │ └── test.rs │ │ ├── reg_mr │ │ ├── Cargo.toml │ │ ├── src │ │ │ ├── console_msgs.rs │ │ │ └── lib.rs │ │ └── tests │ │ │ └── test.rs │ │ ├── rpc │ │ ├── Cargo.toml │ │ ├── src │ │ │ ├── console_msgs.rs │ │ │ └── lib.rs │ │ └── tests │ │ │ └── test.rs │ │ └── run_tests.py │ ├── deps │ ├── no-std-net │ │ ├── Cargo.toml │ │ ├── LICENSE │ │ ├── README.md │ │ └── src │ │ │ ├── addr.rs │ │ │ ├── de.rs │ │ │ ├── ip.rs │ │ │ ├── lib.rs │ │ │ ├── parser.rs │ │ │ └── ser.rs │ └── rust-kernel-module │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── CODE_OF_CONDUCT.md │ │ ├── CONTRIBUTING.md │ │ ├── Cargo.toml │ │ ├── LICENSE │ │ ├── NOTES.md │ │ ├── README.md │ │ ├── build.rs │ │ ├── hello-world │ │ ├── Cargo.toml │ │ ├── Kbuild │ │ ├── Makefile │ │ └── src │ │ │ └── lib.rs │ │ ├── scripts │ │ └── copy_wxd.sh │ │ ├── src │ │ ├── allocator.rs │ │ ├── bindings.rs │ │ ├── bindings_helper.h │ │ ├── c_types.rs │ │ ├── chrdev.rs │ │ ├── error.rs │ │ ├── file_operations.rs │ │ ├── filesystem.rs │ │ ├── helpers.c │ │ ├── inline_helper.h │ │ ├── lib.rs │ │ ├── mutex.rs │ │ ├── printk.rs │ │ ├── random.rs │ │ ├── sync.rs │ │ ├── sysctl.rs │ │ ├── types.rs │ │ └── user_ptr.rs │ │ ├── testlib │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ │ └── tests │ │ ├── Kbuild │ │ ├── Makefile │ │ ├── chrdev-region-allocation │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── tests.rs │ │ ├── chrdev │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── tests.rs │ │ ├── filesystem │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── tests.rs │ │ ├── modinfo │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── tests.rs │ │ ├── printk │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── tests.rs │ │ ├── random │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── tests.rs │ │ ├── run_tests.py │ │ ├── sysctl-get │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── tests.rs │ │ ├── sysctl │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── tests.rs │ │ └── utils │ │ ├── Cargo.toml │ │ ├── src │ │ └── lib.rs │ │ └── tests │ │ └── tests.rs │ ├── include │ ├── common.h │ └── syscall.h │ ├── rust-kernel-linux-util │ ├── Cargo.toml │ ├── README.md │ ├── build.rs │ ├── src │ │ ├── bindings.rs │ │ ├── lib.rs │ │ ├── native │ │ │ ├── kernel_helper.c │ │ │ └── kernel_helper.h │ │ ├── rwlock.rs │ │ └── timer.rs │ └── unitests │ │ ├── Kbuild │ │ ├── Makefile │ │ ├── run_tests.py │ │ └── sample │ │ ├── Cargo.toml │ │ ├── src │ │ └── lib.rs │ │ └── tests │ │ └── test.rs │ └── rust-kernel-rdma-base │ ├── Cargo.toml │ ├── README.md │ ├── build.rs │ ├── src │ ├── allocator.rs │ ├── bindings.rs │ ├── consts.rs │ ├── funcs.rs │ ├── lib.rs │ ├── native │ │ ├── kernel_helper.c │ │ └── kernel_helper.h │ ├── ofed_4_4_2_0_7_0.rs │ ├── ofed_4_9_3_1_5_0.rs │ ├── ofed_5_4_1_0_3_0.rs │ └── types.rs │ └── unitests │ ├── Kbuild │ ├── Makefile │ ├── cm_funcs │ ├── Cargo.toml │ ├── src │ │ ├── console_msgs.rs │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── create_dct │ ├── Cargo.toml │ ├── src │ │ ├── console_msgs.rs │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── create_qps │ ├── Cargo.toml │ ├── src │ │ ├── console_msgs.rs │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── get_devices │ ├── Cargo.toml │ ├── src │ │ ├── console_msgs.rs │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── run_tests.py │ └── sample │ ├── Cargo.toml │ ├── src │ └── lib.rs │ └── tests │ └── test.rs ├── KRdmaKit ├── Cargo.toml ├── examples │ ├── doorbell.rs │ ├── hello.rs │ ├── ib-exp.rs │ ├── loopback_rc.rs │ ├── loopback_ud.rs │ ├── memory_window.rs │ ├── rc_read_bench.rs │ └── user_rc_cm.rs ├── src │ ├── comm_manager │ │ ├── client.rs │ │ ├── explorer.rs │ │ ├── mod.rs │ │ ├── send.rs │ │ └── server.rs │ ├── completion_queue.rs │ ├── consts.rs │ ├── context.rs │ ├── ctrl.rs │ ├── device.rs │ ├── kdriver.rs │ ├── lib.rs │ ├── memory_region.rs │ ├── memory_window.rs │ ├── queue_pairs │ │ ├── builder.rs │ │ ├── callbacks.rs │ │ ├── doorbell_helper.rs │ │ ├── dynamic_connected_transport.rs │ │ ├── endpoint.rs │ │ ├── handshake_kernel.rs │ │ ├── handshake_user.rs │ │ ├── mod.rs │ │ ├── operations_kernel.rs │ │ ├── operations_user.rs │ │ └── rc_comm.rs │ ├── random.rs │ ├── runtime │ │ ├── error.rs │ │ ├── mod.rs │ │ ├── task.rs │ │ ├── tid.rs │ │ ├── waitable.rs │ │ ├── wake_fn.rs │ │ ├── worker.rs │ │ └── worker_group.rs │ ├── services │ │ ├── dc.rs │ │ ├── mod.rs │ │ ├── rc.rs │ │ └── ud.rs │ ├── services_user │ │ ├── cm.rs │ │ └── mod.rs │ ├── udriver.rs │ └── utils.rs └── unitests-kernel │ ├── Kbuild │ ├── Makefile │ ├── comm_manager │ ├── Cargo.lock │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── comm_manager_error │ ├── Cargo.lock │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── dynamic_connected_transport │ ├── Cargo.lock │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── global_context │ ├── Cargo.lock │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── memory_region │ ├── Cargo.lock │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── reliable_connection │ ├── Cargo.lock │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── tests │ │ └── test.rs │ ├── run_tests.py │ └── unreliable_datagram │ ├── Cargo.lock │ ├── Cargo.toml │ ├── src │ └── lib.rs │ └── tests │ └── test.rs ├── README.md ├── benchs ├── Kbuild ├── Makefile ├── rc_read │ ├── Cargo.toml │ ├── src │ │ ├── console_msgs.rs │ │ ├── lib.rs │ │ └── rc_read.rs │ └── tests │ │ └── test.rs ├── run_tests.py └── ud │ ├── Cargo.toml │ ├── src │ ├── console_msgs.rs │ ├── lib.rs │ └── ud.rs │ └── tests │ └── test.rs ├── deps └── r2 │ ├── .gitignore │ ├── .gitlab-ci.yml │ ├── .gitmodules │ ├── CMakeLists.txt │ ├── README.md │ ├── benchs │ ├── bench.cmake │ ├── bench_server.cc │ ├── co_bench │ │ └── client.cc │ ├── huge_region.hh │ └── mem_region.hh │ ├── deps │ └── deps.cmake │ ├── src │ ├── allocator.hh │ ├── allocator_master.hh │ ├── channel │ │ └── mod.hh │ ├── common.hh │ ├── libroutine.hh │ ├── linked_list.hh │ ├── logging.cc │ ├── logging.hh │ ├── mem_block.hh │ ├── msg │ │ ├── msg_session.hh │ │ ├── protocol.hpp │ │ ├── rc_session.hh │ │ ├── ud_msg.cc │ │ ├── ud_msg.hh │ │ ├── ud_msg.hpp │ │ └── ud_session.hh │ ├── random.hh │ ├── rdma │ │ ├── async_op.hh │ │ └── sop.hh │ ├── ring_msg │ │ ├── cm.hh │ │ ├── id_helper.hh │ │ ├── manager.hh │ │ ├── mod.hh │ │ ├── proto.hh │ │ ├── receiver.hh │ │ ├── recv_bundler.hh │ │ ├── ring.hh │ │ └── session.hh │ ├── routine.hh │ ├── rpc │ │ ├── buf_factory.hpp │ │ ├── rpc.cc │ │ ├── rpc.hpp │ │ └── rpc_data.hpp │ ├── scheduler.cc │ ├── sshed.cc │ ├── sshed.hh │ ├── thread.hh │ ├── timer.hh │ ├── tm_manager.hh │ └── utils │ │ ├── option.hh │ │ └── rdtsc.hh │ └── tests │ ├── test_list.cc │ ├── test_rc_session.cc │ ├── test_rdtsc.cc │ ├── test_rm.cc │ ├── test_srop.cc │ ├── test_ssched.cc │ ├── test_ud_session.cc │ └── tests.cmake ├── docs ├── arch-v20210718.pdf ├── arch.excalidraw ├── arch.graffle ├── arch.pdf ├── arch.png ├── exp.md ├── exp_appendix.md ├── install.md ├── new-arch.png ├── quickstart.md ├── screenshoots │ ├── fig10a.png │ ├── fig10b.png │ ├── fig10c.png │ ├── fig10d.png │ ├── fig11a.png │ ├── fig11b.png │ ├── fig14.png │ ├── fig8a.png │ └── fig9a.png └── testing.md ├── examples ├── Kbuild ├── Makefile ├── README.md ├── krdmakit_kernel_rc │ ├── Cargo.toml │ ├── src │ │ ├── client.rs │ │ └── lib.rs │ └── tests │ │ └── test.rs ├── krdmakit_kernel_ud │ ├── Cargo.toml │ ├── src │ │ ├── client.rs │ │ └── lib.rs │ └── tests │ │ └── test.rs └── run_examples.py ├── exp ├── .gitignore ├── CMakeLists.txt ├── Dockerfile ├── LITE │ ├── common.h │ ├── lib │ │ ├── Makefile │ │ ├── README.md │ │ ├── compiler.h │ │ ├── lite-lib.c │ │ ├── lite-lib.h │ │ ├── lite_join.c │ │ ├── lite_key.h │ │ ├── lite_latency.c │ │ ├── lite_rpc.c │ │ └── lite_write.c │ └── one-sided │ │ └── lite_client.cc ├── README.md ├── deps │ └── deps.cmake ├── full-mesh │ ├── kernel │ │ └── worker.cc │ ├── profile.hh │ ├── trigger.cc │ └── user │ │ ├── kv_server.cc │ │ └── worker.cc ├── huge_region.hh ├── memory_region.hh ├── motiv-connect │ ├── .gitignore │ ├── connect_simulation.cc │ ├── ibv_fork.cc │ ├── mem_profile.cc │ ├── profile.hh │ ├── rc_connect_client.cc │ ├── rc_connect_client_kernel.cc │ ├── rc_connect_server.cc │ ├── rc_onesided_client_kernel.cc │ ├── run.toml │ ├── ud_msg.hh │ └── val │ │ └── cpu.hh ├── motiv-kit-breakdown │ ├── Kbuild │ ├── Makefile │ ├── rc_break_down_client │ │ ├── Cargo.toml │ │ ├── src │ │ │ ├── console_msgs.rs │ │ │ └── lib.rs │ │ └── tests │ │ │ └── test.rs │ └── run_tests.py ├── one-sided │ ├── krc_client-docker.cc │ ├── krc_client.cc │ ├── urc_client.cc │ └── urc_server.cc ├── race-hasing │ ├── analyser.cc │ ├── krcore │ │ ├── elastic_worker.cc │ │ └── elastic_worker_tail_lat.cc │ ├── trigger.cc │ └── user │ │ ├── elastic_worker.cc │ │ ├── elastic_worker_tail_lat.cc │ │ └── server.cc ├── rcopy │ ├── client.cc │ └── server.cc ├── reg_mr.cc ├── reporter.hh ├── two-sided │ ├── kernel_twosided_rc_client.cc │ ├── kernel_twosided_rc_server.cc │ ├── kernel_twosided_rc_zcpy_client.cc │ ├── kernel_twosided_rc_zcpy_server.cc │ ├── user_payload_latency_rc_client.cc │ ├── user_payload_latency_rc_server.cc │ ├── user_twosided_rc_client.cc │ └── user_twosided_rc_server.cc └── val │ └── cpu.hh ├── exp_scripts ├── .gitignore ├── bootstrap.py ├── evaluation_runner.py ├── figures │ ├── painter.py │ └── racehasing_analyser.py ├── log_analyser.py ├── makefile ├── requirements.txt ├── template.toml ├── templates-build │ ├── template-build-dc.toml │ ├── template-build-exp.toml │ ├── template-build-hybrid.toml │ ├── template-build-lite.toml │ ├── template-build-meta-client.toml │ ├── template-build-meta-rpc.toml │ ├── template-build-meta-server.toml │ ├── template-build-rc.toml │ ├── template-build-tdc.toml │ └── template-clean.toml ├── templates-run │ ├── app │ │ ├── template-krcore-race-hashing-async.toml │ │ ├── template-krcore-race-hashing.toml │ │ └── template-verbs-race-hashing.toml │ ├── control-path │ │ ├── template-krcore-connect.toml │ │ └── template-verbs-connect.toml │ └── data-path │ │ ├── one-sided │ │ ├── template-one-sided-krcore-async-read.toml │ │ ├── template-one-sided-krcore-async-write.toml │ │ ├── template-one-sided-krcore-sync-read.toml │ │ ├── template-one-sided-krcore-sync-write.toml │ │ ├── template-one-sided-verbs-async-read.toml │ │ ├── template-one-sided-verbs-async-write.toml │ │ ├── template-one-sided-verbs-sync-read.toml │ │ └── template-one-sided-verbs-sync-write.toml │ │ └── two-sided │ │ ├── template-two-sided-dc-async.toml │ │ ├── template-two-sided-dc-sync.toml │ │ ├── template-two-sided-rc-async.toml │ │ ├── template-two-sided-rc-sync.toml │ │ ├── template-two-sided-verbs-async.toml │ │ └── template-two-sided-verbs-sync.toml └── toml_generator.py ├── git_init.sh ├── include ├── common.h └── syscall.h ├── krdmakit-macros ├── Cargo.toml └── src │ └── lib.rs ├── rdma-shim ├── Cargo.toml └── src │ ├── kernel.rs │ ├── lib.rs │ └── user │ ├── bindings.rs │ ├── ffi.rs │ ├── mod.rs │ └── utils.rs ├── rsync.sh ├── rust-kernel-rdma ├── .gitignore ├── .gitlab-ci.yml ├── .gitmodules ├── README.md ├── ci │ ├── check_kernel.sh │ └── install_deps.sh ├── deps │ ├── no-std-net │ │ ├── Cargo.toml │ │ ├── LICENSE │ │ ├── README.md │ │ └── src │ │ │ ├── addr.rs │ │ │ ├── de.rs │ │ │ ├── ip.rs │ │ │ ├── lib.rs │ │ │ ├── parser.rs │ │ │ └── ser.rs │ └── rust-kernel-module │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── CODE_OF_CONDUCT.md │ │ ├── CONTRIBUTING.md │ │ ├── Cargo.toml │ │ ├── LICENSE │ │ ├── NOTES.md │ │ ├── README.md │ │ ├── build.rs │ │ ├── hello-world │ │ ├── Cargo.toml │ │ ├── Kbuild │ │ ├── Makefile │ │ └── src │ │ │ └── lib.rs │ │ ├── src │ │ ├── allocator.rs │ │ ├── bindings.rs │ │ ├── bindings_helper.h │ │ ├── c_types.rs │ │ ├── chrdev.rs │ │ ├── error.rs │ │ ├── file_operations.rs │ │ ├── filesystem.rs │ │ ├── helpers.c │ │ ├── inline_helper.h │ │ ├── lib.rs │ │ ├── mutex.rs │ │ ├── printk.rs │ │ ├── random.rs │ │ ├── sync.rs │ │ ├── sysctl.rs │ │ ├── types.rs │ │ └── user_ptr.rs │ │ ├── testlib │ │ ├── Cargo.toml │ │ └── src │ │ │ └── lib.rs │ │ └── tests │ │ ├── Kbuild │ │ ├── Makefile │ │ ├── chrdev-region-allocation │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── tests.rs │ │ ├── chrdev │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── tests.rs │ │ ├── filesystem │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── tests.rs │ │ ├── modinfo │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── tests.rs │ │ ├── printk │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── tests.rs │ │ ├── random │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── tests.rs │ │ ├── run_tests.py │ │ ├── sysctl-get │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── tests.rs │ │ ├── sysctl │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── tests.rs │ │ └── utils │ │ ├── Cargo.toml │ │ ├── src │ │ └── lib.rs │ │ └── tests │ │ └── tests.rs ├── krdma-test │ ├── Cargo.toml │ ├── rust-toolchain.toml │ ├── src │ │ └── lib.rs │ └── unitests │ │ ├── Kbuild │ │ ├── Makefile │ │ ├── run_tests.py │ │ └── test-macros │ │ ├── Cargo.toml │ │ ├── src │ │ └── lib.rs │ │ └── tests │ │ └── test.rs ├── rust-kernel-linux-util │ ├── Cargo.toml │ ├── README.md │ ├── build.rs │ ├── src │ │ ├── bindings.rs │ │ ├── kthread.rs │ │ ├── level.rs │ │ ├── lib.rs │ │ ├── macros.rs │ │ ├── native │ │ │ ├── kernel_helper.c │ │ │ └── kernel_helper.h │ │ ├── rwlock.rs │ │ ├── string.rs │ │ └── timer.rs │ └── unitests │ │ ├── Kbuild │ │ ├── Makefile │ │ ├── kthread │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── test.rs │ │ ├── log-level-static │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── test.rs │ │ ├── log-level │ │ ├── Cargo.toml │ │ ├── src │ │ │ └── lib.rs │ │ └── tests │ │ │ └── test.rs │ │ ├── run_tests.py │ │ └── sample │ │ ├── Cargo.toml │ │ ├── src │ │ └── lib.rs │ │ └── tests │ │ └── test.rs ├── rust-kernel-rdma-base │ ├── Cargo.toml │ ├── README.md │ ├── build.rs │ ├── src │ │ ├── allocator.rs │ │ ├── bindings.rs │ │ ├── consts.rs │ │ ├── funcs.rs │ │ ├── lib.rs │ │ ├── native │ │ │ ├── kernel_helper.c │ │ │ └── kernel_helper.h │ │ ├── ofed_4_4_2_0_7_0.rs │ │ ├── ofed_4_9_3_1_5_0.rs │ │ ├── ofed_5_4_1_0_3_0.rs │ │ └── types.rs │ └── unitests │ │ ├── Kbuild │ │ ├── Makefile │ │ ├── cm_funcs │ │ ├── Cargo.toml │ │ ├── src │ │ │ ├── console_msgs.rs │ │ │ └── lib.rs │ │ └── tests │ │ │ └── test.rs │ │ ├── create_dct │ │ ├── Cargo.toml │ │ ├── Cargo.toml~ │ │ ├── src │ │ │ ├── console_msgs.rs │ │ │ └── lib.rs │ │ └── tests │ │ │ └── test.rs │ │ ├── create_qps │ │ ├── Cargo.toml │ │ ├── src │ │ │ ├── console_msgs.rs │ │ │ └── lib.rs │ │ └── tests │ │ │ └── test.rs │ │ ├── run_tests.py │ │ └── sample │ │ ├── Cargo.toml │ │ ├── src │ │ └── lib.rs │ │ └── tests │ │ └── test.rs └── testlib │ ├── Cargo.toml │ └── src │ └── lib.rs ├── rust-user-rdma ├── Cargo.toml ├── README.md ├── build.rs └── src │ ├── bindings.h │ ├── lib.rs │ └── native │ └── exp.c ├── testlib ├── Cargo.toml └── src │ └── lib.rs └── user-benchs ├── README.md ├── bench_rdma ├── Cargo.toml └── src │ └── main.rs ├── bench_runtime ├── server │ ├── Cargo.toml │ └── src │ │ └── main.rs └── throughput │ ├── Cargo.toml │ └── src │ ├── main.rs │ └── random.rs ├── bench_server ├── Cargo.toml └── src │ └── main.rs └── scripts ├── build.toml ├── copy_bins.toml └── run_basic.toml /.gitattributes: -------------------------------------------------------------------------------- 1 | mlnx-ofed-4.9-driver/libmlx4_41mlnx1.orig.tar.gz filter=lfs diff=lfs merge=lfs -text 2 | mlnx-ofed-4.9-driver/mlnx-ofed-kernel_4.9-OFED.4.9.3.1.5.1.debian.tar.xz filter=lfs diff=lfs merge=lfs -text 3 | mlnx-ofed-4.9-driver/mlnx-ofed-kernel_4.9.orig.tar.gz filter=lfs diff=lfs merge=lfs -text 4 | mlnx-ofed-4.9-driver/MLNX_OFED_LINUX-4.9-3.1.5.0-ubuntu16.04-x86_64.tgz filter=lfs diff=lfs merge=lfs -text 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/target 2 | !mlnx-ofed-4.9-driver/**/target 3 | **/.idea 4 | **/.vscode 5 | .DS_Store -------------------------------------------------------------------------------- /.gitlab/issue_templates/bug-report.md: -------------------------------------------------------------------------------- 1 | ## Summary 2 | 3 | (Summarize the bug encountered concisely) 4 | 5 | ## Steps to reproduce 6 | 7 | (Provide a reproducible test case that is the bare minimum necessary to generate the problem) 8 | 9 | ## What is the current bug behavior? 10 | 11 | (What actually happens) 12 | 13 | ## What is the expected correct behavior? 14 | 15 | (What you should see instead) 16 | 17 | ## Relevant logs and/or screenshots 18 | 19 | (Paste any relevant logs - use code blocks (```) to format console output, logs, and code, as 20 | it's very hard to read otherwise.) 21 | 22 | ## Possible fixes 23 | 24 | (If you can, link to the line of code that might be responsible for the problem) -------------------------------------------------------------------------------- /.gitlab/issue_templates/feature.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | (A clear and concise description of the problem or missing capability.) 4 | 5 | ## Relevant Modules 6 | 7 | (how many modules you use?) 8 | 9 | ## Deliverable 10 | 11 | (After the issue is closed, what we can have?) 12 | 13 | ## Tasks 14 | 15 | (Optional. A list of tasks to complete. ) 16 | 17 | 18 | --- 19 | 20 | 21 | ## Reference 22 | 23 | (Optional. Related issues or links to related resources) 24 | -------------------------------------------------------------------------------- /.gitlab/merge_request_templates/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing to Mitosis 2 | 3 | **Check list** 4 | 5 | - [ ] Make sure you fixed all the warnings generated by the rust compile. If not, specific why the warning exists in the merge request. 6 | 7 | - [ ] Add brief comments to describe what you are doing 8 | 9 | - [ ] Each single function should be written in a single `fn test_xxx()`, with comments describing what is testing and what is the pre-request (e.g., `init_ctx`) of this function. 10 | 11 | - [ ] If you update the submodule, be sure to run `git submodule update --init --recursive --remote` to update the references. 12 | 13 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "deps/r2/deps/rlib"] 2 | path = deps/r2/deps/rlib 3 | url = https://github.com/wxdwfc/rlibv2.git 4 | [submodule "deps/r2/deps/gflags"] 5 | path = deps/r2/deps/gflags 6 | url = https://github.com/gflags/gflags.git 7 | [submodule "deps/r2/deps/googletest"] 8 | path = deps/r2/deps/googletest 9 | url = https://github.com/google/googletest.git 10 | [submodule "deps/r2/deps/jemalloc"] 11 | path = deps/r2/deps/jemalloc 12 | url = https://github.com/jemalloc/jemalloc.git 13 | [submodule "mlnx-ofed-4.9-driver"] 14 | path = mlnx-ofed-4.9-driver 15 | url = https://github.com/ProjectMitosisOS/mlnx-ofed-4.9-driver-dct.git 16 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := KRdmaKitSyscall.o 2 | KRdmaKitSyscall-objs := KRdmaKitSyscall.rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | 9 | $(src)/target/$(TARGET)/debug/libKRdmaKitSyscall.a: cargo_will_determine_dependencies 10 | cd $(src); $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) 11 | 12 | .PHONY: cargo_will_determine_dependencies 13 | 14 | %.rust.o: target/$(TARGET)/debug/lib%.a 15 | $(LD) -r -o $@ --whole-archive $< 16 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/Kbuild-DC: -------------------------------------------------------------------------------- 1 | obj-m := KRdmaKitSyscall.o 2 | KRdmaKitSyscall-objs := KRdmaKitSyscall.rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | 9 | $(src)/target/$(TARGET)/debug/libKRdmaKitSyscall.a: cargo_will_determine_dependencies 10 | cd $(src); $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) --features "KRdmaKit virtual_queue dct_qp meta_cache" --no-default-features 11 | 12 | .PHONY: cargo_will_determine_dependencies 13 | 14 | %.rust.o: target/$(TARGET)/debug/lib%.a 15 | $(LD) -r -o $@ --whole-archive $< 16 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/Kbuild-RC: -------------------------------------------------------------------------------- 1 | obj-m := KRdmaKitSyscall.o 2 | KRdmaKitSyscall-objs := KRdmaKitSyscall.rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | 9 | $(src)/target/$(TARGET)/debug/libKRdmaKitSyscall.a: cargo_will_determine_dependencies 10 | cd $(src); $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) --features "KRdmaKit virtual_queue" --no-default-features 11 | 12 | .PHONY: cargo_will_determine_dependencies 13 | 14 | %.rust.o: target/$(TARGET)/debug/lib%.a 15 | $(LD) -r -o $@ --whole-archive $< 16 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/Kbuild-hybrid: -------------------------------------------------------------------------------- 1 | obj-m := KRdmaKitSyscall.o 2 | KRdmaKitSyscall-objs := KRdmaKitSyscall.rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | 9 | $(src)/target/$(TARGET)/debug/libKRdmaKitSyscall.a: cargo_will_determine_dependencies 10 | cd $(src); $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) --features "KRdmaKit virtual_queue dct_qp meta_cache migrate_qp" --no-default-features 11 | 12 | .PHONY: cargo_will_determine_dependencies 13 | 14 | %.rust.o: target/$(TARGET)/debug/lib%.a 15 | $(LD) -r -o $@ --whole-archive $< 16 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/Kbuild-lite: -------------------------------------------------------------------------------- 1 | obj-m := KRdmaKitSyscall.o 2 | KRdmaKitSyscall-objs := KRdmaKitSyscall.rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | 9 | $(src)/target/$(TARGET)/debug/libKRdmaKitSyscall.a: cargo_will_determine_dependencies 10 | cd $(src); $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) --features "KRdmaKit" --no-default-features 11 | 12 | .PHONY: cargo_will_determine_dependencies 13 | 14 | %.rust.o: target/$(TARGET)/debug/lib%.a 15 | $(LD) -r -o $@ --whole-archive $< 16 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/Kbuild-meta-client: -------------------------------------------------------------------------------- 1 | obj-m := KRdmaKitSyscall.o 2 | KRdmaKitSyscall-objs := KRdmaKitSyscall.rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | 9 | $(src)/target/$(TARGET)/debug/libKRdmaKitSyscall.a: cargo_will_determine_dependencies 10 | cd $(src); $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) --features "KRdmaKit virtual_queue dct_qp meta_kv" --no-default-features 11 | 12 | .PHONY: cargo_will_determine_dependencies 13 | 14 | %.rust.o: target/$(TARGET)/debug/lib%.a 15 | $(LD) -r -o $@ --whole-archive $< 16 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/Kbuild-meta-rpc: -------------------------------------------------------------------------------- 1 | obj-m := KRdmaKitSyscall.o 2 | KRdmaKitSyscall-objs := KRdmaKitSyscall.rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | 9 | $(src)/target/$(TARGET)/debug/libKRdmaKitSyscall.a: cargo_will_determine_dependencies 10 | cd $(src); $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) --features "KRdmaKit virtual_queue dct_qp" --no-default-features 11 | 12 | .PHONY: cargo_will_determine_dependencies 13 | 14 | %.rust.o: target/$(TARGET)/debug/lib%.a 15 | $(LD) -r -o $@ --whole-archive $< 16 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/Kbuild-meta-server: -------------------------------------------------------------------------------- 1 | obj-m := KRdmaKitSyscall.o 2 | KRdmaKitSyscall-objs := KRdmaKitSyscall.rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | 9 | $(src)/target/$(TARGET)/debug/libKRdmaKitSyscall.a: cargo_will_determine_dependencies 10 | cd $(src); $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) --features "KRdmaKit virtual_queue dct_qp rpc_server meta_kv" --no-default-features 11 | 12 | .PHONY: cargo_will_determine_dependencies 13 | 14 | %.rust.o: target/$(TARGET)/debug/lib%.a 15 | $(LD) -r -o $@ --whole-archive $< 16 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | components = ["rust-src"] -------------------------------------------------------------------------------- /KRdmaKit-syscall/src/bindings.rs: -------------------------------------------------------------------------------- 1 | #[allow( 2 | clippy::all, 3 | non_camel_case_types, 4 | non_upper_case_globals, 5 | non_snake_case, 6 | improper_ctypes, 7 | non_upper_case_globals, 8 | dead_code 9 | )] 10 | mod bindings { 11 | use crate::linux_kernel_module::c_types; 12 | include!(concat!(env!("OUT_DIR"), "/bindings-",env!("CARGO_PKG_NAME"),".rs")); 13 | } 14 | 15 | pub use bindings::*; 16 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/src/consts.rs: -------------------------------------------------------------------------------- 1 | // Default gid of the meta server 2 | pub const META_SERVER_GID: &str = "fe80:0000:0000:0000:ec0d:9a03:0078:645e"; 3 | pub const RPC_BUFFER_N: usize = 16; 4 | 5 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/src/native/kernel_helper.c: -------------------------------------------------------------------------------- 1 | #include "kernel_helper.h" 2 | #define BUF_LENGTH 256 3 | #define DEFAULT_PERMISSION S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH 4 | 5 | char gids_arr[BUF_LENGTH] = "fe80:0000:0000:0000:ec0d:9a03:0078:645e"; 6 | char* meta_server_gid = gids_arr; 7 | module_param_string(meta_server_gid, gids_arr, BUF_LENGTH, DEFAULT_PERMISSION); 8 | 9 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/src/native/kernel_helper.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/src/rpc/mod.rs: -------------------------------------------------------------------------------- 1 | mod protocol; 2 | pub use protocol::*; -------------------------------------------------------------------------------- /KRdmaKit-syscall/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(KRdmaKit-syscall-tests) 2 | ADD_DEFINITIONS(-std=c++17) 3 | cmake_minimum_required(VERSION 3.2) 4 | 5 | set(tests 6 | test_nil test_connect test_rc 7 | test_bind test_poll_rpc 8 | test_reg_mr 9 | ) 10 | 11 | add_executable(test_nil test_nil.cc) 12 | add_executable(test_connect test_connect.cc) 13 | add_executable(test_rc test_rc.cc) 14 | add_executable(test_bind test_bind.cc) 15 | add_executable(test_poll_rpc test_poll_rpc.cc) 16 | add_executable(test_reg_mr test_reg_mr.cc) 17 | 18 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/tests/test_bind.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../../include/syscall.h" 5 | 6 | int 7 | main(int argc, char *argv[]) { 8 | int qd = queue(); 9 | assert(qd >= 0); 10 | int ret; 11 | ret = qbind(qd, 1024); 12 | printf("first] bind res: %d\n", ret); 13 | #if 1 14 | ret = qbind(qd, 1024); 15 | printf("second] bind res: %d\n", ret); 16 | #endif 17 | ret = qunbind(qd, 1024); 18 | printf("unbind res: %d\n", ret); 19 | 20 | return 0; 21 | } -------------------------------------------------------------------------------- /KRdmaKit-syscall/tests/test_connect.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../../include/syscall.h" 5 | 6 | int 7 | main(int argc, char *argv[]) { 8 | int qd = queue(); 9 | assert(qd >= 0); 10 | 11 | const char *addr = "fe80:0000:0000:0000:ec0d:9a03:0078:645e"; 12 | int ret = qconnect(qd, addr, strlen(addr), 16); 13 | printf("get qd connect res: %d\n", ret); 14 | usleep(200 * 1000); 15 | #if 0 16 | ret = qconnect(qd, addr, strlen(addr), 16); 17 | printf("second] get qd re-connect res: %d\n", ret); 18 | #endif 19 | return 0; 20 | } -------------------------------------------------------------------------------- /KRdmaKit-syscall/tests/test_nil.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../../include/syscall.h" 5 | 6 | int 7 | main(int argc, char *argv[]) { 8 | int qd = queue(); 9 | assert(qd >= 0); 10 | 11 | // issue the sys call 12 | for (int i = 0; i < 5; ++i) { 13 | int ret = qnil(qd); 14 | printf("sanity check nil return: %d\n", ret); 15 | } 16 | 17 | return 0; 18 | } -------------------------------------------------------------------------------- /KRdmaKit-syscall/tests/test_poll_rpc.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../../include/syscall.h" 5 | 6 | int 7 | main(int argc, char *argv[]) { 8 | int qd = queue(); 9 | assert(qd >= 0); 10 | 11 | // issue the sys call 12 | for (int i = 0; i < 1000 * 20; ++i) { 13 | int ret = qpoll_rpc(qd); 14 | usleep(5000); 15 | } 16 | 17 | return 0; 18 | } -------------------------------------------------------------------------------- /KRdmaKit-syscall/tests/test_reg_mr.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "../../include/syscall.h" 6 | 7 | #define K 1024 8 | #define M 1024 * K 9 | 10 | int 11 | main(int argc, char *argv[]) { 12 | int qd = queue(); 13 | assert(qd >= 0); 14 | std::vector vec = { 15 | // 128 * K 16 | // 128, 512, 1 * K, 4 * K, 16 * K, 256 * K, 512 * K, 1 * M, 4 * M, 17 | // 16 * M, 18 | // 64 * M, 19 | // 128 * M 20 | 512 * M 21 | }; 22 | 23 | for (auto size: vec) { 24 | void *ptr = malloc(size); 25 | int ret = 0; 26 | ret = qreg_mr(qd, (uint64_t) ptr, size, 16); 27 | } 28 | 29 | return 0; 30 | } -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit-syscall/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "KRdmaKitSyscall" 3 | version = "0.1.0" 4 | edition = "2018" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [lib] 9 | crate-type = ["staticlib"] 10 | test = false 11 | 12 | [features] 13 | #default = ["KRdmaKit"] 14 | default = ["KRdmaKit", "virtual_queue"] 15 | #default = ["KRdmaKit", "virtual_queue", "dct_qp"] 16 | 17 | # virtual queue cache 18 | virtual_queue = [] 19 | 20 | # dct 21 | dct_qp = [] 22 | 23 | [dependencies] 24 | KRdmaKit = { path = "../KRdmaKit", optional = true, features = ["dct"] } 25 | hashbrown = { git = "https://github.com/ProjectMitosisOS/hashbrown.git", branch = "main" } 26 | no-std-net = { path = "../deps/no-std-net" } 27 | 28 | [build-dependencies] 29 | bindgen = "0.54" 30 | cc = "1.0" 31 | shlex = "0.1" 32 | 33 | ## lazy static 34 | [dependencies.lazy_static] 35 | version = "1.0" 36 | features = ["spin_no_std"] 37 | 38 | [profile.dev] 39 | opt-level = 2 40 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit-syscall/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := KRdmaKitSyscall.o 2 | KRdmaKitSyscall-objs := KRdmaKitSyscall.rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | 9 | $(src)/target/$(TARGET)/debug/libKRdmaKitSyscall.a: cargo_will_determine_dependencies 10 | cd $(src); $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) --features "KRdmaKit virtual_queue dct_qp" --no-default-features 11 | 12 | .PHONY: cargo_will_determine_dependencies 13 | 14 | %.rust.o: target/$(TARGET)/debug/lib%.a 15 | $(LD) -r -o $@ --whole-archive $< 16 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit-syscall/src/bindings.rs: -------------------------------------------------------------------------------- 1 | #[allow( 2 | clippy::all, 3 | non_camel_case_types, 4 | non_upper_case_globals, 5 | non_snake_case, 6 | improper_ctypes, 7 | non_upper_case_globals, 8 | dead_code 9 | )] 10 | mod bindings { 11 | use crate::linux_kernel_module::c_types; 12 | include!(concat!(env!("OUT_DIR"), "/bindings-",env!("CARGO_PKG_NAME"),".rs")); 13 | } 14 | 15 | pub use bindings::*; 16 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit-syscall/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(KRdmaKit-syscall-tests) 2 | ADD_DEFINITIONS(-std=c++17) 3 | cmake_minimum_required(VERSION 3.2) 4 | 5 | set(tests 6 | test_nil test_connect test_rc 7 | test_bind 8 | ) 9 | 10 | add_executable(test_nil test_nil.cc) 11 | add_executable(test_connect test_connect.cc) 12 | add_executable(test_rc test_rc.cc) 13 | add_executable(test_bind test_bind.cc) 14 | 15 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit-syscall/tests/test_bind.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../../include/syscall.h" 5 | 6 | int 7 | main(int argc, char *argv[]) { 8 | int qd = queue(); 9 | assert(qd >= 0); 10 | int ret; 11 | ret = qbind(qd, 1024); 12 | printf("first] bind res: %d\n", ret); 13 | #if 1 14 | ret = qbind(qd, 1024); 15 | printf("second] bind res: %d\n", ret); 16 | #endif 17 | ret = qunbind(qd, 1024); 18 | printf("unbind res: %d\n", ret); 19 | 20 | return 0; 21 | } -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit-syscall/tests/test_connect.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../../include/syscall.h" 5 | 6 | int 7 | main(int argc, char *argv[]) { 8 | int qd = queue(); 9 | assert(qd >= 0); 10 | 11 | const char *addr = "fe80:0000:0000:0000:ec0d:9a03:0078:645e"; 12 | int ret = qconnect(qd, addr, strlen(addr), 1); 13 | printf("first] get qd connect res: %d\n", ret); 14 | #if 1 15 | ret = qconnect(qd, addr, strlen(addr), 1); 16 | printf("second] get qd re-connect res: %d\n", ret); 17 | #endif 18 | return 0; 19 | } -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit-syscall/tests/test_nil.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../../include/syscall.h" 5 | 6 | int 7 | main(int argc, char *argv[]) { 8 | int qd = queue(); 9 | assert(qd >= 0); 10 | 11 | // issue the sys call 12 | for (int i = 0; i < 5; ++i) { 13 | int ret = qnil(qd); 14 | printf("sanity check nil return: %d\n", ret); 15 | } 16 | 17 | return 0; 18 | } -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "KRdmaKit" 3 | version = "0.1.0" 4 | authors = ["xmm "] 5 | edition = "2018" 6 | 7 | 8 | [dependencies] 9 | rust-kernel-rdma-base = { path = "../rust-kernel-rdma-base" } 10 | no-std-net = { path = "../deps/no-std-net" } 11 | 12 | ## spinlock 13 | spin = "0.9.2" ## spin lock 14 | hashbrown = { git = "https://github.com/ProjectMitosisOS/hashbrown.git", branch = "main" } 15 | 16 | [features] 17 | #default = ["profile"] 18 | dct = ["rust-kernel-rdma-base/dct"] 19 | profile = [] 20 | ## lazy static 21 | [dependencies.lazy_static] 22 | version = "1.0" 23 | features = ["spin_no_std"] 24 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/src/cm/mod.rs: -------------------------------------------------------------------------------- 1 | mod client; 2 | mod sidr; 3 | 4 | pub use client::ClientCM; 5 | pub use sidr::{EndPoint, SidrCM}; 6 | 7 | pub type ServerCM = ClientCM; -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/src/consts.rs: -------------------------------------------------------------------------------- 1 | //! Consts used in the whole KRdmaKit module 2 | use rust_kernel_rdma_base::*; 3 | 4 | pub const IB_PD_UNSAFE_GLOBAL_RKEY: usize = 0x01; 5 | pub const CONNECT_TIME_OUT_MS: linux_kernel_module::c_types::c_int = 5000; // connect time out. set 5 seconds 6 | 7 | pub const AF_INET: sa_family_t = 2; 8 | pub const AF_UNSPEC: sa_family_t = 0; 9 | 10 | pub const MAX_RD_ATOMIC: usize = 16; 11 | 12 | // max kmalloc size in kernel module (4M) 13 | pub const MAX_KMALLOC_SZ: usize = 1024 * 1024 * 4; 14 | pub const K_REG_ALWAYS: bool = true; 15 | 16 | // RPC related 17 | pub const DEFAULT_RPC_HINT: usize = 73; 18 | pub const UD_HEADER_SZ: usize = 40; 19 | 20 | pub const DEFAULT_TWO_SIDED_RC_VID: usize = 1024; -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/src/net_util.rs: -------------------------------------------------------------------------------- 1 | //! Util libs support for gid transformation et al. 2 | 3 | use rust_kernel_rdma_base::*; 4 | use alloc::string::String; 5 | use no_std_net::Guid; 6 | 7 | /// Transform net address of type `String` into `ib_gid` 8 | #[inline] 9 | pub fn str_to_gid(addr: &String) -> ib_gid { 10 | let addr: Guid = (addr as &str).parse().unwrap(); 11 | let mut res: ib_gid = Default::default(); 12 | res.raw = addr.get_raw(); 13 | res 14 | } 15 | 16 | /// Transform net address of type `ib_gid` into `String` 17 | #[inline] 18 | pub fn gid_to_str(gid: ib_gid) -> String { 19 | let gid: Guid = Guid::new_u8(unsafe { &gid.raw }); 20 | alloc::format!("{}", gid) 21 | } 22 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/src/qp/statistics.rs: -------------------------------------------------------------------------------- 1 | use crate::rust_kernel_rdma_base::*; 2 | use rust_kernel_linux_util::timer::RTimer; 3 | 4 | #[derive(Debug)] 5 | pub struct QPProfile { 6 | timer: RTimer, 7 | post_cycles: u64, 8 | poll_cycles: u64, 9 | } 10 | 11 | impl QPProfile { 12 | pub fn new() -> Self { 13 | Self { 14 | timer: RTimer::new(), 15 | post_cycles: 0, 16 | poll_cycles: 0, 17 | } 18 | } 19 | 20 | pub fn reset_timer(&mut self) { 21 | self.timer.reset(); 22 | } 23 | 24 | pub fn reset_post_cycles(&mut self) { 25 | self.post_cycles = 0; 26 | } 27 | 28 | pub fn reset_poll_cycles(&mut self) { 29 | self.poll_cycles = 0; 30 | } 31 | 32 | pub fn add_cur_timer_to_post(&mut self) { 33 | self.post_cycles += self.timer.passed(); 34 | } 35 | 36 | pub fn add_cur_timer_to_poll(&mut self) { 37 | self.poll_cycles += self.timer.passed(); 38 | } 39 | 40 | pub fn get_post_poll_cycles(&self) -> (u64, u64) { 41 | (self.post_cycles, self.poll_cycles) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/src/random.rs: -------------------------------------------------------------------------------- 1 | /// taken from a java-version implementation: 2 | /// http://developer.classpath.org/doc/java/util/Random-source.htmlv 3 | #[allow(dead_code)] 4 | pub struct FastRandom { 5 | seed: u64, 6 | } 7 | 8 | #[allow(dead_code)] 9 | impl FastRandom { 10 | pub fn new(seed: u64) -> Self { 11 | Self { 12 | seed: Self::set_seed0(seed), 13 | } 14 | } 15 | 16 | pub fn get_next(&mut self) -> u64 { 17 | self.next(32).wrapping_shl(32).wrapping_add(self.next(32)) 18 | } 19 | 20 | pub fn get_cur_seed(&self) -> u64 { 21 | self.seed 22 | } 23 | 24 | #[inline] 25 | fn next(&mut self, bits: usize) -> u64 { 26 | self.seed = (self 27 | .seed 28 | .wrapping_mul(0x5DEECE66D as u64) 29 | .wrapping_add(0xB as u64)) 30 | & (((1 as u64) << 48) - 1); 31 | // self.seed 32 | self.seed.wrapping_shr((48 - bits) as u32) 33 | } 34 | 35 | #[inline] 36 | fn set_seed0(seed: u64) -> u64 { 37 | (seed ^ (0x5DEECE66D as u64)) & (((1 as u64) << 48) - 1) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/src/thread_local.rs: -------------------------------------------------------------------------------- 1 | #![allow(clippy::mut_from_ref)] 2 | 3 | use core::cell::UnsafeCell; 4 | pub struct ThreadLocal { 5 | data: UnsafeCell, 6 | } 7 | unsafe impl Send for ThreadLocal {} 8 | unsafe impl Sync for ThreadLocal {} 9 | 10 | impl ThreadLocal { 11 | #[inline] 12 | pub fn new(data: T) -> ThreadLocal { 13 | Self { 14 | data: UnsafeCell::new(data), 15 | } 16 | } 17 | 18 | // we assume that self is thread_local 19 | #[inline(always)] 20 | pub fn get_mut(&self) -> &mut T { 21 | unsafe { &mut *self.data.get() } 22 | } 23 | } 24 | 25 | impl<'a, T> ThreadLocal { 26 | pub fn get_ref(&'a self) -> &'a T { 27 | unsafe { &*self.data.get() } 28 | } 29 | } 30 | 31 | use core::ops::{Deref, DerefMut}; 32 | 33 | impl Deref for ThreadLocal { 34 | type Target = T; 35 | fn deref(&self) -> &T { 36 | unsafe { &*self.data.get() as &T } 37 | } 38 | } 39 | 40 | impl DerefMut for ThreadLocal { 41 | fn deref_mut(&mut self) -> &mut T { 42 | unsafe { &mut *self.data.get() as &mut T } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/unitests/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := testmodule.o 2 | testmodule-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | 6 | export c_flags 7 | export UTEST 8 | 9 | $(src)/target/x86_64-linux-kernel/debug/lib%.a: cargo_will_determine_dependencies 10 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=x86_64-linux-kernel 11 | # cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) clippy -Z build-std=core,alloc --target=x86_64-linux-kernel -- -Dwarnings 12 | 13 | .PHONY: cargo_will_determine_dependencies 14 | 15 | %.rust.o: target/x86_64-linux-kernel/debug/lib%.a 16 | $(LD) -r -o $@ --whole-archive $< 17 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/unitests/dct/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "dct_tests" 5 | version = "0.1.0" 6 | authors = ["CaribouW <1071956678@qq.com>"] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [lib] 12 | crate-type = ["staticlib"] 13 | test = false 14 | 15 | [features] 16 | default = ["KRdmaKit"] 17 | 18 | [dependencies] 19 | KRdmaKit = { path = "../..", optional = true, features=["dct"] } 20 | hashbrown = { git = "https://github.com/ProjectMitosisOS/hashbrown.git", branch = "main" } 21 | 22 | ## lazy static 23 | [dependencies.lazy_static] 24 | version = "1.0" 25 | features = ["spin_no_std"] 26 | 27 | [dev-dependencies] 28 | kernel-module-testlib = { path = "../../../testlib" } 29 | 30 | [profile.dev] 31 | opt-level = 2 32 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/unitests/dct/src/console_msgs.rs: -------------------------------------------------------------------------------- 1 | pub static SUCC : [&str;2] = ["client ok","Dev ok"]; 2 | pub static ERR : [&str;2] = ["cleint err","Dev empty"]; 3 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/unitests/dct/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module}; 2 | use kernel_module_testlib::dmesg_contains; 3 | 4 | #[test] 5 | fn test_dmesg() { 6 | // a dummy test func 7 | with_kernel_module(|| { 8 | // other err messages 9 | assert_eq!(dmesg_contains(&String::from("err")),false); 10 | }); 11 | } 12 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/unitests/device/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "device_tests" 5 | version = "0.1.0" 6 | authors = ["lfm <1071956678caribou@gmail.com>"] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["KRdmaKit"] 16 | 17 | [dependencies] 18 | KRdmaKit = { path = "../..", optional = true , features = ["dct"]} 19 | 20 | ## lazy static 21 | [dependencies.lazy_static] 22 | version = "1.0" 23 | features = ["spin_no_std"] 24 | 25 | [dev-dependencies] 26 | kernel-module-testlib = { path = "../../../testlib" } 27 | 28 | [profile.dev] 29 | opt-level = 2 -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/unitests/device/src/console_msgs.rs: -------------------------------------------------------------------------------- 1 | pub static SUCC : [&str;2] = ["client ok","Dev ok"]; 2 | pub static ERR : [&str;2] = ["cleint err","Dev empty"]; 3 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/unitests/device/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module, assert_dmesg_contains, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_dmesg() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | // ok strings 8 | let test_strs2 = [String::from("client ok"), String::from("Dev ok")]; 9 | assert_dmesg_contains(&test_strs2); 10 | 11 | }); 12 | } 13 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/unitests/qp/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "qp_tests" 5 | version = "0.1.0" 6 | authors = ["CaribouW <1071956678@qq.com>"] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [lib] 12 | crate-type = ["staticlib"] 13 | test = false 14 | 15 | [features] 16 | default = ["KRdmaKit"] 17 | 18 | [dependencies] 19 | KRdmaKit = { path = "../..", optional = true, features = ["dct"] } 20 | hashbrown = { git = "https://github.com/ProjectMitosisOS/hashbrown.git", branch = "main" } 21 | 22 | ## lazy static 23 | [dependencies.lazy_static] 24 | version = "1.0" 25 | features = ["spin_no_std"] 26 | 27 | [dev-dependencies] 28 | kernel-module-testlib = { path = "../../../testlib" } 29 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/unitests/qp/src/console_msgs.rs: -------------------------------------------------------------------------------- 1 | pub static SUCC : [&str;2] = ["client ok","Dev ok"]; 2 | pub static ERR : [&str;2] = ["cleint err","Dev empty"]; 3 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/unitests/qp/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module}; 2 | 3 | #[test] 4 | fn test_dmesg() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/unitests/qp_state/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "qp_state_tests" 5 | version = "0.1.0" 6 | authors = ["CaribouW <1071956678@qq.com>"] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [lib] 12 | crate-type = ["staticlib"] 13 | test = false 14 | 15 | [features] 16 | default = ["KRdmaKit"] 17 | 18 | [dependencies] 19 | KRdmaKit = { path = "../..", optional = true, features = ["dct"] } 20 | hashbrown = { git = "https://github.com/ProjectMitosisOS/hashbrown.git", branch = "main" } 21 | 22 | ## lazy static 23 | [dependencies.lazy_static] 24 | version = "1.0" 25 | features = ["spin_no_std"] 26 | 27 | [dev-dependencies] 28 | kernel-module-testlib = { path = "../../../testlib" } 29 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/unitests/qp_state/src/console_msgs.rs: -------------------------------------------------------------------------------- 1 | pub static SUCC : [&str;2] = ["client ok","Dev ok"]; 2 | pub static ERR : [&str;2] = ["cleint err","Dev empty"]; 3 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/unitests/qp_state/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module}; 2 | 3 | #[test] 4 | fn test_dmesg() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/unitests/reg_mr/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "reg_mr_tests" 5 | version = "0.1.0" 6 | authors = ["CaribouW <1071956678@qq.com>"] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [lib] 12 | crate-type = ["staticlib"] 13 | test = false 14 | 15 | [features] 16 | default = ["KRdmaKit"] 17 | [dependencies] 18 | KRdmaKit = { path = "../..", optional = true, features = ["dct"] } 19 | hashbrown = { git = "https://github.com/ProjectMitosisOS/hashbrown.git", branch = "main" } 20 | 21 | ## lazy static 22 | [dependencies.lazy_static] 23 | version = "1.0" 24 | features = ["spin_no_std"] 25 | 26 | [dev-dependencies] 27 | kernel-module-testlib = { path = "../../../testlib" } 28 | 29 | [profile.dev] 30 | opt-level = 2 -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/unitests/reg_mr/src/console_msgs.rs: -------------------------------------------------------------------------------- 1 | pub static SUCC : [&str;2] = ["client ok","Dev ok"]; 2 | pub static ERR : [&str;2] = ["cleint err","Dev empty"]; 3 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/unitests/reg_mr/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module}; 2 | 3 | #[test] 4 | fn test_dmesg() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/unitests/rpc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "rpc_tests" 5 | version = "0.1.0" 6 | authors = ["CaribouW <1071956678@qq.com>"] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [lib] 12 | crate-type = ["staticlib"] 13 | test = false 14 | 15 | [features] 16 | default = ["KRdmaKit"] 17 | 18 | [dependencies] 19 | KRdmaKit = { path = "../..", optional = true, features = ["dct"] } 20 | hashbrown = { git = "https://github.com/ProjectMitosisOS/hashbrown.git", branch = "main" } 21 | 22 | ## lazy static 23 | [dependencies.lazy_static] 24 | version = "1.0" 25 | features = ["spin_no_std"] 26 | 27 | [dev-dependencies] 28 | kernel-module-testlib = { path = "../../../testlib" } 29 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/unitests/rpc/src/console_msgs.rs: -------------------------------------------------------------------------------- 1 | pub static SUCC : [&str;2] = ["client ok","Dev ok"]; 2 | pub static ERR : [&str;2] = ["cleint err","Dev empty"]; 3 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/KRdmaKit/unitests/rpc/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module}; 2 | 3 | #[test] 4 | fn test_dmesg() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/no-std-net/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "no-std-net" 3 | description = "Rust's std::net... without the 'std'." 4 | version = "0.4.0" 5 | authors = [ "M@ Dunlap " ] 6 | categories = [ "embedded", "network-programming", "no-std" ] 7 | repository = "https://github.com/dunmatt/no-std-net" 8 | license = "MIT" 9 | 10 | [badges] 11 | maintenance = { status = "actively-developed" } 12 | travis-ci = { repository = "dunmatt/no-std-net" } 13 | 14 | [dependencies] 15 | serde = { version = "^1", default-features = false, optional = true } 16 | 17 | [dev-dependencies] 18 | serde_test = "^1" 19 | 20 | [features] 21 | default = [ ] 22 | 23 | # Deprecated. Does nothing. 24 | i128 = [ ] 25 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/no-std-net/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 M@ 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/no-std-net/README.md: -------------------------------------------------------------------------------- 1 | // XD: forked from https://github.com/dunmatt/no-std-net 2 | 3 | # no-std-net 4 | Rust's std::net except without the std. 5 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/.gitignore: -------------------------------------------------------------------------------- 1 | **/target 2 | **/*.rs.bk 3 | Cargo.lock 4 | .cache.mk 5 | .*o.cmd 6 | .tmp_versions/ 7 | Module.symvers 8 | *.ko 9 | *.mod.c 10 | *.o 11 | modules.order 12 | dummy.c 13 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/.travis.yml: -------------------------------------------------------------------------------- 1 | matrix: 2 | include: 3 | - dist: bionic 4 | 5 | language: rust 6 | rust: 7 | - nightly-2020-08-27 8 | 9 | branches: 10 | only: 11 | - master 12 | 13 | install: 14 | - sudo apt-get install -y "linux-headers-$(uname -r)" coreutils 15 | - sudo apt-get install clang-9 16 | - rustup component add rust-src rustfmt clippy 17 | 18 | script: 19 | - CLANG=clang-9 ./tests/run_tests.py 20 | - | 21 | for p in . hello-world tests/*; do 22 | if [ -d "$p" ]; then 23 | (cd "$p" && cargo fmt --all -- --check) || exit 1 24 | fi 25 | done 26 | 27 | after_failure: 28 | - dmesg 29 | 30 | notifications: 31 | email: false 32 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We're always excited to have contributions of any form! 4 | 5 | Examples of contributions include: 6 | 7 | * Code patches 8 | * Documentation improvements 9 | * Bug reports and patch reviews 10 | 11 | ## Filing issues 12 | 13 | If you're filing an issue for a build error, please include enough information 14 | for us to diagnose and reproduce the issue. This generally means, at a minimum 15 | the kernel version (and, if it's not a vanilla upstream kernel, where you got 16 | the kernel from) and your compiler versions (Rust, Clang, and GCC). 17 | 18 | ## Contributing code 19 | 20 | To contribute code, you can send a pull request on Github. Please make sure your 21 | code is formatted with `cargo fmt`, builds, the tests pass, and it's `cargo 22 | clippy`-clean. Don't worry, we've got continuous integration if you miss 23 | anything. 24 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "linux-kernel-module" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | bitflags = "1" 9 | 10 | [build-dependencies] 11 | bindgen = "0.54" 12 | cc = "1.0" 13 | shlex = "0.1" 14 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/hello-world/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello-world" 3 | version = "0.1.0" 4 | authors = ["Geoffrey Thomas "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | 10 | [dependencies] 11 | linux-kernel-module = { path = ".." } 12 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/hello-world/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := helloworld.o 2 | helloworld-objs := hello_world.rust.o 3 | 4 | CARGO ?= cargo 5 | 6 | export c_flags 7 | 8 | $(src)/target/x86_64-linux-kernel/debug/libhello_world.a: cargo_will_determine_dependencies 9 | cd $(src); $(CARGO) build -Z build-std=core,alloc --target=x86_64-linux-kernel 10 | 11 | .PHONY: cargo_will_determine_dependencies 12 | 13 | %.rust.o: target/x86_64-linux-kernel/debug/lib%.a 14 | $(LD) -r -o $@ --whole-archive $< 15 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/hello-world/Makefile: -------------------------------------------------------------------------------- 1 | export KDIR ?= /lib/modules/$(shell uname -r)/build 2 | 3 | CLANG ?= clang-9 4 | ifeq ($(origin CC),default) 5 | CC := ${CLANG} 6 | endif 7 | 8 | all: 9 | $(MAKE) -C $(KDIR) M=$(CURDIR) CC=$(CC) CONFIG_CC_IS_CLANG=y 10 | 11 | clean: 12 | $(MAKE) -C $(KDIR) M=$(CURDIR) CC=$(CC) clean 13 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/hello-world/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | extern crate alloc; 4 | 5 | use alloc::borrow::ToOwned; 6 | use alloc::string::String; 7 | 8 | use linux_kernel_module::println; 9 | 10 | struct HelloWorldModule { 11 | message: String, 12 | } 13 | 14 | impl linux_kernel_module::KernelModule for HelloWorldModule { 15 | fn init() -> linux_kernel_module::KernelResult { 16 | println!("Hello kernel module!"); 17 | Ok(HelloWorldModule { 18 | message: "on the heap!".to_owned(), 19 | }) 20 | } 21 | } 22 | 23 | impl Drop for HelloWorldModule { 24 | fn drop(&mut self) { 25 | println!("My message is {}", self.message); 26 | println!("Goodbye kernel module!"); 27 | } 28 | } 29 | 30 | linux_kernel_module::kernel_module!( 31 | HelloWorldModule, 32 | author: b"Fish in a Barrel Contributors", 33 | description: b"An extremely simple kernel module", 34 | license: b"GPL" 35 | ); 36 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/scripts/copy_wxd.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | target="wxd@val01:~/projects/rust-kernel-module" 4 | 5 | rsync -i -rtuv \ 6 | $PWD/../. \ 7 | $target \ 8 | --exclude '../target' \ 9 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/src/allocator.rs: -------------------------------------------------------------------------------- 1 | use core::alloc::{GlobalAlloc, Layout}; 2 | use core::ptr; 3 | 4 | use crate::bindings; 5 | use crate::c_types; 6 | 7 | pub struct KernelAllocator; 8 | 9 | unsafe impl GlobalAlloc for KernelAllocator { 10 | unsafe fn alloc(&self, layout: Layout) -> *mut u8 { 11 | // krealloc is used instead of kmalloc because kmalloc is an inline function and can't be 12 | // bound to as a result 13 | bindings::krealloc(ptr::null(), layout.size(), bindings::GFP_KERNEL) as *mut u8 14 | } 15 | 16 | unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) { 17 | bindings::kfree(ptr as *const c_types::c_void); 18 | } 19 | } 20 | 21 | #[alloc_error_handler] 22 | fn oom(_layout: Layout) -> ! { 23 | panic!("Out of memory!"); 24 | } 25 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/src/bindings.rs: -------------------------------------------------------------------------------- 1 | #[allow( 2 | clippy::all, 3 | non_camel_case_types, 4 | non_upper_case_globals, 5 | non_snake_case, 6 | improper_ctypes 7 | )] 8 | mod bindings { 9 | use crate::c_types; 10 | include!(concat!(env!("OUT_DIR"), "/bindings.rs")); 11 | } 12 | pub use bindings::*; 13 | 14 | pub const GFP_KERNEL: gfp_t = BINDINGS_GFP_KERNEL; 15 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/src/bindings_helper.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | // Bindgen gets confused at certain things 11 | // 12 | const gfp_t BINDINGS_GFP_KERNEL = GFP_KERNEL; 13 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/src/c_types.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_camel_case_types)] 2 | 3 | #[cfg(target_arch = "x86_64")] 4 | mod c { 5 | use core::ffi; 6 | 7 | pub type c_int = i32; 8 | pub type c_char = i8; 9 | pub type c_long = i64; 10 | pub type c_longlong = i64; 11 | pub type c_short = i16; 12 | pub type c_uchar = u8; 13 | pub type c_uint = u32; 14 | pub type c_ulong = u64; 15 | pub type c_ulonglong = u64; 16 | pub type c_ushort = u16; 17 | pub type c_schar = i8; 18 | pub type c_size_t = usize; 19 | pub type c_ssize_t = isize; 20 | pub type c_void = ffi::c_void; 21 | } 22 | 23 | pub use c::*; 24 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/src/helpers.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | void 7 | mutex_init_helper(struct mutex* mutex) 8 | { 9 | mutex_init(mutex); 10 | } 11 | 12 | void bug_helper(void) 13 | { 14 | BUG(); 15 | } 16 | 17 | int access_ok_helper(const void __user *addr, unsigned long n) 18 | { 19 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) /* v5.0-rc1~46 */ 20 | return access_ok(addr, n); 21 | #else 22 | return access_ok(0, addr, n); 23 | #endif 24 | } 25 | 26 | /* see https://github.com/rust-lang/rust-bindgen/issues/1671 */ 27 | _Static_assert(__builtin_types_compatible_p(size_t, uintptr_t), 28 | "size_t must match uintptr_t, what architecture is this??"); 29 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/src/inline_helper.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void 4 | mutex_init_helper(struct mutex* mutex); -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/src/sync.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2020-2021 Andre Richter 4 | 5 | //! Synchronization primitives. 6 | //! 7 | //! # Resources 8 | //! 9 | //! - 10 | //! - 11 | //! - 12 | 13 | //-------------------------------------------------------------------------------------------------- 14 | // Public Definitions 15 | //-------------------------------------------------------------------------------------------------- 16 | 17 | /// Any object implementing this trait guarantees exclusive access to the data wrapped within 18 | /// the Mutex for the duration of the provided closure. 19 | pub trait Mutex<'a, T: 'a> { 20 | /// The type of the data that is wrapped by this mutex. 21 | // type Data; 22 | 23 | /// Locks the mutex and grants the closure temporary mutable access to the wrapped data. 24 | fn lock_f(&self, f: impl FnOnce(&'a mut T) -> R) -> R; 25 | } 26 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/testlib/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "kernel-module-testlib" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | tempfile = "3" 9 | libc = "0.2.58" 10 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := testmodule.o 2 | testmodule-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | 6 | export c_flags 7 | 8 | $(src)/target/x86_64-linux-kernel/debug/lib%.a: cargo_will_determine_dependencies 9 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=x86_64-linux-kernel 10 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) clippy -Z build-std=core,alloc --target=x86_64-linux-kernel -- -Dwarnings 11 | 12 | .PHONY: cargo_will_determine_dependencies 13 | 14 | %.rust.o: target/x86_64-linux-kernel/debug/lib%.a 15 | $(LD) -r -o $@ --whole-archive $< 16 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/Makefile: -------------------------------------------------------------------------------- 1 | export KDIR ?= /lib/modules/$(shell uname -r)/build 2 | 3 | CLANG ?= clang 4 | ifeq ($(origin CC),default) 5 | CC := ${CLANG} 6 | endif 7 | 8 | all: 9 | $(MAKE) -C $(KDIR) M=$(CURDIR) CC=$(CC) CONFIG_CC_IS_CLANG=y 10 | 11 | clean: 12 | $(MAKE) -C $(KDIR) M=$(CURDIR) CC=$(CC) clean 13 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/chrdev-region-allocation/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "chrdev-region-allocation-tests" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor ", "Geoffrey Thomas "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | test = false 10 | 11 | [features] 12 | default = ["linux-kernel-module"] 13 | 14 | [dependencies] 15 | linux-kernel-module = { path = "../..", optional = true } 16 | 17 | [dev-dependencies] 18 | kernel-module-testlib = { path = "../../testlib" } 19 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/chrdev-region-allocation/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | use linux_kernel_module::{self, cstr}; 4 | 5 | struct ChrdevRegionAllocationTestModule { 6 | _chrdev_reg: linux_kernel_module::chrdev::Registration, 7 | } 8 | 9 | impl linux_kernel_module::KernelModule for ChrdevRegionAllocationTestModule { 10 | fn init() -> linux_kernel_module::KernelResult { 11 | let chrdev_reg = 12 | linux_kernel_module::chrdev::builder(cstr!("chrdev-region-allocation-tests"), 0..1)? 13 | .build()?; 14 | 15 | Ok(ChrdevRegionAllocationTestModule { 16 | _chrdev_reg: chrdev_reg, 17 | }) 18 | } 19 | } 20 | 21 | linux_kernel_module::kernel_module!( 22 | ChrdevRegionAllocationTestModule, 23 | author: b"Fish in a Barrel Contributors", 24 | description: b"A module for testing character device region allocation", 25 | license: b"GPL" 26 | ); 27 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/chrdev-region-allocation/tests/tests.rs: -------------------------------------------------------------------------------- 1 | use std::fs; 2 | 3 | use kernel_module_testlib::with_kernel_module; 4 | 5 | #[test] 6 | fn test_proc_devices() { 7 | with_kernel_module(|| { 8 | let devices = fs::read_to_string("/proc/devices").unwrap(); 9 | let dev_no_line = devices 10 | .lines() 11 | .find(|l| l.ends_with("chrdev-region-allocation-tests")) 12 | .unwrap(); 13 | let elements = dev_no_line.rsplitn(2, " ").collect::>(); 14 | assert_eq!(elements.len(), 2); 15 | assert_eq!(elements[0], "chrdev-region-allocation-tests"); 16 | assert!(elements[1].trim().parse::().is_ok()); 17 | }); 18 | 19 | let devices = fs::read_to_string("/proc/devices").unwrap(); 20 | assert!(devices 21 | .lines() 22 | .find(|l| l.ends_with("chrdev-region-allocation-tests")) 23 | .is_none()); 24 | } 25 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/chrdev/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "chrdev-tests" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor ", "Geoffrey Thomas "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | test = false 10 | 11 | [features] 12 | default = ["linux-kernel-module"] 13 | 14 | [dependencies] 15 | linux-kernel-module = { path = "../..", optional = true } 16 | 17 | [dev-dependencies] 18 | kernel-module-testlib = { path = "../../testlib" } 19 | libc = "0.2.58" 20 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/filesystem/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "filesystem-tests" 3 | version = "0.1.0" 4 | authors = ["Luis Gerhorst ", "Alex Gaynor ", "Geoffrey Thomas "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | test = false 10 | 11 | [features] 12 | default = ["linux-kernel-module"] 13 | 14 | [dependencies] 15 | linux-kernel-module = { path = "../..", optional = true } 16 | 17 | [dev-dependencies] 18 | kernel-module-testlib = { path = "../../testlib" } 19 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/filesystem/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | extern crate alloc; 4 | 5 | use linux_kernel_module::filesystem::{self, FileSystem, FileSystemFlags}; 6 | use linux_kernel_module::{self, cstr, CStr}; 7 | 8 | struct TestFSModule { 9 | _fs_registration: filesystem::Registration, 10 | } 11 | 12 | struct TestFS {} 13 | 14 | impl FileSystem for TestFS { 15 | const NAME: CStr<'static> = cstr!("testfs"); 16 | const FLAGS: FileSystemFlags = FileSystemFlags::empty(); 17 | } 18 | 19 | impl linux_kernel_module::KernelModule for TestFSModule { 20 | fn init() -> linux_kernel_module::KernelResult { 21 | let fs_registration = filesystem::register::()?; 22 | Ok(TestFSModule { 23 | _fs_registration: fs_registration, 24 | }) 25 | } 26 | } 27 | 28 | linux_kernel_module::kernel_module!( 29 | TestFSModule, 30 | author: b"Fish in a Barrel Contributors", 31 | description: b"A module for testing filesystem::register", 32 | license: b"GPL" 33 | ); 34 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/filesystem/tests/tests.rs: -------------------------------------------------------------------------------- 1 | use std::fs; 2 | 3 | use kernel_module_testlib::with_kernel_module; 4 | 5 | #[test] 6 | fn test_proc_filesystems() { 7 | let filesystems = fs::read_to_string("/proc/filesystems").unwrap(); 8 | assert!(!filesystems.contains("testfs")); 9 | 10 | with_kernel_module(|| { 11 | let filesystems = fs::read_to_string("/proc/filesystems").unwrap(); 12 | assert!(filesystems.contains("testfs")); 13 | }); 14 | 15 | let filesystems = fs::read_to_string("/proc/filesystems").unwrap(); 16 | assert!(!filesystems.contains("testfs")); 17 | } 18 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/modinfo/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "modinfo-tests" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor ", "Geoffrey Thomas "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | test = false 10 | 11 | [features] 12 | default = ["linux-kernel-module"] 13 | 14 | [dependencies] 15 | linux-kernel-module = { path = "../..", optional = true } 16 | 17 | [dev-dependencies] 18 | kernel-module-testlib = { path = "../../testlib" } 19 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/modinfo/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | struct ModinfoTestModule; 4 | 5 | impl linux_kernel_module::KernelModule for ModinfoTestModule { 6 | fn init() -> linux_kernel_module::KernelResult { 7 | Ok(ModinfoTestModule) 8 | } 9 | } 10 | 11 | linux_kernel_module::kernel_module!( 12 | ModinfoTestModule, 13 | author: b"Fish in a Barrel Contributors", 14 | description: b"Empty module for testing modinfo", 15 | license: b"GPL" 16 | ); 17 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/printk/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "printk-tests" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor ", "Geoffrey Thomas "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | test = false 10 | 11 | [features] 12 | default = ["linux-kernel-module"] 13 | 14 | [dependencies] 15 | linux-kernel-module = { path = "../..", optional = true } 16 | 17 | [dev-dependencies] 18 | kernel-module-testlib = { path = "../../testlib" } 19 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/printk/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | #![allow(clippy::print_literal)] 3 | 4 | use linux_kernel_module::{self, println}; 5 | 6 | struct PrintkTestModule; 7 | 8 | impl linux_kernel_module::KernelModule for PrintkTestModule { 9 | fn init() -> linux_kernel_module::KernelResult { 10 | println!("Single element printk"); 11 | println!(); 12 | println!("printk with {} parameters{}", 2, "!"); 13 | 14 | Ok(PrintkTestModule) 15 | } 16 | } 17 | 18 | linux_kernel_module::kernel_module!( 19 | PrintkTestModule, 20 | author: b"Fish in a Barrel Contributors", 21 | description: b"A module for testing println!()", 22 | license: b"GPL" 23 | ); 24 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/printk/tests/tests.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{assert_dmesg_contains, with_kernel_module}; 2 | 3 | #[test] 4 | fn test_printk() { 5 | with_kernel_module(|| { 6 | assert_dmesg_contains(&[b"Single element printk", b"", b"printk with 2 parameters!"]); 7 | }); 8 | } 9 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/random/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "random-tests" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor ", "Geoffrey Thomas "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | test = false 10 | 11 | [features] 12 | default = ["linux-kernel-module"] 13 | 14 | [dependencies] 15 | linux-kernel-module = { path = "../..", optional = true } 16 | 17 | [dev-dependencies] 18 | kernel-module-testlib = { path = "../../testlib" } 19 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/random/tests/tests.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashSet; 2 | use std::fs; 3 | use std::io::Read; 4 | 5 | use kernel_module_testlib::with_kernel_module; 6 | 7 | #[test] 8 | fn test_random_entropy_read() { 9 | with_kernel_module(|| { 10 | let mut keys = HashSet::new(); 11 | for _ in 0..1024 { 12 | let mut key = [0; 16]; 13 | let mut f = fs::File::open("/proc/sys/rust/random-tests/entropy").unwrap(); 14 | f.read_exact(&mut key).unwrap(); 15 | keys.insert(key); 16 | } 17 | assert_eq!(keys.len(), 1024); 18 | }); 19 | } 20 | 21 | #[test] 22 | fn test_random_entropy_write() { 23 | with_kernel_module(|| { 24 | fs::write("/proc/sys/rust/random-tests/entropy", b"1234567890").unwrap(); 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/sysctl-get/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sysctl-get-tests" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | test = false 10 | 11 | [features] 12 | default = ["linux-kernel-module"] 13 | 14 | [dependencies] 15 | linux-kernel-module = { path = "../..", optional = true } 16 | 17 | [dev-dependencies] 18 | kernel-module-testlib = { path = "../../testlib" } 19 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/sysctl-get/tests/tests.rs: -------------------------------------------------------------------------------- 1 | use std::fs; 2 | 3 | use kernel_module_testlib::{assert_dmesg_contains, with_kernel_module}; 4 | 5 | #[test] 6 | fn test_get() { 7 | with_kernel_module(|| { 8 | fs::write("/proc/sys/rust/sysctl-get-tests/a", "1").unwrap(); 9 | }); 10 | assert_dmesg_contains(&[b"A_VAL: true", b"SYSCTL_A: true"]); 11 | } 12 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/sysctl/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sysctl-tests" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | test = false 10 | 11 | [features] 12 | default = ["linux-kernel-module"] 13 | 14 | [dependencies] 15 | linux-kernel-module = { path = "../..", optional = true } 16 | 17 | [dev-dependencies] 18 | kernel-module-testlib = { path = "../../testlib" } 19 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/utils/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "utils-tests" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor ", "Geoffrey Thomas "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | test = false 10 | 11 | [features] 12 | default = ["linux-kernel-module"] 13 | 14 | [dependencies] 15 | linux-kernel-module = { path = "../..", optional = true } 16 | 17 | [dev-dependencies] 18 | kernel-module-testlib = { path = "../../testlib" } 19 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/utils/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | struct UtilsTestModule; 4 | 5 | #[allow(dead_code)] 6 | const TEST_CSTR: linux_kernel_module::CStr<'static> = linux_kernel_module::cstr!("abc"); 7 | 8 | impl linux_kernel_module::KernelModule for UtilsTestModule { 9 | fn init() -> linux_kernel_module::KernelResult { 10 | Ok(UtilsTestModule) 11 | } 12 | } 13 | 14 | linux_kernel_module::kernel_module!( 15 | UtilsTestModule, 16 | author: b"Fish in a Barrel Contributors", 17 | description: b"A module for testing various utilities", 18 | license: b"GPL" 19 | ); 20 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/deps/rust-kernel-module/tests/utils/tests/tests.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::with_kernel_module; 2 | 3 | #[test] 4 | fn test_module_loads() { 5 | with_kernel_module(|| {}); 6 | } 7 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-linux-util/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust-kernel-linux-util" 3 | version = "0.1.0" 4 | authors = ["CaribouW <1071956678@qq.com>"] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | linux-kernel-module = { path = "../deps/rust-kernel-module" } 11 | no-std-net = {path = "../deps/no-std-net" } 12 | 13 | 14 | [build-dependencies] 15 | bindgen = "0.54" 16 | cc = "1.0" 17 | shlex = "0.1" -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-linux-util/README.md: -------------------------------------------------------------------------------- 1 | # rust-kernel-linux-util 2 | ## Tested linux kernel version 3 | - kernel `4.15.0-46-generic` 4 | ## Rust dependency 5 | 6 | install rustc 7 | 8 | ```sh 9 | curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh 10 | ``` 11 | 12 | Currently, RLib is only tested on a specific version of `rust`: `rustup-nightly` @**version 2020-11-10**. 13 | We will fix problem using the latest rust compiler in the future. 14 | 15 | ```sh 16 | rustup default nightly-2020-11-10-x86_64-unknown-linux-gnu 17 | rustup component add rust-src 18 | ``` 19 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-linux-util/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | //! Utils used for native linux interface 4 | #[allow(non_upper_case_globals)] 5 | 6 | pub use linux_kernel_module; 7 | pub mod timer; 8 | 9 | /// core module, direct export the kernel's internal C functions related to RDMA 10 | /// note that we shall not use `pub use bindings::*;` 11 | /// this is because it will export functions/types related to linux kernel 12 | pub mod bindings; 13 | pub mod rwlock; 14 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-linux-util/unitests/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := testmodule.o 2 | testmodule-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | 6 | export c_flags 7 | export UTEST 8 | 9 | $(src)/target/x86_64-linux-kernel/debug/lib%.a: cargo_will_determine_dependencies 10 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=x86_64-linux-kernel 11 | # cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) clippy -Z build-std=core,alloc --target=x86_64-linux-kernel -- -Dwarnings 12 | 13 | .PHONY: cargo_will_determine_dependencies 14 | 15 | %.rust.o: target/x86_64-linux-kernel/debug/lib%.a 16 | $(LD) -r -o $@ --whole-archive $< 17 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-linux-util/unitests/sample/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "sample_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["rust-kernel-rdma-base"] 16 | 17 | [dependencies] 18 | rust-kernel-rdma-base = {path = "../../../rust-kernel-rdma-base",optional = true} 19 | 20 | 21 | [dev-dependencies] 22 | kernel-module-testlib = { path = "../../../testlib" } 23 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-linux-util/unitests/sample/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | struct SampleTestModule { 4 | } 5 | 6 | use rust_kernel_rdma_base::linux_kernel_module; 7 | use linux_kernel_module::println; 8 | 9 | impl linux_kernel_module::KernelModule for SampleTestModule { 10 | fn init() -> linux_kernel_module::KernelResult { 11 | println!("sample test module in raw kernel rdma bindings!"); 12 | 13 | println!("check version"); 14 | Ok(Self {}) 15 | } 16 | } 17 | 18 | linux_kernel_module::kernel_module!( 19 | SampleTestModule, 20 | author: b"xmm", 21 | description: b"A sample module for unit testing", 22 | license: b"GPL" 23 | ); 24 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-linux-util/unitests/sample/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module,assert_dmesg_ends,assert_dmesg_contains, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_simple() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | println!("sampe test"); 8 | 9 | let test_strs = ["bindings!".as_bytes()]; 10 | assert_dmesg_ends(&test_strs); 11 | 12 | let test_strs2 = [String::from("raw kernel")]; 13 | assert_dmesg_contains(&test_strs2); 14 | 15 | assert_eq!(dmesg_contains(&String::from("unknown")),false); 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust-kernel-rdma-base" 3 | version = "0.1.0" 4 | authors = ["xmm "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | linux-kernel-module = { path = "../deps/rust-kernel-module" } 11 | rust-kernel-linux-util = { path = "../rust-kernel-linux-util" } 12 | no-std-net = {path = "../deps/no-std-net" } 13 | paste = "1.0" 14 | 15 | [build-dependencies] 16 | bindgen = "0.54" 17 | cc = "1.0" 18 | shlex = "0.1" 19 | 20 | [features] 21 | dct = [] -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/README.md: -------------------------------------------------------------------------------- 1 | # rust-kernel-rdma-base 2 | 3 | > Raw RDMA interface communicate with C linux kernel 4 | 5 | This module is the lowest tier to the raw linux kernel, close to 6 | the linux native functions/type definitions for `RDMA`. The upper kernel rdma 7 | interface(`KRdmaKit`) could directly use the service in this module. 8 | 9 | ## Tested linux kernel version 10 | - kernel `4.15.0-46-generic` 11 | ## Rust dependency 12 | 13 | install rustc 14 | 15 | ```sh 16 | curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh 17 | ``` 18 | 19 | Currently, RLib is only tested on a specific version of `rust`: `rustup-nightly` @**version 2020-11-10**. 20 | We will fix problem using the latest rust compiler in the future. 21 | 22 | ```sh 23 | rustup default nightly-2020-11-10-x86_64-unknown-linux-gnu 24 | rustup component add rust-src 25 | ``` 26 | 27 | ## RDMA dependencies 28 | - MLNX_OFED_LINUX-4.4-2.0.7.0 (OFED-4.4-2.0.7)` 29 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/src/allocator.rs: -------------------------------------------------------------------------------- 1 | //use core::alloc::{Layout, AllocRef, AllocError}; 2 | use core::alloc::{AllocError, Allocator}; 3 | use core::ptr::NonNull; 4 | 5 | use core::alloc::Layout; 6 | 7 | use crate::linux_kernel_module::c_types; 8 | 9 | use crate::rust_kernel_linux_util::bindings; 10 | 11 | #[derive(Copy, Clone, Default, Debug)] 12 | pub struct VmallocAllocator; 13 | 14 | unsafe impl Allocator for VmallocAllocator { 15 | fn allocate(&self, layout: Layout) -> Result, AllocError> { 16 | match layout.size() { 17 | 0 => Ok(NonNull::slice_from_raw_parts(layout.dangling(), 0)), 18 | // SAFETY: `layout` is non-zero in size, 19 | size => { 20 | let raw_ptr = unsafe { bindings::vmalloc(size as u64) } as *mut u8; 21 | let ptr = NonNull::new(raw_ptr).ok_or(AllocError)?; 22 | Ok(NonNull::slice_from_raw_parts(ptr, size)) 23 | } 24 | } 25 | } 26 | 27 | unsafe fn deallocate(&self, ptr: NonNull, _layout: Layout) { 28 | bindings::vfree(ptr.as_ptr() as *const c_types::c_void); 29 | } 30 | } -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/src/bindings.rs: -------------------------------------------------------------------------------- 1 | #[allow( 2 | clippy::all, 3 | non_camel_case_types, 4 | non_upper_case_globals, 5 | non_snake_case, 6 | improper_ctypes, 7 | non_upper_case_globals, 8 | dead_code 9 | )] 10 | mod bindings { 11 | use linux_kernel_module::c_types; 12 | include!(concat!(env!("OUT_DIR"), "/bindings-",env!("CARGO_PKG_NAME"),".rs")); 13 | } 14 | 15 | pub use bindings::*; 16 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/src/consts.rs: -------------------------------------------------------------------------------- 1 | pub const MAX_UD_RECV_CQE: usize = 2048; 2 | pub const MAX_UD_RECV_WR: usize = 2048; 3 | 4 | 5 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/unitests/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := testmodule.o 2 | testmodule-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | 6 | export c_flags 7 | export UTEST 8 | 9 | $(src)/target/x86_64-linux-kernel/debug/lib%.a: cargo_will_determine_dependencies 10 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=x86_64-linux-kernel 11 | # cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) clippy -Z build-std=core,alloc --target=x86_64-linux-kernel -- -Dwarnings 12 | 13 | .PHONY: cargo_will_determine_dependencies 14 | 15 | %.rust.o: target/x86_64-linux-kernel/debug/lib%.a 16 | $(LD) -r -o $@ --whole-archive $< 17 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/unitests/cm_funcs/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "cm_funcs_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["rust-kernel-rdma-base"] 16 | 17 | [dependencies] 18 | rust-kernel-rdma-base = {path = "../..",optional = true} 19 | 20 | ## lazy static 21 | [dependencies.lazy_static] 22 | version = "1.0" 23 | features = ["spin_no_std"] 24 | 25 | 26 | [dev-dependencies] 27 | kernel-module-testlib = { path = "../../../testlib" } 28 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/unitests/cm_funcs/src/console_msgs.rs: -------------------------------------------------------------------------------- 1 | pub static SUCC : [&str;2] = ["client ok","Dev ok"]; 2 | pub static ERR : [&str;2] = ["cleint err","Dev empty"]; 3 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/unitests/cm_funcs/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module,dmesg_contains}; 2 | 3 | #[test] 4 | fn test_cm_funcs_exists() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | // other err messages 8 | assert_eq!(dmesg_contains(&String::from("null")),false); 9 | }); 10 | } 11 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/unitests/create_dct/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "create_dct_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["rust-kernel-rdma-base"] 16 | 17 | [dependencies] 18 | rust-kernel-rdma-base = {path = "../..",optional = true, features=["dct"]} 19 | 20 | ## lazy static 21 | [dependencies.lazy_static] 22 | version = "1.0" 23 | features = ["spin_no_std"] 24 | 25 | 26 | [dev-dependencies] 27 | kernel-module-testlib = { path = "../../../testlib" } 28 | 29 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/unitests/create_dct/src/console_msgs.rs: -------------------------------------------------------------------------------- 1 | pub static SUCC : [&str;2] = ["client ok","Dev ok"]; 2 | pub static ERR : [&str;2] = ["cleint err","Dev empty"]; 3 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/unitests/create_dct/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module,assert_dmesg_contains,dmesg_contains}; 2 | 3 | #[test] 4 | fn test_create_dct() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | // ok strings 8 | let test_strs2 = [String::from("client ok"), String::from("create cq ok")]; 9 | assert_dmesg_contains(&test_strs2); 10 | 11 | // bad msgs 12 | assert_eq!(dmesg_contains(&String::from("null cq")),false); 13 | assert_eq!(dmesg_contains(&String::from("null qp")),false); 14 | 15 | // other err messages 16 | assert_eq!(dmesg_contains(&String::from("err")),false); 17 | 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/unitests/create_qps/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "create_qps_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["rust-kernel-rdma-base"] 16 | 17 | [dependencies] 18 | rust-kernel-rdma-base = {path = "../..",optional = true} 19 | 20 | ## lazy static 21 | [dependencies.lazy_static] 22 | version = "1.0" 23 | features = ["spin_no_std"] 24 | 25 | 26 | [dev-dependencies] 27 | kernel-module-testlib = { path = "../../../testlib" } 28 | 29 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/unitests/create_qps/src/console_msgs.rs: -------------------------------------------------------------------------------- 1 | pub static SUCC : [&str;2] = ["client ok","Dev ok"]; 2 | pub static ERR : [&str;2] = ["cleint err","Dev empty"]; 3 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/unitests/create_qps/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module,assert_dmesg_contains,dmesg_contains}; 2 | 3 | #[test] 4 | fn test_create_qp() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | // ok strings 8 | let test_strs2 = [String::from("client ok"), String::from("create cq ok")]; 9 | assert_dmesg_contains(&test_strs2); 10 | 11 | // bad msgs 12 | assert_eq!(dmesg_contains(&String::from("null cq")),false); 13 | assert_eq!(dmesg_contains(&String::from("null qp")),false); 14 | 15 | // other err messages 16 | assert_eq!(dmesg_contains(&String::from("err")),false); 17 | 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/unitests/get_devices/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "get_devices_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["rust-kernel-rdma-base"] 16 | 17 | [dependencies] 18 | rust-kernel-rdma-base = {path = "../..",optional = true} 19 | 20 | ## lazy static 21 | [dependencies.lazy_static] 22 | version = "1.0" 23 | features = ["spin_no_std"] 24 | 25 | 26 | [dev-dependencies] 27 | kernel-module-testlib = { path = "../../../testlib" } 28 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/unitests/get_devices/src/console_msgs.rs: -------------------------------------------------------------------------------- 1 | pub static SUCC : [&str;2] = ["client ok","Dev ok"]; 2 | pub static ERR : [&str;2] = ["cleint err","Dev empty"]; 3 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/unitests/get_devices/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module,assert_dmesg_contains,dmesg_contains}; 2 | 3 | #[test] 4 | fn test_getdev() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | // ok strings 8 | let test_strs2 = [String::from("client ok"), String::from("Dev ok")]; 9 | assert_dmesg_contains(&test_strs2); 10 | 11 | // bad msgs 12 | assert_eq!(dmesg_contains(&String::from("client err")),false); 13 | assert_eq!(dmesg_contains(&String::from("Dev empty")),false); 14 | assert_eq!(dmesg_contains(&String::from("err")),false); 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/unitests/sample/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "sample_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["rust-kernel-rdma-base"] 16 | 17 | [dependencies] 18 | rust-kernel-rdma-base = {path = "../..",optional = true} 19 | 20 | 21 | [dev-dependencies] 22 | kernel-module-testlib = { path = "../../../testlib" } 23 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/unitests/sample/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | struct SampleTestModule { 4 | } 5 | 6 | use rust_kernel_rdma_base::linux_kernel_module; 7 | use linux_kernel_module::println; 8 | 9 | impl linux_kernel_module::KernelModule for SampleTestModule { 10 | fn init() -> linux_kernel_module::KernelResult { 11 | println!("sample test module in raw kernel rdma bindings!"); 12 | 13 | println!("check version"); 14 | Ok(Self {}) 15 | } 16 | } 17 | 18 | linux_kernel_module::kernel_module!( 19 | SampleTestModule, 20 | author: b"xmm", 21 | description: b"A sample module for unit testing", 22 | license: b"GPL" 23 | ); 24 | -------------------------------------------------------------------------------- /KRdmaKit-syscall/two-sided-dc/rust-kernel-rdma-base/unitests/sample/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module,assert_dmesg_ends,assert_dmesg_contains, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_simple() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | println!("sampe test"); 8 | 9 | let test_strs = ["bindings!".as_bytes()]; 10 | assert_dmesg_ends(&test_strs); 11 | 12 | let test_strs2 = [String::from("raw kernel")]; 13 | assert_dmesg_contains(&test_strs2); 14 | 15 | assert_eq!(dmesg_contains(&String::from("unknown")),false); 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /KRdmaKit/examples/hello.rs: -------------------------------------------------------------------------------- 1 | #[allow(non_snake_case)] 2 | extern crate KRdmaKit; 3 | use KRdmaKit::*; 4 | 5 | fn main() { 6 | println!( 7 | "Num RDMA devices found: {}", 8 | UDriver::create().unwrap().devices().len() 9 | ); 10 | } 11 | -------------------------------------------------------------------------------- /KRdmaKit/examples/ib-exp.rs: -------------------------------------------------------------------------------- 1 | #[allow(non_snake_case)] 2 | extern crate KRdmaKit; 3 | 4 | #[allow(unused_imports)] 5 | use KRdmaKit::*; 6 | 7 | /// Aims to use RDMA's advanced APIs 8 | fn main() { 9 | #[cfg(feature = "exp")] 10 | { 11 | let ctx = UDriver::create() 12 | .expect("failed to query device") 13 | .devices() 14 | .into_iter() 15 | .next() 16 | .expect("no rdma device available") 17 | .open_context() 18 | .expect("failed to create RDMA context"); 19 | 20 | let device_attr = ctx.get_exp_device_attr().unwrap(); 21 | println!("check device max atomic arg {}", device_attr.exp_atomic_cap); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /KRdmaKit/src/consts.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused)] 2 | 3 | //! Consts used in the whole KRdmaKit module 4 | mod inner { 5 | pub const IB_PD_UNSAFE_GLOBAL_RKEY: usize = 0x01; 6 | pub const CONNECT_TIME_OUT_MS: rdma_shim::ffi::c_types::c_int = 5000; // connect time out. set 5 seconds 7 | 8 | //pub const AF_INET: sa_family_t = 2; 9 | //pub const AF_UNSPEC: sa_family_t = 0; 10 | 11 | pub const MAX_RD_ATOMIC: usize = 16; 12 | 13 | // max kmalloc size in kernel module (4M) 14 | pub const MAX_KMALLOC_SZ: usize = 1024 * 1024 * 4; 15 | pub const K_REG_ALWAYS: bool = true; 16 | 17 | // RPC related 18 | pub const DEFAULT_RPC_HINT: usize = 73; 19 | pub const UD_HEADER_SZ: usize = 40; 20 | 21 | pub const DEFAULT_TWO_SIDED_RC_VID: usize = 1024; 22 | } 23 | 24 | pub use inner::*; 25 | -------------------------------------------------------------------------------- /KRdmaKit/src/random.rs: -------------------------------------------------------------------------------- 1 | /// taken from a java-version implementation: 2 | /// http://developer.classpath.org/doc/java/util/Random-source.htmlv 3 | #[allow(dead_code)] 4 | pub struct FastRandom { 5 | seed: u64, 6 | } 7 | 8 | #[allow(dead_code)] 9 | impl FastRandom { 10 | pub fn new(seed: u64) -> Self { 11 | Self { 12 | seed: Self::set_seed0(seed), 13 | } 14 | } 15 | 16 | pub fn get_next(&mut self) -> u64 { 17 | self.next(32).wrapping_shl(32).wrapping_add(self.next(32)) 18 | } 19 | 20 | pub fn get_cur_seed(&self) -> u64 { 21 | self.seed 22 | } 23 | 24 | #[inline] 25 | fn next(&mut self, bits: usize) -> u64 { 26 | self.seed = (self 27 | .seed 28 | .wrapping_mul(0x5DEECE66D as u64) 29 | .wrapping_add(0xB as u64)) 30 | & (((1 as u64) << 48) - 1); 31 | // self.seed 32 | self.seed.wrapping_shr((48 - bits) as u32) 33 | } 34 | 35 | #[inline] 36 | fn set_seed0(seed: u64) -> u64 { 37 | (seed ^ (0x5DEECE66D as u64)) & (((1 as u64) << 48) - 1) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /KRdmaKit/src/runtime/error.rs: -------------------------------------------------------------------------------- 1 | use failure::Fail; 2 | 3 | #[derive(Fail, Debug)] 4 | pub enum RuntimeError { 5 | #[fail(display = "{}", _0)] 6 | Error(&'static str), 7 | } 8 | -------------------------------------------------------------------------------- /KRdmaKit/src/runtime/mod.rs: -------------------------------------------------------------------------------- 1 | //! A basic runtime structure for Rust async programming 2 | //! 3 | //! This module provides runtime functionality for the cooperative scheduling 4 | //! 5 | //! # Organization 6 | //! 7 | //! - [`waitable::Waitable`] allows you to build your own waiting function by implementing this trait. 8 | //! - [`worker_group::WorkerGroup`] controls [`worker::Worker`]'s lifetime, you can submit new workers to it and spawn tasks on a specific worker 9 | //! - [`worker::Worker`] is the core struct of this runtime. Each `Worker` runs in a separate thread and has its own context. A worker must be started manually. 10 | //! 11 | //! 12 | //! 13 | //! 14 | //! 15 | //! 16 | 17 | 18 | mod error; 19 | mod task; 20 | mod tid; 21 | mod wake_fn; 22 | 23 | pub mod waitable; 24 | pub mod worker_group; 25 | pub mod worker; 26 | 27 | pub use task::yield_now; 28 | -------------------------------------------------------------------------------- /KRdmaKit/src/runtime/tid.rs: -------------------------------------------------------------------------------- 1 | use std::sync::atomic::{AtomicUsize, Ordering}; 2 | 3 | pub(super) type TaskId = usize; 4 | 5 | /// [`TaskIdGenerator`] generates task_id in incremental sequence. Each worker has its own TaskIdGenerator. 6 | pub(super) struct TaskIdGenerator { 7 | next: AtomicUsize, 8 | } 9 | 10 | impl TaskIdGenerator { 11 | pub(super) fn new() -> Self { 12 | Self { 13 | next: AtomicUsize::new(0), 14 | } 15 | } 16 | 17 | #[inline] 18 | pub(super) fn next(&self) -> TaskId { 19 | self.next.fetch_add(1, Ordering::SeqCst) 20 | } 21 | } 22 | 23 | unsafe impl Send for TaskIdGenerator {} 24 | unsafe impl Sync for TaskIdGenerator {} 25 | -------------------------------------------------------------------------------- /KRdmaKit/src/services/dc.rs: -------------------------------------------------------------------------------- 1 | use super::{GenerateConnectionReply, GetQueuePairInfo}; 2 | 3 | #[allow(dead_code)] 4 | #[repr(C, align(8))] 5 | #[derive(Copy, Clone, Debug)] 6 | pub struct DynamicConnectedMeta { 7 | pub datagram_addr: super::DatagramMeta, 8 | pub dct_num: u32, 9 | pub dc_key: u64, 10 | } 11 | 12 | impl GenerateConnectionReply for crate::queue_pairs::DynamicConnectedTarget { 13 | fn generate_connection_reply( 14 | &self, 15 | ) -> Result { 16 | Ok(DynamicConnectedMeta { 17 | datagram_addr: self.get_datagram_meta()?, 18 | dct_num: self.dct_num(), 19 | dc_key: self.dc_key(), 20 | }) 21 | } 22 | } 23 | 24 | /// A dummy implementation of the trait 25 | /// DCT metadata doesn't really need this 26 | impl GetQueuePairInfo for crate::queue_pairs::DynamicConnectedTarget { 27 | fn get_qkey(&self) -> u32 { 28 | 0 29 | } 30 | 31 | fn get_qp_num(&self) -> u32 { 32 | 0 33 | } 34 | } 35 | 36 | pub type DCTargetService = 37 | super::ConnectionService; 38 | -------------------------------------------------------------------------------- /KRdmaKit/src/utils.rs: -------------------------------------------------------------------------------- 1 | use crate::alloc::string::ToString; 2 | use rdma_shim::ffi::c_types::c_char; 3 | 4 | use alloc::string::String; 5 | 6 | pub fn convert_c_str_to_string<'s>(string: &'s [c_char]) -> String { 7 | let mut count = 0; 8 | 9 | for i in 0..string.len() { 10 | if string[i] == 0 { 11 | break; 12 | } else { 13 | count += 1; 14 | } 15 | } 16 | 17 | if count == 0 { 18 | String::from("\0") 19 | } else { 20 | unsafe { 21 | core::str::from_utf8_unchecked(core::slice::from_raw_parts(string.as_ptr() as _, count)) 22 | .to_string() 23 | } 24 | } 25 | } 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /KRdmaKit/unitests-kernel/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := testmodule.o 2 | testmodule-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | export UTEST 9 | 10 | $(src)/target/$(TARGET)/debug/lib%.a: cargo_will_determine_dependencies 11 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) 12 | 13 | .PHONY: cargo_will_determine_dependencies 14 | 15 | %.rust.o: target/$(TARGET)/debug/lib%.a 16 | $(LD) -r -o $@ --whole-archive $< 17 | -------------------------------------------------------------------------------- /KRdmaKit/unitests-kernel/comm_manager/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_cm() { 5 | with_kernel_module(|| { 6 | // log::error! will print ERROR in dmesg 7 | assert_eq!(dmesg_contains(&String::from("ERROR")),false); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /KRdmaKit/unitests-kernel/comm_manager_error/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_cm() { 5 | with_kernel_module(|| { 6 | // log::error! will print ERROR in dmesg 7 | // however, this test will always print error log in the kernel 8 | // we only to ensure there is not "general protection fault" in the kernel 9 | assert_eq!(dmesg_contains(&String::from("general protection fault")),false); 10 | }); 11 | } 12 | -------------------------------------------------------------------------------- /KRdmaKit/unitests-kernel/dynamic_connected_transport/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_dynamic_connected_transport_related_tests() { 5 | with_kernel_module(|| { 6 | // log::error! will print ERROR in dmesg 7 | assert_eq!(dmesg_contains(&String::from("ERROR")),false); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /KRdmaKit/unitests-kernel/global_context/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | #![feature(get_mut_unchecked)] 3 | #[warn(non_snake_case)] 4 | #[warn(dead_code)] 5 | extern crate alloc; 6 | 7 | use rust_kernel_linux_util as log; 8 | 9 | use krdma_test::*; 10 | use KRdmaKit::rdma_shim::linux_kernel_module; 11 | 12 | #[krdma_main] 13 | fn test_global_context() { 14 | use KRdmaKit::KDriver; 15 | let driver = unsafe { KDriver::create().unwrap() }; 16 | let client_dev = driver 17 | .devices() 18 | .into_iter() 19 | .next() 20 | .expect("no rdma device available"); 21 | //.open() 22 | //.unwrap(); 23 | log::info!("{:?} ", client_dev.get_device_attr()); 24 | 25 | for i in 1..5 { 26 | log::info!("check port {} res: {:?}", i, client_dev.get_port_attr(i)); 27 | } 28 | 29 | let client_ctx = client_dev.open_context(); 30 | log::info!("ctx open result: {:?}", client_ctx); 31 | 32 | log::info!("pass all tests"); 33 | } 34 | -------------------------------------------------------------------------------- /KRdmaKit/unitests-kernel/global_context/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_dmesg() { 5 | with_kernel_module(|| { 6 | // log::error! will print ERROR in dmesg 7 | assert_eq!(dmesg_contains(&String::from("ERROR")),false); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /KRdmaKit/unitests-kernel/memory_region/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_memory_region() { 5 | with_kernel_module(|| { 6 | // log::error! will print ERROR in dmesg 7 | assert_eq!(dmesg_contains(&String::from("ERROR")),false); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /KRdmaKit/unitests-kernel/reliable_connection/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_reliable_connection_related_tests() { 5 | with_kernel_module(|| { 6 | // log::error! will print ERROR in dmesg 7 | assert_eq!(dmesg_contains(&String::from("ERROR")),false); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /KRdmaKit/unitests-kernel/unreliable_datagram/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_unreliable_datagram_related_tests() { 5 | with_kernel_module(|| { 6 | // log::error! will print ERROR in dmesg 7 | assert_eq!(dmesg_contains(&String::from("ERROR")),false); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /benchs/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := testmodule.o 2 | testmodule-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | 6 | export c_flags 7 | export UTEST 8 | 9 | $(src)/target/x86_64-linux-kernel/debug/lib%.a: cargo_will_determine_dependencies 10 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=x86_64-linux-kernel 11 | # cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) clippy -Z build-std=core,alloc --target=x86_64-linux-kernel -- -Dwarnings 12 | 13 | .PHONY: cargo_will_determine_dependencies 14 | 15 | %.rust.o: target/x86_64-linux-kernel/debug/lib%.a 16 | $(LD) -r -o $@ --whole-archive $< 17 | -------------------------------------------------------------------------------- /benchs/rc_read/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "rc_read_tests" 5 | version = "0.1.0" 6 | authors = ["CaribouW <1071956678@qq.com>"] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [lib] 12 | crate-type = ["staticlib"] 13 | test = false 14 | 15 | [features] 16 | default = ["KRdmaKit"] 17 | 18 | [dependencies] 19 | KRdmaKit = { path = "../../KRdmaKit", optional = true } 20 | hashbrown = { git = "https://github.com/ProjectMitosisOS/hashbrown.git", branch = "main" } 21 | 22 | ## lazy static 23 | [dependencies.lazy_static] 24 | version = "1.0" 25 | features = ["spin_no_std"] 26 | 27 | [dev-dependencies] 28 | kernel-module-testlib = { path = "../../testlib" } 29 | 30 | [profile.dev] 31 | opt-level = 2 32 | -------------------------------------------------------------------------------- /benchs/rc_read/src/console_msgs.rs: -------------------------------------------------------------------------------- 1 | pub static SUCC : [&str;2] = ["client ok","Dev ok"]; 2 | pub static ERR : [&str;2] = ["cleint err","Dev empty"]; 3 | -------------------------------------------------------------------------------- /benchs/rc_read/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module}; 2 | 3 | #[test] 4 | fn test_dmesg() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /benchs/ud/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "ud_tests" 5 | version = "0.1.0" 6 | authors = ["CaribouW <1071956678@qq.com>"] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [lib] 12 | crate-type = ["staticlib"] 13 | test = false 14 | 15 | [features] 16 | default = ["KRdmaKit"] 17 | 18 | [dependencies] 19 | KRdmaKit = { path = "../../KRdmaKit", optional = true } 20 | hashbrown = { git = "https://github.com/ProjectMitosisOS/hashbrown.git", branch = "main" } 21 | 22 | ## lazy static 23 | [dependencies.lazy_static] 24 | version = "1.0" 25 | features = ["spin_no_std"] 26 | 27 | [dev-dependencies] 28 | kernel-module-testlib = { path = "../../testlib" } 29 | -------------------------------------------------------------------------------- /benchs/ud/src/console_msgs.rs: -------------------------------------------------------------------------------- 1 | pub static SUCC : [&str;2] = ["client ok","Dev ok"]; 2 | pub static ERR : [&str;2] = ["cleint err","Dev empty"]; 3 | -------------------------------------------------------------------------------- /benchs/ud/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module}; 2 | 3 | #[test] 4 | fn test_dmesg() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /deps/r2/.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.exe 3 | *.swp 4 | *.DS_Store 5 | build/ 6 | .vs/ 7 | .vscode/ 8 | .git/ 9 | .settings/ 10 | .cproject 11 | .project 12 | 13 | -------------------------------------------------------------------------------- /deps/r2/.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | before_script: 2 | - python -V # Print out python version for debugging 3 | - pip install toml 4 | - git config --global user.email "wxdwfc@gmail.com" 5 | - git config --global user.name "wxd" 6 | - git submodule sync 7 | - git submodule update --init 8 | - git submodule update --remote deps/rlib 9 | - export export CXX=g++-7 10 | 11 | cache: 12 | key: ${CI_COMMIT_REF_SLUG} 13 | paths: 14 | - deps/ 15 | 16 | # run tests using the binary built before 17 | build: 18 | stage: build 19 | tags: 20 | - rdma 21 | script: 22 | - cmake .; make boost; make jemalloc; make; 23 | 24 | 25 | test: 26 | stage: test 27 | tags: 28 | - rdma 29 | script: 30 | # - cmake .; make boost; 31 | - cmake .; make coretest; ./coretest; 32 | - cmake .; make coretest_wo_rdma; ./coretest_wo_rdma; 33 | 34 | -------------------------------------------------------------------------------- /deps/r2/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "deps/rlib"] 2 | path = deps/rlib 3 | url = https://github.com/wxdwfc/rlibv2.git 4 | [submodule "deps/gflags"] 5 | path = deps/gflags 6 | url = https://github.com/gflags/gflags.git 7 | [submodule "deps/googletest"] 8 | path = deps/googletest 9 | url = https://github.com/google/googletest.git 10 | [submodule "deps/jemalloc"] 11 | path = deps/jemalloc 12 | url = https://github.com/jemalloc/jemalloc.git 13 | -------------------------------------------------------------------------------- /deps/r2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | 3 | project(rtwo) 4 | 5 | ADD_DEFINITIONS(-std=c++14) 6 | 7 | set(CMAKE_CXX_FLAGS "-O2") 8 | 9 | ## install dependies 10 | include(deps/deps.cmake) 11 | 12 | find_library(jemalloc_lib NAMES jemalloc PATHS ./deps/jemalloc PATH_SUFFIXES lib 13 | NO_DEFAULT_PATH) 14 | 15 | if(NOT jemalloc_lib) 16 | 17 | set(jemalloc_lib "") 18 | 19 | endif() 20 | 21 | add_library(r2 src/logging.cc src/sshed.cc) 22 | target_include_directories (r2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) 23 | target_link_libraries(r2 boost_context boost_system boost_coroutine boost_thread boost_chrono) 24 | 25 | ## tests 26 | include(tests/tests.cmake) 27 | 28 | ## examples 29 | #include(examples/examples.cmake) 30 | 31 | ## benchs 32 | include(benchs/bench.cmake) 33 | 34 | enable_testing() 35 | 36 | 37 | add_test(NAME test COMMAND tests/coretest) 38 | add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --verbose 39 | DEPENDS tests/coretest ) 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /deps/r2/benchs/bench.cmake: -------------------------------------------------------------------------------- 1 | find_library(boost_serialization_lib NAMES boost_serialization PATHS ./deps/boost PATH_SUFFIXES lib 2 | NO_DEFAULT_PATH) 3 | 4 | set(benchs 5 | bench_server co_client) 6 | 7 | add_executable(co_client benchs/co_bench/client.cc) 8 | add_executable(bench_server benchs/bench_server.cc) 9 | 10 | foreach(b ${benchs}) 11 | target_link_libraries(${b} pthread gflags ${rocksdb_lib} ${mkl_rt_lib} ${boost_serialization_lib} ${jemalloc_lib} ibverbs boost_coroutine boost_chrono boost_thread boost_context boost_system r2) 12 | add_dependencies(${b} jemalloc ) 13 | endforeach(b) 14 | -------------------------------------------------------------------------------- /deps/r2/benchs/mem_region.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../deps/rlib/core/lib.hh" 4 | 5 | #include "../src/common.hh" 6 | 7 | namespace r2 { 8 | 9 | namespace bench { 10 | 11 | using namespace rdmaio; 12 | 13 | struct MemoryRegion { 14 | u64 sz; // total region size 15 | 16 | void *addr = nullptr; // region 17 | 18 | void *start_ptr() const { return addr; } 19 | 20 | u64 size() const { return sz; } 21 | 22 | MemoryRegion() = default; 23 | 24 | MemoryRegion(const u64 &sz, void *addr) : sz(sz), addr(addr) {} 25 | 26 | virtual bool valid() { return addr != nullptr; } 27 | 28 | ::rdmaio::Option> convert_to_rmem() { 29 | if (!valid()) 30 | return {}; 31 | return std::make_shared( 32 | sz, [this](u64 s) { return addr; }, [](rmem::RMem::raw_ptr_t p) {}); 33 | } 34 | }; 35 | 36 | class DRAMRegion : public MemoryRegion { 37 | public: 38 | explicit DRAMRegion(const u64 &sz) : MemoryRegion(sz, new char[sz]) {} 39 | 40 | static ::rdmaio::Option> create(const u64 &sz) { 41 | return std::make_shared(sz); 42 | } 43 | }; 44 | } // namespace bench 45 | 46 | } // namespace r2 47 | -------------------------------------------------------------------------------- /deps/r2/src/allocator.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "jemalloc/jemalloc.h" 4 | 5 | #include "common.hh" 6 | 7 | namespace r2 8 | { 9 | 10 | using ptr_t = void *; 11 | 12 | class Allocator 13 | { 14 | public: 15 | explicit Allocator(unsigned id) : id(id) 16 | { 17 | } 18 | 19 | inline ptr_t alloc(u32 size, int flag = 0) 20 | { 21 | auto ptr = jemallocx(size, id | flag); 22 | return ptr; 23 | } 24 | 25 | inline void dealloc(ptr_t ptr) { free(ptr); } 26 | 27 | inline void free(ptr_t ptr) 28 | { 29 | /*! 30 | According to WenHao, using 0 is fine, because jemalloc will 31 | automatically free the memory to this thread's allocation. 32 | But according to my test, if using id has better scalability.d 33 | */ 34 | //jedallocx(ptr,0); 35 | jedallocx(ptr, id); 36 | } 37 | 38 | private: 39 | unsigned id; 40 | }; 41 | 42 | } // end namespace r2 43 | -------------------------------------------------------------------------------- /deps/r2/src/mem_block.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "./common.hh" 4 | 5 | namespace r2 { 6 | 7 | /*! 8 | Msg is a safe wrapper over a raw pointer. 9 | To safely create/destory a message, 10 | please refer to constructors at msg_factory.hpp 11 | */ 12 | 13 | struct MemBlock { 14 | void *mem_ptr = nullptr; 15 | u32 sz = 0; 16 | 17 | MemBlock() = default; 18 | 19 | MemBlock(void *data_p, const u32 &sz) : mem_ptr(data_p), sz(sz) {} 20 | 21 | template inline T *interpret_as(const u32 &offset = 0) const { 22 | if (unlikely(sz - offset < sizeof(T))) 23 | return nullptr; 24 | { // unsafe 25 | return reinterpret_cast((char *)mem_ptr + offset); 26 | } 27 | } 28 | }; 29 | 30 | } // namespace r2 31 | -------------------------------------------------------------------------------- /deps/r2/src/msg/ud_msg.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "./ud_session.hh" 6 | 7 | namespace r2 { 8 | 9 | class UDMsg { 10 | using session_id_t = u32; 11 | using session_map_t = std::unordered_map < session_id_t, Arc; 12 | 13 | session_map_t opened_sessions; 14 | 15 | Arc ud; 16 | 17 | explicit UDMsg(Arc ud) : ud(ud) {} 18 | 19 | 20 | }; 21 | } // namespace r2 22 | -------------------------------------------------------------------------------- /deps/r2/src/ring_msg/id_helper.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../common.hh" 4 | 5 | namespace r2 { 6 | 7 | namespace ring_msg { 8 | 9 | using id_t = u16; 10 | using sz_t = u16; 11 | 12 | class IDEncoder { 13 | public: 14 | static u32 encode_id_sz(const id_t &id, const sz_t &sz) { 15 | u32 base = static_cast(id); 16 | return base << 16 | sz; 17 | } 18 | }; 19 | 20 | /** 21 | * This nice piece of code comes from 22 | * https://stackoverflow.com/questions/1392059/algorithm-to-generate-bit-mask 23 | */ 24 | template static constexpr R bitmask(unsigned int const onecount) { 25 | return static_cast(-(onecount != 0)) & 26 | (static_cast(-1) >> ((sizeof(R) * CHAR_BIT) - onecount)); 27 | } 28 | 29 | class IDDecoder { 30 | public: 31 | static std::pair decode(const usize &val) { 32 | usize sz_mask = bitmask(16); 33 | return std::make_pair(val >> 16, sz_mask & val); 34 | } 35 | }; 36 | 37 | } // namespace ring_msg 38 | } // namespace r2 39 | -------------------------------------------------------------------------------- /deps/r2/src/ring_msg/proto.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "rlib/core/bootstrap/proto.hh" 4 | 5 | namespace r2 { 6 | 7 | namespace ring_msg { 8 | 9 | using namespace rdmaio; 10 | using namespace rdmaio::qp; 11 | using namespace rdmaio::proto; 12 | using namespace rdmaio::rmem; 13 | 14 | const u32 kMagic = 73; 15 | 16 | struct __attribute__((packed)) RingReply { 17 | RCReply rc_reply; 18 | u64 base_off; 19 | RegAttr mr; 20 | }; 21 | 22 | struct __attribute__((packed)) RingBootstrap { 23 | u64 base_off; 24 | RegAttr mr; 25 | u32 magic_key = kMagic; 26 | }; 27 | 28 | } // namespace ring_msg 29 | 30 | } // namespace r2 31 | -------------------------------------------------------------------------------- /deps/r2/src/rpc/rpc_data.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../msg/protocol.hpp" 4 | 5 | namespace r2 { 6 | 7 | namespace rpc { 8 | 9 | enum MsgType { 10 | REQ = 1, // RPC request 11 | REPLY // RPC reply 12 | }; 13 | 14 | /** 15 | * RPC request structure 16 | */ 17 | class Req { 18 | public: 19 | struct __attribute__((packed)) Meta { 20 | u8 cor_id; 21 | Addr dest; 22 | }; 23 | 24 | struct Arg { 25 | const char *send_buf = nullptr; 26 | u32 len = 0; 27 | char *reply_buf = nullptr; 28 | u32 reply_cnt = 0; 29 | }; 30 | 31 | // internal data structures used in RPC 32 | struct __attribute__ ((packed)) Header { 33 | u32 type : 2; 34 | u32 rpc_id : 5; 35 | u32 payload : 18; 36 | u32 cor_id : 7; 37 | } __attribute__ ((aligned (sizeof(u64)))); 38 | 39 | public: 40 | static int sizeof_header(void) { 41 | return sizeof(Header); 42 | } 43 | }; // end class RPC data 44 | 45 | /** 46 | * record the pending reply structures 47 | */ 48 | struct Reply { 49 | char *reply_buf = nullptr; 50 | int reply_count = 0; 51 | }; 52 | 53 | } // end namespace rpc 54 | 55 | } // end namespace r2 56 | -------------------------------------------------------------------------------- /deps/r2/src/utils/option.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(__GNUC__) && __GNUC__ < 7 4 | #include 5 | #define _r2_optional std::experimental::optional 6 | #else 7 | #include 8 | #define _r2_optional std::optional 9 | #endif 10 | 11 | namespace r2 { 12 | template using Option = _r2_optional; 13 | } // namespace r2 14 | -------------------------------------------------------------------------------- /deps/r2/src/utils/rdtsc.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../common.hh" 4 | 5 | namespace r2 { 6 | 7 | class RDTSC { 8 | public: 9 | static inline u64 read_tsc(void) { 10 | u32 a, d; 11 | __asm __volatile("rdtsc" : "=a"(a), "=d"(d)); 12 | return ((u64)a) | (((u64)d) << 32); 13 | } 14 | 15 | RDTSC() : start(read_tsc()) {} 16 | u64 passed() const { return read_tsc() - start; } 17 | 18 | private: 19 | u64 start; 20 | }; 21 | 22 | } // namespace r2 23 | -------------------------------------------------------------------------------- /deps/r2/tests/test_list.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "../src/linked_list.hh" 4 | #include "../src/logging.hh" 5 | 6 | using namespace r2; 7 | 8 | namespace test { 9 | 10 | TEST(List, Basic) { 11 | 12 | LinkedList test; 13 | for(uint i = 0;i < 12;++i){ 14 | test.add(new Node(i)); 15 | //LOG(2) << "tailer's value " << test.tailer_p->val << "; prev: " << test.tailer_p->prev_p->val; 16 | } 17 | 18 | for (uint i = 0;i < 12;++i) { 19 | auto n = test.peek().value(); 20 | ASSERT_EQ(n->val,i); 21 | delete n; 22 | } 23 | } 24 | 25 | } // namespace test 26 | -------------------------------------------------------------------------------- /deps/r2/tests/test_rdtsc.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "../src/utils/rdtsc.hh" 4 | 5 | using namespace r2; 6 | 7 | namespace test { 8 | 9 | TEST(Util, Rdtsc) { 10 | RDTSC rdtsc; 11 | sleep(1); 12 | ASSERT_GE(rdtsc.passed(), 0); 13 | } 14 | } // namespace test 15 | -------------------------------------------------------------------------------- /deps/r2/tests/test_ssched.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "../src/libroutine.hh" 4 | #include "../src/logging.hh" 5 | 6 | using namespace r2; 7 | 8 | namespace test { 9 | 10 | TEST(SSched, Basic) { 11 | 12 | usize counter = 0; 13 | SScheduler ssched; 14 | #if 1 15 | for (uint i = 0; i < 12; ++i) 16 | ssched.spawn([&counter,i](R2_ASYNC) { 17 | 18 | counter += 1; 19 | if (i == 11) 20 | R2_STOP(); 21 | //LOG(2) << "inc done"; 22 | R2_RET; 23 | }); 24 | #endif 25 | 26 | ssched.run(); 27 | ASSERT_EQ(12,counter); 28 | } 29 | 30 | } // namespace test 31 | -------------------------------------------------------------------------------- /deps/r2/tests/tests.cmake: -------------------------------------------------------------------------------- 1 | ## main test files 2 | file(GLOB TSOURCES "tests/test_srop.cc" "tests/test_ud_session.cc" "tests/test_rc_session.cc" "tests/test_rm.cc") 3 | add_executable(coretest ${TSOURCES} ) 4 | 5 | find_library(boost_serialization_lib NAMES boost_serialization PATHS ./deps/boost PATH_SUFFIXES lib 6 | NO_DEFAULT_PATH) 7 | 8 | if(NOT boost_serialization_lib) 9 | 10 | set(boost_serialization_lib "") 11 | 12 | endif() 13 | 14 | target_link_libraries(coretest gtest gtest_main ${rocksdb_lib} ${mkl_rt_lib} ${boost_serialization_lib} ${jemalloc_lib} ibverbs boost_coroutine boost_chrono boost_thread boost_context boost_system r2) 15 | add_dependencies(coretest jemalloc ) 16 | 17 | ## test file when there is no RDMA, allow local debug 18 | file(GLOB T_WO_SOURCES "tests/test_list.cc" "tests/test_rdtsc.cc" "tests/test_ssched.cc" ) 19 | add_executable(coretest_wo_rdma ${T_WO_SOURCES} "src/logging.cc") 20 | target_link_libraries(coretest_wo_rdma gtest gtest_main boost_context boost_system boost_coroutine boost_thread boost_chrono r2) 21 | -------------------------------------------------------------------------------- /docs/arch-v20210718.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/krcore-artifacts/cbfc9b4407110a300f840ab348c3f07dda0e115d/docs/arch-v20210718.pdf -------------------------------------------------------------------------------- /docs/arch.graffle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/krcore-artifacts/cbfc9b4407110a300f840ab348c3f07dda0e115d/docs/arch.graffle -------------------------------------------------------------------------------- /docs/arch.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/krcore-artifacts/cbfc9b4407110a300f840ab348c3f07dda0e115d/docs/arch.pdf -------------------------------------------------------------------------------- /docs/arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/krcore-artifacts/cbfc9b4407110a300f840ab348c3f07dda0e115d/docs/arch.png -------------------------------------------------------------------------------- /docs/new-arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/krcore-artifacts/cbfc9b4407110a300f840ab348c3f07dda0e115d/docs/new-arch.png -------------------------------------------------------------------------------- /docs/screenshoots/fig10a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/krcore-artifacts/cbfc9b4407110a300f840ab348c3f07dda0e115d/docs/screenshoots/fig10a.png -------------------------------------------------------------------------------- /docs/screenshoots/fig10b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/krcore-artifacts/cbfc9b4407110a300f840ab348c3f07dda0e115d/docs/screenshoots/fig10b.png -------------------------------------------------------------------------------- /docs/screenshoots/fig10c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/krcore-artifacts/cbfc9b4407110a300f840ab348c3f07dda0e115d/docs/screenshoots/fig10c.png -------------------------------------------------------------------------------- /docs/screenshoots/fig10d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/krcore-artifacts/cbfc9b4407110a300f840ab348c3f07dda0e115d/docs/screenshoots/fig10d.png -------------------------------------------------------------------------------- /docs/screenshoots/fig11a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/krcore-artifacts/cbfc9b4407110a300f840ab348c3f07dda0e115d/docs/screenshoots/fig11a.png -------------------------------------------------------------------------------- /docs/screenshoots/fig11b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/krcore-artifacts/cbfc9b4407110a300f840ab348c3f07dda0e115d/docs/screenshoots/fig11b.png -------------------------------------------------------------------------------- /docs/screenshoots/fig14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/krcore-artifacts/cbfc9b4407110a300f840ab348c3f07dda0e115d/docs/screenshoots/fig14.png -------------------------------------------------------------------------------- /docs/screenshoots/fig8a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/krcore-artifacts/cbfc9b4407110a300f840ab348c3f07dda0e115d/docs/screenshoots/fig8a.png -------------------------------------------------------------------------------- /docs/screenshoots/fig9a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SJTU-IPADS/krcore-artifacts/cbfc9b4407110a300f840ab348c3f07dda0e115d/docs/screenshoots/fig9a.png -------------------------------------------------------------------------------- /docs/testing.md: -------------------------------------------------------------------------------- 1 | # Run tests of KRCore 2 | 3 | # 0. Basic unittests 4 | 5 | ### 0.0 User-space unittests 6 | 7 | Just run: 8 | 9 | ``` 10 | cargo test --features user 11 | ``` 12 | 13 | 14 | 15 | ## x. Examples 16 | 17 | For each **user-space** example, run: 18 | 19 | ``` 20 | cargo run --example EXAMPLE_NAME_TO_RUN --features user 21 | ``` 22 | 23 | -------------------------------------------------------------------------------- /examples/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := testmodule.o 2 | testmodule-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | 6 | export c_flags 7 | export UTEST 8 | 9 | $(src)/target/x86_64-unknown-none-linuxkernel/debug/lib%.a: cargo_will_determine_dependencies 10 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=x86_64-unknown-none-linuxkernel 11 | 12 | .PHONY: cargo_will_determine_dependencies 13 | 14 | %.rust.o: target/x86_64-unknown-none-linuxkernel/debug/lib%.a 15 | $(LD) -r -o $@ --whole-archive $< 16 | -------------------------------------------------------------------------------- /examples/krdmakit_kernel_rc/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::with_kernel_module; 2 | 3 | #[test] 4 | fn test_reliable_connection_related_tests() { 5 | with_kernel_module(|| {}); 6 | } 7 | -------------------------------------------------------------------------------- /examples/krdmakit_kernel_ud/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::with_kernel_module; 2 | 3 | #[test] 4 | fn test_unreliable_datagram_related_tests() { 5 | with_kernel_module(|| {}); 6 | } 7 | -------------------------------------------------------------------------------- /exp/.gitignore: -------------------------------------------------------------------------------- 1 | cmake-build-debug -------------------------------------------------------------------------------- /exp/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM val01:5000/rdma-ubuntu:16.04-ofed-driver 2 | 3 | COPY krc_client_sync /krc_client_sync 4 | CMD ["/krc_client_sync", "-payload_sz", "4096"] -------------------------------------------------------------------------------- /exp/LITE/common.h: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | -------------------------------------------------------------------------------- /exp/LITE/lib/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS := -std=gnu11 -Wall -Wmissing-prototypes -Wstrict-prototypes\ 2 | -fomit-frame-pointer -freg-struct-return -O2 3 | 4 | CFLAGS := -fomit-frame-pointer -freg-struct-return -lrdmacm -libverbs -lpthread -ldl 5 | 6 | SRCS := $(wildcard example*.c) 7 | SRCS += $(wildcard lite_*.c) 8 | OBJS := $(SRCS:.c=.o) 9 | DEPS := lite-lib.h 10 | 11 | all: $(OBJS) 12 | 13 | clean: 14 | rm -f *.o 15 | 16 | %.o: %.c 17 | gcc lite-lib.c -lpthread -o $@ $(CFLAGS) $< 18 | -------------------------------------------------------------------------------- /exp/LITE/lib/README.md: -------------------------------------------------------------------------------- 1 | LITE Local Indirection TiEr - userspace example 2 | ==== 3 | 4 | `lite-lib.c` and `lite-lib.h` contain the code of lite-userspace library call. 5 | `lite-lib.c` mainly interacts with LITE-kernel with syscall. 6 | Syscall definition should match 7 | 1. `lite-syscall/lite_syscall.c` 8 | 2. `kernel_src/arch/x86/syscalls/syscall_64.tbl`. 9 | Regular example call for send-reply and send are in `lite_example.c` and `lite_send.c` respectively. 10 | 11 | ## How to Run LITE example 12 | 13 | ### S1: run cluster manager 14 | ./mgmt_server 15 | ### S2: follow step 5.2.2 in README.md to initial userspace_ibapi_join 16 | ``` 17 | userspace_ibapi_join(IP, eth-port, IB-port) --> change to correct IP and port 18 | ``` 19 | or you could study `lite_join.c` to find the way to join cluster 20 | ### S3: compile by Makefile 21 | make all 22 | ### S4: execute RPC example example 23 | on node 1, execute `./lite_rpc.o 0` 24 | on node 2, execute `./lite_rpc.o 1` 25 | ### S5: execute LITE-Write example 26 | on node 2, execute ./lite_write.o 1 27 | Remember to rebuild the whole cluster after running examples. 28 | -------------------------------------------------------------------------------- /exp/LITE/lib/lite_join.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "lite-lib.h" 16 | 17 | int main(int argc, char *argv[]) 18 | { 19 | printf("Ready to join a LITE cluster\n"); 20 | userspace_liteapi_join("192.168.11.247", 18500, 1); 21 | printf("after join cluster as %d\n", userspace_liteapi_get_node_id()); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /exp/README.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /exp/motiv-connect/.gitignore: -------------------------------------------------------------------------------- 1 | cmake-build-debug/ 2 | -------------------------------------------------------------------------------- /exp/motiv-connect/run.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | host = "val13" 3 | path = '' 4 | cmd = 'cd projects/krdmakit/exp; ./rc_connect_server' 5 | 6 | [[pass]] 7 | host = "val14" 8 | path = '' 9 | cmd = 'cd projects/krdmakit/exp; ./rc_connect_client -threads=1 -addr=val13:8888' 10 | -------------------------------------------------------------------------------- /exp/motiv-kit-breakdown/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := testmodule.o 2 | testmodule-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | TARGET ?= x86_64-unknown-none-linuxkernel 6 | 7 | export c_flags 8 | export UTEST 9 | 10 | $(src)/target/$(TARGET)/debug/lib%.a: cargo_will_determine_dependencies 11 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=$(TARGET) 12 | 13 | .PHONY: cargo_will_determine_dependencies 14 | 15 | %.rust.o: target/$(TARGET)/debug/lib%.a 16 | $(LD) -r -o $@ --whole-archive $< 17 | -------------------------------------------------------------------------------- /exp/motiv-kit-breakdown/rc_break_down_client/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "rc_break_down_client_tests" 5 | version = "0.1.0" 6 | authors = ["CaribouW <1071956678@qq.com>"] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | 11 | [lib] 12 | crate-type = ["staticlib"] 13 | test = false 14 | 15 | [features] 16 | default = ["KRdmaKit"] 17 | 18 | [dependencies] 19 | KRdmaKit = { path = "../../../rust-kernel-rdma/KRdmaKit", optional = true, features = ["dct", "profile"] } 20 | hashbrown = { git = "https://github.com/ProjectMitosisOS/hashbrown.git", branch = "main" } 21 | 22 | ## lazy static 23 | [dependencies.lazy_static] 24 | version = "1.0" 25 | features = ["spin_no_std"] 26 | 27 | [dev-dependencies] 28 | kernel-module-testlib = { path = "../../../testlib" } 29 | 30 | [profile.dev] 31 | opt-level = 2 32 | -------------------------------------------------------------------------------- /exp/motiv-kit-breakdown/rc_break_down_client/src/console_msgs.rs: -------------------------------------------------------------------------------- 1 | pub static SUCC : [&str;2] = ["client ok","Dev ok"]; 2 | pub static ERR : [&str;2] = ["cleint err","Dev empty"]; 3 | -------------------------------------------------------------------------------- /exp/motiv-kit-breakdown/rc_break_down_client/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module}; 2 | 3 | #[test] 4 | fn test_dmesg() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /exp_scripts/.gitignore: -------------------------------------------------------------------------------- 1 | *.out 2 | copy_lfm.sh 3 | *.xlsx 4 | run-build.toml 5 | out 6 | run.toml -------------------------------------------------------------------------------- /exp_scripts/requirements.txt: -------------------------------------------------------------------------------- 1 | numpy 2 | toml 3 | paramiko 4 | matplotlib -------------------------------------------------------------------------------- /exp_scripts/template.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | global_configs = "-undefok=or_sz" 3 | 4 | [template] 5 | [[template.pass]] 6 | role = 'server' 7 | path = "projects/krdmakit/exp" 8 | cmd = "./user_twosided_rc_server -run_sec=${run_sec_s} -host_len=${host_len} -port=${port} -or_sz=${or_sz} -payload_sz=${payload_sz} -threads=${threads} " 9 | 10 | 11 | [[template.pass]] 12 | role = 'client' 13 | path = "projects/krdmakit/exp" 14 | cmd = './user_twosided_rc_client -run_sec=${run_sec_c} -host=${@incr} -addr=${server_host} -port=${port} -id=${@incr} -or_sz=${or_sz} -payload_sz=${payload_sz} -threads=${threads}' 15 | 16 | [template.placeholder] 17 | threads = [1, 2, 4, 8, 12, 16, 18, 20, 24] 18 | host_len = 12 19 | run_sec_s = 20 20 | run_sec_c = 10 21 | @incr = 0 22 | or_sz = 1 23 | payload_sz = 64 24 | 25 | -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-build-dc.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | 5 | [[template.pass]] 6 | role = 'builder' 7 | path = 'KRdmaKit-syscall' 8 | cmd = 'source $HOME/.cargo/env; cp ${kbuild} Kbuild ; make -j; make uninstall ; make install' 9 | 10 | [template.placeholder] 11 | name = ["build"] 12 | kbuild = "Kbuild-DC" 13 | 14 | 15 | -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-build-exp.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'builder' 6 | path = 'exp' 7 | cmd = 'cmake . ; make boost all -j' 8 | 9 | [template.placeholder] 10 | name = ["build"] 11 | 12 | 13 | -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-build-hybrid.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | 3 | [template] 4 | 5 | 6 | [[template.pass]] 7 | role = 'builder' 8 | path = 'KRdmaKit-syscall' 9 | cmd = 'source $HOME/.cargo/env; cp ${kbuild} Kbuild ; make -j; make uninstall ; make install META_GID=${meta_server_gid}' 10 | 11 | [template.placeholder] 12 | name = ["build"] 13 | kbuild = "Kbuild-hybrid" 14 | meta_server_gid= "fe80:0000:0000:0000:ec0d:9a03:0078:645e" 15 | 16 | -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-build-lite.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'builder' 6 | path = 'KRdmaKit-syscall' 7 | cmd = 'source $HOME/.cargo/env; cp ${kbuild} Kbuild ; make -j; make uninstall ; make install' 8 | 9 | [template.placeholder] 10 | name = ["build"] 11 | kbuild = "Kbuild-lite" 12 | 13 | 14 | -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-build-meta-client.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | 3 | [template] 4 | 5 | 6 | [[template.pass]] 7 | role = 'meta-client' 8 | path = 'KRdmaKit-syscall' 9 | cmd = 'source $HOME/.cargo/env; cp ${kbuild} Kbuild ; make -j; make uninstall ; make install META_GID=${meta_server_gid}' 10 | 11 | [template.placeholder] 12 | name = ["build"] 13 | kbuild = "Kbuild-meta-client" 14 | meta_server_gid= "fe80:0000:0000:0000:ec0d:9a03:0078:645e" 15 | 16 | -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-build-meta-rpc.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | [[template.pass]] 5 | role = 'builder' 6 | path = 'KRdmaKit-syscall' 7 | cmd = 'source $HOME/.cargo/env; cp ${kbuild} Kbuild ; make -j; make uninstall ; make install' 8 | 9 | [template.placeholder] 10 | name = ["build"] 11 | kbuild = "Kbuild-meta-rpc" 12 | 13 | 14 | -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-build-meta-server.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | 5 | [[template.pass]] 6 | role = 'meta-server' 7 | path = 'KRdmaKit-syscall' 8 | cmd = 'source $HOME/.cargo/env; cp ${kbuild} Kbuild ; make -j; make uninstall ; make install META_GID=${meta_server_gid}' 9 | 10 | [template.placeholder] 11 | name = ["build"] 12 | kbuild = "Kbuild-meta-server" 13 | 14 | 15 | -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-build-rc.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | 5 | [[template.pass]] 6 | role = 'builder' 7 | path = 'KRdmaKit-syscall' 8 | cmd = 'source $HOME/.cargo/env; cp ${kbuild} Kbuild ; make -j; make uninstall ; make install' 9 | 10 | [template.placeholder] 11 | name = ["build"] 12 | kbuild = "Kbuild-RC" 13 | 14 | 15 | -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-build-tdc.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | 4 | 5 | [[template.pass]] 6 | role = 'builder' 7 | path = 'KRdmaKit-syscall/two-sided-dc/KRdmaKit-syscall' 8 | cmd = 'source $HOME/.cargo/env; make -j; make uninstall ; make install' 9 | 10 | [template.placeholder] 11 | name = ["build"] 12 | 13 | 14 | -------------------------------------------------------------------------------- /exp_scripts/templates-build/template-clean.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | [template] 3 | [[template.pass]] 4 | role = "builder" 5 | path = 'KRdmaKit-syscall' 6 | cmd = 'rm -rf target ; make uninstall' 7 | 8 | [template.placeholder] 9 | name = ["build"] 10 | 11 | 12 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/app/template-krcore-race-hashing-async.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | global_configs= "-or_sz=2 -payload_sz=96 -write_imm=0 -undefok=write_imm,or_sz " 3 | 4 | [template] 5 | [[template.pass]] 6 | role = 'server' 7 | path = 'exp' 8 | cmd = './racing_hash_analyser -host_len=10 -threads=1 -run_sec=60 -tick_interval_us=1000 -port=${port}' 9 | 10 | [[template.pass]] 11 | role = 'client' 12 | path = 'exp' 13 | cmd = './racing_hash_kernel_elastic_worker -host=${@incr} -analyser_addr=${server_host}:${port} -tick_interval_us=100 -threads=24 -run_sec=50 -server_gid=${server_gid}' 14 | 15 | 16 | [[template.pass]] 17 | role = 'trigger' 18 | path = "exp" 19 | cmd = "./racing_hash_trigger -worker_addrs='${client_hosts}' -threads=1" 20 | 21 | 22 | [template.placeholder] 23 | name = ["krcore-race-hashing-async"] 24 | run_sec_c = 20 25 | rdma_op = 0 # 0 means read, 1 means write 26 | or_sz = 12 27 | payload_sz = 8 28 | 29 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/app/template-krcore-race-hashing.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | global_configs= "-or_sz=1 -payload_sz=96 -write_imm=0 -undefok=write_imm,or_sz " 3 | 4 | [template] 5 | [[template.pass]] 6 | role = 'server' 7 | path = 'exp' 8 | cmd = './racing_hash_analyser -host_len=10 -threads=1 -run_sec=60 -tick_interval_us=1000 -port=${port}' 9 | 10 | [[template.pass]] 11 | role = 'client' 12 | path = 'exp' 13 | cmd = './racing_hash_kernel_elastic_worker -host=${@incr} -analyser_addr=${server_host}:${port} -tick_interval_us=100 -threads=24 -run_sec=50 -server_gid=${server_gid}' 14 | 15 | 16 | [[template.pass]] 17 | role = 'trigger' 18 | path = "exp" 19 | cmd = "./racing_hash_trigger -worker_addrs='${client_hosts}' -threads=1" 20 | 21 | 22 | [template.placeholder] 23 | name = ["krcore-race-hashing"] 24 | run_sec_c = 20 25 | rdma_op = 0 # 0 means read, 1 means write 26 | or_sz = 1 27 | payload_sz = 8 28 | 29 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/app/template-verbs-race-hashing.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | global_configs= "-or_sz=2 -payload_sz=96 -write_imm=0 -undefok=write_imm,or_sz" 3 | 4 | [template] 5 | [[template.pass]] 6 | role = 'server' 7 | path = 'exp' 8 | cmd = './racing_hash_analyser -host_len=10 -threads=1 -run_sec=60 -tick_interval_us=1000 -port=8000' 9 | 10 | [[template.pass]] 11 | role = 'server' 12 | path = 'exp' 13 | cmd = './racing_hash_user_server -run_sec=60 -port=9000' 14 | 15 | 16 | [[template.pass]] 17 | role = 'client' 18 | path = 'exp' 19 | cmd = './racing_hash_user_elastic_worker -host=${@incr} -analyser_addr=${server_host}:8000 -threads=24 -tick_interval_us=100 -server_addr=${server_host}:9000 -run_sec=50' 20 | 21 | 22 | [[template.pass]] 23 | role = 'trigger' 24 | path = "exp" 25 | cmd = "./racing_hash_trigger -worker_addrs='${client_hosts}' -threads=1" 26 | 27 | 28 | [template.placeholder] 29 | name = ["verbs-race-hashing"] 30 | run_sec_c = 20 31 | rdma_op = 0 # 0 means read, 1 means write 32 | or_sz = 1 33 | payload_sz = 8 34 | 35 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/control-path/template-krcore-connect.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | 3 | [template] 4 | [[template.pass]] 5 | role = "client" 6 | path = "exp" 7 | cmd = "./rc_connect_client_kernel -threads=${threads} -gid=${server_gid}" 8 | 9 | [template.placeholder] 10 | threads = [1, 2, 4, 8, 12, 14, 16, 18, 20, 22] 11 | 12 | 13 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/control-path/template-verbs-connect.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | 3 | [template] 4 | 5 | [[template.pass]] 6 | role = "server" 7 | path = "exp" 8 | cmd = "./rc_connect_server -port=${port} -run_sec=${run_sec_s}" 9 | 10 | 11 | [[template.pass]] 12 | role = "client" 13 | path = "exp" 14 | cmd = "./rc_connect_client -addr=${server_host}:${port} -threads=${threads} -run_sec=${run_sec_c}" 15 | 16 | [template.placeholder] 17 | threads = [1, 2, 4, 8, 12, 14, 16, 18, 20] 18 | run_sec_s = 15 19 | run_sec_c = 10 20 | 21 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/data-path/one-sided/template-one-sided-krcore-async-read.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | 3 | [template] 4 | [[template.pass]] 5 | role = 'client' 6 | path = "exp" 7 | cmd = "./krc_client_sync -threads=${threads} -gid=${server_gid} -run_sec=${run_sec_c} -rdma_op=${rdma_op} -or_sz=${or_sz} -payload_sz=${payload_sz} " 8 | 9 | [template.placeholder] 10 | threads = [1, 2, 4, 8, 12, 16, 18, 20, 24] 11 | run_sec_c = 20 12 | rdma_op = 0 # 0 means read, 1 means write 13 | or_sz = 12 14 | payload_sz = 8 15 | 16 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/data-path/one-sided/template-one-sided-krcore-async-write.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | 3 | [template] 4 | [[template.pass]] 5 | role = 'client' 6 | path = "exp" 7 | cmd = "./krc_client_sync -threads=${threads} -gid=${server_gid} -run_sec=${run_sec_c} -rdma_op=${rdma_op} -or_sz=${or_sz} -payload_sz=${payload_sz} " 8 | 9 | [template.placeholder] 10 | threads = [1, 2, 4, 8, 12, 16, 18, 20, 24] 11 | run_sec_c = 20 12 | rdma_op = 1 # 0 means read, 1 means write 13 | or_sz = 12 14 | payload_sz = 8 15 | 16 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/data-path/one-sided/template-one-sided-krcore-sync-read.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | 3 | [template] 4 | [[template.pass]] 5 | role = 'client' 6 | path = "exp" 7 | cmd = "./krc_client_sync -threads=${threads} -gid=${server_gid} -run_sec=${run_sec_c} -rdma_op=${rdma_op} -or_sz=${or_sz} -payload_sz=${payload_sz} " 8 | 9 | [template.placeholder] 10 | threads = [1, 2, 4, 8, 12, 16, 18, 20, 24] 11 | run_sec_c = 20 12 | rdma_op = 0 # 0 means read, 1 means write 13 | or_sz = 1 14 | payload_sz = 8 15 | 16 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/data-path/one-sided/template-one-sided-krcore-sync-write.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | 3 | [template] 4 | [[template.pass]] 5 | role = 'client' 6 | path = "exp" 7 | cmd = "./krc_client_sync -threads=${threads} -gid=${server_gid} -run_sec=${run_sec_c} -rdma_op=${rdma_op} -or_sz=${or_sz} -payload_sz=${payload_sz} " 8 | 9 | [template.placeholder] 10 | threads = [1, 2, 4, 8, 12, 16, 18, 20, 24] 11 | run_sec_c = 20 12 | rdma_op = 1 # 0 means read, 1 means write 13 | or_sz = 1 14 | payload_sz = 8 15 | 16 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/data-path/one-sided/template-one-sided-verbs-async-read.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | 3 | [template] 4 | [[template.pass]] 5 | role = 'server' 6 | path = "exp" 7 | cmd = "./urc_server_sync -port=${port} -run_sec=${run_sec_s}" 8 | 9 | 10 | [[template.pass]] 11 | role = 'client' 12 | path = "exp" 13 | cmd = "./urc_client_sync -threads=${threads} -addr=${server_host}:${port} -run_sec=${run_sec_c} -rdma_op=${rdma_op} -or_sz=${or_sz} -payload_sz=${payload_sz} " 14 | 15 | [template.placeholder] 16 | threads = [1, 2, 4, 8, 12, 16, 18, 20, 24] 17 | run_sec_s = 20 18 | run_sec_c = 10 19 | rdma_op = 0 # 0 means read, 1 means write 20 | or_sz = 12 21 | payload_sz = 8 22 | 23 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/data-path/one-sided/template-one-sided-verbs-async-write.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | 3 | [template] 4 | [[template.pass]] 5 | role = 'server' 6 | path = "exp" 7 | cmd = "./urc_server_sync -port=${port} -run_sec=${run_sec_s}" 8 | 9 | 10 | [[template.pass]] 11 | role = 'client' 12 | path = "exp" 13 | cmd = "./urc_client_sync -threads=${threads} -addr=${server_host}:${port} -run_sec=${run_sec_c} -rdma_op=${rdma_op} -or_sz=${or_sz} -payload_sz=${payload_sz} " 14 | 15 | [template.placeholder] 16 | threads = [1, 2, 4, 8, 12, 16, 18, 20, 24] 17 | run_sec_s = 20 18 | run_sec_c = 10 19 | rdma_op = 1 # 0 means read, 1 means write 20 | or_sz = 12 21 | payload_sz = 8 22 | 23 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/data-path/one-sided/template-one-sided-verbs-sync-read.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | 3 | [template] 4 | [[template.pass]] 5 | role = 'server' 6 | path = "exp" 7 | cmd = "./urc_server_sync -port=${port} -run_sec=${run_sec_s}" 8 | 9 | 10 | [[template.pass]] 11 | role = 'client' 12 | path = "exp" 13 | cmd = "./urc_client_sync -threads=${threads} -addr=${server_host}:${port} -run_sec=${run_sec_c} -rdma_op=${rdma_op} -or_sz=${or_sz} -payload_sz=${payload_sz} " 14 | 15 | [template.placeholder] 16 | threads = [1, 2, 4, 8, 12, 16, 18, 20, 24] 17 | run_sec_s = 20 18 | run_sec_c = 10 19 | rdma_op = 0 # 0 means read, 1 means write 20 | or_sz = 1 21 | payload_sz = 8 22 | 23 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/data-path/one-sided/template-one-sided-verbs-sync-write.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | 3 | [template] 4 | [[template.pass]] 5 | role = 'server' 6 | path = "exp" 7 | cmd = "./urc_server_sync -port=${port} -run_sec=${run_sec_s}" 8 | 9 | 10 | [[template.pass]] 11 | role = 'client' 12 | path = "exp" 13 | cmd = "./urc_client_sync -threads=${threads} -addr=${server_host}:${port} -run_sec=${run_sec_c} -rdma_op=${rdma_op} -or_sz=${or_sz} -payload_sz=${payload_sz} " 14 | 15 | [template.placeholder] 16 | threads = [1, 2, 4, 8, 12, 16, 18, 20, 24] 17 | run_sec_s = 20 18 | run_sec_c = 10 19 | rdma_op = 1 # 0 means read, 1 means write 20 | or_sz = 1 21 | payload_sz = 8 22 | 23 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/data-path/two-sided/template-two-sided-dc-async.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | 3 | [template] 4 | [[template.pass]] 5 | role = 'server' 6 | path = "exp" 7 | cmd = "./kernel_twosided_rc_server -host_len=${host_len} -or_sz=2048 -threads=${threads} -run_sec=${run_sec_s} -port=1 " 8 | 9 | 10 | [[template.pass]] 11 | role = 'client' 12 | path = "exp" 13 | cmd = './kernel_twosided_rc_client -vid=${@incr} -or_sz=${or_sz} -threads=${threads} -run_sec=${run_sec_c} -port=1 -gid=${server_gid}' 14 | 15 | [template.placeholder] 16 | threads = [1, 2, 4, 8, 12, 16, 18, 20, 24] 17 | host_len = 12 18 | run_sec_s = 20 19 | run_sec_c = 10 20 | @incr = 0 21 | or_sz = 2 22 | payload_sz = 64 23 | 24 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/data-path/two-sided/template-two-sided-dc-sync.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | 3 | [template] 4 | [[template.pass]] 5 | role = 'server' 6 | path = "exp" 7 | cmd = "./kernel_twosided_rc_server -host_len=${host_len} -or_sz=2048 -threads=${threads} -run_sec=${run_sec_s} -port=1 " 8 | 9 | 10 | [[template.pass]] 11 | role = 'client' 12 | path = "exp" 13 | cmd = './kernel_twosided_rc_client -vid=${@incr} -or_sz=${or_sz} -threads=${threads} -run_sec=${run_sec_c} -port=1 -gid=${server_gid}' 14 | 15 | [template.placeholder] 16 | threads = [1, 2, 4, 8, 12, 16, 18, 20, 24] 17 | host_len = 12 18 | run_sec_s = 20 19 | run_sec_c = 10 20 | @incr = 0 21 | or_sz = 1 22 | payload_sz = 64 23 | 24 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/data-path/two-sided/template-two-sided-rc-async.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | 3 | [template] 4 | [[template.pass]] 5 | role = 'server' 6 | path = "exp" 7 | cmd = "./kernel_twosided_rc_server -host_len=${host_len} -or_sz=2048 -threads=${threads} -run_sec=${run_sec_s} -port=1 " 8 | 9 | 10 | [[template.pass]] 11 | role = 'client' 12 | path = "exp" 13 | cmd = './kernel_twosided_rc_client -vid=${@incr} -or_sz=${or_sz} -threads=${threads} -run_sec=${run_sec_c} -port=1 -gid=${server_gid}' 14 | 15 | [template.placeholder] 16 | threads = [1, 2, 4, 8, 12, 16, 18, 20, 24] 17 | host_len = 12 18 | run_sec_s = 20 19 | run_sec_c = 10 20 | @incr = 0 21 | or_sz = 2 22 | payload_sz = 64 23 | 24 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/data-path/two-sided/template-two-sided-rc-sync.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | 3 | [template] 4 | [[template.pass]] 5 | role = 'server' 6 | path = "exp" 7 | cmd = "./kernel_twosided_rc_server -host_len=${host_len} -or_sz=2048 -threads=${threads} -run_sec=${run_sec_s} -port=1 " 8 | 9 | 10 | [[template.pass]] 11 | role = 'client' 12 | path = "exp" 13 | cmd = './kernel_twosided_rc_client -vid=${@incr} -or_sz=${or_sz} -threads=${threads} -run_sec=${run_sec_c} -port=1 -gid=${server_gid}' 14 | 15 | [template.placeholder] 16 | threads = [1, 2, 4, 8, 12, 16, 18, 20, 24] 17 | host_len = 12 18 | run_sec_s = 20 19 | run_sec_c = 10 20 | @incr = 0 21 | or_sz = 1 22 | payload_sz = 64 23 | 24 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/data-path/two-sided/template-two-sided-verbs-async.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | global_configs = "-undefok=or_sz" 3 | 4 | [template] 5 | [[template.pass]] 6 | role = 'server' 7 | path = "exp" 8 | cmd = "./user_twosided_rc_server -run_sec=${run_sec_s} -host_len=${host_len} -port=${port} -or_sz=${or_sz} -payload_sz=${payload_sz} -threads=${threads} " 9 | 10 | 11 | [[template.pass]] 12 | role = 'client' 13 | path = "exp" 14 | cmd = './user_twosided_rc_client -run_sec=${run_sec_c} -host=${@incr} -addr=${server_host} -port=${port} -id=${@incr} -or_sz=${or_sz} -payload_sz=${payload_sz} -threads=${threads}' 15 | 16 | [template.placeholder] 17 | threads = [1, 2, 4, 8, 12, 16, 18, 20, 24] 18 | host_len = 12 19 | run_sec_s = 20 20 | run_sec_c = 10 21 | @incr = 0 22 | or_sz = 2 23 | payload_sz = 64 24 | 25 | -------------------------------------------------------------------------------- /exp_scripts/templates-run/data-path/two-sided/template-two-sided-verbs-sync.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | global_configs = "-undefok=or_sz" 3 | 4 | [template] 5 | [[template.pass]] 6 | role = 'server' 7 | path = "exp" 8 | cmd = "./user_twosided_rc_server -run_sec=${run_sec_s} -host_len=${host_len} -port=${port} -or_sz=${or_sz} -payload_sz=${payload_sz} -threads=${threads} " 9 | 10 | 11 | [[template.pass]] 12 | role = 'client' 13 | path = "exp" 14 | cmd = './user_twosided_rc_client -run_sec=${run_sec_c} -host=${@incr} -addr=${server_host} -port=${port} -id=${@incr} -or_sz=${or_sz} -payload_sz=${payload_sz} -threads=${threads}' 15 | 16 | [template.placeholder] 17 | threads = [1, 2, 4, 8, 12, 16, 18, 20, 24] 18 | host_len = 12 19 | run_sec_s = 20 20 | run_sec_c = 10 21 | @incr = 0 22 | or_sz = 1 23 | payload_sz = 64 24 | 25 | -------------------------------------------------------------------------------- /git_init.sh: -------------------------------------------------------------------------------- 1 | git submodule update --init --recursive -------------------------------------------------------------------------------- /krdmakit-macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "krdmakit-macros" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | quote = "1.0" 10 | syn = { version = "1.0.56", features = ["full"] } 11 | proc-macro2 = "1.0.36" 12 | 13 | [lib] 14 | proc-macro = true 15 | -------------------------------------------------------------------------------- /rdma-shim/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rdma-shim" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | rust-kernel-rdma-base = { path = "../rust-kernel-rdma/rust-kernel-rdma-base", optional = true} 10 | rust-user-rdma = {path = "../rust-user-rdma", optional = true} 11 | libc = {version = "0.2.0", optional = true} 12 | log = {version = "0.4", optional = true, features = ["max_level_debug", "release_max_level_info"]} 13 | 14 | [features] 15 | kernel = ["rust-kernel-rdma-base"] 16 | dct = ["rust-kernel-rdma-base/dct"] 17 | user = ["rust-user-rdma", "libc", "log"] 18 | OFED_5_4 = ["rust-user-rdma/OFED_5_4"] 19 | exp = ["rust-user-rdma/exp"] 20 | 21 | 22 | -------------------------------------------------------------------------------- /rdma-shim/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | #[cfg(all(feature = "kernel", feature = "user"))] 4 | compile_error!("features `crate/kernel` and `crate/user` are mutually exclusive"); 5 | 6 | #[cfg(feature = "kernel")] 7 | pub mod kernel; 8 | 9 | #[cfg(feature = "kernel")] 10 | pub use kernel::*; 11 | 12 | #[cfg(feature = "user")] 13 | pub mod user; 14 | 15 | #[cfg(feature = "user")] 16 | pub use user::*; -------------------------------------------------------------------------------- /rdma-shim/src/user/ffi.rs: -------------------------------------------------------------------------------- 1 | #[allow(non_camel_case_types)] 2 | 3 | pub mod c_types { 4 | pub type c_int = libc::c_int; 5 | pub type c_char = libc::c_char; 6 | pub type c_long = libc::c_long; 7 | pub type c_longlong = libc::c_longlong; 8 | pub type c_short = libc::c_short; 9 | pub type c_uchar = libc::c_uchar; 10 | pub type c_uint = libc::c_uint; 11 | pub type c_ulong = libc::c_ulong; 12 | pub type c_ulonglong = libc::c_ulonglong; 13 | pub type c_ushort = libc::c_ushort; 14 | pub type c_schar = libc::c_schar; 15 | pub type c_size_t = libc::size_t; 16 | pub type c_ssize_t = libc::ssize_t; 17 | pub type c_void = core::ffi::c_void; 18 | } 19 | -------------------------------------------------------------------------------- /rdma-shim/src/user/utils.rs: -------------------------------------------------------------------------------- 1 | /// A timer to record the time 2 | /// Not used now 3 | pub struct KTimer; 4 | 5 | impl KTimer { 6 | pub fn new() -> Self { 7 | unimplemented!(); 8 | } 9 | 10 | pub fn reset(&self) { 11 | unimplemented!(); 12 | } 13 | 14 | pub fn get_passed_usec(&self) -> u64 { 15 | unimplemented!(); 16 | } 17 | } -------------------------------------------------------------------------------- /rsync.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | user="wxd" 4 | #target=("val12" "val14") 5 | #target=("val02" "val01") 6 | target=("val01") 7 | 8 | path="./krdmakit" 9 | 10 | for machine in ${target[*]} 11 | do 12 | rsync -i -rtuv \ 13 | $PWD/deps \ 14 | $PWD/user-benchs \ 15 | $PWD/benchs \ 16 | $PWD/KRdmaKit \ 17 | $PWD/KRdmaKit-syscall \ 18 | $PWD/krdmakit-macros \ 19 | $PWD/rdma-shim \ 20 | $PWD/rust-user-rdma \ 21 | $PWD/rust-kernel-rdma \ 22 | $PWD/testlib \ 23 | $PWD/include \ 24 | $PWD/exp \ 25 | $PWD/exp_scripts \ 26 | $user@$machine:/home/${user}/${path} \ 27 | --exclude target \ 28 | --exclude Cargo.lock 29 | 30 | done 31 | -------------------------------------------------------------------------------- /rust-kernel-rdma/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vscode/ 3 | target/ 4 | Cargo.lock 5 | scripts/ 6 | **/target 7 | .DS_Store -------------------------------------------------------------------------------- /rust-kernel-rdma/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "deps/no-std-net"] 2 | path = deps/no-std-net 3 | url = https://gitlab-runner-ci:3gFbZWxNq7FnTAhrJRbC@ipads.se.sjtu.edu.cn:1312/distributed-rdma-serverless/kernel-rdma/no-std-net.git 4 | [submodule "deps/rust-kernel-module"] 5 | path = deps/rust-kernel-module 6 | url = https://gitlab-runner-ci:f-CnbRzz74CiG5e8k7nS@ipads.se.sjtu.edu.cn:1312/distributed-rdma-serverless/kernel-rdma/rust-kernel-module.git 7 | 8 | -------------------------------------------------------------------------------- /rust-kernel-rdma/README.md: -------------------------------------------------------------------------------- 1 | ## rust-kernel-rdma 2 | 3 | KRdmakit for basic RDMA operations in the kernel. 4 | 5 | ```sh 6 | rustup default nightly-2022-02-04-x86_64-unknown-linux-gnu 7 | rustup component add rust-src 8 | ``` 9 | 10 | ## Credits 11 | - Many code is inspired from https://github.com/jonhoo/rust-ibverbs/blob/master/ibverbs/src/lib.rs 12 | 13 | -------------------------------------------------------------------------------- /rust-kernel-rdma/ci/check_kernel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | test_machine=$1 4 | username=$2 5 | password=$3 6 | # show debug information 7 | dmesg 8 | result=$(dmesg | grep "kernel BUG") 9 | if [ "($result)" != "()" ];then 10 | echo "There is a bug in kernel, and we need to reboot the test machine" 11 | sudo ipmitool -I lanplus -H idrac-$test_machine -U $username -P $password chassis power cycle 12 | else 13 | echo "Seems like everything is alright" 14 | fi 15 | -------------------------------------------------------------------------------- /rust-kernel-rdma/ci/install_deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # verify rust installed or not 4 | if rustc --version; then 5 | echo "rust is already installed" 6 | else 7 | echo "install rust now" 8 | curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh -s -- -y 9 | source $HOME/.cargo/env 10 | fi 11 | 12 | rustup default nightly-2022-02-05-x86_64-unknown-linux-gnu 13 | rustup component add rust-src 14 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/no-std-net/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "no-std-net" 3 | description = "Rust's std::net... without the 'std'." 4 | version = "0.4.0" 5 | authors = [ "M@ Dunlap " ] 6 | categories = [ "embedded", "network-programming", "no-std" ] 7 | repository = "https://github.com/dunmatt/no-std-net" 8 | license = "MIT" 9 | 10 | [badges] 11 | maintenance = { status = "actively-developed" } 12 | travis-ci = { repository = "dunmatt/no-std-net" } 13 | 14 | [dependencies] 15 | serde = { version = "^1", default-features = false, optional = true } 16 | 17 | [dev-dependencies] 18 | serde_test = "^1" 19 | 20 | [features] 21 | default = [ ] 22 | 23 | # Deprecated. Does nothing. 24 | i128 = [ ] 25 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/no-std-net/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 M@ 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/no-std-net/README.md: -------------------------------------------------------------------------------- 1 | // XD: forked from https://github.com/dunmatt/no-std-net 2 | 3 | # no-std-net 4 | Rust's std::net except without the std. 5 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/.gitignore: -------------------------------------------------------------------------------- 1 | **/target 2 | **/*.rs.bk 3 | Cargo.lock 4 | .cache.mk 5 | .*o.cmd 6 | .tmp_versions/ 7 | Module.symvers 8 | *.ko 9 | *.mod.c 10 | *.o 11 | modules.order 12 | dummy.c 13 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/.travis.yml: -------------------------------------------------------------------------------- 1 | matrix: 2 | include: 3 | - dist: bionic 4 | 5 | language: rust 6 | rust: 7 | - nightly-2020-08-27 8 | 9 | branches: 10 | only: 11 | - master 12 | 13 | install: 14 | - sudo apt-get install -y "linux-headers-$(uname -r)" coreutils 15 | - sudo apt-get install clang-9 16 | - rustup component add rust-src rustfmt clippy 17 | 18 | script: 19 | - CLANG=clang-9 ./tests/run_tests.py 20 | - | 21 | for p in . hello-world tests/*; do 22 | if [ -d "$p" ]; then 23 | (cd "$p" && cargo fmt --all -- --check) || exit 1 24 | fi 25 | done 26 | 27 | after_failure: 28 | - dmesg 29 | 30 | notifications: 31 | email: false 32 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We're always excited to have contributions of any form! 4 | 5 | Examples of contributions include: 6 | 7 | * Code patches 8 | * Documentation improvements 9 | * Bug reports and patch reviews 10 | 11 | ## Filing issues 12 | 13 | If you're filing an issue for a build error, please include enough information 14 | for us to diagnose and reproduce the issue. This generally means, at a minimum 15 | the kernel version (and, if it's not a vanilla upstream kernel, where you got 16 | the kernel from) and your compiler versions (Rust, Clang, and GCC). 17 | 18 | ## Contributing code 19 | 20 | To contribute code, you can send a pull request on Github. Please make sure your 21 | code is formatted with `cargo fmt`, builds, the tests pass, and it's `cargo 22 | clippy`-clean. Don't worry, we've got continuous integration if you miss 23 | anything. 24 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "linux-kernel-module" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | bitflags = "1" 9 | 10 | [build-dependencies] 11 | bindgen = {version = "0.59.1"} 12 | cc = "1.0" 13 | shlex = "0.1" 14 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/hello-world/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello-world" 3 | version = "0.1.0" 4 | authors = ["Geoffrey Thomas "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | 10 | [dependencies] 11 | linux-kernel-module = { path = ".." } 12 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/hello-world/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := helloworld.o 2 | helloworld-objs := hello_world.rust.o 3 | 4 | CARGO ?= cargo 5 | 6 | export c_flags 7 | 8 | $(src)/target/x86_64-linux-kernel/debug/libhello_world.a: cargo_will_determine_dependencies 9 | cd $(src); $(CARGO) build -Z build-std=core,alloc --target=x86_64-linux-kernel 10 | 11 | .PHONY: cargo_will_determine_dependencies 12 | 13 | %.rust.o: target/x86_64-linux-kernel/debug/lib%.a 14 | $(LD) -r -o $@ --whole-archive $< 15 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/hello-world/Makefile: -------------------------------------------------------------------------------- 1 | export KDIR ?= /lib/modules/$(shell uname -r)/build 2 | 3 | CLANG ?= clang-9 4 | ifeq ($(origin CC),default) 5 | CC := ${CLANG} 6 | endif 7 | 8 | all: 9 | $(MAKE) -C $(KDIR) M=$(CURDIR) CC=$(CC) CONFIG_CC_IS_CLANG=y 10 | 11 | clean: 12 | $(MAKE) -C $(KDIR) M=$(CURDIR) CC=$(CC) clean 13 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/hello-world/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | extern crate alloc; 4 | 5 | use alloc::borrow::ToOwned; 6 | use alloc::string::String; 7 | 8 | use linux_kernel_module::println; 9 | 10 | struct HelloWorldModule { 11 | message: String, 12 | } 13 | 14 | impl linux_kernel_module::KernelModule for HelloWorldModule { 15 | fn init() -> linux_kernel_module::KernelResult { 16 | println!("Hello kernel module!"); 17 | Ok(HelloWorldModule { 18 | message: "on the heap!".to_owned(), 19 | }) 20 | } 21 | } 22 | 23 | impl Drop for HelloWorldModule { 24 | fn drop(&mut self) { 25 | println!("My message is {}", self.message); 26 | println!("Goodbye kernel module!"); 27 | } 28 | } 29 | 30 | linux_kernel_module::kernel_module!( 31 | HelloWorldModule, 32 | author: b"Fish in a Barrel Contributors", 33 | description: b"An extremely simple kernel module", 34 | license: b"GPL" 35 | ); 36 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/src/allocator.rs: -------------------------------------------------------------------------------- 1 | use core::alloc::{GlobalAlloc, Layout}; 2 | use core::ptr; 3 | 4 | use crate::bindings; 5 | use crate::c_types; 6 | 7 | pub struct KernelAllocator; 8 | 9 | unsafe impl GlobalAlloc for KernelAllocator { 10 | unsafe fn alloc(&self, layout: Layout) -> *mut u8 { 11 | // krealloc is used instead of kmalloc because kmalloc is an inline function and can't be 12 | // bound to as a result 13 | bindings::krealloc(ptr::null(), layout.size(), bindings::GFP_KERNEL) as *mut u8 14 | } 15 | 16 | unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) { 17 | bindings::kfree(ptr as *const c_types::c_void); 18 | } 19 | } 20 | 21 | #[alloc_error_handler] 22 | fn oom(_layout: Layout) -> ! { 23 | panic!("Out of memory!"); 24 | } 25 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/src/bindings.rs: -------------------------------------------------------------------------------- 1 | #[allow( 2 | clippy::all, 3 | non_camel_case_types, 4 | non_upper_case_globals, 5 | non_snake_case, 6 | improper_ctypes 7 | )] 8 | mod bindings { 9 | use crate::c_types; 10 | include!(concat!(env!("OUT_DIR"), "/bindings.rs")); 11 | } 12 | pub use bindings::*; 13 | 14 | pub const GFP_KERNEL: gfp_t = BINDINGS_GFP_KERNEL; 15 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/src/bindings_helper.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | // Bindgen gets confused at certain things 11 | // 12 | const gfp_t BINDINGS_GFP_KERNEL = GFP_KERNEL; 13 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/src/c_types.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_camel_case_types)] 2 | 3 | #[cfg(target_arch = "x86_64")] 4 | mod c { 5 | use core::ffi; 6 | 7 | pub type c_int = i32; 8 | pub type c_char = i8; 9 | pub type c_long = i64; 10 | pub type c_longlong = i64; 11 | pub type c_short = i16; 12 | pub type c_uchar = u8; 13 | pub type c_uint = u32; 14 | pub type c_ulong = u64; 15 | pub type c_ulonglong = u64; 16 | pub type c_ushort = u16; 17 | pub type c_schar = i8; 18 | pub type c_size_t = usize; 19 | pub type c_ssize_t = isize; 20 | pub type c_void = ffi::c_void; 21 | } 22 | 23 | pub use c::*; 24 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/src/helpers.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | void 7 | mutex_init_helper(struct mutex* mutex) 8 | { 9 | mutex_init(mutex); 10 | } 11 | 12 | void bug_helper(void) 13 | { 14 | BUG(); 15 | } 16 | 17 | int access_ok_helper(const void __user *addr, unsigned long n) 18 | { 19 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) /* v5.0-rc1~46 */ 20 | return access_ok(addr, n); 21 | #else 22 | return access_ok(0, addr, n); 23 | #endif 24 | } 25 | 26 | /* see https://github.com/rust-lang/rust-bindgen/issues/1671 */ 27 | _Static_assert(__builtin_types_compatible_p(size_t, uintptr_t), 28 | "size_t must match uintptr_t, what architecture is this??"); 29 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/src/inline_helper.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void 4 | mutex_init_helper(struct mutex* mutex); -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/src/sync.rs: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | // 3 | // Copyright (c) 2020-2021 Andre Richter 4 | 5 | //! Synchronization primitives. 6 | //! 7 | //! # Resources 8 | //! 9 | //! - 10 | //! - 11 | //! - 12 | 13 | //-------------------------------------------------------------------------------------------------- 14 | // Public Definitions 15 | //-------------------------------------------------------------------------------------------------- 16 | 17 | /// Any object implementing this trait guarantees exclusive access to the data wrapped within 18 | /// the Mutex for the duration of the provided closure. 19 | pub trait Mutex<'a, T: 'a> { 20 | /// The type of the data that is wrapped by this mutex. 21 | // type Data; 22 | 23 | /// Locks the mutex and grants the closure temporary mutable access to the wrapped data. 24 | fn lock_f(&self, f: impl FnOnce(&'a mut T) -> R) -> R; 25 | } 26 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/testlib/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "kernel-module-testlib" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | tempfile = "3" 9 | libc = "0.2.58" 10 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := testmodule.o 2 | testmodule-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | 6 | export c_flags 7 | 8 | $(src)/target/x86_64-linux-kernel/debug/lib%.a: cargo_will_determine_dependencies 9 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=x86_64-linux-kernel 10 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) clippy -Z build-std=core,alloc --target=x86_64-linux-kernel -- -Dwarnings 11 | 12 | .PHONY: cargo_will_determine_dependencies 13 | 14 | %.rust.o: target/x86_64-linux-kernel/debug/lib%.a 15 | $(LD) -r -o $@ --whole-archive $< 16 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/Makefile: -------------------------------------------------------------------------------- 1 | export KDIR ?= /lib/modules/$(shell uname -r)/build 2 | 3 | CLANG ?= clang 4 | ifeq ($(origin CC),default) 5 | CC := ${CLANG} 6 | endif 7 | 8 | all: 9 | $(MAKE) -C $(KDIR) M=$(CURDIR) CC=$(CC) CONFIG_CC_IS_CLANG=y 10 | 11 | clean: 12 | $(MAKE) -C $(KDIR) M=$(CURDIR) CC=$(CC) clean 13 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/chrdev-region-allocation/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "chrdev-region-allocation-tests" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor ", "Geoffrey Thomas "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | test = false 10 | 11 | [features] 12 | default = ["linux-kernel-module"] 13 | 14 | [dependencies] 15 | linux-kernel-module = { path = "../..", optional = true } 16 | 17 | [dev-dependencies] 18 | kernel-module-testlib = { path = "../../testlib" } 19 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/chrdev-region-allocation/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | use linux_kernel_module::{self, cstr}; 4 | 5 | struct ChrdevRegionAllocationTestModule { 6 | _chrdev_reg: linux_kernel_module::chrdev::Registration, 7 | } 8 | 9 | impl linux_kernel_module::KernelModule for ChrdevRegionAllocationTestModule { 10 | fn init() -> linux_kernel_module::KernelResult { 11 | let chrdev_reg = 12 | linux_kernel_module::chrdev::builder(cstr!("chrdev-region-allocation-tests"), 0..1)? 13 | .build()?; 14 | 15 | Ok(ChrdevRegionAllocationTestModule { 16 | _chrdev_reg: chrdev_reg, 17 | }) 18 | } 19 | } 20 | 21 | linux_kernel_module::kernel_module!( 22 | ChrdevRegionAllocationTestModule, 23 | author: b"Fish in a Barrel Contributors", 24 | description: b"A module for testing character device region allocation", 25 | license: b"GPL" 26 | ); 27 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/chrdev-region-allocation/tests/tests.rs: -------------------------------------------------------------------------------- 1 | use std::fs; 2 | 3 | use kernel_module_testlib::with_kernel_module; 4 | 5 | #[test] 6 | fn test_proc_devices() { 7 | with_kernel_module(|| { 8 | let devices = fs::read_to_string("/proc/devices").unwrap(); 9 | let dev_no_line = devices 10 | .lines() 11 | .find(|l| l.ends_with("chrdev-region-allocation-tests")) 12 | .unwrap(); 13 | let elements = dev_no_line.rsplitn(2, " ").collect::>(); 14 | assert_eq!(elements.len(), 2); 15 | assert_eq!(elements[0], "chrdev-region-allocation-tests"); 16 | assert!(elements[1].trim().parse::().is_ok()); 17 | }); 18 | 19 | let devices = fs::read_to_string("/proc/devices").unwrap(); 20 | assert!(devices 21 | .lines() 22 | .find(|l| l.ends_with("chrdev-region-allocation-tests")) 23 | .is_none()); 24 | } 25 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/chrdev/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "chrdev-tests" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor ", "Geoffrey Thomas "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | test = false 10 | 11 | [features] 12 | default = ["linux-kernel-module"] 13 | 14 | [dependencies] 15 | linux-kernel-module = { path = "../..", optional = true } 16 | 17 | [dev-dependencies] 18 | kernel-module-testlib = { path = "../../testlib" } 19 | libc = "0.2.58" 20 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/filesystem/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "filesystem-tests" 3 | version = "0.1.0" 4 | authors = ["Luis Gerhorst ", "Alex Gaynor ", "Geoffrey Thomas "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | test = false 10 | 11 | [features] 12 | default = ["linux-kernel-module"] 13 | 14 | [dependencies] 15 | linux-kernel-module = { path = "../..", optional = true } 16 | no-std-net = {path = "../deps/no-std-net"} 17 | 18 | [dev-dependencies] 19 | kernel-module-testlib = { path = "../../testlib" } 20 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/filesystem/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | extern crate alloc; 4 | 5 | use linux_kernel_module::filesystem::{self, FileSystem, FileSystemFlags}; 6 | use linux_kernel_module::{self, cstr, CStr}; 7 | 8 | struct TestFSModule { 9 | _fs_registration: filesystem::Registration, 10 | } 11 | 12 | struct TestFS {} 13 | 14 | impl FileSystem for TestFS { 15 | const NAME: CStr<'static> = cstr!("testfs"); 16 | const FLAGS: FileSystemFlags = FileSystemFlags::empty(); 17 | } 18 | 19 | impl linux_kernel_module::KernelModule for TestFSModule { 20 | fn init() -> linux_kernel_module::KernelResult { 21 | let fs_registration = filesystem::register::()?; 22 | Ok(TestFSModule { 23 | _fs_registration: fs_registration, 24 | }) 25 | } 26 | } 27 | 28 | linux_kernel_module::kernel_module!( 29 | TestFSModule, 30 | author: b"Fish in a Barrel Contributors", 31 | description: b"A module for testing filesystem::register", 32 | license: b"GPL" 33 | ); 34 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/filesystem/tests/tests.rs: -------------------------------------------------------------------------------- 1 | use std::fs; 2 | 3 | use kernel_module_testlib::with_kernel_module; 4 | 5 | #[test] 6 | fn test_proc_filesystems() { 7 | let filesystems = fs::read_to_string("/proc/filesystems").unwrap(); 8 | assert!(!filesystems.contains("testfs")); 9 | 10 | with_kernel_module(|| { 11 | let filesystems = fs::read_to_string("/proc/filesystems").unwrap(); 12 | assert!(filesystems.contains("testfs")); 13 | }); 14 | 15 | let filesystems = fs::read_to_string("/proc/filesystems").unwrap(); 16 | assert!(!filesystems.contains("testfs")); 17 | } 18 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/modinfo/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "modinfo-tests" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor ", "Geoffrey Thomas "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | test = false 10 | 11 | [features] 12 | default = ["linux-kernel-module"] 13 | 14 | [dependencies] 15 | linux-kernel-module = { path = "../..", optional = true } 16 | 17 | [dev-dependencies] 18 | kernel-module-testlib = { path = "../../testlib" } 19 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/modinfo/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | struct ModinfoTestModule; 4 | 5 | impl linux_kernel_module::KernelModule for ModinfoTestModule { 6 | fn init() -> linux_kernel_module::KernelResult { 7 | Ok(ModinfoTestModule) 8 | } 9 | } 10 | 11 | linux_kernel_module::kernel_module!( 12 | ModinfoTestModule, 13 | author: b"Fish in a Barrel Contributors", 14 | description: b"Empty module for testing modinfo", 15 | license: b"GPL" 16 | ); 17 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/printk/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "printk-tests" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor ", "Geoffrey Thomas "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | test = false 10 | 11 | [features] 12 | default = ["linux-kernel-module"] 13 | 14 | [dependencies] 15 | linux-kernel-module = { path = "../..", optional = true } 16 | 17 | [dev-dependencies] 18 | kernel-module-testlib = { path = "../../testlib" } 19 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/printk/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | #![allow(clippy::print_literal)] 3 | 4 | use linux_kernel_module::{self, println}; 5 | 6 | struct PrintkTestModule; 7 | 8 | impl linux_kernel_module::KernelModule for PrintkTestModule { 9 | fn init() -> linux_kernel_module::KernelResult { 10 | println!("Single element printk"); 11 | println!(); 12 | println!("printk with {} parameters{}", 2, "!"); 13 | 14 | Ok(PrintkTestModule) 15 | } 16 | } 17 | 18 | linux_kernel_module::kernel_module!( 19 | PrintkTestModule, 20 | author: b"Fish in a Barrel Contributors", 21 | description: b"A module for testing println!()", 22 | license: b"GPL" 23 | ); 24 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/printk/tests/tests.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{assert_dmesg_contains, with_kernel_module}; 2 | 3 | #[test] 4 | fn test_printk() { 5 | with_kernel_module(|| { 6 | assert_dmesg_contains(&[b"Single element printk", b"", b"printk with 2 parameters!"]); 7 | }); 8 | } 9 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/random/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "random-tests" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor ", "Geoffrey Thomas "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | test = false 10 | 11 | [features] 12 | default = ["linux-kernel-module"] 13 | 14 | [dependencies] 15 | linux-kernel-module = { path = "../..", optional = true } 16 | 17 | [dev-dependencies] 18 | kernel-module-testlib = { path = "../../testlib" } 19 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/random/tests/tests.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashSet; 2 | use std::fs; 3 | use std::io::Read; 4 | 5 | use kernel_module_testlib::with_kernel_module; 6 | 7 | #[test] 8 | fn test_random_entropy_read() { 9 | with_kernel_module(|| { 10 | let mut keys = HashSet::new(); 11 | for _ in 0..1024 { 12 | let mut key = [0; 16]; 13 | let mut f = fs::File::open("/proc/sys/rust/random-tests/entropy").unwrap(); 14 | f.read_exact(&mut key).unwrap(); 15 | keys.insert(key); 16 | } 17 | assert_eq!(keys.len(), 1024); 18 | }); 19 | } 20 | 21 | #[test] 22 | fn test_random_entropy_write() { 23 | with_kernel_module(|| { 24 | fs::write("/proc/sys/rust/random-tests/entropy", b"1234567890").unwrap(); 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/sysctl-get/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sysctl-get-tests" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | test = false 10 | 11 | [features] 12 | default = ["linux-kernel-module"] 13 | 14 | [dependencies] 15 | linux-kernel-module = { path = "../..", optional = true } 16 | 17 | [dev-dependencies] 18 | kernel-module-testlib = { path = "../../testlib" } 19 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/sysctl-get/tests/tests.rs: -------------------------------------------------------------------------------- 1 | use std::fs; 2 | 3 | use kernel_module_testlib::{assert_dmesg_contains, with_kernel_module}; 4 | 5 | #[test] 6 | fn test_get() { 7 | with_kernel_module(|| { 8 | fs::write("/proc/sys/rust/sysctl-get-tests/a", "1").unwrap(); 9 | }); 10 | assert_dmesg_contains(&[b"A_VAL: true", b"SYSCTL_A: true"]); 11 | } 12 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/sysctl/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "sysctl-tests" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | test = false 10 | 11 | [features] 12 | default = ["linux-kernel-module"] 13 | 14 | [dependencies] 15 | linux-kernel-module = { path = "../..", optional = true } 16 | 17 | [dev-dependencies] 18 | kernel-module-testlib = { path = "../../testlib" } 19 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/utils/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "utils-tests" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor ", "Geoffrey Thomas "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["staticlib"] 9 | test = false 10 | 11 | [features] 12 | default = ["linux-kernel-module"] 13 | 14 | [dependencies] 15 | linux-kernel-module = { path = "../..", optional = true } 16 | 17 | [dev-dependencies] 18 | kernel-module-testlib = { path = "../../testlib" } 19 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/utils/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | struct UtilsTestModule; 4 | 5 | #[allow(dead_code)] 6 | const TEST_CSTR: linux_kernel_module::CStr<'static> = linux_kernel_module::cstr!("abc"); 7 | 8 | impl linux_kernel_module::KernelModule for UtilsTestModule { 9 | fn init() -> linux_kernel_module::KernelResult { 10 | Ok(UtilsTestModule) 11 | } 12 | } 13 | 14 | linux_kernel_module::kernel_module!( 15 | UtilsTestModule, 16 | author: b"Fish in a Barrel Contributors", 17 | description: b"A module for testing various utilities", 18 | license: b"GPL" 19 | ); 20 | -------------------------------------------------------------------------------- /rust-kernel-rdma/deps/rust-kernel-module/tests/utils/tests/tests.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::with_kernel_module; 2 | 3 | #[test] 4 | fn test_module_loads() { 5 | with_kernel_module(|| {}); 6 | } 7 | -------------------------------------------------------------------------------- /rust-kernel-rdma/krdma-test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "krdma-test" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | quote = "1.0" 10 | syn = { version = "1.0.56", features = ["full"] } 11 | 12 | [lib] 13 | proc-macro = true -------------------------------------------------------------------------------- /rust-kernel-rdma/krdma-test/rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | components = ["rust-src"] -------------------------------------------------------------------------------- /rust-kernel-rdma/krdma-test/unitests/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := testmodule.o 2 | testmodule-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | 6 | export c_flags 7 | export UTEST 8 | 9 | $(src)/target/x86_64-unknown-none-linuxkernel/debug/lib%.a: cargo_will_determine_dependencies 10 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=x86_64-unknown-none-linuxkernel 11 | 12 | .PHONY: cargo_will_determine_dependencies 13 | 14 | %.rust.o: target/x86_64-unknown-none-linuxkernel/debug/lib%.a 15 | $(LD) -r -o $@ --whole-archive $< 16 | -------------------------------------------------------------------------------- /rust-kernel-rdma/krdma-test/unitests/test-macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "test-macros-tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["rust-kernel-linux-util","krdma-test"] 16 | 17 | [dependencies] 18 | rust-kernel-linux-util = {path = "../../../rust-kernel-linux-util",optional = true, features=["static_log_check","max_level_info"]} 19 | krdma-test = {path = "../../../krdma-test",optional = true} 20 | 21 | [dev-dependencies] 22 | kernel-module-testlib = { path = "../../../testlib" } 23 | -------------------------------------------------------------------------------- /rust-kernel-rdma/krdma-test/unitests/test-macros/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | use krdma_test::{krdma_test, krdma_drop}; 4 | 5 | use rust_kernel_linux_util::linux_kernel_module; 6 | use rust_kernel_linux_util as log; 7 | 8 | fn test_0() { 9 | log::info!("test case 0!"); 10 | } 11 | 12 | fn test_1() { 13 | log::info!("test case 1!"); 14 | } 15 | 16 | #[krdma_test(test_0,test_1)] 17 | fn init() { 18 | log::info!("in init"); 19 | } 20 | 21 | #[krdma_drop] 22 | fn drop() { 23 | log::info!("in drop"); 24 | } 25 | -------------------------------------------------------------------------------- /rust-kernel-rdma/krdma-test/unitests/test-macros/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module}; 2 | 3 | #[test] 4 | fn test_work() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | println!("work"); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-linux-util/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust-kernel-linux-util" 3 | version = "0.1.0" 4 | authors = ["CaribouW <1071956678@qq.com>"] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | linux-kernel-module = { path = "../deps/rust-kernel-module" } 11 | no-std-net = {path = "../deps/no-std-net"} 12 | cfg-if = "1.0" 13 | 14 | [build-dependencies] 15 | bindgen = "0.59.1" 16 | cc = "1.0" 17 | shlex = "0.1" 18 | 19 | [features] 20 | max_level_off = [] 21 | max_level_error = [] 22 | max_level_warn = [] 23 | max_level_info = [] 24 | max_level_debug = [] 25 | max_level_trace = [] 26 | 27 | static_log_check = [] ## avoid dynamically reading the global max_level for better performance -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-linux-util/README.md: -------------------------------------------------------------------------------- 1 | # rust-kernel-linux-util 2 | ## Tested linux kernel version 3 | - kernel `4.15.0-46-generic` 4 | ## Rust dependency 5 | 6 | install rustc 7 | 8 | ```sh 9 | curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh 10 | ``` 11 | 12 | Currently, RLib is only tested on a specific version of `rust`: `rustup-nightly` @**version 2020-11-10**. 13 | We will fix problem using the latest rust compiler in the future. 14 | 15 | ```sh 16 | rustup default nightly-2020-11-10-x86_64-unknown-linux-gnu 17 | rustup component add rust-src 18 | ``` 19 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-linux-util/src/string.rs: -------------------------------------------------------------------------------- 1 | extern crate alloc; 2 | 3 | use alloc::string::String; 4 | 5 | use core::{str, slice}; 6 | 7 | pub unsafe fn strlen(ptr: *const u8) -> usize { 8 | let mut res: usize = 0; 9 | loop { 10 | if *ptr.add(res as usize) == 0 { 11 | return res; 12 | } 13 | res += 1; 14 | } 15 | } 16 | 17 | pub unsafe fn ptr2string(ptr: *const u8) -> String { 18 | let s = str::from_utf8_unchecked(slice::from_raw_parts(ptr, strlen(ptr))); 19 | String::from(s) 20 | } 21 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-linux-util/unitests/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := testmodule.o 2 | testmodule-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | 6 | export c_flags 7 | export UTEST 8 | 9 | $(src)/target/x86_64-unknown-none-linuxkernel/debug/lib%.a: cargo_will_determine_dependencies 10 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=x86_64-unknown-none-linuxkernel 11 | 12 | .PHONY: cargo_will_determine_dependencies 13 | 14 | %.rust.o: target/x86_64-unknown-none-linuxkernel/debug/lib%.a 15 | $(LD) -r -o $@ --whole-archive $< 16 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-linux-util/unitests/kthread/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "kthread-tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["rust-kernel-linux-util"] 16 | 17 | [dependencies] 18 | rust-kernel-linux-util = {path = "../../../rust-kernel-linux-util",optional = true, features=["static_log_check","max_level_info"]} 19 | krdma-test = {path = "../../../krdma-test"} 20 | 21 | [dev-dependencies] 22 | kernel-module-testlib = { path = "../../../testlib" } 23 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-linux-util/unitests/kthread/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_kthread() { 5 | with_kernel_module(|| { 6 | assert_eq!(dmesg_contains(&String::from("error")),false); 7 | }); 8 | } 9 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-linux-util/unitests/log-level-static/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "log-level-static-tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["rust-kernel-linux-util"] 16 | 17 | [dependencies] 18 | rust-kernel-linux-util = {path = "../../../rust-kernel-linux-util",optional = true, features=["static_log_check","max_level_error"]} 19 | 20 | 21 | [dev-dependencies] 22 | kernel-module-testlib = { path = "../../../testlib" } 23 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-linux-util/unitests/log-level-static/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | struct SampleTestModule { 4 | } 5 | 6 | use rust_kernel_linux_util::{linux_kernel_module}; 7 | 8 | impl linux_kernel_module::KernelModule for SampleTestModule { 9 | 10 | fn init() -> linux_kernel_module::KernelResult { 11 | 12 | use rust_kernel_linux_util as log; 13 | // log::set_max_level(log::LevelFilter::Trace); 14 | log::info!("info"); 15 | log::error!("error"); 16 | log::warn!("warn"); 17 | log::debug!("debug"); 18 | 19 | Ok(Self {}) 20 | } 21 | } 22 | 23 | linux_kernel_module::kernel_module!( 24 | SampleTestModule, 25 | author: b"xmm", 26 | description: b"Test static log level in the kernel", 27 | license: b"GPL" 28 | ); 29 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-linux-util/unitests/log-level-static/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module}; 2 | 3 | #[test] 4 | fn test_simple() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | println!("sampe test"); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-linux-util/unitests/log-level/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "log-level-tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["rust-kernel-linux-util"] 16 | 17 | [dependencies] 18 | rust-kernel-linux-util = {path = "../../../rust-kernel-linux-util",optional = true} 19 | 20 | 21 | [dev-dependencies] 22 | kernel-module-testlib = { path = "../../../testlib" } 23 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-linux-util/unitests/log-level/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | struct SampleTestModule { 4 | } 5 | 6 | use rust_kernel_linux_util::{linux_kernel_module}; 7 | 8 | impl linux_kernel_module::KernelModule for SampleTestModule { 9 | 10 | fn init() -> linux_kernel_module::KernelResult { 11 | 12 | use rust_kernel_linux_util as log; 13 | log::set_max_level(log::LevelFilter::Trace); 14 | log::info!("info"); 15 | log::error!("error"); 16 | log::warn!("warn"); 17 | log::debug!("debug"); 18 | 19 | Ok(Self {}) 20 | } 21 | } 22 | 23 | linux_kernel_module::kernel_module!( 24 | SampleTestModule, 25 | author: b"xmm", 26 | description: b"Test log level in the kernel", 27 | license: b"GPL" 28 | ); 29 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-linux-util/unitests/log-level/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module,assert_dmesg_ends,assert_dmesg_contains, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_simple() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | println!("sampe test"); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-linux-util/unitests/sample/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "sample_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["rust-kernel-rdma-base"] 16 | 17 | [dependencies] 18 | rust-kernel-rdma-base = {path = "../../../rust-kernel-rdma-base",optional = true} 19 | 20 | 21 | [dev-dependencies] 22 | kernel-module-testlib = { path = "../../../testlib" } 23 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-linux-util/unitests/sample/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | struct SampleTestModule { 4 | } 5 | 6 | use rust_kernel_rdma_base::linux_kernel_module; 7 | use linux_kernel_module::println; 8 | 9 | impl linux_kernel_module::KernelModule for SampleTestModule { 10 | fn init() -> linux_kernel_module::KernelResult { 11 | println!("sample test module in raw kernel rdma bindings!"); 12 | 13 | println!("check version"); 14 | Ok(Self {}) 15 | } 16 | } 17 | 18 | linux_kernel_module::kernel_module!( 19 | SampleTestModule, 20 | author: b"xmm", 21 | description: b"A sample module for unit testing", 22 | license: b"GPL" 23 | ); 24 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-linux-util/unitests/sample/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module,assert_dmesg_ends,assert_dmesg_contains, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_simple() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | println!("sampe test"); 8 | 9 | let test_strs = ["bindings!".as_bytes()]; 10 | assert_dmesg_ends(&test_strs); 11 | 12 | let test_strs2 = [String::from("raw kernel")]; 13 | assert_dmesg_contains(&test_strs2); 14 | 15 | assert_eq!(dmesg_contains(&String::from("unknown")),false); 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-rdma-base/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust-kernel-rdma-base" 3 | version = "0.1.0" 4 | authors = ["xmm "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | linux-kernel-module = { path = "../deps/rust-kernel-module" } 11 | rust-kernel-linux-util = { path = "../rust-kernel-linux-util" } 12 | no-std-net = {path = "../deps/no-std-net"} 13 | paste = "1.0" 14 | 15 | [build-dependencies] 16 | bindgen = "0.59.1" ## FIXME: update 17 | cc = "1.0" 18 | shlex = "0.1" 19 | 20 | [features] 21 | dct = [] -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-rdma-base/README.md: -------------------------------------------------------------------------------- 1 | # rust-kernel-rdma-base 2 | 3 | > Raw RDMA interface communicate with C linux kernel 4 | 5 | This module is the lowest tier to the raw linux kernel, close to 6 | the linux native functions/type definitions for `RDMA`. The upper kernel rdma 7 | interface(`KRdmaKit`) could directly use the service in this module. 8 | 9 | ## Tested linux kernel version 10 | - kernel `4.15.0-46-generic` 11 | ## Rust dependency 12 | 13 | install rustc 14 | 15 | ```sh 16 | curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh 17 | ``` 18 | 19 | Currently, RLib is only tested on a specific version of `rust`: `rustup-nightly` @**version 2020-11-10**. 20 | We will fix problem using the latest rust compiler in the future. 21 | 22 | ```sh 23 | rustup default nightly-2020-11-10-x86_64-unknown-linux-gnu 24 | rustup component add rust-src 25 | ``` 26 | 27 | ## RDMA dependencies 28 | - MLNX_OFED_LINUX-4.4-2.0.7.0 (OFED-4.4-2.0.7)` 29 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-rdma-base/src/allocator.rs: -------------------------------------------------------------------------------- 1 | //use core::alloc::{Layout, AllocRef, AllocError}; 2 | use core::alloc::{AllocError, Allocator}; 3 | use core::ptr::NonNull; 4 | 5 | use core::alloc::Layout; 6 | 7 | use crate::linux_kernel_module::c_types; 8 | 9 | use crate::rust_kernel_linux_util::bindings; 10 | 11 | #[derive(Copy, Clone, Default, Debug)] 12 | pub struct VmallocAllocator; 13 | 14 | unsafe impl Allocator for VmallocAllocator { 15 | fn allocate(&self, layout: Layout) -> Result, AllocError> { 16 | match layout.size() { 17 | 0 => Ok(NonNull::slice_from_raw_parts(layout.dangling(), 0)), 18 | // SAFETY: `layout` is non-zero in size, 19 | size => { 20 | let raw_ptr = unsafe { bindings::vmalloc(size as u64) } as *mut u8; 21 | let ptr = NonNull::new(raw_ptr).ok_or(AllocError)?; 22 | Ok(NonNull::slice_from_raw_parts(ptr, size)) 23 | } 24 | } 25 | } 26 | 27 | unsafe fn deallocate(&self, ptr: NonNull, _layout: Layout) { 28 | bindings::vfree(ptr.as_ptr() as *const c_types::c_void); 29 | } 30 | } -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-rdma-base/src/bindings.rs: -------------------------------------------------------------------------------- 1 | #[allow( 2 | clippy::all, 3 | non_camel_case_types, 4 | non_upper_case_globals, 5 | non_snake_case, 6 | improper_ctypes, 7 | non_upper_case_globals, 8 | dead_code 9 | )] 10 | mod bindings { 11 | use linux_kernel_module::c_types; 12 | include!(concat!(env!("OUT_DIR"), "/bindings-",env!("CARGO_PKG_NAME"),".rs")); 13 | } 14 | 15 | pub use bindings::*; 16 | 17 | impl PartialEq for ib_gid { 18 | fn eq(&self, other: &ib_gid) -> bool { 19 | unsafe { self.raw == other.raw } 20 | } 21 | } 22 | 23 | impl Eq for ib_gid {} 24 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-rdma-base/src/consts.rs: -------------------------------------------------------------------------------- 1 | pub const MAX_UD_RECV_CQE: usize = 2048; 2 | pub const MAX_UD_RECV_WR: usize = 2048; 3 | 4 | 5 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-rdma-base/unitests/Kbuild: -------------------------------------------------------------------------------- 1 | obj-m := testmodule.o 2 | testmodule-objs := $(TEST_NAME).rust.o 3 | 4 | CARGO ?= cargo 5 | 6 | export c_flags 7 | export UTEST 8 | 9 | $(src)/target/x86_64-unknown-none-linuxkernel/debug/lib%.a: cargo_will_determine_dependencies 10 | cd $(src)/$(TEST_PATH); CARGO_TARGET_DIR=../target $(CARGO) build -Z build-std=core,alloc --target=x86_64-unknown-none-linuxkernel 11 | 12 | .PHONY: cargo_will_determine_dependencies 13 | 14 | %.rust.o: target/x86_64-unknown-none-linuxkernel/debug/lib%.a 15 | $(LD) -r -o $@ --whole-archive $< 16 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-rdma-base/unitests/cm_funcs/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "cm_funcs_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["rust-kernel-rdma-base"] 16 | 17 | [dependencies] 18 | rust-kernel-rdma-base = {path = "../../../rust-kernel-rdma-base",optional = true} 19 | 20 | ## lazy static 21 | [dependencies.lazy_static] 22 | version = "1.0" 23 | features = ["spin_no_std"] 24 | 25 | 26 | [dev-dependencies] 27 | kernel-module-testlib = { path = "../../../testlib" } 28 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-rdma-base/unitests/cm_funcs/src/console_msgs.rs: -------------------------------------------------------------------------------- 1 | pub static SUCC : [&str;2] = ["client ok","Dev ok"]; 2 | pub static ERR : [&str;2] = ["cleint err","Dev empty"]; 3 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-rdma-base/unitests/cm_funcs/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module,dmesg_contains}; 2 | 3 | #[test] 4 | fn test_cm_funcs_exists() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | // other err messages 8 | assert_eq!(dmesg_contains(&String::from("null")),false); 9 | }); 10 | } 11 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-rdma-base/unitests/create_dct/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "create_dct_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["rust-kernel-rdma-base"] 16 | 17 | [dependencies] 18 | rust-kernel-rdma-base = {path = "../../../rust-kernel-rdma-base",optional = true, features=["dct"]} 19 | 20 | ## lazy static 21 | [dependencies.lazy_static] 22 | version = "1.0" 23 | features = ["spin_no_std"] 24 | 25 | 26 | [dev-dependencies] 27 | kernel-module-testlib = { path = "../../../testlib" } 28 | 29 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-rdma-base/unitests/create_dct/Cargo.toml~: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "create_qps_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["rust-kernel-rdma-base"] 16 | 17 | [dependencies] 18 | rust-kernel-rdma-base = {path = "../../../rust-kernel-rdma-base",optional = true} 19 | 20 | ## lazy static 21 | [dependencies.lazy_static] 22 | version = "1.0" 23 | features = ["spin_no_std"] 24 | 25 | 26 | [dev-dependencies] 27 | kernel-module-testlib = { path = "../../../testlib" } 28 | 29 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-rdma-base/unitests/create_dct/src/console_msgs.rs: -------------------------------------------------------------------------------- 1 | pub static SUCC : [&str;2] = ["client ok","Dev ok"]; 2 | pub static ERR : [&str;2] = ["cleint err","Dev empty"]; 3 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-rdma-base/unitests/create_dct/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module,assert_dmesg_contains,dmesg_contains}; 2 | 3 | #[test] 4 | fn test_create_dct() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | // ok strings 8 | let test_strs2 = [String::from("client ok"), String::from("create cq ok")]; 9 | assert_dmesg_contains(&test_strs2); 10 | 11 | // bad msgs 12 | assert_eq!(dmesg_contains(&String::from("null cq")),false); 13 | assert_eq!(dmesg_contains(&String::from("null qp")),false); 14 | 15 | // other err messages 16 | assert_eq!(dmesg_contains(&String::from("err")),false); 17 | 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-rdma-base/unitests/create_qps/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "create_qps_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["rust-kernel-rdma-base"] 16 | 17 | [dependencies] 18 | rust-kernel-rdma-base = {path = "../../../rust-kernel-rdma-base",optional = true} 19 | 20 | ## lazy static 21 | [dependencies.lazy_static] 22 | version = "1.0" 23 | features = ["spin_no_std"] 24 | 25 | 26 | [dev-dependencies] 27 | kernel-module-testlib = { path = "../../../testlib" } 28 | 29 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-rdma-base/unitests/create_qps/src/console_msgs.rs: -------------------------------------------------------------------------------- 1 | pub static SUCC : [&str;2] = ["client ok","Dev ok"]; 2 | pub static ERR : [&str;2] = ["cleint err","Dev empty"]; 3 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-rdma-base/unitests/create_qps/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module,assert_dmesg_contains,dmesg_contains}; 2 | 3 | #[test] 4 | fn test_create_qp() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | // ok strings 8 | let test_strs2 = [String::from("client ok"), String::from("create cq ok")]; 9 | assert_dmesg_contains(&test_strs2); 10 | 11 | // bad msgs 12 | assert_eq!(dmesg_contains(&String::from("null cq")),false); 13 | assert_eq!(dmesg_contains(&String::from("null qp")),false); 14 | 15 | // other err messages 16 | assert_eq!(dmesg_contains(&String::from("err")),false); 17 | 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-rdma-base/unitests/sample/Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | 3 | [package] 4 | name = "sample_tests" 5 | version = "0.1.0" 6 | authors = ["xmm "] 7 | edition = "2018" 8 | 9 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 10 | [lib] 11 | crate-type = ["staticlib"] 12 | test = false 13 | 14 | [features] 15 | default = ["rust-kernel-rdma-base"] 16 | 17 | [dependencies] 18 | rust-kernel-rdma-base = {path = "../../../rust-kernel-rdma-base",optional = true} 19 | 20 | 21 | [dev-dependencies] 22 | kernel-module-testlib = { path = "../../../testlib" } 23 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-rdma-base/unitests/sample/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![no_std] 2 | 3 | struct SampleTestModule { 4 | } 5 | 6 | use rust_kernel_rdma_base::linux_kernel_module; 7 | use linux_kernel_module::println; 8 | 9 | impl linux_kernel_module::KernelModule for SampleTestModule { 10 | fn init() -> linux_kernel_module::KernelResult { 11 | println!("sample test module in raw kernel rdma bindings!"); 12 | 13 | println!("check version"); 14 | Ok(Self {}) 15 | } 16 | } 17 | 18 | linux_kernel_module::kernel_module!( 19 | SampleTestModule, 20 | author: b"xmm", 21 | description: b"A sample module for unit testing", 22 | license: b"GPL" 23 | ); 24 | -------------------------------------------------------------------------------- /rust-kernel-rdma/rust-kernel-rdma-base/unitests/sample/tests/test.rs: -------------------------------------------------------------------------------- 1 | use kernel_module_testlib::{with_kernel_module,assert_dmesg_ends,assert_dmesg_contains, dmesg_contains}; 2 | 3 | #[test] 4 | fn test_simple() { 5 | // a dummy test func 6 | with_kernel_module(|| { 7 | println!("sampe test"); 8 | 9 | let test_strs = ["bindings!".as_bytes()]; 10 | assert_dmesg_ends(&test_strs); 11 | 12 | let test_strs2 = [String::from("raw kernel")]; 13 | assert_dmesg_contains(&test_strs2); 14 | 15 | assert_eq!(dmesg_contains(&String::from("unknown")),false); 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /rust-kernel-rdma/testlib/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "kernel-module-testlib" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | tempfile = "3" 9 | libc = "0.2.58" 10 | -------------------------------------------------------------------------------- /rust-user-rdma/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust-user-rdma" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | libc = "0.2" 10 | no-std-net = {path = "../rust-kernel-rdma/deps/no-std-net"} 11 | 12 | 13 | [build-dependencies] 14 | bindgen = "0.59.1" ## FIXME: update 15 | cc = "1.0" 16 | shlex ="1" 17 | 18 | [features] 19 | OFED_5_4 = [] 20 | exp = [] 21 | 22 | -------------------------------------------------------------------------------- /rust-user-rdma/README.md: -------------------------------------------------------------------------------- 1 | # Rust user RDMA base 2 | 3 | Provide an RDMA bindings in the user space (similar to `rust-kernel-rdma-base` crate in this repository). 4 | 5 | ## Credits 6 | Several binding scripts (e.g., `build.rs`) are from https://github.com/datenlord/rdma-sys. 7 | Yet, since they don't support Mellanox drivers, we provide a simplified version. 8 | In the future, we may port it back to `rdma-sys`. 9 | 10 | 11 | -------------------------------------------------------------------------------- /rust-user-rdma/src/bindings.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int 7 | bd_ibv_exp_query_device(struct ibv_context* context, 8 | struct ibv_exp_device_attr* attr); -------------------------------------------------------------------------------- /rust-user-rdma/src/native/exp.c: -------------------------------------------------------------------------------- 1 | #include "../bindings.h" 2 | 3 | int bd_ibv_exp_query_device(struct ibv_context *context, 4 | struct ibv_exp_device_attr *attr) { 5 | return ibv_exp_query_device(context, attr); 6 | } 7 | -------------------------------------------------------------------------------- /testlib/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "kernel-module-testlib" 3 | version = "0.1.0" 4 | authors = ["Alex Gaynor "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | tempfile = "3" 9 | libc = "0.2.58" 10 | -------------------------------------------------------------------------------- /user-benchs/README.md: -------------------------------------------------------------------------------- 1 | # Benchmark the performance of KRCore under user-space 2 | 3 | ## Cargo descriptions 4 | 5 | - `bench_server`: server-side code for the RDMA evaluations 6 | - `bench_rdma`: client-side code for the RDMA evaluations 7 | 8 | 9 | ## Build 10 | 11 | Note: please read the build script file `scripts/build.toml` and modify the fields accordingly. 12 | 13 | ``` 14 | python3 ../exp_scripts/bootstrap.py -f scripts/build.toml -u YOUR NAME -p YOUR_PASSWORD 15 | ``` 16 | 17 | Be sure to copy the binaries to the machines that run the test with: 18 | 19 | ``` 20 | python3 ../exp_scripts/bootstrap.py -f scripts/copy_bins.toml -u YOUR NAME -p YOUR_PASSWORD 21 | ``` 22 | 23 | ## Run 24 | 25 | Be sure the configurations in the `scripts/run_basic.toml` match the one with the above build process. 26 | 27 | ``` 28 | python3 ../exp_scripts/bootstrap.py -f scripts/run_basic.toml -u YOUR NAME -p YOUR_PASSWORD 29 | ``` 30 | -------------------------------------------------------------------------------- /user-benchs/bench_rdma/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bench_rdma" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | clap = "3.2.19" 10 | KRdmaKit = { path = "../../KRdmaKit", features = ["user"] } 11 | lazy_static = "1.4.0" 12 | rand = "0.8.5" 13 | rand_chacha = "*" 14 | 15 | [features] 16 | OFED_5_4 = ["KRdmaKit/OFED_5_4"] 17 | signaled = [] 18 | -------------------------------------------------------------------------------- /user-benchs/bench_runtime/server/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "server" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | KRdmaKit = { path = "../../../KRdmaKit", features = ["user", "rdma-runtime"] } 10 | ctrlc = "3.2.3" -------------------------------------------------------------------------------- /user-benchs/bench_runtime/throughput/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "throughput" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | KRdmaKit = { path = "../../../KRdmaKit", features = ["user", "rdma-runtime"] } 10 | rand = "0.8.5" 11 | clap = { version = "4.0.24", features = ["derive"] } 12 | 13 | [profile.release] 14 | opt-level = 3 15 | debug = false 16 | rpath = false 17 | lto = false 18 | debug-assertions = false 19 | codegen-units = 1 -------------------------------------------------------------------------------- /user-benchs/bench_runtime/throughput/src/random.rs: -------------------------------------------------------------------------------- 1 | /// taken from a java-version implementation: 2 | /// http://developer.classpath.org/doc/java/util/Random-source.htmlv 3 | #[allow(dead_code)] 4 | pub struct FastRandom { 5 | seed: u64, 6 | } 7 | 8 | #[allow(dead_code)] 9 | impl FastRandom { 10 | pub fn new(seed: u64) -> Self { 11 | Self { 12 | seed: Self::set_seed0(seed), 13 | } 14 | } 15 | 16 | pub fn get_next(&mut self) -> u64 { 17 | self.next(32).wrapping_shl(32).wrapping_add(self.next(32)) 18 | } 19 | 20 | pub fn get_cur_seed(&self) -> u64 { 21 | self.seed 22 | } 23 | 24 | #[inline] 25 | fn next(&mut self, bits: usize) -> u64 { 26 | self.seed = (self 27 | .seed 28 | .wrapping_mul(0x5DEECE66D as u64) 29 | .wrapping_add(0xB as u64)) 30 | & (((1 as u64) << 48) - 1); 31 | // self.seed 32 | self.seed.wrapping_shr((48 - bits) as u32) 33 | } 34 | 35 | #[inline] 36 | fn set_seed0(seed: u64) -> u64 { 37 | (seed ^ (0x5DEECE66D as u64)) & (((1 as u64) << 48) - 1) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /user-benchs/bench_server/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bench_server" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | clap = "3.2.19" 10 | KRdmaKit = { path = "../../KRdmaKit", features = ["user"] } 11 | lazy_static = "1.4.0" 12 | ctrlc = "3.2.3" 13 | 14 | [features] 15 | OFED_5_4 = ["KRdmaKit/OFED_5_4"] 16 | -------------------------------------------------------------------------------- /user-benchs/scripts/build.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | path = "./krcore/krcore/user-benchs/bench_rdma" 3 | host = "localhost" 4 | cmd = "/home/wxd/.cargo/bin/cargo build --release" 5 | 6 | [[pass]] 7 | path = "./krcore/krcore/user-benchs/bench_server" 8 | host = "localhost" 9 | cmd = "/home/wxd/.cargo/bin/cargo build --release" 10 | 11 | -------------------------------------------------------------------------------- /user-benchs/scripts/copy_bins.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | path = "./krcore/krcore/user-benchs/bench_rdma/target/release" 3 | host = "localhost" 4 | cmd = "scp bench_rdma val01:~; scp bench_rdma val02:~; " 5 | -------------------------------------------------------------------------------- /user-benchs/scripts/run_basic.toml: -------------------------------------------------------------------------------- 1 | [[pass]] 2 | path = "./krcore/krcore/user-benchs/bench_server/target/release" 3 | host = "val01" 4 | cmd = './bench_server --addr="192.168.12.113:8888"' 5 | 6 | [[pass]] 7 | path = "~/" 8 | host = "val02" 9 | cmd = 'sleep 1; ./bench_rdma --addr "192.168.12.113:8888" --factor=12 --threads=12' 10 | 11 | --------------------------------------------------------------------------------