linux/drivers/net/wwan/wwan_core.c

// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2021, Linaro Ltd <[email protected]> */

#include <linux/bitmap.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/debugfs.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/idr.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/poll.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/uaccess.h>
#include <linux/termios.h>
#include <linux/wwan.h>
#include <net/rtnetlink.h>
#include <uapi/linux/wwan.h>

/* Maximum number of minors in use */
#define WWAN_MAX_MINORS

static DEFINE_MUTEX(wwan_register_lock); /* WWAN device create|remove lock */
static DEFINE_IDA(minors); /* minors for WWAN port chardevs */
static DEFINE_IDA(wwan_dev_ids); /* for unique WWAN device IDs */
static const struct class wwan_class =;
static int wwan_major;
static struct dentry *wwan_debugfs_dir;

#define to_wwan_dev(d)
#define to_wwan_port(d)

/* WWAN port flags */
#define WWAN_PORT_TX_OFF

/**
 * struct wwan_device - The structure that defines a WWAN device
 *
 * @id: WWAN device unique ID.
 * @dev: Underlying device.
 * @port_id: Current available port ID to pick.
 * @ops: wwan device ops
 * @ops_ctxt: context to pass to ops
 * @debugfs_dir:  WWAN device debugfs dir
 */
struct wwan_device {};

/**
 * struct wwan_port - The structure that defines a WWAN port
 * @type: Port type
 * @start_count: Port start counter
 * @flags: Store port state and capabilities
 * @ops: Pointer to WWAN port operations
 * @ops_lock: Protect port ops
 * @dev: Underlying device
 * @rxq: Buffer inbound queue
 * @waitqueue: The waitqueue for port fops (read/write/poll)
 * @data_lock: Port specific data access serialization
 * @headroom_len: SKB reserved headroom size
 * @frag_len: Length to fragment packet
 * @at_data: AT port specific data
 */
struct wwan_port {};

static ssize_t index_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(index);

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

static void wwan_dev_destroy(struct device *dev)
{}

static const struct device_type wwan_dev_type =;

static int wwan_dev_parent_match(struct device *dev, const void *parent)
{}

static struct wwan_device *wwan_dev_get_by_parent(struct device *parent)
{}

static int wwan_dev_name_match(struct device *dev, const void *name)
{}

static struct wwan_device *wwan_dev_get_by_name(const char *name)
{}

#ifdef CONFIG_WWAN_DEBUGFS
struct dentry *wwan_get_debugfs_dir(struct device *parent)
{}
EXPORT_SYMBOL_GPL();

static int wwan_dev_debugfs_match(struct device *dev, const void *dir)
{}

static struct wwan_device *wwan_dev_get_by_debugfs(struct dentry *dir)
{}

void wwan_put_debugfs_dir(struct dentry *dir)
{}
EXPORT_SYMBOL_GPL();
#endif

/* This function allocates and registers a new WWAN device OR if a WWAN device
 * already exist for the given parent, it gets a reference and return it.
 * This function is not exported (for now), it is called indirectly via
 * wwan_create_port().
 */
static struct wwan_device *wwan_create_dev(struct device *parent)
{}

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

static void wwan_remove_dev(struct wwan_device *wwandev)
{}

/* ------- WWAN port management ------- */

static const struct {} wwan_port_types[WWAN_PORT_MAX + 1] =;

static ssize_t type_show(struct device *dev, struct device_attribute *attr,
			 char *buf)
{}
static DEVICE_ATTR_RO(type);

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

static void wwan_port_destroy(struct device *dev)
{}

static const struct device_type wwan_port_dev_type =;

static int wwan_port_minor_match(struct device *dev, const void *minor)
{}

static struct wwan_port *wwan_port_get_by_minor(unsigned int minor)
{}

/* Allocate and set unique name based on passed format
 *
 * Name allocation approach is highly inspired by the __dev_alloc_name()
 * function.
 *
 * To avoid names collision, the caller must prevent the new port device
 * registration as well as concurrent invocation of this function.
 */
static int __wwan_port_dev_assign_name(struct wwan_port *port, const char *fmt)
{}

struct wwan_port *wwan_create_port(struct device *parent,
				   enum wwan_port_type type,
				   const struct wwan_port_ops *ops,
				   struct wwan_port_caps *caps,
				   void *drvdata)
{}
EXPORT_SYMBOL_GPL();

