Commit 32199ec3 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'ntb-4.8' of git://github.com/jonmason/ntb

Pull NTB updates from Jon Mason:
 "NTB bug fixes for the ntb_tool and ntb_perf, and improvements to the
  ntb_perf and ntb_pingpong for increased debugability.

  Also, modification to the ntb_transport layer to increase/decrease
  the number of transport entries depending on the ring size"

* tag 'ntb-4.8' of git://github.com/jonmason/ntb:
  NTB: ntb_hw_intel: use local variable pdev
  NTB: ntb_hw_intel: show BAR size in debugfs info
  ntb_test: Add a selftest script for the NTB subsystem
  ntb_perf: clear link_is_up flag when the link goes down.
  ntb_pingpong: Add a debugfs file to get the ping count
  ntb_tool: Add link status and files to debugfs
  ntb_tool: Postpone memory window initialization for the user
  ntb_perf: Wait for link before running test
  ntb_perf: Return results by reading the run file
  ntb_perf: Improve thread handling to increase robustness
  ntb_perf: Schedule based on time not on performance
  ntb_transport: Check the number of spads the hardware supports
  ntb_tool: Add memory window debug support
  ntb_perf: Allow limiting the size of the memory windows
  NTB: allocate number transport entries depending on size of ring size
  ntb_tool: BUG: Ensure the buffer size is large enough to return all spads
  ntb_tool: Fix infinite loop bug when writing spad/peer_spad file
