Skip to content

Commit 30c8bd5

Browse files
ssamudraladavem330
authored andcommitted
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: Sridhar Samudrala <sridhar.samudrala@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent cb16039 commit 30c8bd5

File tree

7 files changed

+407
-0
lines changed

7 files changed

+407
-0
lines changed

Documentation/networking/failover.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
========
4+
FAILOVER
5+
========
6+
7+
Overview
8+
========
9+
10+
The failover module provides a generic interface for paravirtual drivers
11+
to register a netdev and a set of ops with a failover instance. The ops
12+
are used as event handlers that get called to handle netdev register/
13+
unregister/link change/name change events on slave pci ethernet devices
14+
with the same mac address as the failover netdev.
15+
16+
This enables paravirtual drivers to use a VF as an accelerated low latency
17+
datapath. It also allows live migration of VMs with direct attached VFs by
18+
failing over to the paravirtual datapath when the VF is unplugged.

MAINTAINERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5411,6 +5411,14 @@ S: Maintained
54115411
F: Documentation/hwmon/f71805f
54125412
F: drivers/hwmon/f71805f.c
54135413

5414+
FAILOVER MODULE
5415+
M: Sridhar Samudrala <sridhar.samudrala@intel.com>
5416+
L: netdev@vger.kernel.org
5417+
S: Supported
5418+
F: net/core/failover.c
5419+
F: include/net/failover.h
5420+
F: Documentation/networking/failover.rst
5421+
54145422
FANOTIFY
54155423
M: Jan Kara <jack@suse.cz>
54165424
R: Amir Goldstein <amir73il@gmail.com>

include/linux/netdevice.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,8 @@ struct net_device_ops {
14251425
* entity (i.e. the master device for bridged veth)
14261426
* @IFF_MACSEC: device is a MACsec device
14271427
* @IFF_NO_RX_HANDLER: device doesn't support the rx_handler hook
1428+
* @IFF_FAILOVER: device is a failover master device
1429+
* @IFF_FAILOVER_SLAVE: device is lower dev of a failover master device
14281430
*/
14291431
enum netdev_priv_flags {
14301432
IFF_802_1Q_VLAN = 1<<0,
@@ -1454,6 +1456,8 @@ enum netdev_priv_flags {
14541456
IFF_PHONY_HEADROOM = 1<<24,
14551457
IFF_MACSEC = 1<<25,
14561458
IFF_NO_RX_HANDLER = 1<<26,
1459+
IFF_FAILOVER = 1<<27,
1460+
IFF_FAILOVER_SLAVE = 1<<28,
14571461
};
14581462

14591463
#define IFF_802_1Q_VLAN IFF_802_1Q_VLAN
@@ -1482,6 +1486,8 @@ enum netdev_priv_flags {
14821486
#define IFF_RXFH_CONFIGURED IFF_RXFH_CONFIGURED
14831487
#define IFF_MACSEC IFF_MACSEC
14841488
#define IFF_NO_RX_HANDLER IFF_NO_RX_HANDLER
1489+
#define IFF_FAILOVER IFF_FAILOVER
1490+
#define IFF_FAILOVER_SLAVE IFF_FAILOVER_SLAVE
14851491

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

4345+
static inline bool netif_is_failover(const struct net_device *dev)
4346+
{
4347+
return dev->priv_flags & IFF_FAILOVER;
4348+
}
4349+
4350+
static inline bool netif_is_failover_slave(const struct net_device *dev)
4351+
{
4352+
return dev->priv_flags & IFF_FAILOVER_SLAVE;
4353+
}
4354+
43394355
/* This device needs to keep skb dst for qdisc enqueue or ndo_start_xmit() */
43404356
static inline void netif_keep_dst(struct net_device *dev)
43414357
{

include/net/failover.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/* Copyright (c) 2018, Intel Corporation. */
3+
4+
#ifndef _FAILOVER_H
5+
#define _FAILOVER_H
6+
7+
#include <linux/netdevice.h>
8+
9+
struct failover_ops {
10+
int (*slave_pre_register)(struct net_device *slave_dev,
11+
struct net_device *failover_dev);
12+
int (*slave_register)(struct net_device *slave_dev,
13+
struct net_device *failover_dev);
14+
int (*slave_pre_unregister)(struct net_device *slave_dev,
15+
struct net_device *failover_dev);
16+
int (*slave_unregister)(struct net_device *slave_dev,
17+
struct net_device *failover_dev);
18+
int (*slave_link_change)(struct net_device *slave_dev,
19+
struct net_device *failover_dev);
20+
int (*slave_name_change)(struct net_device *slave_dev,
21+
struct net_device *failover_dev);
22+
rx_handler_result_t (*slave_handle_frame)(struct sk_buff **pskb);
23+
};
24+
25+
struct failover {
26+
struct list_head list;
27+
struct net_device __rcu *failover_dev;
28+
struct failover_ops __rcu *ops;
29+
};
30+
31+
struct failover *failover_register(struct net_device *dev,
32+
struct failover_ops *ops);
33+
void failover_unregister(struct failover *failover);
34+
int failover_slave_unregister(struct net_device *slave_dev);
35+
36+
#endif /* _FAILOVER_H */

net/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,19 @@ config MAY_USE_DEVLINK
432432
config PAGE_POOL
433433
bool
434434

435+
config FAILOVER
436+
tristate "Generic failover module"
437+
help
438+
The failover module provides a generic interface for paravirtual
439+
drivers to register a netdev and a set of ops with a failover
440+
instance. The ops are used as event handlers that get called to
441+
handle netdev register/unregister/link change/name change events
442+
on slave pci ethernet devices with the same mac address as the
443+
failover netdev. This enables paravirtual drivers to use a
444+
VF as an accelerated low latency datapath. It also allows live
445+
migration of VMs with direct attached VFs by failing over to the
446+
paravirtual datapath when the VF is unplugged.
447+
435448
endif # if NET
436449

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

net/core/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ obj-$(CONFIG_DST_CACHE) += dst_cache.o
3131
obj-$(CONFIG_HWBM) += hwbm.o
3232
obj-$(CONFIG_NET_DEVLINK) += devlink.o
3333
obj-$(CONFIG_GRO_CELLS) += gro_cells.o
34+
obj-$(CONFIG_FAILOVER) += failover.o

0 commit comments

Comments
 (0)