linux/drivers/ntb/ntb_transport.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) 2012 Intel Corporation. All rights reserved.
 *   Copyright (C) 2015 EMC Corporation. 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) 2012 Intel Corporation. All rights reserved.
 *   Copyright (C) 2015 EMC Corporation. 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 Transport Linux driver
 *
 * Contact Information:
 * Jon Mason <[email protected]>
 */
#include <linux/debugfs.h>
#include <linux/delay.h>
#include <linux/dmaengine.h>
#include <linux/dma-mapping.h>
#include <linux/errno.h>
#include <linux/export.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/uaccess.h>
#include "linux/ntb.h"
#include "linux/ntb_transport.h"

#define NTB_TRANSPORT_VERSION
#define NTB_TRANSPORT_VER
#define NTB_TRANSPORT_NAME
#define NTB_TRANSPORT_DESC
#define NTB_TRANSPORT_MIN_SPADS

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

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

static unsigned int transport_mtu =;
module_param(transport_mtu, uint, 0644);
MODULE_PARM_DESC();

static unsigned char max_num_clients;
module_param(max_num_clients, byte, 0644);
MODULE_PARM_DESC();

static unsigned int copy_bytes =;
module_param(copy_bytes, uint, 0644);
MODULE_PARM_DESC();

static bool use_dma;
module_param(use_dma, bool, 0644);
MODULE_PARM_DESC();

static bool use_msi;
#ifdef CONFIG_NTB_MSI
module_param(use_msi, bool, 0644);
MODULE_PARM_DESC();
#endif

static struct dentry *nt_debugfs_dir;

/* Only two-ports NTB devices are supported */
#define PIDX

struct ntb_queue_entry {};

struct ntb_rx_info {};

struct ntb_transport_qp {};

struct ntb_transport_mw {};

struct ntb_transport_client_dev {};

struct ntb_transport_ctx {};

enum {};

struct ntb_payload_header {};

enum {};

#define dev_client_dev(__dev)

#define drv_client(__drv)

#define QP_TO_MW(nt, qp)
#define NTB_QP_DEF_NUM_ENTRIES
#define NTB_LINK_DOWN_TIMEOUT

static void ntb_transport_rxc_db(unsigned long data);
static const struct ntb_ctx_ops ntb_transport_ops;
static struct ntb_client ntb_transport_client;
static int ntb_async_tx_submit(struct ntb_transport_qp *qp,
			       struct ntb_queue_entry *entry);
static void ntb_memcpy_tx(struct ntb_queue_entry *entry, void __iomem *offset);
static int ntb_async_rx_submit(struct ntb_queue_entry *entry, void *offset);
static void ntb_memcpy_rx(struct ntb_queue_entry *entry, void *offset);


static int ntb_transport_bus_match(struct device *dev,
				   const struct device_driver *drv)
{}

static int ntb_transport_bus_probe(struct device *dev)
{}

static void ntb_transport_bus_remove(struct device *dev)
{}

static struct bus_type ntb_transport_bus =;

static LIST_HEAD(ntb_transport_list);

static int ntb_bus_init(struct ntb_transport_ctx *nt)
{}

static void ntb_bus_remove(struct ntb_transport_ctx *nt)
{}

static void ntb_transport_client_release(struct device *dev)
{}

/**
 * ntb_transport_unregister_client_dev - Unregister NTB client device
 * @device_name: Name of NTB client device
 *
 * Unregister an NTB client device with the NTB transport layer
 */
void ntb_transport_unregister_client_dev(char *device_name)
{}
EXPORT_SYMBOL_GPL();

/**
 * ntb_transport_register_client_dev - Register NTB client device
 * @device_name: Name of NTB client device
 *
 * Register an NTB client device with the NTB transport layer
 */
int ntb_transport_register_client_dev(char *device_name)
{}
EXPORT_SYMBOL_GPL();

/**
 * ntb_transport_register_client - Register NTB client driver
 * @drv: NTB client driver to be registered
 *
 * Register an NTB client driver with the NTB transport layer
 *
 * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
 */
int ntb_transport_register_client(struct ntb_transport_client *drv)
{}
EXPORT_SYMBOL_GPL();

/**
 * ntb_transport_unregister_client - Unregister NTB client driver
 * @drv: NTB client driver to be unregistered
 *
 * Unregister an NTB client driver with the NTB transport layer
 *
 * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
 */
