diff options
author | dexuan <dexuan@FreeBSD.org> | 2017-02-22 06:26:50 +0000 |
---|---|---|
committer | dexuan <dexuan@FreeBSD.org> | 2017-02-22 06:26:50 +0000 |
commit | 0590f59df5e2d84793cd570f9b02dce680f303a2 (patch) | |
tree | 337969fabbec1809b87e2972010c51dac8a4988b | |
parent | 0d270c4f2e86fc714836fc3afd1a3650aa6417cb (diff) | |
download | FreeBSD-src-0590f59df5e2d84793cd570f9b02dce680f303a2.zip FreeBSD-src-0590f59df5e2d84793cd570f9b02dce680f303a2.tar.gz |
MFC: 312687, 312688
Approved by: sephe (mentor)
r312687
ifnet: introduce event handlers for ifup/ifdown events
Hyper-V's NIC SR-IOV implementation needs a Hyper-V synthetic NIC and
a VF NIC to work together, mainly to support seamless live migration.
When the VF device becomes UP (or DOWN), the synthetic NIC driver needs
to switch the data path from the synthetic NIC to the VF (or the opposite).
So the synthetic NIC driver needs to know when a VF device is becoming
UP or DOWN and hence the patch is made.
Reviewed by: sephe
Approved by: sephe (mentor)
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8963
r312688
hyperv/hn: add the support for VF drivers (SR-IOV)
Hyper-V's NIC SR-IOV implementation needs a Hyper-V synthetic NIC and
a VF NIC to work together (both NICs have the same MAC address), mainly to
support seamless live migration.
When the VF device becomes UP (or DOWN), the synthetic NIC driver needs
to switch the data path from the synthetic NIC to the VF (or the opposite).
Note: multicast/broadcast packets are still received through the synthetic
NIC and we need to inject the packets through the VF interface (if the VF is
UP), even if the synthetic NIC is DOWN (so we need to force the rxfilter
to be NDIS_PACKET_TYPE_PROMISCUOUS, when the VF is UP).
Reviewed by: sephe
Approved by: sephe (mentor)
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8964
-rw-r--r-- | sys/net/if.c | 2 | ||||
-rw-r--r-- | sys/net/if_var.h | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 58c8a06..12f867c 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -2218,6 +2218,7 @@ void if_down(struct ifnet *ifp) { + EVENTHANDLER_INVOKE(ifnet_event, ifp, IFNET_EVENT_DOWN); if_unroute(ifp, IFF_UP, AF_UNSPEC); } @@ -2230,6 +2231,7 @@ if_up(struct ifnet *ifp) { if_route(ifp, IFF_UP, AF_UNSPEC); + EVENTHANDLER_INVOKE(ifnet_event, ifp, IFNET_EVENT_UP); } /* diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 2298de5..89fc2d83 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -359,6 +359,11 @@ EVENTHANDLER_DECLARE(ifnet_departure_event, ifnet_departure_event_handler_t); /* Interface link state change event */ typedef void (*ifnet_link_event_handler_t)(void *, struct ifnet *, int); EVENTHANDLER_DECLARE(ifnet_link_event, ifnet_link_event_handler_t); +/* Interface up/down event */ +#define IFNET_EVENT_UP 0 +#define IFNET_EVENT_DOWN 1 +typedef void (*ifnet_event_fn)(void *, struct ifnet *ifp, int event); +EVENTHANDLER_DECLARE(ifnet_event, ifnet_event_fn); #endif /* _SYS_EVENTHANDLER_H_ */ /* |