linux/drivers/staging/greybus/loopback.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Loopback bridge driver for the Greybus loopback module.
 *
 * Copyright 2014 Google Inc.
 * Copyright 2014 Linaro Ltd.
 */

#define pr_fmt(fmt)

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/slab.h>
#include <linux/kthread.h>
#include <linux/delay.h>
#include <linux/random.h>
#include <linux/sizes.h>
#include <linux/cdev.h>
#include <linux/fs.h>
#include <linux/kfifo.h>
#include <linux/debugfs.h>
#include <linux/list_sort.h>
#include <linux/spinlock.h>
#include <linux/workqueue.h>
#include <linux/atomic.h>
#include <linux/pm_runtime.h>
#include <linux/greybus.h>
#include <asm/div64.h>

#define NSEC_PER_DAY

struct gb_loopback_stats {};

struct gb_loopback_device {};

static struct gb_loopback_device gb_dev;

struct gb_loopback_async_operation {};

struct gb_loopback {};

static struct class loopback_class =;

static DEFINE_IDA(loopback_ida);

/* Min/max values in jiffies */
#define GB_LOOPBACK_TIMEOUT_MIN
#define GB_LOOPBACK_TIMEOUT_MAX

#define GB_LOOPBACK_FIFO_DEFAULT

static unsigned int kfifo_depth =;
module_param(kfifo_depth, uint, 0444);

/* Maximum size of any one send data buffer we support */
#define MAX_PACKET_SIZE

#define GB_LOOPBACK_US_WAIT_MAX

/* interface sysfs attributes */
#define gb_loopback_ro_attr(field)

#define gb_loopback_ro_stats_attr(name, field, type)

#define gb_loopback_ro_avg_attr(name)

#define gb_loopback_stats_attrs(field)

#define gb_loopback_attr(field, type)

#define gb_dev_loopback_ro_attr(field, conn)

#define gb_dev_loopback_rw_attr(field, type)

static void gb_loopback_reset_stats(struct gb_loopback *gb);
static void gb_loopback_check_attr(struct gb_loopback *gb)
{}

/* Time to send and receive one message */
gb_loopback_stats_attrs();
/* Number of requests sent per second on this cport */
gb_loopback_stats_attrs();
/* Quantity of data sent and received on this cport */
gb_loopback_stats_attrs();
/* Latency across the UniPro link from APBridge's perspective */
gb_loopback_stats_attrs();
/* Firmware induced overhead in the GPBridge */
gb_loopback_stats_attrs();

/* Number of errors encountered during loop */
gb_loopback_ro_attr();
/* Number of requests successfully completed async */
gb_loopback_ro_attr();
/* Number of requests timed out async */
gb_loopback_ro_attr();
/* Timeout minimum in useconds */
gb_loopback_ro_attr();
/* Timeout minimum in useconds */
gb_loopback_ro_attr();

/*
 * Type of loopback message to send based on protocol type definitions
 * 0 => Don't send message
 * 2 => Send ping message continuously (message without payload)
 * 3 => Send transfer message continuously (message with payload,
 *					   payload returned in response)
 * 4 => Send a sink message (message with payload, no payload in response)
 */
gb_dev_loopback_rw_attr();
/* Size of transfer message payload: 0-4096 bytes */
gb_dev_loopback_rw_attr();
/* Time to wait between two messages: 0-1000 ms */
gb_dev_loopback_rw_attr();
/* Maximum iterations for a given operation: 1-(2^32-1), 0 implies infinite */
gb_dev_loopback_rw_attr();
/* The current index of the for (i = 0; i < iteration_max; i++) loop */
gb_dev_loopback_ro_attr();
/* A flag to indicate synchronous or asynchronous operations */
gb_dev_loopback_rw_attr();
/* Timeout of an individual asynchronous request */
gb_dev_loopback_rw_attr();
/* Maximum number of in-flight operations before back-off */
gb_dev_loopback_rw_attr();

static struct attribute *loopback_attrs[] =;
ATTRIBUTE_GROUPS();

static void gb_loopback_calculate_stats(struct gb_loopback *gb, bool error);

static u32 gb_loopback_nsec_to_usec_latency(u64 elapsed_nsecs)
{}

static u64 __gb_loopback_calc_latency(u64 t1, u64 t2)
{}

static u64 gb_loopback_calc_latency(ktime_t ts, ktime_t te)
{}

static int gb_loopback_operation_sync(struct gb_loopback *gb, int type,
				      void *request, int request_size,
				      void *response, int response_size)
{}

static void gb_loopback_async_wait_all(struct gb_loopback *gb)
{}

static void gb_loopback_async_operation_callback(struct gb_operation *operation)
{}

static int gb_loopback_async_operation(struct gb_loopback *gb, int type,
				       void *request, int request_size,
				       int response_size,
				       void *completion)
{}

static int gb_loopback_sync_sink(struct gb_loopback *gb, u32 len)
{}

static int gb_loopback_sync_transfer(struct gb_loopback *gb, u32 len)
{}

static int gb_loopback_sync_ping(struct gb_loopback *gb)
{}

static int gb_loopback_async_sink(struct gb_loopback *gb, u32 len)
{}

static int gb_loopback_async_transfer_complete(
				struct gb_loopback_async_operation *op_async)
{}

static int gb_loopback_async_transfer(struct gb_loopback *gb, u32 len)
{}

static int gb_loopback_async_ping(struct gb_loopback *gb)
{}

static int gb_loopback_request_handler(struct gb_operation *operation)
{}

static void gb_loopback_reset_stats(struct gb_loopback *gb)
{}

static void gb_loopback_update_stats(struct gb_loopback_stats *stats, u32 val)
{}

static void gb_loopback_update_stats_window(struct gb_loopback_stats *stats,
					    u64 val, u32 count)
{}

static void gb_loopback_requests_update(struct gb_loopback *gb, u32 latency)
{}

static void gb_loopback_throughput_update(struct gb_loopback *gb, u32 latency)
{}

static void gb_loopback_calculate_latency_stats(struct gb_loopback *gb)
{}

static void gb_loopback_calculate_stats(struct gb_loopback *gb, bool error)
{}

static void gb_loopback_async_wait_to_send(struct gb_loopback *gb)
{}

static int gb_loopback_fn(void *data)
{}

static int gb_loopback_dbgfs_latency_show_common(struct seq_file *s,
						 struct kfifo *kfifo,
						 struct mutex *mutex)
{}

static int gb_loopback_dbgfs_latency_show(struct seq_file *s, void *unused)
{}
DEFINE_SHOW_ATTRIBUTE();

#define DEBUGFS_NAMELEN

static int gb_loopback_probe(struct gb_bundle *bundle,
			     const struct greybus_bundle_id *id)
{}

static void gb_loopback_disconnect(struct gb_bundle *bundle)
{}

static const struct greybus_bundle_id gb_loopback_id_table[] =;
MODULE_DEVICE_TABLE(greybus, gb_loopback_id_table);

static struct greybus_driver gb_loopback_driver =;

static int loopback_init(void)
{}
module_init();

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

MODULE_DESCRIPTION();
MODULE_LICENSE();