322483
hyperv/hn: Update VF's ibytes properly under transparent VF mode.
While, I'm here add comment about why updating VF's imcast stat is
not necessary.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D11948
322485
hyperv/hn: Fix/enhance receiving path when VF is activated.
- Update hn(4)'s stats properly for non-transparent mode VF.
- Allow BPF tapping to hn(4) for non-transparent mode VF.
- Don't setup mbuf hash, if 'options RSS' is set.
In Azure, when VF is activated, TCP SYN and SYN|ACK go through hn(4)
while the rest of segments and ACKs belonging to the same TCP 4-tuple
go through the VF. So don't setup mbuf hash, if a VF is activated
and 'options RSS' is not enabled. hn(4) and the VF may use neither
the same RSS hash key nor the same RSS hash function, so the hash
value for packets belonging to the same flow could be different!
- Disable LRO.
hn(4) will only receive broadcast packets, multicast packets, TCP
SYN and SYN|ACK (in Azure), LRO is useless for these packet types.
For non-transparent, we definitely _cannot_ enable LRO at all, since
the LRO flush will use hn(4) as the receiving interface; i.e.
hn_ifp->if_input(hn_ifp, m).
While I'm here, remove unapplied comment and minor style change.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D11978
322486
hyperv/hn: Minor cleanup
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D11979
322487
hyperv/hn: Re-set datapath after synthetic parts reattached.
Do this even for non-transparent mode VF. Better safe than sorry.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D11981
hyperv/hn: Implement transparent mode network VF.
How network VF works with hn(4) on Hyper-V in transparent mode:
- Each network VF has a cooresponding hn(4).
- The network VF and the it's cooresponding hn(4) have the same hardware
address.
- Once the network VF is attached, the cooresponding hn(4) waits several
seconds to make sure that the network VF attach routing completes, then:
o Set the intersection of the network VF's if_capabilities and the
cooresponding hn(4)'s if_capabilities to the cooresponding hn(4)'s
if_capabilities. And adjust the cooresponding hn(4) if_capable and
if_hwassist accordingly. (*)
o Make sure that the cooresponding hn(4)'s TSO parameters meet the
constraints posed by both the network VF and the cooresponding hn(4).
(*)
o The network VF's if_input is overridden. The overriding if_input
changes the input packet's rcvif to the cooreponding hn(4). The
network layers are tricked into thinking that all packets are
neceived by the cooresponding hn(4).
o If the cooresponding hn(4) was brought up, bring up the network VF.
The transmission dispatched to the cooresponding hn(4) are
redispatched to the network VF.
o Bringing down the cooresponding hn(4) also brings down the network
VF.
o All IOCTLs issued to the cooresponding hn(4) are pass-through'ed to
the network VF; the cooresponding hn(4) changes its internal state
if necessary.
o The media status of the cooresponding hn(4) solely relies on the
network VF.
o If there are multicast filters on the cooresponding hn(4), allmulti
will be enabled on the network VF. (**)
- Once the network VF is detached. Undo all damages did to the
cooresponding hn(4) in the above item.
NOTE:
No operation should be issued directly to the network VF, if the
network VF transparent mode is enabled. The network VF transparent mode
can be enabled by setting tunable hw.hn.vf_transparent to 1. The network
VF transparent mode is _not_ enabled by default, as of this commit.
The benefit of the network VF transparent mode is that the network VF
attachment and detachment are transparent to all network layers; e.g. live
migration detaches and reattaches the network VF.
The major drawbacks of the network VF transparent mode:
- The netmap(4) support is lost, even if the VF supports it.
- ALTQ does not work, since if_start method cannot be properly supported.
(*)
These decisions were made so that things will not be messed up too much
during the transition period.
(**)
This does _not_ need to go through the fancy multicast filter management
stuffs like what vlan(4) has, at least currently:
- As of this write, multicast does not work in Azure.
- As of this write, multicast packets go through the cooresponding hn(4).
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D11803
321836
hyperv/hn: Renaming and minor cleanup
This prepares for the upcoming transparent VF support.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D11708
321837
hyperv/hn: Add comment about ether_ifattach event subscription.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D11710
hyperv/hn: Ignore LINK_SPEED_CHANGE status.
This status will be reported if the backend NIC is wireless; it's not
useful. Due to the high frequency of the reporting, this could be
pretty annoying; ignore it.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D11651
hyperv/hn: Export VF list and VF-HN mapping
The VF-HN map will be used later on to implement "transparent VF".
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D11618
This is a direct commit. Sorted LRO is much better than plain
(linked list LRO), which hash LRO is not available on this
branch.
Sponsored by: Microsoft
hyperv/hn: Use channel0, i.e. TX ring0, for TCP SYN/SYN|ACK.
Hyper-V hot channel effect:
Operation latency on hot channel is only _half_ of the operation
latency on cold channels.
This commit takes the advantage of the above Hyper-V host channel
effect, and can reduce more than 75% latency and more than 50%
latency stdev, i.e. lower and more stable/predictable latency,
for various types of web server workloads.
Sponsored by: Microsoft
hyperv/hn: Fixat RNDIS rxfilter after the successful RNDIS init.
Under certain conditions on certain versions of Hyper-V, the RNDIS
rxfilter is _not_ zero on the hypervisor side after the successful
RNDIS initialization, which breaks the assumption of any following
code (well, it breaks the RNDIS API contract actually). Clear the
RNDIS rxfilter explicitly, drain packets sneaking through, and drain
the interrupt taskqueues scheduled due to the stealth packets.
Reported by: dexuan@
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D10230
314382
hyperv/hn: Simplify RNDIS packet data offset calculation.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D9699
314483
hyperv/hn: Simplify RNDIS packet total length calculation.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D9712
314484
hyperv/hn: Make sure that RNDIS packet message is at least 4B aligned.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D9713
314485
hyperv/hn: Misaligned chimney sending buffers should not be used
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D9714
Approved by: sephe (mentor)
r312689
hyperv/hn: add a sysctl name for the VF interface
This makes it easier for the userland script to find the releated
VF interface.
Reviewed by: sephe
Approved by: sephe (mentor)
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D9101
r312690
hyperv/hn: add devctl_notify for VF_UP/DOWN events
Reviewed by: sephe
Approved by: sephe (mentor)
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D9102
Approved by: sephe (mentor)
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
Approved by: sephe (mentor)
r312686
hyperv/hn: remove the MTU and IFF_DRV_RUNNING checking in hn_rxpkt()
It's unnecessary because the upper nework stack does the same checking.
In the case of Hyper-V SR-IOV, we need to remove the checking because
1) multicast/broadcast packets are still received through the synthetic
NIC and we need to inject the packets through the VF interface;
2) we must inject the packets even if the synthetic NIC is down, or has
a different MTU from the VF device.
Reviewed by: sephe
Approved by: sephe (mentor)
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8962
Approved by: sephe(mentor)
r312685
hyperv/hn: remember the channel pointer in struct hn_rx_ring
This will be used by the coming NIC SR-IOV patch.
Reviewed by: sephe
Approved by: sephe (mentor)
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8909
310652
hyperv/hn: Consolidate hn_{suspend,resume}
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8907
310657
hyperv/hn: Function renaming; no functional changes.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8908
310658
hyperv/hn: Factor out function to set rxfilter.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8928
309346
hyperv/hn: Add HN_DEBUG kernel option.
If bufring is used for per-TX ring descs, don't update "available"
counter, which is only used to help debugging.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8674
309348
hyperv/hn: Don't hold txdesc, if no BPFs are attached.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8675
309353
hyperv/hn: Add 'options RSS' support.
Reviewed by: adrian
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8676
309310
hyperv/hn: Nuke the unused TX taskqueue CPU binding tunable.
It was an experimental tunable, and is now deemed to be road blocker
for further changes. Time to retire it.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8654
309311
hyperv/hn: Allow multiple TX taskqueues.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8655
309316
hyperv/vmbus: Add DEVMETHOD to map cpu to event taskq.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8658
309318
hyperv/hn: Allow TX to share event taskqueues.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8659
hyperv/hn: Fix primary channel revocation
Since hypervisor will not drain the TX bufring, once the channels are
revoked:
- Setup vmbus orphan handler properly.
- Make sure that suspension will not wait the TX bufring draining
forever.
- GC the pending TX descs on detach path, before freeing the busdma
stuffs.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8559
308908
hyperv/hn: Allow enabling IPv6 TX checksum offloading and IPv6 TSO.
They are still disabled by default.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8490
308909
hyperv/hn: Don't abuse hn_{tx,rx}_ring_inuse.
Just in case, the # of TX/RX rings is changed upon synthetic parts
re-attach.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8520
hyperv/hn: Fix WITNESS warnings
And re-enable SIOCADDMULTI/SIOCDELMULTI, after WITNESS warning is fixed.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8489
hyperv/hn: Implement RNDIS multi-packet message support.
Currently, it is only applied to packet sent through chimney sending
buffers. Not enabled by default yet.
This one gives 20%~30% performance boost for non-TSO usage in both
bit/packet rate tests and nginx performance test.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8560
308166
hyperv/hn: Move TSO packet fixup to an earlier place for if_transmit.
While TSO packet header may be still cache-hot.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8393
308167
hyperv/hn: Directly fill chimney sending buffer for small packets.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8394
hyperv/hn: Regroup if_start related functions.
And put them under HN_IFSTART_SUPPORT, which is by default on until
we whack the if_start related bits from base system.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8392
308117
hyperv/hn: Rework temporary channel packet buffer expanding.
And use large default temporary channel packer buffer; we really
don't want it to be expanded at run time.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8367
308118
hyperv/hn: Cleanup RXBUF ack processing.
- Increase the # of retries.
- Add comment.
- Log error, if RXBUF ack fails.
- Add stat for RXBUF ack failures.
RXBUF ack really should _not_ fail...
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8368
308119
hyperv/hn: Reset do_lro, if the hash types are not TCP related.
Mainly because the host side only set TCPCS and IPCS even for
UDP datagrams.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8369
308120
hyperv/hn: Don't start shared TX taskq, if the hypervisor is not Hyper-V.
- Move the SYSINIT to DRIVER/SECOND, i.e. after the vm_guest becomes
determistic.
- Minor style changes.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8370
307989
hyperv/hn: Move hn_softc to if_hnvar.h
While I'm here, use consistent macro names.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8345
307990
hyperv/hn: Move send context to NVS domain.
Since all sends are encapsulated in NVS messages.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8346
307991
hyperv/hn: NVS inclusion cleanup and forward declare functions.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8347
308010
hyperv/hn: Change header guardian; in preparation for the upcoming rename.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8352
307840
hyperv/hn: Properly handle synthetic parts reattach failure.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8310
307842
hyperv/hn: Start link status check, if no network changes were pending.
Link status check is much more lightweight than network change detection.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8311
307838
hyperv/hn: Move chimney buffer index and size to txdesc.
All RNDIS control messages have used SG list for a while. This makes
the send context suitable for further refactoring.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8308
307839
hyperv/hn: Fix chimney sending buffer leakage upon NVS sending failure.
This will not happen in real world, since TX consumption of the vmbus
TX bufring is limitted. Better safe than sorry.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8309
307710
hyperv/hn: Always query RSS capabilities.
- This avoid distributing NDIS version check.
- Only NDIS 6.20 required (earlier NDIS uses different indirect table
format).
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8291
307711
hyperv/hn: Check NVS version for HASHVAL pktinfo on sending path.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8293
307712
hyperv/hn: Add network change support.
Currently the network change is simulated by link status changes.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8295
307714
hyperv/hn: Function renaming; consistent w/ hardware capabilities query.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8296
307012
hyperv/vmbus: Allow driver to inject synchronous task into channel taskq.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8208
307013
hyperv/hn: Rework link status support.
This is the preamble for network device SR-IOV and
NDIS_STATUS_NETWORK_CHANGE handling.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8209
307262
hyperv/hn: Management parts always need suspend and resume.
Sponsored by: Microsoft
306484
hyperv/vmbus: Add missing vmbus_if.c to module build.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8067
306485
hyperv/hn: Add stubs for OFFLOAD_CURRENT_CONFIG and NETWORK_CHANGE status
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8068
306482
hyperv/hn: If synthetic parts are detached, don't touch them.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8065
306483
hyperv/hn: Fix detach and attach error handling.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8066
hyperv/hn: Don't set HASHVAL pktinfo for NDIS < 6.30
This unbreaks packet sending on WS2008R2.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8057
306431
hyperv/hn: Move TX tasks' draining into hn_suspend().
This prepares to consolidate hn_stop() and netvsc_detach().
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8055
306432
hyperv/hn: Consolidate hn_init() and hn_stop()
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8056
hyperv/hn: Flatten RX filter configuration.
This paves way for more fixes.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8049
306390
hyperv/hn: Suspend and resume the backend properly upon MTU change.
Suspend:
- Prevent the backend from being touched on TX path.
- Clear the RNDIS RX filter, and wait for RX to drain.
- Make sure that NVS see the chimney sending buffer and RXBUF
disconnection, before unlink these buffers from the channel.
Resume:
- Reconfigure the RNDIS filter.
- Allow TX path to work on the backend.
- Kick start the TX eof task, in case the OACTIVE is set.
This fixes various panics, when the interface has traffic and MTU
is being changed.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8046
306391
hyperv/hn: Reorganize the synthetic parts detach.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8047
306392
hyperv/hn: Reorder the comment a little bit.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D8048
306072
hyperv/vmbus: Allow bufrings preallocation.
The assumption that the channel is only opened upon synthetic device
attach time no longer holds, e.g. Hyper-V network device MTU changes.
We have to allow device drivers to preallocate bufrings, e.g. in
attach DEVMETHOD, to prevent bufring allocation failure once the
system memory is fragmented after running for a while.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7960
306073
hyperv/hn: Allocate bufrings in attach DEVMETHOD.
So that reinitialization, e.g. MTU change, will not fail when the system
memory is excessively fragmented.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7961
306074
hyperv/vmbus: Assert that the bufring address is page aligned.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7962
306076
hyperv/hn: Put debug messages under bootverbose
While I'm here, strip blank line.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7963
306013
hyperv/hn: Fix ifnet hwassist setup.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7948
306014
hyperv/hn: Let the caller of hn_nvs_doinit() do the error logging.
So that NVS version probing failure does not look too scary.
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7950