RDS self-tests
==============
-These scripts provide a coverage test for RDS-TCP by creating two
-network namespaces and running rds packets between them. A loopback
-network is provisioned with optional probability of packet loss or
-corruption. A workload of 50000 hashes, each 64 characters in size,
-are passed over an RDS socket on this test network. A passing test means
-the RDS-TCP stack was able to recover properly. The provided config.sh
-can be used to compile the kernel with the necessary gcov options. The
-kernel may optionally be configured to omit the coverage report as well.
+These scripts provide a coverage test for RDS-TCP and RDS-RDMA (over
+RoCE/RXE) by setting up two endpoints and running RDS packets between
+them. The TCP path creates two network namespaces; the RDMA path uses
+an RXE (soft RoCE) device backed by a veth pair. A workload of 50000
+hashes, each 64 characters in size, is passed over an RDS socket on
+this test network with an optional probability of packet loss or
+corruption. A passing test means the RDS stack was able to recover
+properly. The provided config.sh can be used to compile the kernel
+with the necessary gcov options; pass -r to also enable the kernel
+configs required for the RDMA transport. The kernel may optionally be
+configured to omit the coverage report as well.
USAGE:
run.sh [-d logdir] [-l packet_loss] [-c packet_corruption]
[-u packet_duplicate] [-t timeout]
+ [-T tcp|rdma|tcp,rdma]
OPTIONS:
-d Log directory. If set, logs will be stored in the
-t Test timeout. Defaults to tools/testing/selftests/net/rds/settings
+ -T Comma-separated list of transports to test. Accepts
+ "tcp", "rdma", or "tcp,rdma". Defaults to "tcp". Use
+ config.sh -r to enable required RDMA configs
+
ENV VARIABLES:
RDS_LOG_DIR Log directory. If set, logs will be stored in
the given dir, or skipped if unset. Log dir
# Create a suitable gcov enabled .config
tools/testing/selftests/net/rds/config.sh -g
+ # Optionally add RDMA configs (CONFIG_RDS_RDMA, CONFIG_RDMA_RXE)
+ tools/testing/selftests/net/rds/config.sh -r
+
# Alternatly create a gcov disabled .config
tools/testing/selftests/net/rds/config.sh
"export PYTHONPATH=tools/testing/selftests/net/; \
export SUDO_USER=example_user; \
export RDS_LOG_DIR=tools/testing/selftests/net/rds/rds_logs; \
- tools/testing/selftests/net/rds/run.sh"
+ tools/testing/selftests/net/rds/run.sh -T tcp,rdma"
FLAGS=()
GENERATE_GCOV_REPORT=0
-while getopts "gc:" opt; do
+ENABLE_RDMA=0
+while getopts "gc:r" opt; do
case ${opt} in
g)
GENERATE_GCOV_REPORT=1
c)
CONF_FILE=$OPTARG
;;
+ r)
+ ENABLE_RDMA=1
+ ;;
:)
- echo "USAGE: config.sh [-g] [-c config]"
+ echo "USAGE: config.sh [-g] [-c config] [-r]"
exit 1
;;
?)
# simulate packet loss
scripts/config "${FLAGS[@]}" --enable CONFIG_NET_SCH_NETEM
+if [ "$ENABLE_RDMA" -eq 1 ]; then
+ # enable RDS over InfiniBand / RDMA (rds_rdma test)
+ scripts/config "${FLAGS[@]}" --enable CONFIG_INFINIBAND
+ scripts/config "${FLAGS[@]}" --enable CONFIG_INFINIBAND_ADDR_TRANS
+ scripts/config "${FLAGS[@]}" --enable CONFIG_RDMA_RXE
+ scripts/config "${FLAGS[@]}" --enable CONFIG_RDS_RDMA
+fi
exit 4
fi
}
+
+check_rdma_conf_enabled() {
+ if ! grep -x "$1=y" "$kconfig" > /dev/null 2>&1; then
+ echo "selftests: [SKIP] rdma transport requires $1 enabled"
+ echo "To enable, run " \
+ "tools/testing/selftests/net/rds/config.sh -r and rebuild"
+ exit 4
+ fi
+}
+
check_conf_disabled() {
if grep -x "$1=y" "$kconfig" > /dev/null 2>&1; then
echo "selftests: [SKIP] This test requires $1 disabled"
check_conf_disabled CONFIG_MODULES
}
+# Check kernel config and host environment for RDS-RDMA support.
+# Exits with SKIP (4) if the user requested rdma but prerequisites
+# are not met.
+check_rdma_conf()
+{
+ case "$TRANSPORT" in
+ *rdma*) ;;
+ *) return ;;
+ esac
+
+ # Kconfig will enforce CONFIG_INFINIBAND_* as dependencies
+ # of CONFIG_RDMA_RXE
+ check_rdma_conf_enabled CONFIG_RDMA_RXE
+ check_rdma_conf_enabled CONFIG_RDS_RDMA
+
+ if ! which rdma > /dev/null 2>&1; then
+ echo "selftests: [SKIP] rdma transport requires the 'rdma'" \
+ " tool (iproute2)"
+ exit 4
+ fi
+}
+
check_env()
{
if ! test -d "$obj_dir"; then
LOG_DIR="${RDS_LOG_DIR:-}"
TIMEOUT=$timeout
GENERATE_GCOV_REPORT=1
+TRANSPORT=tcp
FLAGS=()
-while getopts "d:l:c:u:t:" opt; do
+
+while getopts "d:l:c:u:t:T:" opt; do
case ${opt} in
d)
LOG_DIR=${OPTARG}
u)
FLAGS+=("-u" "${OPTARG}")
;;
+ T)
+ TRANSPORT=${OPTARG}
+ ;;
:)
echo "USAGE: run.sh [-d logdir] [-l packet_loss] [-c packet_corruption]" \
- "[-u packet_duplicate] [-t timeout]"
+ "[-u packet_duplicate] [-t timeout] [-T tcp|rdma|tcp,rdma]"
exit 1
;;
?)
esac
done
+# Validate transport tokens
+IFS=',' read -ra transports <<< "$TRANSPORT"
+for t in "${transports[@]}"; do
+ if [ "$t" != "tcp" ] && [ "$t" != "rdma" ]; then
+ echo "run.sh: unknown transport '$t' (expected tcp or rdma)"
+ exit 1
+ fi
+done
+
+FLAGS+=("--transport" "${TRANSPORT}")
+
check_env
check_conf
check_gcov_conf
+check_rdma_conf
TRACE_CMD=()
if [[ -n "$LOG_DIR" ]]; then