linux/drivers/net/xen-netfront.c

/*
 * Virtual network driver for conversing with remote driver backends.
 *
 * Copyright (c) 2002-2005, K A Fraser
 * Copyright (c) 2005, XenSource Ltd
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License version 2
 * as published by the Free Software Foundation; or, when distributed
 * separately from the Linux kernel or incorporated into other
 * software packages, subject to the following license:
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this source file (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use, copy, modify,
 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
 * and to permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */

#define pr_fmt(fmt)

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/ethtool.h>
#include <linux/if_ether.h>
#include <net/tcp.h>
#include <linux/udp.h>
#include <linux/moduleparam.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <net/ip.h>
#include <linux/bpf.h>
#include <net/page_pool/types.h>
#include <linux/bpf_trace.h>

#include <xen/xen.h>
#include <xen/xenbus.h>
#include <xen/events.h>
#include <xen/page.h>
#include <xen/platform_pci.h>
#include <xen/grant_table.h>

#include <xen/interface/io/netif.h>
#include <xen/interface/memory.h>
#include <xen/interface/grant_table.h>

/* Module parameters */
#define MAX_QUEUES_DEFAULT
static unsigned int xennet_max_queues;
module_param_named(max_queues, xennet_max_queues, uint, 0644);
MODULE_PARM_DESC();

static bool __read_mostly xennet_trusted =;
module_param_named(trusted, xennet_trusted, bool, 0644);
MODULE_PARM_DESC();

#define XENNET_TIMEOUT

static const struct ethtool_ops xennet_ethtool_ops;

struct netfront_cb {};

#define NETFRONT_SKB_CB(skb)

#define RX_COPY_THRESHOLD

#define NET_TX_RING_SIZE
#define NET_RX_RING_SIZE

/* Minimum number of Rx slots (includes slot for GSO metadata). */
#define NET_RX_SLOTS_MIN

/* Queue name is interface name with "-qNNN" appended */
#define QUEUE_NAME_SIZE

/* IRQ name is queue name with "-tx" or "-rx" appended */
#define IRQ_NAME_SIZE

static DECLARE_WAIT_QUEUE_HEAD(module_wq);

struct netfront_stats {};

struct netfront_info;

struct netfront_queue {};

struct netfront_info {};

struct netfront_rx_info {};

/*
 * Access macros for acquiring freeing slots in tx_skbs[].
 */

static void add_id_to_list(unsigned *head, unsigned short *list,
			   unsigned short id)
{}

static unsigned short get_id_from_list(unsigned *head, unsigned short *list)
{}

static int xennet_rxidx(RING_IDX idx)
{}

static struct sk_buff *xennet_get_rx_skb(struct netfront_queue *queue,
					 RING_IDX ri)
{}

static grant_ref_t xennet_get_rx_ref(struct netfront_queue *queue,
					    RING_IDX ri)
{}

#ifdef CONFIG_SYSFS
static const struct attribute_group xennet_dev_group;
#endif

static bool xennet_can_sg(struct net_device *dev)
{}


static void rx_refill_timeout(struct timer_list *t)
{}

static int netfront_tx_slot_available(struct netfront_queue *queue)
{}

static void xennet_maybe_wake_tx(struct netfront_queue *queue)
{}


static struct sk_buff *xennet_alloc_one_rx_buffer(struct netfront_queue *queue)
{}


static void xennet_alloc_rx_buffers(struct netfront_queue *queue)
{}

static int xennet_open(struct net_device *dev)
{}

static bool xennet_tx_buf_gc(struct netfront_queue *queue)
{}

struct xennet_gnttab_make_txreq {};

static void xennet_tx_setup_grant(unsigned long gfn, unsigned int offset,
				  unsigned int len, void *data)
{}

static struct xen_netif_tx_request *xennet_make_first_txreq(
	struct xennet_gnttab_make_txreq *info,
	unsigned int offset, unsigned int len)
{}

