Skip to content

Commit

Permalink
net: Introduce generic failover module
Browse files Browse the repository at this point in the history
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: Sridhar Samudrala <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
ssamudrala authored and davem330 committed May 29, 2018
1 parent cb16039 commit 30c8bd5
Show file tree
Hide file tree
Showing 7 changed files with 407 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Documentation/networking/failover.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.. 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 changes: 8 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -5411,6 +5411,14 @@ S: Maintained
F: Documentation/hwmon/f71805f
F: drivers/hwmon/f71805f.c

FAILOVER MODULE
M: Sridhar Samudrala <[email protected]>
L: [email protected]
S: Supported
F: net/core/failover.c
F: include/net/failover.h
F: Documentation/networking/failover.rst

FANOTIFY
M: Jan Kara <[email protected]>
R: Amir Goldstein <[email protected]>
Expand Down
16 changes: 16 additions & 0 deletions include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
{
Expand Down
36 changes: 36 additions & 0 deletions include/net/failover.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* 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 changes: 13 additions & 0 deletions net/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions net/core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ obj-$(CONFIG_DST_CACHE) += dst_cache.o
obj-$(CONFIG_HWBM) += hwbm.o
obj-$(CONFIG_NET_DEVLINK) += devlink.o
obj-$(CONFIG_GRO_CELLS) += gro_cells.o
obj-$(CONFIG_FAILOVER) += failover.o
Loading

0 comments on commit 30c8bd5

Please sign in to comment.