Commit Graph

173 Commits

Author SHA1 Message Date
Mateusz Guzik
068dbf361a virtio: clean up empty lines in .c and .h files 2020-09-01 21:31:26 +00:00
Alfredo Dal'Ava Junior
a4dea14159 virtio: fix mips regression introduced by r357596
PowerPC support was fixed in r357596 by changing PCI bustag to BE as
part of the solution, but this caused regression on mips. This change
implements byte swapping of virtio PCI config area in the driver,
leaving lower layer untouched.

Submittnd by:	Fernando Valle <fernando.valle@eldorado.org.br>
Reported by:	arichardson
Reviewed by:	alfredo, arichardson
Sponsored by:	Eldorado Research Institute (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D25416
2020-07-28 11:23:37 +00:00
Andrew Turner
7377c1df84 Only write to VIRTIO_MMIO_GUEST_PAGE_SIZE with virtio mmio version 1
This register is only defined for the legacy v1 interface so only write
to it when interacting with a legacy device.

Sponsored by:	Innovate UK
2020-07-21 14:25:36 +00:00
Allan Jude
2cc8a524af Add VIRTIO_BLK_T_DISCARD support to the virtio-blk driver
If the hypervisor advertises support for the DISCARD command then the
guest can perform TRIM commands, freeing space on the backing store.

If VIRTIO_BLK_F_DISCARD is enabled, advertise DISKFLAG_CANDELETE

Tested with FreeBSD guests on bhyve and KVM

Reviewed by:	jhb
Tested by:	freqlabs
MFC after:	1 month
Relnotes:	yes
Sponsored by:	Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D21708
2020-07-16 16:32:16 +00:00
Vincenzo Maffione
ef6fdb3312 if_vtnet: let vtnet_rx_vq_intr() and vtnet_rxq_tq_intr() share code
Since the two functions are similar, introduce a common function
(vtnet_rx_vq_process()) to share common code.
This also improves locking, by ensuring vrxs_rescheduled is accessed
under the RXQ lock, and taskqueue_enqueue() is not called under the
lock (therefore avoiding a spurious duplicate lock warning).

Reported by:	jrtc27
MFC after:	2 weeks
2020-06-15 19:46:34 +00:00
Jessica Clarke
576b099a5f vtnet: Fix regression introduced in r361944
For legacy devices that don't support MrgRxBuf (such as bhyve pre-r358180),
r361944 failed to update the receive handler to account for the additional
padding introduced by the unused num_buffers field that is now always present
in struct vtnet_rx_header. Thus, calculate the padding dynamically based on
vtnet_hdr_size.

PR:		247242
Reported by:	thj
Tested by:	thj
2020-06-14 22:39:34 +00:00
Vincenzo Maffione
16f224b5f8 netmap: vtnet: fix races in vtnet_netmap_reg()
The nm_register callback needs to call nm_set_native_flags()
or nm_clear_native_flags() once the device has been stopped.
However, in the current implementation this is not true,
as the device is stopped by vtnet_init_locked(). This causes
race conditions where the driver crashes as soon as it
dequeues netmap buffers assuming they are mbufs (or the other
way around).
To fix the issue, we extend vtnet_init_locked() with a second
argument that, if not zero, will set/clear the netmap flags.
This results in a huge simplification of the nm_register
callback itself.
Also, use netmap_reset() to check if a ring is going to be
re-initialized in netmap mode.

MFC after:	1 week
2020-06-14 20:47:31 +00:00
Vincenzo Maffione
6682323732 netmap: introduce netmap_kring_on()
This function returns NULL if the ring identified by
queue id and direction is in netmap mode. Otherwise
return the corresponding kring.
Use this function to replace vtnet_netmap_queue_on().

MFC after:	1 week
2020-06-11 20:35:28 +00:00
Jessica Clarke
8c3988dff9 virtio: Support non-legacy network device and queue
The non-legacy interface always defines num_buffers in the header,
regardless of whether VIRTIO_NET_F_MRG_RXBUF, just leaving it unused. We
also need to ensure our virtqueue doesn't filter out VIRTIO_F_VERSION_1
during negotiation, as it supports non-legacy transports just fine. This
fixes network packet transmission on TinyEMU.

Reviewed by:	br, brooks (mentor), jhb (mentor)
Approved by:	br, brooks (mentor), jhb (mentor)
Differential Revision:	https://reviews.freebsd.org/D25132
2020-06-08 21:51:36 +00:00
Jessica Clarke
16ca3d0f59 virtio_mmio: Negotiate the upper half of the feature bits too
The feature bits are exposed as a 32-bit register with 2 banks, so we
should negotiate both halves. Notably, VIRTIO_F_VERSION_1 is in the
upper half, and will be used in an upcoming commit.

The PCI bus driver also has this bug, but the legacy BAR layout did not
include selector registers and is rather different from the modern
layout, so it remains solely as legacy.

Reviewed by:	br, brooks (mentor), jhb (mentor)
Approved by:	br, brooks (mentor), jhb (mentor)
Differential Revision:	https://reviews.freebsd.org/D25131
2020-06-08 21:49:42 +00:00
Vincenzo Maffione
2d769e25b1 netmap: vtnet: add vtnrx_nm_refill index to receive queues
The new index tracks the next netmap slot that is going
to be enqueued into the virtqueue. The index is necessary
to prevent the receive VQ and the netmap rx ring from going
out of sync, considering that we never enqueue N slots, but
at most N-1. This change fixes a bug that causes the VQ
and the netmap ring to go out of sync after N-1 packets
have been received.

MFC after:	1 week
2020-06-03 17:42:17 +00:00
Vincenzo Maffione
f0d8d352c0 netmap: vtnet: call netmap_rx_irq() under VQ lock
The netmap_rx_irq() function normally wakes up user-space threads
waiting for more packets. In this case, it is not necessary to
call it under the driver queue lock. However, if the interface is
attached to a VALE switch, netmap_rx_irq() ends up calling rxsync
on the interface (see netmap_bwrap_intr_notify()). Although
concurrent rxsyncs are serialized through the kring lock
(see nm_kr_tryget()), the lock acquire operation is not blocking.
As a result, it may happen that netmap_rx_irq() is called on
an RX ring while another instance is running, causing the
second call to fail, and received packets stall in the receive VQ.
We fix this issue by calling netmap_irx_irq() under the VQ lock.

MFC after:	1 week
2020-06-03 05:27:29 +00:00
Vincenzo Maffione
1b89d00bd4 netmap: vtnet: honor NM_IRQ_RESCHED
The netmap_rx_irq() function may return NM_IRQ_RESCHED to inform the
driver that more work is pending, and that netmap expects netmap_rx_irq()
to be called again as soon as possible.
This change implements this behaviour in the vtnet driver.

MFC after:	1 week
2020-06-03 05:09:33 +00:00
Jessica Clarke
cfe6a221ad virtio_mmio: Add casts missing from r360722
This fixes -Wshift-count-overflow warnings/errors on architectures using
32-bit physical addresses.

Reported by:	lwhsu
2020-05-07 17:59:17 +00:00
Jessica Clarke
a1da7a46f6 virtio: Support MMIO bus for all devices
The bus is independent of the device, so all devices can be attached to
either a PCI bus or an MMIO bus. For example, QEMU's virtio-rng-device
gives the MMIO variant of virtio-rng-pci, and is now detected.

Reviewed by:	andrew, br, brooks (mentor)
Approved by:	andrew, br, brooks (mentor)
Differential Revision:	https://reviews.freebsd.org/D24730
2020-05-06 23:31:30 +00:00
Jessica Clarke
046096d5c7 virtio_mmio: Support non-transitional version 2 devices
The non-legacy virtio MMIO specification drops the use of PFNs and
replaces them with physical addresses. Whilst many implementations are
so-called transitional devices, also implementing the legacy
specification, TinyEMU[1] does not. Device-specific configuration
registers have also changed to being little-endian, and must be accessed
using a single aligned access for registers up to 32 bits, and two
32-bit aligned accesses for 64-bit registers.

[1] https://bellard.org/tinyemu/

Reviewed by:	br, brooks (mentor)
Approved by:	br, brooks (mentor)
Differential Revision:	https://reviews.freebsd.org/D24681
2020-05-06 23:28:51 +00:00
Warner Losh
5f8395cce4 Remove FreeBSD 8 support from virtio.
The sbuf API has evolved since 8, as have many others. The other API sweeps
didn't make the changes conditional, so this is now noise.
2020-03-01 18:18:07 +00:00
Pawel Biernacki
7029da5c36 Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Mark all obvious cases as MPSAFE.  All entries that haven't been marked
as MPSAFE before are by default marked as NEEDGIANT

Approved by:	kib (mentor, blanket)
Commented by:	kib, gallatin, melifaro
Differential Revision:	https://reviews.freebsd.org/D23718
2020-02-26 14:26:36 +00:00
Gleb Smirnoff
e87c494015 Although most of the NIC drivers are epoch ready, due to peer pressure
switch over to opt-in instead of opt-out for epoch.

Instead of IFF_NEEDSEPOCH, provide IFF_KNOWSEPOCH. If driver marks
itself with IFF_KNOWSEPOCH, then ether_input() would not enter epoch
when processing its packets.

Now this will create recursive entrance in epoch in >90% network
drivers, but will guarantee safeness of the transition.

Mark several tested drivers as IFF_KNOWSEPOCH.

Reviewed by:		hselasky, jeff, bz, gallatin
Differential Revision:	https://reviews.freebsd.org/D23674
2020-02-24 21:07:30 +00:00
Kristof Provost
55cd93249b virtio: Pass the interrupt type in mmio mode
When we register an interrupt handler we need to pass the intr_type along in
bus_setup_intr().

The interrupt type matters because it is used to decide if we need to enter
NET_EPOCH. That meant that vtmmio-based if_vtnet did not, which led to panics
with INVARIANTS set.

Sponsored by:	Axiado
2020-02-20 17:26:08 +00:00
Gleb Smirnoff
6c3e93cb5a Use NET_TASK_INIT() and NET_GROUPTASK_INIT() for drivers that process
incoming packets in taskqueue context.

Reviewed by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D23518
2020-02-11 18:57:07 +00:00
Scott Long
d176b8039e Ever since the block layer expanded its command syntax beyond just
BIO_READ and BIO_WRITE, we've handled this expanded syntax poorly in
drivers when the driver doesn't support a particular command.  Do a
sweep and fix that.

Reported by:	imp
2020-02-07 09:22:08 +00:00
Alfredo Dal'Ava Junior
f272c8de6e [virtio] Fix r/w to PCI configuration area on big endian platforms
In legacy VirtIO drivers, the header must be PCI endianness (little) and the
device-specific region is encoded in the native endian of the guest.

This patch makes the access (read/write) to VirtIO header using the little
endian order. Other read and write access are native endianness. This also
sets the device's IO region as big endian if on big endian machine.

PR:		205178
Submitted by:	Andre Silva <afscoelho@gmail.com>
Reported by:	Kenneth Salerno <kennethsalerno@yahoo.com>
Reviewed by:	bryanv, bdragon, luporl, alfredo
Approved by:	jhibbits (mentor)
Differential Revision:	https://reviews.freebsd.org/D23401
2020-02-05 20:39:18 +00:00
Andriy Gapon
adbf6af741 virtio_scsi: use max target ID plus one as the initiator ID
This bus does not really have a concept of the initiator ID, so use
a guaranteed dummy one that won't conflict with any real target.

This change fixes a problem with virtio_scsi on GCE where disks get
sequential target IDs starting from one.  If there are seven or more
disks, then a disk with the target ID of seven would not be discovered
by FreeBSD as that ID was reserved as the initiator ID -- see
scsi_scan_bus().

Discussed with:	bryanv
MFC after:	2 weeks
Sponsored by:	Panzura
2020-01-23 10:13:56 +00:00
Gleb Smirnoff
629667a148 Pacify gcc.
Reported by:	rlibby
2020-01-11 20:07:30 +00:00
Gleb Smirnoff
ed6cbf4805 Add pfil(9) hook to vtnet(4).
The patch could be simplier, using only the second chunk to
vtnet_rxq_eof(), that passes full mbufs to pfil(9). Packet
filter would m_free() them in case of returning PFIL_DROPPED.

However, we pretend to be a hardware driver, so we first try
to pass a memory buffer via PFIL_MEMPTR feature. This is mostly
done for debugging purposes, so that one can experiment in bhyve
with packet filters utilizing same features as a true driver.
2020-01-10 21:22:03 +00:00
Kristof Provost
29bfe2102d vtnet: Pre-allocate debugnet data immediately
Don't wait until the vtnet_debugnet_init() call happens, because at that
point we might already have allocated something from
vtnet_tx_header_zone.

Some systems showed this panic:

        vtnet0: link state changed to UP
        panic: keg vtnet_tx_hdr initialization after use.
        cpuid = 5
        time = 1578427700
        KDB: stack backtrace:
        db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe004db427f0
        vpanic() at vpanic+0x17e/frame 0xfffffe004db42850
        panic() at panic+0x43/frame 0xfffffe004db428b0
        uma_zone_reserve() at uma_zone_reserve+0xf6/frame 0xfffffe004db428f0
        vtnet_debugnet_init() at vtnet_debugnet_init+0x77/frame 0xfffffe004db42930
        debugnet_any_ifnet_update() at debugnet_any_ifnet_update+0x42/frame 0xfffffe004db42980
        do_link_state_change() at do_link_state_change+0x1b3/frame 0xfffffe004db429d0
        taskqueue_run_locked() at taskqueue_run_locked+0x178/frame 0xfffffe004db42a30
        taskqueue_run() at taskqueue_run+0x4d/frame 0xfffffe004db42a50
        ithread_loop() at ithread_loop+0x1d6/frame 0xfffffe004db42ab0
        fork_exit() at fork_exit+0x80/frame 0xfffffe004db42af0
        fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe004db42af0
        --- trap 0, rip = 0, rsp = 0, rbp = 0 ---
        KDB: enter: panic
        [ thread pid 12 tid 100011 ]
        Stopped at      kdb_enter+0x37: movq    $0,0x1084eb6(%rip)
        db>

Reviewed by:	cem, markj
Differential Revision:	https://reviews.freebsd.org/D23073
2020-01-08 10:06:32 +00:00
Conrad Meyer
9b31a8daad virtio_random(4): Drop no longer needed unload kludge
After r356194, source deregistration no longer races with concurrent use.

Reviewed by:	bryanv, markm
Differential Revision:	https://reviews.freebsd.org/D22490
2019-12-30 01:40:59 +00:00
Mark Johnston
5cff1f4dc3 Introduce vm_page_astate.
This is a 32-bit structure embedded in each vm_page, consisting mostly
of page queue state.  The use of a structure makes it easy to store a
snapshot of a page's queue state in a stack variable and use cmpset
loops to update that state without requiring the page lock.

This change merely adds the structure and updates references to atomic
state fields.  No functional change intended.

Reviewed by:	alc, jeff, kib
Sponsored by:	Netflix, Intel
Differential Revision:	https://reviews.freebsd.org/D22650
2019-12-10 18:14:50 +00:00
Gleb Smirnoff
7dce56596f Convert to if_foreach_llmaddr() KPI. 2019-10-21 17:59:02 +00:00
Vincenzo Maffione
f8bc74e2f4 tap: add support for virtio-net offloads
This patch is part of an effort to make bhyve networking (in particular TCP)
faster. The key strategy to enhance TCP throughput is to let the whole packet
datapath work with TSO/LRO packets (up to 64KB each), so that the per-packet
overhead is amortized over a large number of bytes.
This capability is supported in the guest by means of the vtnet(4) driver,
which is able to handle TSO/LRO packets leveraging the virtio-net header
(see struct virtio_net_hdr and struct virtio_net_hdr_mrg_rxbuf).
A bhyve VM exchanges packets with the host through a network backend,
which can be vale(4) or if_tap(4).
While vale(4) supports TSO/LRO packets, if_tap(4) does not.
This patch extends if_tap(4) with the ability to understand the virtio-net
header, so that a tapX interface can process TSO/LRO packets.
A couple of ioctl commands have been added to configure and probe the
virtio-net header. Once the virtio-net header is set, the tapX interface
acquires all the IFCAP capabilities necessary for TSO/LRO.

Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D21263
2019-10-18 21:53:27 +00:00
Conrad Meyer
7790c8c199 Split out a more generic debugnet(4) from netdump(4)
Debugnet is a simplistic and specialized panic- or debug-time reliable
datagram transport.  It can drive a single connection at a time and is
currently unidirectional (debug/panic machine transmit to remote server
only).

It is mostly a verbatim code lift from netdump(4).  Netdump(4) remains
the only consumer (until the rest of this patch series lands).

The INET-specific logic has been extracted somewhat more thoroughly than
previously in netdump(4), into debugnet_inet.c.  UDP-layer logic and up, as
much as possible as is protocol-independent, remains in debugnet.c.  The
separation is not perfect and future improvement is welcome.  Supporting
INET6 is a long-term goal.

Much of the diff is "gratuitous" renaming from 'netdump_' or 'nd_' to
'debugnet_' or 'dn_' -- sorry.  I thought keeping the netdump name on the
generic module would be more confusing than the refactoring.

The only functional change here is the mbuf allocation / tracking.  Instead
of initiating solely on netdump-configured interface(s) at dumpon(8)
configuration time, we watch for any debugnet-enabled NIC for link
activation and query it for mbuf parameters at that time.  If they exceed
the existing high-water mark allocation, we re-allocate and track the new
high-water mark.  Otherwise, we leave the pre-panic mbuf allocation alone.
In a future patch in this series, this will allow initiating netdump from
panic ddb(4) without pre-panic configuration.

No other functional change intended.

Reviewed by:	markj (earlier version)
Some discussion with:	emaste, jhb
Objection from:	marius
Differential Revision:	https://reviews.freebsd.org/D21421
2019-10-17 16:23:03 +00:00
Mark Johnston
e8bcf6966b Revert r352406, which contained changes I didn't intend to commit. 2019-09-16 15:04:45 +00:00
Mark Johnston
41fd4b9422 Fix a couple of nits in r352110.
- Remove a dead variable from the amd64 pmap_extract_and_hold().
- Fix grammar in the vm_page_wire man page.

Reported by:	alc
Reviewed by:	alc, kib
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D21639
2019-09-16 15:03:12 +00:00
Kristof Provost
776d3d5924 virtio: Fix running on machines with memory above 0xffffffff
We want to allocate a contiguous memory block anywhere in memory, but
expressed this as having to be between 0 and 0xffffffff. This limits us
on 64-bit machines, and outright breaks on machines where memory is
mapped above that address range.

Allow the full address range to be used for this allocation.

Sponsored by:	Axiado
2019-07-26 19:16:02 +00:00
Eric van Gyzen
df8406543f VirtIO SCSI: validate seg_max on attach
Until r349278, bhyve presented a seg_max to the guest that was too large.
Detect this case and clamp it to the virtqueue size.  Otherwise, we would
fail the "too many segments to enqueue" assertion in virtqueue_enqueue().

I hit this by running a guest with a MAXPHYS of 256 KB.

Reviewed by:	bryanv cem
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D20703
2019-06-22 01:20:45 +00:00
Conrad Meyer
0f6040f03e virtio(4): Add PNP match metadata for virtio devices
Register MODULE_PNP_INFO for virtio devices using the newbus PNP information
provided by the previous commit.  Matching can be quite simple; existing
probe routines only matched on bus (implicit) and device_type.  The same
matching criteria are retained exactly, but is now also available to
devmatch(8).

Reviewed by:	bryanv, markj; imp (earlier version)
Differential Revision:	https://reviews.freebsd.org/D20407
2019-06-04 02:37:11 +00:00
Conrad Meyer
dfca0a8b3d virtio(4): Expose PNP metadata through newbus
Expose the same fields and widths from both vtio buses, even though they
don't quite line up; several virtio drivers can attach to both buses,
and sharing a PNP info table for both seems more convenient.

In practice, I doubt any virtio driver really needs to match on anything
other than bus and device_type (eliminating the unused entries for
vtmmio), and also in practice device_type is << 2^16 (so far, values
range from 1 to 20).  So it might be fine to only expose a 16-bit
device_type for PNP purposes.  On the other hand, I don't see much harm
in overkill here.

Reviewed by:	bryanv, markj (earlier version)
Differential Revision:	https://reviews.freebsd.org/D20406
2019-06-04 02:34:59 +00:00
Conrad Meyer
ad5979f7da virtio_random(4): Fix random(4) integration
random(4) masks unregistered entropy sources.  Prior to this revision,
virtio_random(4) did not correctly register a random_source and did not
function as a source of entropy.

Random source registration for loadable pure sources requires registering a
poll callback, which is invoked periodically by random(4)'s harvestq
kthread.  The periodic poll makes virtio_random(4)'s periodic entropy
collection redundant, so this revision removes the callout.

The current random source API is somewhat limiting, so simply fail to attach
any virtio_random devices if one is already registered as a source.  This
scenario is expected to be uncommon.

While here, handle the possibility of short reads from the hypervisor random
device gracefully / correctly.  It is not clear why a hypervisor would
return a short read or if it is allowed by spec, but we may as well handle
it.

Reviewed by:	bryanv (earlier version), markm
Security:	yes (note: many other "pure" random sources remain broken)
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D20419
2019-06-04 00:01:37 +00:00
Conrad Meyer
5ca5dfe938 random(4): Fix RANDOM_LOADABLE build
I introduced an obvious compiler error in r346282, so this change fixes
that.

Unfortunately, RANDOM_LOADABLE isn't covered by our existing tinderbox, and
it seems like there were existing latent linking problems.  I believe these
were introduced on accident in r338324 during reduction of the boolean
expression(s) adjacent to randomdev.c and hash.c.  It seems the
RANDOM_LOADABLE build breakage has gone unnoticed for nine months.

This change correctly annotates randomdev.c and hash.c with !random_loadable
to match the pre-r338324 logic; and additionally updates the HWRNG drivers
in MD 'files.*', which depend on random_device symbols, with
!random_loadable (it is invalid for the kernel to depend on symbols from a
module).

(The expression for both randomdev.c and hash.c was the same, prior to
r338324: "optional random random_yarrow | random !random_yarrow
!random_loadable".  I.e., "random && (yarrow || !loadable)."  When Yarrow
was removed ("yarrow := False"), the expression was incorrectly reduced to
"optional random" when it should have retained "random && !loadable".)

Additionally, I discovered that virtio_random was missing a MODULE_DEPEND on
random_device, which breaks kld load/link of the driver on RANDOM_LOADABLE
kernels.  Address that issue as well.

PR:		238223
Reported by:	Eir Nym <eirnym AT gmail.com>
Reviewed by:	delphij, markm
Approved by:	secteam(delphij)
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D20466
2019-06-01 01:22:21 +00:00
Conrad Meyer
af8f74ad14 virtio_random(4): Remove unneeded reference to device
The device_t always references the softc, so we can pass the device and
obtain the softc instead of the other way around.
2019-05-27 00:55:46 +00:00
Conrad Meyer
7cc8e55be6 virtio_pci(4): Fix typo in read_ivar method
Prior to this revision, vtpci's BUS_READ_IVAR method on VIRTIO_IVAR_SUBVENDOR
accidentally returned the PCI subdevice.

The typo seems to have been introduced with the original commit adding
VIRTIO_IVAR_{{SUB,}DEVICE,{SUB,}VENDOR} to virtio_pci.  The commit log and code
strongly suggest that the ivar was intended to return the subvendor rather than
the subdevice; it was likely just a copy/paste mistake.

Go ahead and rectify that.
2019-05-25 01:59:24 +00:00
Michael Tuexen
132ea9f2ad Remove non-functional SCTP checksum offload support for virtio.
Checksum offloading for SCTP is not currently specified for virtio.
If the hypervisor announces checksum offloading support, it means TCP
and UDP checksum offload. If an SCTP packet is sent and the host announced
checksum offload support, the hypervisor inserts the IP checksum (16-bit)
at the correct offset, but this is not the right checksum, which is a CRC32c.
This results in all outgoing packets having the wrong checksum and therefore
breaking SCTP based communications.

This patch removes SCTP checksum offloading support from the virtio
network interface.

Thanks to Felix Weinrank for making me aware of the issue.

Reviewed by:		bryanv@
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D20147
2019-05-07 20:28:12 +00:00
Alexander Motin
e5355d3319 Fix SCSI sense data pass through.
MFC after:	1 week
Sponsored by:	iXsystems, Inc.
2019-04-12 18:54:09 +00:00
Vincenzo Maffione
93ef29690e vtnet: fix typo in vtnet_free_taskqueues
Because of a typo, the code was mistakenly resetting the
vtnrx_vq pointer rather than vtntx_tq.

Reviewed by:	bryanv
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D19015
2019-01-29 14:31:41 +00:00
Vincenzo Maffione
2e42b74a6f vtnet: fix netmap support
netmap(4) support for vtnet(4) was incomplete and had multiple bugs.
This commit fixes those bugs to bring netmap on vtnet in a functional state.

Changelist:
  - handle errors returned by virtqueue_enqueue() properly (they were
    previously ignored)
  - make sure netmap XOR rest of the kernel access each virtqueue.
  - compute the number of netmap slots for TX and RX separately, according to
    whether indirect descriptors are used or not for a given virtqueue.
  - make sure sglist are freed according to their type (mbufs or netmap
    buffers)
  - add support for mulitiqueue and netmap host (aka sw) rings.
  - intercept VQ interrupts directly instead of intercepting them in txq_eof
    and rxq_eof. This simplifies the code and makes it easier to make sure
    taskqueues are not running for a VQ while it is in netmap mode.
  - implement vntet_netmap_config() to cope with changes in the number of queues.

Reviewed by:	bryanv
Approved by:	gnn (mentor)
MFC after:	3 days
Sponsored by:	Sunny Valley Networks
Differential Revision:	https://reviews.freebsd.org/D17916
2018-11-14 15:39:48 +00:00
Andrew Turner
a3609b82c5 Split out the virtio mmio FDT attachment and add an ACPI attachment.
This allows the memory mapped I/O virtio driver to attach when we boot
with ACPI tables, for example in some cases with QEMU emulating arm64.

MFC after:	1 month
2018-10-21 15:43:20 +00:00
Mark Murray
19fa89e938 Remove the Yarrow PRNG algorithm option in accordance with due notice
given in random(4).

This includes updating of the relevant man pages, and no-longer-used
harvesting parameters.

Ensure that the pseudo-unit-test still does something useful, now also
with the "other" algorithm instead of Yarrow.

PR:		230870
Reviewed by:	cem
Approved by:	so(delphij,gtetlow)
Approved by:	re(marius)
Differential Revision:	https://reviews.freebsd.org/D16898
2018-08-26 12:51:46 +00:00
Bryan Venteicher
56f63b7364 Update VirtIO definitions from Linux virtio_config.h and virtio_ring.h headers 2018-06-17 20:45:48 +00:00
Ruslan Bukin
1147facec3 Make virtio queue re-initialization steps to be similar to
original initialization, so we don't miss few registers to
configure.

This fixes vtnet(4) operation with QEMU's virtio-net-device.

Tested in QEMU with FreeBSD/RISC-V.

Reviewed by:	bryanv
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D15821
2018-06-15 16:19:10 +00:00