# @name IPC  performance test script.
# @desc Test does IPC Performance test.
# @requires ipc 

IPC_S_FUNC_RPMSG_RPC source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods rpmsg_rpc; toggle_rprocs stop ; setup_firmware 'test_omx_*'; toggle_rprocs start ; num_proc=$(get_num_remote_procs); rpmsg_rpc_test -p $num_proc
IPC_S_FUNC_RPMSG_RPC_KILL source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods rpmsg_rpc; toggle_rprocs stop ; setup_firmware 'test_omx_*'; toggle_rprocs start ; num_proc=$(get_num_remote_procs); rpmsg_rpc_test -p $num_proc -f triple -s 5; rpmsg_rpc_test -p $num_proc
IPC_S_FUNC_RPMSG_RPC_MMU_FAULT source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods rpmsg_rpc; toggle_rprocs stop ; setup_firmware 'test_omx_*'; toggle_rprocs start ; num_proc=$(get_num_remote_procs); rpmsg_rpc_test -p $num_proc -m 1; rpmsg_rpc_test -p $num_proc
IPC_S_FUNC_RPMSG_RPC_MMU_FAULT_FIRST_MSG source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods rpmsg_rpc; toggle_rprocs stop ; setup_firmware 'test_omx_*'; toggle_rprocs start ; num_proc=$(get_num_remote_procs); rpmsg_rpc_test -p $num_proc -m 0; rpmsg_rpc_test -p $num_proc
IPC_S_FUNC_RPMSG_RPC_MMU_FAULT_LAST_MSG source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods rpmsg_rpc; toggle_rprocs stop ; setup_firmware 'test_omx_*'; toggle_rprocs start ; num_proc=$(get_num_remote_procs); rpmsg_rpc_test -p $num_proc -m 2; rpmsg_rpc_test -p $num_proc
IPC_S_FUNC_RPMSG_PROTO source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods rpmsg_proto; toggle_rprocs stop ; setup_firmware 'messageq_single.*'; toggle_rprocs start; start_lad  || die "lad did not start" ; num_proc=$(get_num_remote_procs); rpmsg_proto_msgqapp_test $num_proc
IPC_S_FUNC_RPMSG_PROTO_KILL source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods rpmsg_proto; toggle_rprocs stop ; setup_firmware 'messageq_single.*'; toggle_rprocs start; start_lad  || die "lad did not start" ; num_proc=$(get_num_remote_procs); rpmsg_proto_msgqapp_test $num_proc 8000 2; rpmsg_proto_msgqapp_test $num_proc
IPC_S_PERF_RPMSG_PROTO_BENCH_8BYTES source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods rpmsg_proto; toggle_rprocs stop ; setup_firmware 'messageq_single.*'; toggle_rprocs start; start_lad  || die "lad did not start" ; num_proc=$(get_num_remote_procs); rpmsg_proto_msgqbench_test $num_proc
IPC_S_PERF_RPMSG_PROTO_BENCH_228BYTES source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods rpmsg_proto; toggle_rprocs stop ; setup_firmware 'messageq_single.*'; toggle_rprocs start; start_lad  || die "lad did not start" ; num_proc=$(get_num_remote_procs); rpmsg_proto_msgqbench_test $num_proc 5000 228
IPC_S_PERF_RPMSG_PROTO_BENCH_456BYTES source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods rpmsg_proto; toggle_rprocs stop ; setup_firmware 'messageq_single.*'; toggle_rprocs start; start_lad  || die "lad did not start" ; num_proc=$(get_num_remote_procs); rpmsg_proto_msgqbench_test $num_proc 5000 456
IPC_S_FUNC_RPMSG_PROTO_MULTI source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods rpmsg_proto; toggle_rprocs stop ; setup_firmware 'messageq_multi.*'; toggle_rprocs start; start_lad  || die "lad did not start" ; rpmsg_proto_msgqmulti_test 25 1000
IPC_S_FUNC_RPMSG_PROTO_MULTI_KILL source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods rpmsg_proto; toggle_rprocs stop ; setup_firmware 'messageq_multi.*'; toggle_rprocs start; start_lad  || die "lad did not start" ; rpmsg_proto_msgqmulti_test 25 1000 3; rpmsg_proto_msgqmulti_test 25 1000
IPC_S_FUNC_RPMSG_SAMPLE_CLIENT source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods; toggle_rprocs stop r5f dsp; setup_firmware 'ping_tasks.*'; toggle_rprocs start r5f dsp; num_proc=$(get_num_remote_procs); rpmsg_client_sample_test $num_proc 10
IPC_S_FUNC_RPMSG_RPC_RECOVERY source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods rpmsg_rpc; toggle_rprocs stop ; setup_firmware 'test_omx_*'; rec_events=$(toggle_rprocs start); num_proc=$(get_num_remote_procs); rpmsg_rpc_recovery_test -p $num_proc -f triple -r "$rec_events"; sleep 5; rpmsg_rpc_test -p $num_proc
IPC_S_FUNC_RPMSG_RPC_KILL_RECOVERY source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods rpmsg_rpc; toggle_rprocs stop ; setup_firmware 'test_omx_*'; rec_events=$(toggle_rprocs start); num_proc=$(get_num_remote_procs); rpmsg_rpc_test -p $num_proc -f triple -s 5; rpmsg_rpc_recovery_test -p $num_proc -f triple -r "$rec_events"; sleep 5; rpmsg_rpc_test -p $num_proc
IPC_S_FUNC_RPMSG_PROTO_RECOVERY source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods rpmsg_proto; toggle_rprocs stop ; setup_firmware 'messageq_single.*'; toggle_rprocs start; start_lad  || die "lad did not start" ; num_proc=$(get_num_remote_procs); rpmsg_recovery_event rec_cmd; rpmsg_proto_msgqapp_test $num_proc 8000 5 "$rec_cmd"; sleep 5; kill_lad; start_lad; rpmsg_proto_msgqapp_test $num_proc
IPC_S_FUNC_RPMSG_PROTO_KILL_RECOVERY source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods rpmsg_proto; toggle_rprocs stop ; setup_firmware 'messageq_single.*'; toggle_rprocs start; start_lad  || die "lad did not start" ; num_proc=$(get_num_remote_procs); rpmsg_recovery_event rec_cmd; rpmsg_proto_msgqapp_test $num_proc 8000 2; rpmsg_proto_msgqapp_test $num_proc 8000 5 "$rec_cmd"; sleep 5; ; kill_lad; start_lad; rpmsg_proto_msgqapp_test $num_proc

