linux/drivers/most/core.c

// SPDX-License-Identifier: GPL-2.0
/*
 * core.c - Implementation of core module of MOST Linux driver stack
 *
 * Copyright (C) 2013-2020 Microchip Technology Germany II GmbH & Co. KG
 */

#include <linux/module.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/list.h>
#include <linux/poll.h>
#include <linux/wait.h>
#include <linux/kobject.h>
#include <linux/mutex.h>
#include <linux/completion.h>
#include <linux/sysfs.h>
#include <linux/kthread.h>
#include <linux/dma-mapping.h>
#include <linux/idr.h>
#include <linux/most.h>

#define MAX_CHANNELS
#define STRING_SIZE

static struct ida mdev_id;
static int dummy_num_buffers;
static struct list_head comp_list;

struct pipe {};

struct most_channel {};

#define to_channel(d)

struct interface_private {};

static const struct {} ch_data_type[] =;

/**
 * list_pop_mbo - retrieves the first MBO of the list and removes it
 * @ptr: the list head to grab the MBO from.
 */
#define list_pop_mbo(ptr)

/**
 * most_free_mbo_coherent - free an MBO and its coherent buffer
 * @mbo: most buffer
 */
static void most_free_mbo_coherent(struct mbo *mbo)
{}

/**
 * flush_channel_fifos - clear the channel fifos
 * @c: pointer to channel object
 */
static void flush_channel_fifos(struct most_channel *c)
{}

/**
 * flush_trash_fifo - clear the trash fifo
 * @c: pointer to channel object
 */
static int flush_trash_fifo(struct most_channel *c)
{}

static ssize_t available_directions_show(struct device *dev,
					 struct device_attribute *attr,
					 char *buf)
{}

static ssize_t available_datatypes_show(struct device *dev,
					struct device_attribute *attr,
					char *buf)
{}

static ssize_t number_of_packet_buffers_show(struct device *dev,
					     struct device_attribute *attr,
					     char *buf)
{}

static ssize_t number_of_stream_buffers_show(struct device *dev,
					     struct device_attribute *attr,
					     char *buf)
{}

static ssize_t size_of_packet_buffer_show(struct device *dev,
					  struct device_attribute *attr,
					  char *buf)
{}

static ssize_t size_of_stream_buffer_show(struct device *dev,
					  struct device_attribute *attr,
					  char *buf)
{}

static ssize_t channel_starving_show(struct device *dev,
				     struct device_attribute *attr,
				     char *buf)
{}

static ssize_t set_number_of_buffers_show(struct device *dev,
					  struct device_attribute *attr,
					  char *buf)
{}

static ssize_t set_buffer_size_show(struct device *dev,
				    struct device_attribute *attr,
				    char *buf)
{}

static ssize_t set_direction_show(struct device *dev,
				  struct device_attribute *attr,
				  char *buf)
{}

static ssize_t set_datatype_show(struct device *dev,
				 struct device_attribute *attr,
				 char *buf)
{}

static ssize_t set_subbuffer_size_show(struct device *dev,
				       struct device_attribute *attr,
				       char *buf)
{}

static ssize_t set_packets_per_xact_show(struct device *dev,
					 struct device_attribute *attr,
					 char *buf)
{}

static ssize_t set_dbr_size_show(struct device *dev,
				 struct device_attribute *attr, char *buf)
{}

#define to_dev_attr(a)
static umode_t channel_attr_is_visible(struct kobject *kobj,
				       struct attribute *attr, int index)
{}

#define DEV_ATTR(_name)

static DEVICE_ATTR_RO(available_directions);
static DEVICE_ATTR_RO(available_datatypes);
static DEVICE_ATTR_RO(number_of_packet_buffers);
static DEVICE_ATTR_RO(number_of_stream_buffers);
static DEVICE_ATTR_RO(size_of_stream_buffer);
static DEVICE_ATTR_RO(size_of_packet_buffer);
static DEVICE_ATTR_RO(channel_starving);
static DEVICE_ATTR_RO(set_buffer_size);
static DEVICE_ATTR_RO(set_number_of_buffers);
static DEVICE_ATTR_RO(set_direction);
static DEVICE_ATTR_RO(set_datatype);
static DEVICE_ATTR_RO(set_subbuffer_size);
static DEVICE_ATTR_RO(set_packets_per_xact);
static DEVICE_ATTR_RO(set_dbr_size);