static void xennet_make_one_txreq(unsigned long gfn, unsigned int offset,
				  unsigned int len, void *data)
{}

static void xennet_make_txreqs(
	struct xennet_gnttab_make_txreq *info,
	struct page *page,
	unsigned int offset, unsigned int len)
{}

/*
 * Count how many ring slots are required to send this skb. Each frag
 * might be a compound page.
 */
static int xennet_count_skb_slots(struct sk_buff *skb)
{}

static u16 xennet_select_queue(struct net_device *dev, struct sk_buff *skb,
			       struct net_device *sb_dev)
{}

static void xennet_mark_tx_pending(struct netfront_queue *queue)
{}

static int xennet_xdp_xmit_one(struct net_device *dev,
			       struct netfront_queue *queue,
			       struct xdp_frame *xdpf)
{}

static int xennet_xdp_xmit(struct net_device *dev, int n,
			   struct xdp_frame **frames, u32 flags)
{}

static struct sk_buff *bounce_skb(const struct sk_buff *skb)
{}

#define MAX_XEN_SKB_FRAGS

static netdev_tx_t xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
{}

static int xennet_close(struct net_device *dev)
{}

static void xennet_destroy_queues(struct netfront_info *info)
{}

static void xennet_uninit(struct net_device *dev)
{}

static void xennet_set_rx_rsp_cons(struct netfront_queue *queue, RING_IDX val)
{}

static void xennet_move_rx_slot(struct netfront_queue *queue, struct sk_buff *skb,
				grant_ref_t ref)
{}

static int xennet_get_extras(struct netfront_queue *queue,
			     struct xen_netif_extra_info *extras,
			     RING_IDX rp)

{}

static u32 xennet_run_xdp(struct netfront_queue *queue, struct page *pdata,
		   struct xen_netif_rx_response *rx, struct bpf_prog *prog,
		   struct xdp_buff *xdp, bool *need_xdp_flush)
{}

static int xennet_get_responses(struct netfront_queue *queue,
				struct netfront_rx_info *rinfo, RING_IDX rp,
				struct sk_buff_head *list,
				bool *need_xdp_flush)
{}

static int xennet_set_skb_gso(struct sk_buff *skb,
			      struct xen_netif_extra_info *gso)
{}

static int xennet_fill_frags(struct netfront_queue *queue,
			     struct sk_buff *skb,
			     struct sk_buff_head *list)
{}

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

static int handle_incoming_queue(struct netfront_queue *queue,
				 struct sk_buff_head *rxq)
{}

static int xennet_poll(struct napi_struct *napi, int budget)
{}

static int xennet_change_mtu(struct net_device *dev, int mtu)
{}

static void xennet_get_stats64(struct net_device *dev,
			       struct rtnl_link_stats64 *tot)
{}

static void xennet_release_tx_bufs(struct netfront_queue *queue)
{}

static void xennet_release_rx_bufs(struct netfront_queue *queue)
{}

static netdev_features_t xennet_fix_features(struct net_device *dev,
	netdev_features_t features)
{}

static int xennet_set_features(struct net_device *dev,
	netdev_features_t features)
{}

static bool xennet_handle_tx(struct netfront_queue *queue, unsigned int *eoi)
{}

static irqreturn_t xennet_tx_interrupt(int irq, void *dev_id)
{}

static bool xennet_handle_rx(struct netfront_queue *queue, unsigned int *eoi)
{}

static irqreturn_t xennet_rx_interrupt(int irq, void *dev_id)
{}

static irqreturn_t xennet_interrupt(int irq, void *dev_id)
{}

#ifdef CONFIG_NET_POLL_CONTROLLER
static void xennet_poll_controller(struct net_device *dev)
{}
#endif

#define NETBACK_XDP_HEADROOM_DISABLE
#define NETBACK_XDP_HEADROOM_ENABLE