IPC_S_FUNC_PRU_LOAD source ipc_funcs.sh; prus=( `list_prus` ) ; ifdown_eth; toggle_rprocs stop; rm_pru_mods; ins_pru_mods; ifdown_eth; toggle_rprocs stop; setup_firmware '*U_RPMsg_Echo_Interrupt*'; dmesg -c > /dev/null; toggle_rprocs start; sleep 5; probe_info=$(dmesg); num_loaded=$(echo -e "$probe_info" | grep -c -i 'PRU rproc node.*probed successfully'); [[ $num_loaded -eq ${#prus[@]} ]] || die "PRUs did not load successfully $probe_info ====== $num_loaded != ${#prus[@]} ======"
IPC_S_FUNC_PRU_ECHO source ipc_funcs.sh; ifdown_eth; toggle_rprocs stop r5f; rm_pru_mods; ins_pru_mods; ifdown_eth; toggle_rprocs stop r5f; setup_firmware '*U_RPMsg_Echo_Interrupt*'; toggle_rprocs start r5f; sleep 5; rpmsg_pru_test || die "PRU test failed";

IPC_S_FUNC_RPMSG_PROTO_MPM source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods_mpm rpmsg_proto; load_rproc_mpm 'messageq_single.*'; start_lad  || die "lad did not start"; num_proc=$(get_num_remote_procs); rpmsg_proto_msgqapp_test $num_proc
IPC_S_PERF_RPMSG_PROTO_MPM_BENCH_8BYTES source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods_mpm rpmsg_proto; load_rproc_mpm 'messageq_single.*'; start_lad  || die "lad did not start"; num_proc=$(get_num_remote_procs); rpmsg_proto_msgqbench_test $num_proc
IPC_S_PERF_RPMSG_PROTO_MPM_BENCH_228BYTES source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods_mpm rpmsg_proto; load_rproc_mpm 'messageq_single.*'; start_lad  || die "lad did not start"; num_proc=$(get_num_remote_procs); rpmsg_proto_msgqbench_test $num_proc 5000 228
IPC_S_PERF_RPMSG_PROTO_MPM_BENCH_456BYTES source ipc_funcs.sh; rm_ipc_mods; ins_ipc_mods_mpm rpmsg_proto; load_rproc_mpm 'messageq_single.*'; start_lad  || die "lad did not start"; num_proc=$(get_num_remote_procs); rpmsg_proto_msgqbench_test $num_proc 5000 456