static struct attribute *channel_attrs[] =;

static const struct attribute_group channel_attr_group =;

static const struct attribute_group *channel_attr_groups[] =;

static ssize_t description_show(struct device *dev,
				struct device_attribute *attr,
				char *buf)
{}

static ssize_t interface_show(struct device *dev,
			      struct device_attribute *attr,
			      char *buf)
{}

static DEVICE_ATTR_RO(description);
static DEVICE_ATTR_RO(interface);

static struct attribute *interface_attrs[] =;

static const struct attribute_group interface_attr_group =;

static const struct attribute_group *interface_attr_groups[] =;

static struct most_component *match_component(char *name)
{}

struct show_links_data {};

static int print_links(struct device *dev, void *data)
{}

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

static const struct bus_type mostbus =;

static ssize_t links_show(struct device_driver *drv, char *buf)
{}

static ssize_t components_show(struct device_driver *drv, char *buf)
{}

/**
 * get_channel - get pointer to channel
 * @mdev: name of the device interface
 * @mdev_ch: name of channel
 */
static struct most_channel *get_channel(char *mdev, char *mdev_ch)
{}

static
inline int link_channel_to_component(struct most_channel *c,
				     struct most_component *comp,
				     char *name,
				     char *comp_param)
{}

int most_set_cfg_buffer_size(char *mdev, char *mdev_ch, u16 val)
{}

int most_set_cfg_subbuffer_size(char *mdev, char *mdev_ch, u16 val)
{}

int most_set_cfg_dbr_size(char *mdev, char *mdev_ch, u16 val)
{}

int most_set_cfg_num_buffers(char *mdev, char *mdev_ch, u16 val)
{}

int most_set_cfg_datatype(char *mdev, char *mdev_ch, char *buf)
{}

int most_set_cfg_direction(char *mdev, char *mdev_ch, char *buf)
{}

int most_set_cfg_packets_xact(char *mdev, char *mdev_ch, u16 val)
{}

int most_cfg_complete(char *comp_name)
{}

int most_add_link(char *mdev, char *mdev_ch, char *comp_name, char *link_name,
		  char *comp_param)
{}

int most_remove_link(char *mdev, char *mdev_ch, char *comp_name)
{}

#define DRV_ATTR(_name)

static DRIVER_ATTR_RO(links);
static DRIVER_ATTR_RO(components);

static struct attribute *mc_attrs[] =;

static const struct attribute_group mc_attr_group =;

static const struct attribute_group *mc_attr_groups[] =;

static struct device_driver mostbus_driver =;

static inline void trash_mbo(struct mbo *mbo)
{}

static bool hdm_mbo_ready(struct most_channel *c)
{}

static void nq_hdm_mbo(struct mbo *mbo)
{}

static int hdm_enqueue_thread(void *data)
{}

static int run_enqueue_thread(struct most_channel *c, int channel_id)
{}

/**
 * arm_mbo - recycle MBO for further usage
 * @mbo: most buffer
 *
 * This puts an MBO back to the list to have it ready for up coming
 * tx transactions.
 *
 * In case the MBO belongs to a channel that recently has been
 * poisoned, the MBO is scheduled to be trashed.
 * Calls the completion handler of an attached component.
 */
static void arm_mbo(struct mbo *mbo)
{}

/**
 * arm_mbo_chain - helper function that arms an MBO chain for the HDM
 * @c: pointer to interface channel
 * @dir: direction of the channel
 * @compl: pointer to completion function
 *
 * This allocates buffer objects including the containing DMA coherent
 * buffer and puts them in the fifo.
 * Buffers of Rx channels are put in the kthread fifo, hence immediately
 * submitted to the HDM.
 *
 * Returns the number of allocated and enqueued MBOs.
 */
static int arm_mbo_chain(struct most_channel *c, int dir,
			 void (*compl)(struct mbo *))
{}

/**
 * most_submit_mbo - submits an MBO to fifo
 * @mbo: most buffer
 */
void most_submit_mbo(struct mbo *mbo)
{}
EXPORT_SYMBOL_GPL();