static int talk_to_netback_xdp(struct netfront_info *np, int xdp)
{}

static int xennet_xdp_set(struct net_device *dev, struct bpf_prog *prog,
			  struct netlink_ext_ack *extack)
{}

static int xennet_xdp(struct net_device *dev, struct netdev_bpf *xdp)
{}

static const struct net_device_ops xennet_netdev_ops =;

static void xennet_free_netdev(struct net_device *netdev)
{}

static struct net_device *xennet_create_dev(struct xenbus_device *dev)
{}

/*
 * Entry point to this code when a new device is created.  Allocate the basic
 * structures and the ring buffers for communication with the backend, and
 * inform the backend of the appropriate details for those.
 */
static int netfront_probe(struct xenbus_device *dev,
			  const struct xenbus_device_id *id)
{}

static void xennet_end_access(int ref, void *page)
{}

static void xennet_disconnect_backend(struct netfront_info *info)
{}

/*
 * We are reconnecting to the backend, due to a suspend/resume, or a backend
 * driver restart.  We tear down our netif structure and recreate it, but
 * leave the device-layer structures intact so that this is transparent to the
 * rest of the kernel.
 */
static int netfront_resume(struct xenbus_device *dev)
{}

static int xen_net_read_mac(struct xenbus_device *dev, u8 mac[])
{}

static int setup_netfront_single(struct netfront_queue *queue)
{}

static int setup_netfront_split(struct netfront_queue *queue)
{}

static int setup_netfront(struct xenbus_device *dev,
			struct netfront_queue *queue, unsigned int feature_split_evtchn)
{}

/* Queue-specific initialisation
 * This used to be done in xennet_create_dev() but must now
 * be run per-queue.
 */
static int xennet_init_queue(struct netfront_queue *queue)
{}

static int write_queue_xenstore_keys(struct netfront_queue *queue,
			   struct xenbus_transaction *xbt, int write_hierarchical)
{}



static int xennet_create_page_pool(struct netfront_queue *queue)
{}

static int xennet_create_queues(struct netfront_info *info,
				unsigned int *num_queues)
{}

/* Common code used when first setting up, and when resuming. */
static int talk_to_netback(struct xenbus_device *dev,
			   struct netfront_info *info)
{}

static int xennet_connect(struct net_device *dev)
{}

/*
 * Callback received when the backend's state changes.
 */
static void netback_changed(struct xenbus_device *dev,
			    enum xenbus_state backend_state)
{}

static const struct xennet_stat {} xennet_stats[] =;

static int xennet_get_sset_count(struct net_device *dev, int string_set)
{}

static void xennet_get_ethtool_stats(struct net_device *dev,
				     struct ethtool_stats *stats, u64 * data)
{}

static void xennet_get_strings(struct net_device *dev, u32 stringset, u8 * data)
{}

static const struct ethtool_ops xennet_ethtool_ops =;

#ifdef CONFIG_SYSFS
static ssize_t show_rxbuf(struct device *dev,
			  struct device_attribute *attr, char *buf)
{}

static ssize_t store_rxbuf(struct device *dev,
			   struct device_attribute *attr,
			   const char *buf, size_t len)
{}

static DEVICE_ATTR(rxbuf_min, 0644, show_rxbuf, store_rxbuf);
static DEVICE_ATTR(rxbuf_max, 0644, show_rxbuf, store_rxbuf);
static DEVICE_ATTR(rxbuf_cur, 0444, show_rxbuf, NULL);

static struct attribute *xennet_dev_attrs[] =;

static const struct attribute_group xennet_dev_group =;
#endif /* CONFIG_SYSFS */

static void xennet_bus_close(struct xenbus_device *dev)
{}

static void xennet_remove(struct xenbus_device *dev)
{}

static const struct xenbus_device_id netfront_ids[] =;

static struct xenbus_driver netfront_driver =;

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


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

MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_ALIAS();
MODULE_ALIAS();