void ntb_transport_unregister_client(struct ntb_transport_client *drv)
{}
EXPORT_SYMBOL_GPL();

static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count,
			    loff_t *offp)
{}

static const struct file_operations ntb_qp_debugfs_stats =;

static void ntb_list_add(spinlock_t *lock, struct list_head *entry,
			 struct list_head *list)
{}

static struct ntb_queue_entry *ntb_list_rm(spinlock_t *lock,
					   struct list_head *list)
{}

static struct ntb_queue_entry *ntb_list_mv(spinlock_t *lock,
					   struct list_head *list,
					   struct list_head *to_list)
{}

static int ntb_transport_setup_qp_mw(struct ntb_transport_ctx *nt,
				     unsigned int qp_num)
{}

static irqreturn_t ntb_transport_isr(int irq, void *dev)
{}

static void ntb_transport_setup_qp_peer_msi(struct ntb_transport_ctx *nt,
					    unsigned int qp_num)
{}

static void ntb_transport_setup_qp_msi(struct ntb_transport_ctx *nt,
				       unsigned int qp_num)
{}

static void ntb_transport_msi_peer_desc_changed(struct ntb_transport_ctx *nt)
{}

static void ntb_transport_msi_desc_changed(void *data)
{}

static void ntb_free_mw(struct ntb_transport_ctx *nt, int num_mw)
{}

static int ntb_alloc_mw_buffer(struct ntb_transport_mw *mw,
			       struct device *dma_dev, size_t align)
{}

static int ntb_set_mw(struct ntb_transport_ctx *nt, int num_mw,
		      resource_size_t size)
{}

static void ntb_qp_link_context_reset(struct ntb_transport_qp *qp)
{}

static void ntb_qp_link_down_reset(struct ntb_transport_qp *qp)
{}

static void ntb_qp_link_cleanup(struct ntb_transport_qp *qp)
{}

static void ntb_qp_link_cleanup_work(struct work_struct *work)
{}

static void ntb_qp_link_down(struct ntb_transport_qp *qp)
{}

static void ntb_transport_link_cleanup(struct ntb_transport_ctx *nt)
{}

static void ntb_transport_link_cleanup_work(struct work_struct *work)
{}

static void ntb_transport_event_callback(void *data)
{}

static void ntb_transport_link_work(struct work_struct *work)
{}

static void ntb_qp_link_work(struct work_struct *work)
{}

static int ntb_transport_init_queue(struct ntb_transport_ctx *nt,
				    unsigned int qp_num)
{}

static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev)
{}

static void ntb_transport_free(struct ntb_client *self, struct ntb_dev *ndev)
{}

static void ntb_complete_rxc(struct ntb_transport_qp *qp)
{}

static void ntb_rx_copy_callback(void *data,
				 const struct dmaengine_result *res)
{}

static void ntb_memcpy_rx(struct ntb_queue_entry *entry, void *offset)
{}

static int ntb_async_rx_submit(struct ntb_queue_entry *entry, void *offset)
{}

static void ntb_async_rx(struct ntb_queue_entry *entry, void *offset)
{}

static int ntb_process_rxc(struct ntb_transport_qp *qp)
{}

static void ntb_transport_rxc_db(unsigned long data)
{}

static void ntb_tx_copy_callback(void *data,
				 const struct dmaengine_result *res)
{}

static void ntb_memcpy_tx(struct ntb_queue_entry *entry, void __iomem *offset)
{}

static int ntb_async_tx_submit(struct ntb_transport_qp *qp,
			       struct ntb_queue_entry *entry)
{}

static void ntb_async_tx(struct ntb_transport_qp *qp,
			 struct ntb_queue_entry *entry)
{}

static int ntb_process_tx(struct ntb_transport_qp *qp,
			  struct ntb_queue_entry *entry)
{}

static void ntb_send_link_down(struct ntb_transport_qp *qp)
{}

static bool ntb_dma_filter_fn(struct dma_chan *chan, void *node)
{}

/**
 * ntb_transport_create_queue - Create a new NTB transport layer queue
 * @rx_handler: receive callback function
 * @tx_handler: transmit callback function
 * @event_handler: event callback function
 *
 * Create a new NTB transport layer queue and provide the queue with a callback
 * routine for both transmit and receive.  The receive callback routine will be
 * used to pass up data when the transport has received it on the queue.   The
 * transmit callback routine will be called when the transport has completed the
 * transmission of the data on the queue and the data is ready to be freed.
 *
 * RETURNS: pointer to newly created ntb_queue, NULL on error.
 */