/**
 * most_write_completion - write completion handler
 * @mbo: most buffer
 *
 * This recycles the MBO for further usage. In case the channel has been
 * poisoned, the MBO is scheduled to be trashed.
 */
static void most_write_completion(struct mbo *mbo)
{}

int channel_has_mbo(struct most_interface *iface, int id,
		    struct most_component *comp)
{}
EXPORT_SYMBOL_GPL();

/**
 * most_get_mbo - get pointer to an MBO of pool
 * @iface: pointer to interface instance
 * @id: channel ID
 * @comp: driver component
 *
 * This attempts to get a free buffer out of the channel fifo.
 * Returns a pointer to MBO on success or NULL otherwise.
 */
struct mbo *most_get_mbo(struct most_interface *iface, int id,
			 struct most_component *comp)
{}
EXPORT_SYMBOL_GPL();

/**
 * most_put_mbo - return buffer to pool
 * @mbo: most buffer
 */
void most_put_mbo(struct mbo *mbo)
{}
EXPORT_SYMBOL_GPL();

/**
 * most_read_completion - read completion handler
 * @mbo: most buffer
 *
 * This function is called by the HDM when data has been received from the
 * hardware and copied to the buffer of the MBO.
 *
 * In case the channel has been poisoned it puts the buffer in the trash queue.
 * Otherwise, it passes the buffer to an component for further processing.
 */
static void most_read_completion(struct mbo *mbo)
{}

/**
 * most_start_channel - prepares a channel for communication
 * @iface: pointer to interface instance
 * @id: channel ID
 * @comp: driver component
 *
 * This prepares the channel for usage. Cross-checks whether the
 * channel's been properly configured.
 *
 * Returns 0 on success or error code otherwise.
 */
int most_start_channel(struct most_interface *iface, int id,
		       struct most_component *comp)
{}
EXPORT_SYMBOL_GPL();

/**
 * most_stop_channel - stops a running channel
 * @iface: pointer to interface instance
 * @id: channel ID
 * @comp: driver component
 */
int most_stop_channel(struct most_interface *iface, int id,
		      struct most_component *comp)
{}
EXPORT_SYMBOL_GPL();

/**
 * most_register_component - registers a driver component with the core
 * @comp: driver component
 */
int most_register_component(struct most_component *comp)
{}
EXPORT_SYMBOL_GPL();

static int disconnect_channels(struct device *dev, void *data)
{}

/**
 * most_deregister_component - deregisters a driver component with the core
 * @comp: driver component
 */
int most_deregister_component(struct most_component *comp)
{}
EXPORT_SYMBOL_GPL();

static void release_channel(struct device *dev)
{}

/**
 * most_register_interface - registers an interface with core
 * @iface: device interface
 *
 * Allocates and initializes a new interface instance and all of its channels.
 * Returns a pointer to kobject or an error pointer.
 */
int most_register_interface(struct most_interface *iface)
{}
EXPORT_SYMBOL_GPL();

/**
 * most_deregister_interface - deregisters an interface with core
 * @iface: device interface
 *
 * Before removing an interface instance from the list, all running
 * channels are stopped and poisoned.
 */
void most_deregister_interface(struct most_interface *iface)
{}
EXPORT_SYMBOL_GPL();

/**
 * most_stop_enqueue - prevents core from enqueueing MBOs
 * @iface: pointer to interface
 * @id: channel id
 *
 * This is called by an HDM that _cannot_ attend to its duties and
 * is imminent to get run over by the core. The core is not going to
 * enqueue any further packets unless the flagging HDM calls
 * most_resume enqueue().
 */
void most_stop_enqueue(struct most_interface *iface, int id)
{}
EXPORT_SYMBOL_GPL();

/**
 * most_resume_enqueue - allow core to enqueue MBOs again
 * @iface: pointer to interface
 * @id: channel id
 *
 * This clears the enqueue halt flag and enqueues all MBOs currently
 * sitting in the wait fifo.
 */
void most_resume_enqueue(struct most_interface *iface, int id)
{}
EXPORT_SYMBOL_GPL();

static int __init most_init(void)
{}

static void __exit most_exit(void)
{}

subsys_initcall(most_init);
module_exit(most_exit);
MODULE_LICENSE();
MODULE_AUTHOR();
MODULE_DESCRIPTION();