Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 30c8bd5a authored by Sridhar Samudrala's avatar Sridhar Samudrala Committed by David S. Miller
Browse files

net: Introduce generic failover module



The failover module provides a generic interface for paravirtual drivers
to register a netdev and a set of ops with a failover instance. The ops
are used as event handlers that get called to handle netdev register/
unregister/link change/name change events on slave pci ethernet devices
with the same mac address as the failover netdev.

This enables paravirtual drivers to use a VF as an accelerated low latency
datapath. It also allows migration of VMs with direct attached VFs by
failing over to the paravirtual datapath when the VF is unplugged.

Signed-off-by: default avatarSridhar Samudrala <sridhar.samudrala@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cb160394
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
.. SPDX-License-Identifier: GPL-2.0

========
FAILOVER
========

Overview
========

The failover module provides a generic interface for paravirtual drivers
to register a netdev and a set of ops with a failover instance. The ops
are used as event handlers that get called to handle netdev register/
unregister/link change/name change events on slave pci ethernet devices
with the same mac address as the failover netdev.

This enables paravirtual drivers to use a VF as an accelerated low latency
datapath. It also allows live migration of VMs with direct attached VFs by
failing over to the paravirtual datapath when the VF is unplugged.
+8 −0
Original line number Diff line number Diff line
@@ -5411,6 +5411,14 @@ S: Maintained
F:	Documentation/hwmon/f71805f
F:	drivers/hwmon/f71805f.c

FAILOVER MODULE
M:	Sridhar Samudrala <sridhar.samudrala@intel.com>
L:	netdev@vger.kernel.org
S:	Supported
F:	net/core/failover.c
F:	include/net/failover.h
F:	Documentation/networking/failover.rst

FANOTIFY
M:	Jan Kara <jack@suse.cz>
R:	Amir Goldstein <amir73il@gmail.com>
+16 −0
Original line number Diff line number Diff line
@@ -1425,6 +1425,8 @@ struct net_device_ops {
 *	entity (i.e. the master device for bridged veth)
 * @IFF_MACSEC: device is a MACsec device
 * @IFF_NO_RX_HANDLER: device doesn't support the rx_handler hook
 * @IFF_FAILOVER: device is a failover master device
 * @IFF_FAILOVER_SLAVE: device is lower dev of a failover master device
 */
enum netdev_priv_flags {
	IFF_802_1Q_VLAN			= 1<<0,
@@ -1454,6 +1456,8 @@ enum netdev_priv_flags {
	IFF_PHONY_HEADROOM		= 1<<24,
	IFF_MACSEC			= 1<<25,
	IFF_NO_RX_HANDLER		= 1<<26,
	IFF_FAILOVER			= 1<<27,
	IFF_FAILOVER_SLAVE		= 1<<28,
};

#define IFF_802_1Q_VLAN			IFF_802_1Q_VLAN
@@ -1482,6 +1486,8 @@ enum netdev_priv_flags {
#define IFF_RXFH_CONFIGURED		IFF_RXFH_CONFIGURED
#define IFF_MACSEC			IFF_MACSEC
#define IFF_NO_RX_HANDLER		IFF_NO_RX_HANDLER
#define IFF_FAILOVER			IFF_FAILOVER
#define IFF_FAILOVER_SLAVE		IFF_FAILOVER_SLAVE

/**
 *	struct net_device - The DEVICE structure.
@@ -4336,6 +4342,16 @@ static inline bool netif_is_rxfh_configured(const struct net_device *dev)
	return dev->priv_flags & IFF_RXFH_CONFIGURED;
}

static inline bool netif_is_failover(const struct net_device *dev)
{
	return dev->priv_flags & IFF_FAILOVER;
}

static inline bool netif_is_failover_slave(const struct net_device *dev)
{
	return dev->priv_flags & IFF_FAILOVER_SLAVE;
}

/* This device needs to keep skb dst for qdisc enqueue or ndo_start_xmit() */
static inline void netif_keep_dst(struct net_device *dev)
{

include/net/failover.h

0 → 100644
+36 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2018, Intel Corporation. */

#ifndef _FAILOVER_H
#define _FAILOVER_H

#include <linux/netdevice.h>

struct failover_ops {
	int (*slave_pre_register)(struct net_device *slave_dev,
				  struct net_device *failover_dev);
	int (*slave_register)(struct net_device *slave_dev,
			      struct net_device *failover_dev);
	int (*slave_pre_unregister)(struct net_device *slave_dev,
				    struct net_device *failover_dev);
	int (*slave_unregister)(struct net_device *slave_dev,
				struct net_device *failover_dev);
	int (*slave_link_change)(struct net_device *slave_dev,
				 struct net_device *failover_dev);
	int (*slave_name_change)(struct net_device *slave_dev,
				 struct net_device *failover_dev);
	rx_handler_result_t (*slave_handle_frame)(struct sk_buff **pskb);
};

struct failover {
	struct list_head list;
	struct net_device __rcu *failover_dev;
	struct failover_ops __rcu *ops;
};

struct failover *failover_register(struct net_device *dev,
				   struct failover_ops *ops);
void failover_unregister(struct failover *failover);
int failover_slave_unregister(struct net_device *slave_dev);

#endif /* _FAILOVER_H */
+13 −0
Original line number Diff line number Diff line
@@ -432,6 +432,19 @@ config MAY_USE_DEVLINK
config PAGE_POOL
       bool

config FAILOVER
	tristate "Generic failover module"
	help
	  The failover module provides a generic interface for paravirtual
	  drivers to register a netdev and a set of ops with a failover
	  instance. The ops are used as event handlers that get called to
	  handle netdev register/unregister/link change/name change events
	  on slave pci ethernet devices with the same mac address as the
	  failover netdev. This enables paravirtual drivers to use a
	  VF as an accelerated low latency datapath. It also allows live
	  migration of VMs with direct attached VFs by failing over to the
	  paravirtual datapath when the VF is unplugged.

endif   # if NET

# Used by archs to tell that they support BPF JIT compiler plus which flavour.
Loading