linux/drivers/net/net_failover.c

// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2018, Intel Corporation. */

/* This provides a net_failover interface for paravirtual drivers to
 * provide an alternate datapath by exporting APIs to create and
 * destroy a upper 'net_failover' netdev. The upper dev manages the
 * original paravirtual interface as a 'standby' netdev and uses the
 * generic failover infrastructure to register and manage a direct
 * attached VF as a 'primary' netdev. This enables live migration of
 * a VM with direct attached VF by failing over to the paravirtual
 * datapath when the VF is unplugged.
 *
 * Some of the netdev management routines are based on bond/team driver as
 * this driver provides active-backup functionality similar to those drivers.
 */

#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/netpoll.h>
#include <linux/rtnetlink.h>
#include <linux/if_vlan.h>
#include <linux/pci.h>
#include <net/sch_generic.h>
#include <uapi/linux/if_arp.h>
#include <net/net_failover.h>

static bool net_failover_xmit_ready(struct net_device *dev)
{}

static int net_failover_open(struct net_device *dev)
{}

static int net_failover_close(struct net_device *dev)
{}

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

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

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

/* fold stats, assuming all rtnl_link_stats64 fields are u64, but
 * that some drivers can provide 32bit values only.
 */
static void net_failover_fold_stats(struct rtnl_link_stats64 *_res,
				    const struct rtnl_link_stats64 *_new,
				    const struct rtnl_link_stats64 *_old)
{}

static void net_failover_get_stats(struct net_device *dev,
				   struct rtnl_link_stats64 *stats)
{}

static int net_failover_change_mtu(struct net_device *dev, int new_mtu)
{}

static void net_failover_set_rx_mode(struct net_device *dev)
{}

static int net_failover_vlan_rx_add_vid(struct net_device *dev, __be16 proto,
					u16 vid)
{}

static int net_failover_vlan_rx_kill_vid(struct net_device *dev, __be16 proto,
					 u16 vid)
{}

static const struct net_device_ops failover_dev_ops =;

#define FAILOVER_NAME
#define FAILOVER_VERSION

static void nfo_ethtool_get_drvinfo(struct net_device *dev,
				    struct ethtool_drvinfo *drvinfo)
{}

static int nfo_ethtool_get_link_ksettings(struct net_device *dev,
					  struct ethtool_link_ksettings *cmd)
{}

static const struct ethtool_ops failover_ethtool_ops =;

/* Called when slave dev is injecting data into network stack.
 * Change the associated network device from lower dev to failover dev.
 * note: already called with rcu_read_lock
 */
static rx_handler_result_t net_failover_handle_frame(struct sk_buff **pskb)
{}

static void net_failover_compute_features(struct net_device *dev)
{}

static void net_failover_lower_state_changed(struct net_device *slave_dev,
					     struct net_device *primary_dev,
					     struct net_device *standby_dev)
{}

static int net_failover_slave_pre_register(struct net_device *slave_dev,
					   struct net_device *failover_dev)
{}

static int net_failover_slave_register(struct net_device *slave_dev,
				       struct net_device *failover_dev)
{}

static int net_failover_slave_pre_unregister(struct net_device *slave_dev,
					     struct net_device *failover_dev)
{}

static int net_failover_slave_unregister(struct net_device *slave_dev,
					 struct net_device *failover_dev)
{}

static int net_failover_slave_link_change(struct net_device *slave_dev,
					  struct net_device *failover_dev)
{}

static int net_failover_slave_name_change(struct net_device *slave_dev,
					  struct net_device *failover_dev)
{}

static struct failover_ops net_failover_ops =;

/**
 * net_failover_create - Create and register a failover instance
 *
 * @standby_dev: standby netdev
 *
 * Creates a failover netdev and registers a failover instance for a standby
 * netdev. Used by paravirtual drivers that use 3-netdev model.
 * The failover netdev acts as a master device and controls 2 slave devices -
 * the original standby netdev and a VF netdev with the same MAC gets
 * registered as primary netdev.
 *
 * Return: pointer to failover instance
 */
struct failover *net_failover_create(struct net_device *standby_dev)
{}
EXPORT_SYMBOL_GPL();

/**
 * net_failover_destroy - Destroy a failover instance
 *
 * @failover: pointer to failover instance
 *
 * Unregisters any slave netdevs associated with the failover instance by
 * calling failover_slave_unregister().
 * unregisters the failover instance itself and finally frees the failover
 * netdev. Used by paravirtual drivers that use 3-netdev model.
 *
 */
void net_failover_destroy(struct failover *failover)
{}
EXPORT_SYMBOL_GPL();

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

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

MODULE_DESCRIPTION();
MODULE_LICENSE();