void wwan_remove_port(struct wwan_port *port)
{}
EXPORT_SYMBOL_GPL();

void wwan_port_rx(struct wwan_port *port, struct sk_buff *skb)
{}
EXPORT_SYMBOL_GPL();

void wwan_port_txon(struct wwan_port *port)
{}
EXPORT_SYMBOL_GPL();

void wwan_port_txoff(struct wwan_port *port)
{}
EXPORT_SYMBOL_GPL();

void *wwan_port_get_drvdata(struct wwan_port *port)
{}
EXPORT_SYMBOL_GPL();

static int wwan_port_op_start(struct wwan_port *port)
{}

static void wwan_port_op_stop(struct wwan_port *port)
{}

static int wwan_port_op_tx(struct wwan_port *port, struct sk_buff *skb,
			   bool nonblock)
{}

static bool is_read_blocked(struct wwan_port *port)
{}

static bool is_write_blocked(struct wwan_port *port)
{}

static int wwan_wait_rx(struct wwan_port *port, bool nonblock)
{}

static int wwan_wait_tx(struct wwan_port *port, bool nonblock)
{}

static int wwan_port_fops_open(struct inode *inode, struct file *file)
{}

static int wwan_port_fops_release(struct inode *inode, struct file *filp)
{}

static ssize_t wwan_port_fops_read(struct file *filp, char __user *buf,
				   size_t count, loff_t *ppos)
{}

static ssize_t wwan_port_fops_write(struct file *filp, const char __user *buf,
				    size_t count, loff_t *offp)
{}

static __poll_t wwan_port_fops_poll(struct file *filp, poll_table *wait)
{}

/* Implements minimalistic stub terminal IOCTLs support */
static long wwan_port_fops_at_ioctl(struct wwan_port *port, unsigned int cmd,
				    unsigned long arg)
{}

static long wwan_port_fops_ioctl(struct file *filp, unsigned int cmd,
				 unsigned long arg)
{}

static const struct file_operations wwan_port_fops =;

static int wwan_rtnl_validate(struct nlattr *tb[], struct nlattr *data[],
			      struct netlink_ext_ack *extack)
{}

static const struct device_type wwan_type =;

static struct net_device *wwan_rtnl_alloc(struct nlattr *tb[],
					  const char *ifname,
					  unsigned char name_assign_type,
					  unsigned int num_tx_queues,
					  unsigned int num_rx_queues)
{}

static int wwan_rtnl_newlink(struct net *src_net, struct net_device *dev,
			     struct nlattr *tb[], struct nlattr *data[],
			     struct netlink_ext_ack *extack)
{}

static void wwan_rtnl_dellink(struct net_device *dev, struct list_head *head)
{}

static size_t wwan_rtnl_get_size(const struct net_device *dev)
{}

static int wwan_rtnl_fill_info(struct sk_buff *skb,
			       const struct net_device *dev)
{}

static const struct nla_policy wwan_rtnl_policy[IFLA_WWAN_MAX + 1] =;

static struct rtnl_link_ops wwan_rtnl_link_ops __read_mostly =;

static void wwan_create_default_link(struct wwan_device *wwandev,
				     u32 def_link_id)
{}

/**
 * wwan_register_ops - register WWAN device ops
 * @parent: Device to use as parent and shared by all WWAN ports and
 *	created netdevs
 * @ops: operations to register
 * @ctxt: context to pass to operations
 * @def_link_id: id of the default link that will be automatically created by
 *	the WWAN core for the WWAN device. The default link will not be created
 *	if the passed value is WWAN_NO_DEFAULT_LINK.
 *
 * Returns: 0 on success, a negative error code on failure
 */
int wwan_register_ops(struct device *parent, const struct wwan_ops *ops,
		      void *ctxt, u32 def_link_id)
{}
EXPORT_SYMBOL_GPL();

/* Enqueue child netdev deletion */
static int wwan_child_dellink(struct device *dev, void *data)
{}

/**
 * wwan_unregister_ops - remove WWAN device ops
 * @parent: Device to use as parent and shared by all WWAN ports and
 *	created netdevs
 */
void wwan_unregister_ops(struct device *parent)
{}
EXPORT_SYMBOL_GPL();

static int __init wwan_init(void)
{}

static void __exit wwan_exit(void)
{}

module_init();
module_exit(wwan_exit);

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