struct ntb_transport_qp *
ntb_transport_create_queue(void *data, struct device *client_dev,
			   const struct ntb_queue_handlers *handlers)
{}
EXPORT_SYMBOL_GPL();

/**
 * ntb_transport_free_queue - Frees NTB transport queue
 * @qp: NTB queue to be freed
 *
 * Frees NTB transport queue
 */
void ntb_transport_free_queue(struct ntb_transport_qp *qp)
{}
EXPORT_SYMBOL_GPL();

/**
 * ntb_transport_rx_remove - Dequeues enqueued rx packet
 * @qp: NTB queue to be freed
 * @len: pointer to variable to write enqueued buffers length
 *
 * Dequeues unused buffers from receive queue.  Should only be used during
 * shutdown of qp.
 *
 * RETURNS: NULL error value on error, or void* for success.
 */
void *ntb_transport_rx_remove(struct ntb_transport_qp *qp, unsigned int *len)
{}
EXPORT_SYMBOL_GPL();

/**
 * ntb_transport_rx_enqueue - Enqueue a new NTB queue entry
 * @qp: NTB transport layer queue the entry is to be enqueued on
 * @cb: per buffer pointer for callback function to use
 * @data: pointer to data buffer that incoming packets will be copied into
 * @len: length of the data buffer
 *
 * Enqueue a new receive buffer onto the transport queue into which a NTB
 * payload can be received into.
 *
 * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
 */
int ntb_transport_rx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data,
			     unsigned int len)
{}
EXPORT_SYMBOL_GPL();

/**
 * ntb_transport_tx_enqueue - Enqueue a new NTB queue entry
 * @qp: NTB transport layer queue the entry is to be enqueued on
 * @cb: per buffer pointer for callback function to use
 * @data: pointer to data buffer that will be sent
 * @len: length of the data buffer
 *
 * Enqueue a new transmit buffer onto the transport queue from which a NTB
 * payload will be transmitted.  This assumes that a lock is being held to
 * serialize access to the qp.
 *
 * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
 */
int ntb_transport_tx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data,
			     unsigned int len)
{}
EXPORT_SYMBOL_GPL();

/**
 * ntb_transport_link_up - Notify NTB transport of client readiness to use queue
 * @qp: NTB transport layer queue to be enabled
 *
 * Notify NTB transport layer of client readiness to use queue
 */
void ntb_transport_link_up(struct ntb_transport_qp *qp)
{}
EXPORT_SYMBOL_GPL();

/**
 * ntb_transport_link_down - Notify NTB transport to no longer enqueue data
 * @qp: NTB transport layer queue to be disabled
 *
 * Notify NTB transport layer of client's desire to no longer receive data on
 * transport queue specified.  It is the client's responsibility to ensure all
 * entries on queue are purged or otherwise handled appropriately.
 */
void ntb_transport_link_down(struct ntb_transport_qp *qp)
{}
EXPORT_SYMBOL_GPL();

/**
 * ntb_transport_link_query - Query transport link state
 * @qp: NTB transport layer queue to be queried
 *
 * Query connectivity to the remote system of the NTB transport queue
 *
 * RETURNS: true for link up or false for link down
 */
bool ntb_transport_link_query(struct ntb_transport_qp *qp)
{}
EXPORT_SYMBOL_GPL();

/**
 * ntb_transport_qp_num - Query the qp number
 * @qp: NTB transport layer queue to be queried
 *
 * Query qp number of the NTB transport queue
 *
 * RETURNS: a zero based number specifying the qp number
 */
unsigned char ntb_transport_qp_num(struct ntb_transport_qp *qp)
{}
EXPORT_SYMBOL_GPL();

/**
 * ntb_transport_max_size - Query the max payload size of a qp
 * @qp: NTB transport layer queue to be queried
 *
 * Query the maximum payload size permissible on the given qp
 *
 * RETURNS: the max payload size of a qp
 */
unsigned int ntb_transport_max_size(struct ntb_transport_qp *qp)
{}
EXPORT_SYMBOL_GPL();

unsigned int ntb_transport_tx_free_entry(struct ntb_transport_qp *qp)
{}
EXPORT_SYMBOL_GPL();

static void ntb_transport_doorbell_callback(void *data, int vector)
{}

static const struct ntb_ctx_ops ntb_transport_ops =;

static struct ntb_client ntb_transport_client =;

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

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