linux/drivers/ntb/test/ntb_perf.c

/*
 * This file is provided under a dual BSD/GPLv2 license.  When using or
 *   redistributing this file, you may do so under either license.
 *
 *   GPL LICENSE SUMMARY
 *
 *   Copyright(c) 2015 Intel Corporation. All rights reserved.
 *   Copyright(c) 2017 T-Platforms. All Rights Reserved.
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of version 2 of the GNU General Public License as
 *   published by the Free Software Foundation.
 *
 *   BSD LICENSE
 *
 *   Copyright(c) 2015 Intel Corporation. All rights reserved.
 *   Copyright(c) 2017 T-Platforms. All Rights Reserved.
 *
 *   Redistribution and use in source and binary forms, with or without
 *   modification, are permitted provided that the following conditions
 *   are met:
 *
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copy
 *       notice, this list of conditions and the following disclaimer in
 *       the documentation and/or other materials provided with the
 *       distribution.
 *     * Neither the name of Intel Corporation nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * PCIe NTB Perf Linux driver
 */

/*
 * How to use this tool, by example.
 *
 * Assuming $DBG_DIR is something like:
 * '/sys/kernel/debug/ntb_perf/0000:00:03.0'
 * Suppose aside from local device there is at least one remote device
 * connected to NTB with index 0.
 *-----------------------------------------------------------------------------
 * Eg: install driver with specified chunk/total orders and dma-enabled flag
 *
 * root@self# insmod ntb_perf.ko chunk_order=19 total_order=28 use_dma
 *-----------------------------------------------------------------------------
 * Eg: check NTB ports (index) and MW mapping information
 *
 * root@self# cat $DBG_DIR/info
 *-----------------------------------------------------------------------------
 * Eg: start performance test with peer (index 0) and get the test metrics
 *
 * root@self# echo 0 > $DBG_DIR/run
 * root@self# cat $DBG_DIR/run
 */

#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/wait.h>
#include <linux/dma-mapping.h>
#include <linux/dmaengine.h>
#include <linux/pci.h>
#include <linux/ktime.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/sizes.h>
#include <linux/workqueue.h>
#include <linux/debugfs.h>
#include <linux/random.h>
#include <linux/ntb.h>

#define DRIVER_NAME
#define DRIVER_VERSION

MODULE_LICENSE();
MODULE_VERSION();
MODULE_AUTHOR();
MODULE_DESCRIPTION();

#define MAX_THREADS_CNT
#define DEF_THREADS_CNT
#define MAX_CHUNK_SIZE
#define MAX_CHUNK_ORDER

#define DMA_TRIES
#define DMA_MDELAY

#define MSG_TRIES
#define MSG_UDELAY_LOW
#define MSG_UDELAY_HIGH

#define PERF_BUF_LEN

static unsigned long max_mw_size;
module_param(max_mw_size, ulong, 0644);
MODULE_PARM_DESC();

static unsigned char chunk_order =; /* 512K */
module_param(chunk_order, byte, 0644);
MODULE_PARM_DESC();

static unsigned char total_order =; /* 1G */
module_param(total_order, byte, 0644);
MODULE_PARM_DESC();

static bool use_dma; /* default to 0 */
module_param(use_dma, bool, 0644);
MODULE_PARM_DESC();

/*==============================================================================
 *                         Perf driver data definition
 *==============================================================================
 */

enum perf_cmd {};

struct perf_ctx;

struct perf_peer {};
#define to_peer_service(__work)

struct perf_thread {};
#define to_thread_work(__work)

struct perf_ctx {};

/*
 * Scratchpads-base commands interface
 */
#define PERF_SPAD_CNT(_pcnt)
#define PERF_SPAD_CMD(_gidx)
#define PERF_SPAD_LDATA(_gidx)
#define PERF_SPAD_HDATA(_gidx)
#define PERF_SPAD_NOTIFY(_gidx)

/*
 * Messages-base commands interface
 */
#define PERF_MSG_CNT
#define PERF_MSG_CMD
#define PERF_MSG_LDATA
#define PERF_MSG_HDATA

/*==============================================================================
 *                           Static data declarations
 *==============================================================================
 */

static struct dentry *perf_dbgfs_topdir;

static struct workqueue_struct *perf_wq __read_mostly;

/*==============================================================================
 *                  NTB cross-link commands execution service
 *==============================================================================
 */

static void perf_terminate_test(struct perf_ctx *perf);

static inline bool perf_link_is_up(struct perf_peer *peer)
{}

static int perf_spad_cmd_send(struct perf_peer *peer, enum perf_cmd cmd,
			      u64 data)
{}

static int perf_spad_cmd_recv(struct perf_ctx *perf, int *pidx,
			      enum perf_cmd *cmd, u64 *data)
{}

static int perf_msg_cmd_send(struct perf_peer *peer, enum perf_cmd cmd,
			     u64 data)
{}

static int perf_msg_cmd_recv(struct perf_ctx *perf, int *pidx,
			     enum perf_cmd *cmd, u64 *data)
{}

static int perf_cmd_send(struct perf_peer *peer, enum perf_cmd cmd, u64 data)
{}

static int perf_cmd_exec(struct perf_peer *peer, enum perf_cmd cmd)
{}

static int perf_cmd_recv(struct perf_ctx *perf)
{}

static void perf_link_event(void *ctx)
{}

static void perf_db_event(void *ctx, int vec)
{}

static void perf_msg_event(void *ctx)
{}

static const struct ntb_ctx_ops perf_ops =;

static void perf_free_outbuf(struct perf_peer *peer)
{}

static int perf_setup_outbuf(struct perf_peer *peer)
{}

static void perf_free_inbuf(struct perf_peer *peer)
{}

static int perf_setup_inbuf(struct perf_peer *peer)
{}

static void perf_service_work(struct work_struct *work)
{}

static int perf_init_service(struct perf_ctx *perf)
{}

static int perf_enable_service(struct perf_ctx *perf)
{}

static void perf_disable_service(struct perf_ctx *perf)
{}

/*==============================================================================
 *                      Performance measuring work-thread
 *==============================================================================
 */

static void perf_dma_copy_callback(void *data)
{}

static int perf_copy_chunk(struct perf_thread *pthr,
			   void __iomem *dst, void *src, size_t len)
{}

static bool perf_dma_filter(struct dma_chan *chan, void *data)
{}

static int perf_init_test(struct perf_thread *pthr)
{}

static int perf_run_test(struct perf_thread *pthr)
{}

static int perf_sync_test(struct perf_thread *pthr)
{}

static void perf_clear_test(struct perf_thread *pthr)
{}

static void perf_thread_work(struct work_struct *work)
{}

static int perf_set_tcnt(struct perf_ctx *perf, u8 tcnt)
{}

static void perf_terminate_test(struct perf_ctx *perf)
{}

static int perf_submit_test(struct perf_peer *peer)
{}

static int perf_read_stats(struct perf_ctx *perf, char *buf,
			   size_t size, ssize_t *pos)
{}

static void perf_init_threads(struct perf_ctx *perf)
{}

static void perf_clear_threads(struct perf_ctx *perf)
{}

/*==============================================================================
 *                               DebugFS nodes
 *==============================================================================
 */

static ssize_t perf_dbgfs_read_info(struct file *filep, char __user *ubuf,
				    size_t size, loff_t *offp)
{}

static const struct file_operations perf_dbgfs_info =;

static ssize_t perf_dbgfs_read_run(struct file *filep, char __user *ubuf,
				   size_t size, loff_t *offp)
{}

static ssize_t perf_dbgfs_write_run(struct file *filep, const char __user *ubuf,
				    size_t size, loff_t *offp)
{}

static const struct file_operations perf_dbgfs_run =;

static ssize_t perf_dbgfs_read_tcnt(struct file *filep, char __user *ubuf,
				    size_t size, loff_t *offp)
{}

static ssize_t perf_dbgfs_write_tcnt(struct file *filep,
				     const char __user *ubuf,
				     size_t size, loff_t *offp)
{}

static const struct file_operations perf_dbgfs_tcnt =;

static void perf_setup_dbgfs(struct perf_ctx *perf)
{}

static void perf_clear_dbgfs(struct perf_ctx *perf)
{}

/*==============================================================================
 *                        Basic driver initialization
 *==============================================================================
 */

static struct perf_ctx *perf_create_data(struct ntb_dev *ntb)
{}

static int perf_setup_peer_mw(struct perf_peer *peer)
{}

static int perf_init_peers(struct perf_ctx *perf)
{}

static int perf_probe(struct ntb_client *client, struct ntb_dev *ntb)
{}

static void perf_remove(struct ntb_client *client, struct ntb_dev *ntb)
{}

static struct ntb_client perf_client =;

static int __init perf_init(void)
{}
module_init();

static void __exit perf_exit(void)
{}
module_exit(perf_exit);