parents a02040d8 95f1464f
...@@ -8341,6 +8341,7 @@ F: drivers/ntb/ ...@@ -8341,6 +8341,7 @@ F: drivers/ntb/
F: drivers/net/ntb_netdev.c F: drivers/net/ntb_netdev.c
F: include/linux/ntb.h F: include/linux/ntb.h
F: include/linux/ntb_transport.h F: include/linux/ntb_transport.h
F: tools/testing/selftests/ntb/
NTB INTEL DRIVER NTB INTEL DRIVER
M: Jon Mason <jdmason@kudzu.us> M: Jon Mason <jdmason@kudzu.us>
......
...@@ -551,13 +551,15 @@ static ssize_t ndev_debugfs_read(struct file *filp, char __user *ubuf, ...@@ -551,13 +551,15 @@ static ssize_t ndev_debugfs_read(struct file *filp, char __user *ubuf,
size_t count, loff_t *offp) size_t count, loff_t *offp)
{ {
struct intel_ntb_dev *ndev; struct intel_ntb_dev *ndev;
struct pci_dev *pdev;
void __iomem *mmio; void __iomem *mmio;
char *buf; char *buf;
size_t buf_size; size_t buf_size;
ssize_t ret, off; ssize_t ret, off;
union { u64 v64; u32 v32; u16 v16; } u; union { u64 v64; u32 v32; u16 v16; u8 v8; } u;
ndev = filp->private_data; ndev = filp->private_data;
pdev = ndev_pdev(ndev);
mmio = ndev->self_mmio; mmio = ndev->self_mmio;
buf_size = min(count, 0x800ul); buf_size = min(count, 0x800ul);
...@@ -631,6 +633,41 @@ static ssize_t ndev_debugfs_read(struct file *filp, char __user *ubuf, ...@@ -631,6 +633,41 @@ static ssize_t ndev_debugfs_read(struct file *filp, char __user *ubuf,
off += scnprintf(buf + off, buf_size - off, off += scnprintf(buf + off, buf_size - off,
"Doorbell Bell -\t\t%#llx\n", u.v64); "Doorbell Bell -\t\t%#llx\n", u.v64);
off += scnprintf(buf + off, buf_size - off,
"\nNTB Window Size:\n");
pci_read_config_byte(pdev, XEON_PBAR23SZ_OFFSET, &u.v8);
off += scnprintf(buf + off, buf_size - off,
"PBAR23SZ %hhu\n", u.v8);
if (!ndev->bar4_split) {
pci_read_config_byte(pdev, XEON_PBAR45SZ_OFFSET, &u.v8);
off += scnprintf(buf + off, buf_size - off,
"PBAR45SZ %hhu\n", u.v8);
} else {
pci_read_config_byte(pdev, XEON_PBAR4SZ_OFFSET, &u.v8);
off += scnprintf(buf + off, buf_size - off,
"PBAR4SZ %hhu\n", u.v8);
pci_read_config_byte(pdev, XEON_PBAR5SZ_OFFSET, &u.v8);
off += scnprintf(buf + off, buf_size - off,
"PBAR5SZ %hhu\n", u.v8);
}
pci_read_config_byte(pdev, XEON_SBAR23SZ_OFFSET, &u.v8);
off += scnprintf(buf + off, buf_size - off,
"SBAR23SZ %hhu\n", u.v8);
if (!ndev->bar4_split) {
pci_read_config_byte(pdev, XEON_SBAR45SZ_OFFSET, &u.v8);
off += scnprintf(buf + off, buf_size - off,
"SBAR45SZ %hhu\n", u.v8);
} else {
pci_read_config_byte(pdev, XEON_SBAR4SZ_OFFSET, &u.v8);
off += scnprintf(buf + off, buf_size - off,
"SBAR4SZ %hhu\n", u.v8);
pci_read_config_byte(pdev, XEON_SBAR5SZ_OFFSET, &u.v8);
off += scnprintf(buf + off, buf_size - off,
"SBAR5SZ %hhu\n", u.v8);
}
off += scnprintf(buf + off, buf_size - off, off += scnprintf(buf + off, buf_size - off,
"\nNTB Incoming XLAT:\n"); "\nNTB Incoming XLAT:\n");
...@@ -669,7 +706,7 @@ static ssize_t ndev_debugfs_read(struct file *filp, char __user *ubuf, ...@@ -669,7 +706,7 @@ static ssize_t ndev_debugfs_read(struct file *filp, char __user *ubuf,
"LMT45 -\t\t\t%#018llx\n", u.v64); "LMT45 -\t\t\t%#018llx\n", u.v64);
} }
if (pdev_is_xeon(ndev->ntb.pdev)) { if (pdev_is_xeon(pdev)) {
if (ntb_topo_is_b2b(ndev->ntb.topo)) { if (ntb_topo_is_b2b(ndev->ntb.topo)) {
off += scnprintf(buf + off, buf_size - off, off += scnprintf(buf + off, buf_size - off,
"\nNTB Outgoing B2B XLAT:\n"); "\nNTB Outgoing B2B XLAT:\n");
...@@ -750,22 +787,22 @@ static ssize_t ndev_debugfs_read(struct file *filp, char __user *ubuf, ...@@ -750,22 +787,22 @@ static ssize_t ndev_debugfs_read(struct file *filp, char __user *ubuf,
off += scnprintf(buf + off, buf_size - off, off += scnprintf(buf + off, buf_size - off,
"\nXEON NTB Hardware Errors:\n"); "\nXEON NTB Hardware Errors:\n");
if (!pci_read_config_word(ndev->ntb.pdev, if (!pci_read_config_word(pdev,
XEON_DEVSTS_OFFSET, &u.v16)) XEON_DEVSTS_OFFSET, &u.v16))
off += scnprintf(buf + off, buf_size - off, off += scnprintf(buf + off, buf_size - off,
"DEVSTS -\t\t%#06x\n", u.v16); "DEVSTS -\t\t%#06x\n", u.v16);
if (!pci_read_config_word(ndev->ntb.pdev, if (!pci_read_config_word(pdev,
XEON_LINK_STATUS_OFFSET, &u.v16)) XEON_LINK_STATUS_OFFSET, &u.v16))
off += scnprintf(buf + off, buf_size - off, off += scnprintf(buf + off, buf_size - off,
"LNKSTS -\t\t%#06x\n", u.v16); "LNKSTS -\t\t%#06x\n", u.v16);
if (!pci_read_config_dword(ndev->ntb.pdev, if (!pci_read_config_dword(pdev,
XEON_UNCERRSTS_OFFSET, &u.v32)) XEON_UNCERRSTS_OFFSET, &u.v32))
off += scnprintf(buf + off, buf_size - off, off += scnprintf(buf + off, buf_size - off,
"UNCERRSTS -\t\t%#06x\n", u.v32); "UNCERRSTS -\t\t%#06x\n", u.v32);
if (!pci_read_config_dword(ndev->ntb.pdev, if (!pci_read_config_dword(pdev,
XEON_CORERRSTS_OFFSET, &u.v32)) XEON_CORERRSTS_OFFSET, &u.v32))
off += scnprintf(buf + off, buf_size - off, off += scnprintf(buf + off, buf_size - off,
"CORERRSTS -\t\t%#06x\n", u.v32); "CORERRSTS -\t\t%#06x\n", u.v32);
......
...@@ -153,6 +153,7 @@ struct ntb_transport_qp { ...@@ -153,6 +153,7 @@ struct ntb_transport_qp {
unsigned int rx_index; unsigned int rx_index;
unsigned int rx_max_entry; unsigned int rx_max_entry;
unsigned int rx_max_frame; unsigned int rx_max_frame;
unsigned int rx_alloc_entry;
dma_cookie_t last_cookie; dma_cookie_t last_cookie;
struct tasklet_struct rxc_db_work; struct tasklet_struct rxc_db_work;
...@@ -480,7 +481,9 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count, ...@@ -480,7 +481,9 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count,
out_offset += snprintf(buf + out_offset, out_count - out_offset, out_offset += snprintf(buf + out_offset, out_count - out_offset,
"rx_index - \t%u\n", qp->rx_index); "rx_index - \t%u\n", qp->rx_index);
out_offset += snprintf(buf + out_offset, out_count - out_offset, out_offset += snprintf(buf + out_offset, out_count - out_offset,
"rx_max_entry - \t%u\n\n", qp->rx_max_entry); "rx_max_entry - \t%u\n", qp->rx_max_entry);
out_offset += snprintf(buf + out_offset, out_count - out_offset,
"rx_alloc_entry - \t%u\n\n", qp->rx_alloc_entry);
out_offset += snprintf(buf + out_offset, out_count - out_offset, out_offset += snprintf(buf + out_offset, out_count - out_offset,
"tx_bytes - \t%llu\n", qp->tx_bytes); "tx_bytes - \t%llu\n", qp->tx_bytes);
...@@ -597,9 +600,12 @@ static int ntb_transport_setup_qp_mw(struct ntb_transport_ctx *nt, ...@@ -597,9 +600,12 @@ static int ntb_transport_setup_qp_mw(struct ntb_transport_ctx *nt,
{ {
struct ntb_transport_qp *qp = &nt->qp_vec[qp_num]; struct ntb_transport_qp *qp = &nt->qp_vec[qp_num];
struct ntb_transport_mw *mw; struct ntb_transport_mw *mw;
struct ntb_dev *ndev = nt->ndev;
struct ntb_queue_entry *entry;
unsigned int rx_size, num_qps_mw; unsigned int rx_size, num_qps_mw;
unsigned int mw_num, mw_count, qp_count; unsigned int mw_num, mw_count, qp_count;
unsigned int i; unsigned int i;
int node;
mw_count = nt->mw_count; mw_count = nt->mw_count;
qp_count = nt->qp_count; qp_count = nt->qp_count;
...@@ -626,6 +632,23 @@ static int ntb_transport_setup_qp_mw(struct ntb_transport_ctx *nt, ...@@ -626,6 +632,23 @@ static int ntb_transport_setup_qp_mw(struct ntb_transport_ctx *nt,
qp->rx_max_entry = rx_size / qp->rx_max_frame; qp->rx_max_entry = rx_size / qp->rx_max_frame;
qp->rx_index = 0; qp->rx_index = 0;
/*
* Checking to see if we have more entries than the default.
* We should add additional entries if that is the case so we
* can be in sync with the transport frames.
*/
node = dev_to_node(&ndev->dev);
for (i = qp->rx_alloc_entry; i < qp->rx_max_entry; i++) {
entry = kzalloc_node(sizeof(*entry), GFP_ATOMIC, node);
if (!entry)
return -ENOMEM;
entry->qp = qp;
ntb_list_add(&qp->ntb_rx_q_lock, &entry->entry,
&qp->rx_free_q);
qp->rx_alloc_entry++;
}
qp->remote_rx_info->entry = qp->rx_max_entry - 1; qp->remote_rx_info->entry = qp->rx_max_entry - 1;
/* setup the hdr offsets with 0's */ /* setup the hdr offsets with 0's */
...@@ -1037,6 +1060,13 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev) ...@@ -1037,6 +1060,13 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev)
int node; int node;
int rc, i; int rc, i;
mw_count = ntb_mw_count(ndev);
if (ntb_spad_count(ndev) < (NUM_MWS + 1 + mw_count * 2)) {
dev_err(&ndev->dev, "Not enough scratch pad registers for %s",
NTB_TRANSPORT_NAME);
return -EIO;
}
if (ntb_db_is_unsafe(ndev)) if (ntb_db_is_unsafe(ndev))
dev_dbg(&ndev->dev, dev_dbg(&ndev->dev,
"doorbell is unsafe, proceed anyway...\n"); "doorbell is unsafe, proceed anyway...\n");
...@@ -1052,8 +1082,6 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev) ...@@ -1052,8 +1082,6 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev)
nt->ndev = ndev; nt->ndev = ndev;
mw_count = ntb_mw_count(ndev);
nt->mw_count = mw_count; nt->mw_count = mw_count;
nt->mw_vec = kzalloc_node(mw_count * sizeof(*nt->mw_vec), nt->mw_vec = kzalloc_node(mw_count * sizeof(*nt->mw_vec),
...@@ -1722,8 +1750,9 @@ ntb_transport_create_queue(void *data, struct device *client_dev, ...@@ -1722,8 +1750,9 @@ ntb_transport_create_queue(void *data, struct device *client_dev,
ntb_list_add(&qp->ntb_rx_q_lock, &entry->entry, ntb_list_add(&qp->ntb_rx_q_lock, &entry->entry,
&qp->rx_free_q); &qp->rx_free_q);
} }
qp->rx_alloc_entry = NTB_QP_DEF_NUM_ENTRIES;
for (i = 0; i < NTB_QP_DEF_NUM_ENTRIES; i++) { for (i = 0; i < qp->tx_max_entry; i++) {
entry = kzalloc_node(sizeof(*entry), GFP_ATOMIC, node); entry = kzalloc_node(sizeof(*entry), GFP_ATOMIC, node);
if (!entry) if (!entry)
goto err2; goto err2;
...@@ -1744,6 +1773,7 @@ ntb_transport_create_queue(void *data, struct device *client_dev, ...@@ -1744,6 +1773,7 @@ ntb_transport_create_queue(void *data, struct device *client_dev,
while ((entry = ntb_list_rm(&qp->ntb_tx_free_q_lock, &qp->tx_free_q))) while ((entry = ntb_list_rm(&qp->ntb_tx_free_q_lock, &qp->tx_free_q)))
kfree(entry); kfree(entry);
err1: err1:
qp->rx_alloc_entry = 0;
while ((entry = ntb_list_rm(&qp->ntb_rx_q_lock, &qp->rx_free_q))) while ((entry = ntb_list_rm(&qp->ntb_rx_q_lock, &qp->rx_free_q)))
kfree(entry); kfree(entry);
if (qp->tx_dma_chan) if (qp->tx_dma_chan)
......
This diff is collapsed.
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/debugfs.h>
#include <linux/ntb.h> #include <linux/ntb.h>
...@@ -96,8 +97,13 @@ struct pp_ctx { ...@@ -96,8 +97,13 @@ struct pp_ctx {
spinlock_t db_lock; spinlock_t db_lock;
struct timer_list db_timer; struct timer_list db_timer;
unsigned long db_delay; unsigned long db_delay;
struct dentry *debugfs_node_dir;
struct dentry *debugfs_count;
atomic_t count;
}; };
static struct dentry *pp_debugfs_dir;
static void pp_ping(unsigned long ctx) static void pp_ping(unsigned long ctx)
{ {
struct pp_ctx *pp = (void *)ctx; struct pp_ctx *pp = (void *)ctx;
...@@ -171,10 +177,32 @@ static void pp_db_event(void *ctx, int vec) ...@@ -171,10 +177,32 @@ static void pp_db_event(void *ctx, int vec)
dev_dbg(&pp->ntb->dev, dev_dbg(&pp->ntb->dev,
"Pong vec %d bits %#llx\n", "Pong vec %d bits %#llx\n",
vec, db_bits); vec, db_bits);
atomic_inc(&pp->count);
} }
spin_unlock_irqrestore(&pp->db_lock, irqflags); spin_unlock_irqrestore(&pp->db_lock, irqflags);
} }
static int pp_debugfs_setup(struct pp_ctx *pp)
{
struct pci_dev *pdev = pp->ntb->pdev;
if (!pp_debugfs_dir)
return -ENODEV;
pp->debugfs_node_dir = debugfs_create_dir(pci_name(pdev),
pp_debugfs_dir);
if (!pp->debugfs_node_dir)
return -ENODEV;
pp->debugfs_count = debugfs_create_atomic_t("count", S_IRUSR | S_IWUSR,
pp->debugfs_node_dir,
&pp->count);
if (!pp->debugfs_count)
return -ENODEV;
return 0;
}
static const struct ntb_ctx_ops pp_ops = { static const struct ntb_ctx_ops pp_ops = {
.link_event = pp_link_event, .link_event = pp_link_event,
.db_event = pp_db_event, .db_event = pp_db_event,
...@@ -210,6 +238,7 @@ static int pp_probe(struct ntb_client *client, ...@@ -210,6 +238,7 @@ static int pp_probe(struct ntb_client *client,
pp->ntb = ntb; pp->ntb = ntb;
pp->db_bits = 0; pp->db_bits = 0;
atomic_set(&pp->count, 0);
spin_lock_init(&pp->db_lock); spin_lock_init(&pp->db_lock);
setup_timer(&pp->db_timer, pp_ping, (unsigned long)pp); setup_timer(&pp->db_timer, pp_ping, (unsigned long)pp);
pp->db_delay = msecs_to_jiffies(delay_ms); pp->db_delay = msecs_to_jiffies(delay_ms);
...@@ -218,6 +247,10 @@ static int pp_probe(struct ntb_client *client, ...@@ -218,6 +247,10 @@ static int pp_probe(struct ntb_client *client,
if (rc) if (rc)
goto err_ctx; goto err_ctx;
rc = pp_debugfs_setup(pp);
if (rc)
goto err_ctx;
ntb_link_enable(ntb, NTB_SPEED_AUTO, NTB_WIDTH_AUTO); ntb_link_enable(ntb, NTB_SPEED_AUTO, NTB_WIDTH_AUTO);
ntb_link_event(ntb); ntb_link_event(ntb);
...@@ -234,6 +267,8 @@ static void pp_remove(struct ntb_client *client, ...@@ -234,6 +267,8 @@ static void pp_remove(struct ntb_client *client,
{ {
struct pp_ctx *pp = ntb->ctx; struct pp_ctx *pp = ntb->ctx;
debugfs_remove_recursive(pp->debugfs_node_dir);
ntb_clear_ctx(ntb); ntb_clear_ctx(ntb);
del_timer_sync(&pp->db_timer); del_timer_sync(&pp->db_timer);
ntb_link_disable(ntb); ntb_link_disable(ntb);
...@@ -247,4 +282,29 @@ static struct ntb_client pp_client = { ...@@ -247,4 +282,29 @@ static struct ntb_client pp_client = {
.remove = pp_remove, .remove = pp_remove,
}, },
}; };
module_ntb_client(pp_client);
static int __init pp_init(void)
{
int rc;
if (debugfs_initialized())
pp_debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
rc = ntb_register_client(&pp_client);
if (rc)
goto err_client;
return 0;
err_client:
debugfs_remove_recursive(pp_debugfs_dir);
return rc;
}
module_init(pp_init);
static void __exit pp_exit(void)
{
ntb_unregister_client(&pp_client);
debugfs_remove_recursive(pp_debugfs_dir);
}
module_exit(pp_exit);
This diff is collapsed.
#!/bin/bash
# Copyright (c) 2016 Microsemi. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it would be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# Author: Logan Gunthorpe <logang@deltatee.com>
REMOTE_HOST=
LIST_DEVS=FALSE
DEBUGFS=${DEBUGFS-/sys/kernel/debug}
PERF_RUN_ORDER=32
MAX_MW_SIZE=0
RUN_DMA_TESTS=
DONT_CLEANUP=
MW_SIZE=65536
function show_help()
{
echo "Usage: $0 [OPTIONS] LOCAL_DEV REMOTE_DEV"
echo "Run tests on a pair of NTB endpoints."
echo
echo "If the NTB device loops back to the same host then,"
echo "just specifying the two PCI ids on the command line is"
echo "sufficient. Otherwise, if the NTB link spans two hosts"
echo "use the -r option to specify the hostname for the remote"
echo "device. SSH will then be used to test the remote side."
echo "An SSH key between the root users of the host would then"
echo "be highly recommended."
echo
echo "Options:"
echo " -C don't cleanup ntb modules on exit"
echo " -d run dma tests"
echo " -h show this help message"
echo " -l list available local and remote PCI ids"
echo " -r REMOTE_HOST specify the remote's hostname to connect"
echo " to for the test (using ssh)"
echo " -p NUM ntb_perf run order (default: $PERF_RUN_ORDER)"
echo " -w max_mw_size maxmium memory window size"
echo
}
function parse_args()
{
OPTIND=0
while getopts "Cdhlm:r:p:w:" opt; do
case "$opt" in
C) DONT_CLEANUP=1 ;;
d) RUN_DMA_TESTS=1 ;;
h) show_help; exit 0 ;;
l) LIST_DEVS=TRUE ;;
m) MW_SIZE=${OPTARG} ;;
r) REMOTE_HOST=${OPTARG} ;;
p) PERF_RUN_ORDER=${OPTARG} ;;
w) MAX_MW_SIZE=${OPTARG} ;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
}
parse_args "$@"
shift $((OPTIND-1))
LOCAL_DEV=$1
shift
parse_args "$@"
shift $((OPTIND-1))
REMOTE_DEV=$1
shift
parse_args "$@"
set -e
function _modprobe()
{
modprobe "$@"
}
function split_remote()
{
VPATH=$1
REMOTE=
if [[ "$VPATH" == *":/"* ]]; then
REMOTE=${VPATH%%:*}
VPATH=${VPATH#*:}
fi
}
function read_file()
{
split_remote $1
if [[ "$REMOTE" != "" ]]; then
ssh "$REMOTE" cat "$VPATH"
else
cat "$VPATH"
fi
}
function write_file()
{
split_remote $2
VALUE=$1
if [[ "$REMOTE" != "" ]]; then
ssh "$REMOTE" "echo \"$VALUE\" > \"$VPATH\""
else
echo "$VALUE" > "$VPATH"
fi
}
function link_test()
{
LOC=$1
REM=$2
EXP=0
echo "Running link tests on: $(basename $LOC) / $(basename $REM)"
if ! write_file "N" "$LOC/link" 2> /dev/null; then
echo " Unsupported"
return
fi
write_file "N" "$LOC/link_event"
if [[ $(read_file "$REM/link") != "N" ]]; then
echo "Expected remote link to be down in $REM/link" >&2
exit -1
fi
write_file "Y" "$LOC/link"
write_file "Y" "$LOC/link_event"
echo " Passed"
}
function doorbell_test()
{
LOC=$1
REM=$2
EXP=0
echo "Running db tests on: $(basename $LOC) / $(basename $REM)"
write_file "c 0xFFFFFFFF" "$REM/db"
for ((i=1; i <= 8; i++)); do
let DB=$(read_file "$REM/db") || true
if [[ "$DB" != "$EXP" ]]; then
echo "Doorbell doesn't match expected value $EXP " \
"in $REM/db" >&2
exit -1
fi
let "MASK=1 << ($i-1)" || true
let "EXP=$EXP | $MASK" || true
write_file "s $MASK" "$LOC/peer_db"
done
echo " Passed"
}
function read_spad()
{
VPATH=$1
IDX=$2
ROW=($(read_file "$VPATH" | grep -e "^$IDX"))
let VAL=${ROW[1]} || true
echo $VAL
}
function scratchpad_test()
{
LOC=$1
REM=$2
CNT=$(read_file "$LOC/spad" | wc -l)
echo "Running spad tests on: $(basename $LOC) / $(basename $REM)"
for ((i = 0; i < $CNT; i++)); do
VAL=$RANDOM
write_file "$i $VAL" "$LOC/peer_spad"
RVAL=$(read_spad "$REM/spad" $i)
if [[ "$VAL" != "$RVAL" ]]; then
echo "Scratchpad doesn't match expected value $VAL " \
"in $REM/spad, got $RVAL" >&2
exit -1
fi
done
echo " Passed"
}
function write_mw()
{
split_remote $2
if [[ "$REMOTE" != "" ]]; then
ssh "$REMOTE" \
dd if=/dev/urandom "of=$VPATH" 2> /dev/null || true
else
dd if=/dev/urandom "of=$VPATH" 2> /dev/null || true
fi
}
function mw_test()
{
IDX=$1
LOC=$2
REM=$3
echo "Running $IDX tests on: $(basename $LOC) / $(basename $REM)"
write_mw "$LOC/$IDX"
split_remote "$LOC/$IDX"
if [[ "$REMOTE" == "" ]]; then
A=$VPATH
else
A=/tmp/ntb_test.$$.A
ssh "$REMOTE" cat "$VPATH" > "$A"
fi
split_remote "$REM/peer_$IDX"
if [[ "$REMOTE" == "" ]]; then
B=$VPATH
else
B=/tmp/ntb_test.$$.B
ssh "$REMOTE" cat "$VPATH" > "$B"
fi
cmp -n $MW_SIZE "$A" "$B"
if [[ $? != 0 ]]; then
echo "Memory window $MW did not match!" >&2
fi
if [[ "$A" == "/tmp/*" ]]; then
rm "$A"
fi
if [[ "$B" == "/tmp/*" ]]; then
rm "$B"
fi
echo " Passed"
}
function pingpong_test()
{
LOC=$1
REM=$2
echo "Running ping pong tests on: $(basename $LOC) / $(basename $REM)"
LOC_START=$(read_file $LOC/count)
REM_START=$(read_file $REM/count)
sleep 7
LOC_END=$(read_file $LOC/count)
REM_END=$(read_file $REM/count)
if [[ $LOC_START == $LOC_END ]] || [[ $REM_START == $REM_END ]]; then
echo "Ping pong counter not incrementing!" >&2
exit 1
fi
echo " Passed"
}
function perf_test()
{
USE_DMA=$1
if [[ $USE_DMA == "1" ]]; then
WITH="with"
else
WITH="without"
fi
_modprobe ntb_perf run_order=$PERF_RUN_ORDER \
max_mw_size=$MAX_MW_SIZE use_dma=$USE_DMA
echo "Running local perf test $WITH DMA"
write_file "" $LOCAL_PERF/run
echo -n " "
read_file $LOCAL_PERF/run
echo " Passed"
echo "Running remote perf test $WITH DMA"
write_file "" $REMOTE_PERF/run
echo -n " "
read_file $LOCAL_PERF/run
echo " Passed"
_modprobe -r ntb_perf
}
function ntb_tool_tests()
{
LOCAL_TOOL=$DEBUGFS/ntb_tool/$LOCAL_DEV
REMOTE_TOOL=$REMOTE_HOST:$DEBUGFS/ntb_tool/$REMOTE_DEV
echo "Starting ntb_tool tests..."
_modprobe ntb_tool
write_file Y $LOCAL_TOOL/link_event
write_file Y $REMOTE_TOOL/link_event
link_test $LOCAL_TOOL $REMOTE_TOOL
link_test $REMOTE_TOOL $LOCAL_TOOL
for PEER_TRANS in $(ls $LOCAL_TOOL/peer_trans*); do
PT=$(basename $PEER_TRANS)
write_file $MW_SIZE $LOCAL_TOOL/$PT
write_file $MW_SIZE $REMOTE_TOOL/$PT
done
doorbell_test $LOCAL_TOOL $REMOTE_TOOL
doorbell_test $REMOTE_TOOL $LOCAL_TOOL
scratchpad_test $LOCAL_TOOL $REMOTE_TOOL
scratchpad_test $REMOTE_TOOL $LOCAL_TOOL
for MW in $(ls $LOCAL_TOOL/mw*); do
MW=$(basename $MW)
mw_test $MW $LOCAL_TOOL $REMOTE_TOOL
mw_test $MW $REMOTE_TOOL $LOCAL_TOOL
done
_modprobe -r ntb_tool
}
function ntb_pingpong_tests()
{
LOCAL_PP=$DEBUGFS/ntb_pingpong/$LOCAL_DEV
REMOTE_PP=$REMOTE_HOST:$DEBUGFS/ntb_pingpong/$REMOTE_DEV
echo "Starting ntb_pingpong tests..."
_modprobe ntb_pingpong
pingpong_test $LOCAL_PP $REMOTE_PP
_modprobe -r ntb_pingpong
}
function ntb_perf_tests()
{
LOCAL_PERF=$DEBUGFS/ntb_perf/$LOCAL_DEV
REMOTE_PERF=$REMOTE_HOST:$DEBUGFS/ntb_perf/$REMOTE_DEV
echo "Starting ntb_perf tests..."
perf_test 0
if [[ $RUN_DMA_TESTS ]]; then
perf_test 1
fi
}
function cleanup()
{
set +e
_modprobe -r ntb_tool 2> /dev/null
_modprobe -r ntb_perf 2> /dev/null
_modprobe -r ntb_pingpong 2> /dev/null
_modprobe -r ntb_transport 2> /dev/null
set -e
}
cleanup
if ! [[ $$DONT_CLEANUP ]]; then
trap cleanup EXIT
fi
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
if [[ "$LIST_DEVS" == TRUE ]]; then
echo "Local Devices:"
ls -1 /sys/bus/ntb/devices
echo
if [[ "$REMOTE_HOST" != "" ]]; then
echo "Remote Devices:"
ssh $REMOTE_HOST ls -1 /sys/bus/ntb/devices
fi
exit 0
fi
if [[ "$LOCAL_DEV" == $"" ]] || [[ "$REMOTE_DEV" == $"" ]]; then
show_help
exit 1
fi
ntb_tool_tests
echo
ntb_pingpong_tests
echo
ntb_perf_tests
echo
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment