1
0
Fork 0
Commit Graph

24 Commits (redonkable)

Author SHA1 Message Date
Jan Kiszka a1a73e42a4 ivshmem-net: Fix TX queue locking and plug notification races
This reworks the broken locking of the TX queue from ground up. The
locking was broken in many ways. It didn't protect the critical state
in ivshm_net_queue consistently, leaving phases from cleanup was reading
intermediate states while xmit was running. ivshm_net_tx_ok also has to
be covered by the lock because it tests both num_free and tail against
head. The new locking is reusing the TX queue lock of the device because
this is already held across ivshm_net_xmit.

Furthermore, there were many races between the sender and the receiver
around enabling and evaluating TX interrupts. One was about turning on
the TX completion interrupt only after signaling the submission of
packets. That could potentially cause the peer to miss the need for
signaling completion.

The other race that led to stalled senders was around not properly
re-checking for updates and not posting own updates while processing
freed TX descriptors in ivshm_net_tx_clean. Doing so could cause the
sender to miss that there are more free entries or cause the receiver to
stop signaling further free ones after kicking the sender for the first.

Acked-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2020-04-29 15:03:04 +08:00
Jan Kiszka e02c6112f4 ivshmem-net: Simplify interface of ivshm_net_tx_ok
Just pass in the net_device, and the function and can retrieve the mtu
itself.

Acked-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2020-04-29 15:03:04 +08:00
Jan Kiszka b4f51dd09c ivshmem-net: Mark vring_used_event access READ_ONCE
Analogously to vring_avail_event in ivshm_net_notify_tx.

Acked-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2020-04-29 15:03:03 +08:00
Jan Kiszka ddf1fb2984 ivshmem-net: Fix and rework MTU configuration
Use min/max_mtu to define the limits upfront. This also fixes changing
the MTU because the default values of those two prevented it so far.

Furthermore, all limits can be calculated during probe. Thus, there is
no need to validate anything in ivshm_net_change_mtu, provided updates
of a running device are rejected so that no queue can overrun.

Acked-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2020-04-29 15:03:03 +08:00
Jan Kiszka fa954160ab ivshmem-net: Adjust to reworked version of ivshmem in Jailhouse
This contains the changes required to work with the new revision of
ivshmem in Jailhouse, namely:

- changed PCI vendor and device ID
- vendor capability to communicate region location
- new MMIO register layout
- common interrupt control register
- state table support, removal of rstate register
- unidirectional shared memory regions
- vector value has to be written to doorbell register
- support for multiple vectors, used to split config from tx-rx

Note: Specification work for the interface is ongoing, so details may
still change.

Acked-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2020-04-29 15:03:02 +08:00
Jan Kiszka 68ac48b39f ivshmem-net: Switch to netdev_xmit_more helper
The skb field has been removed by 4f296edeb9.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit 80c301552ec0b500dd46a2b4f0c9fef78a610ee6)
2019-11-25 15:43:38 +08:00
Jan Kiszka 0157417e68 ivshmem-net: Refactor and comment ivshm_net_state_change
This should make the state transitioning logic clearer. Also avoid the
harmless but redundant netif_carrier_on/ivshm_net_run in RUN state.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit 8539efe70fbdf4a0bea75a97c1628fbb38b6590b)
2019-11-25 15:43:38 +08:00
Jan Kiszka c3f60880c3 ivshmem-net: Fix bogus transition to RESET state
If we are in READY but the remote is still in INIT, we so far fell back
to RESET which caused the setup to get stuck. Fix this by only
transitioning from READY/RUN to RESET in ivshm_net_state_change if the
remote is in RESET as well.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit b58915e11eba2643d5c68ea0328823a62c21dc49)
2019-11-25 15:43:38 +08:00
Jan Kiszka a9a6524d83 ivshmem-net: Silence compiler warning
At least Linaro's gcc 6.3 does not see the initialization and usage
dependency of fhead and num. Let's silence this false positive.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit 4d067d37d835c35e8f85481b97c51f20b713ae71)
2019-11-25 15:43:37 +08:00
Henning Schild 0de9da4365 ivshmem-net: add MAC changing interface
Allow ifconfig, ip and other such tools to change the MAC of the
virtual NIC.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit 7744d59d11101f75afaa6f550cabba38c2c0d260)
2019-11-25 15:43:36 +08:00
Henning Schild 1a300871de ivshmem-net: set and check descriptor flags
We do not support the use of any flags. Make sure the remote does not
confuse us using flags.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
[Jan: Remove wrong removal of next field initialization]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit 986d58d84245e023a1a66ab6495b354b6b8cd2f0)
2019-11-25 15:43:35 +08:00
Henning Schild 1ef8d65261 ivshmem-net: slightly improve debug output
There where two lines with the same error message, change one of them.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit d66af388dd2512ea7c7a776c731409854ed40a45)
2019-11-25 15:43:31 +08:00
Henning Schild 3ef38ae661 ivshmem-net: fill in and check used descriptor chain len
We are using chains of len==1 make that explicit and expect that from
the remote.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit f958c360044184f58605815d428b83fe4329cafd)
2019-11-25 15:43:31 +08:00
Jan Kiszka 4eccd3f763 ivshmem-net: Switch to pci_alloc_irq_vectors
Required by 4.12, and it also simplifies our code. Needs to be folded
into the initial patch eventually.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit ea6e78c89582711f15a2711f0a35ac3a61d9d074)
2019-11-25 15:43:30 +08:00
Jan Kiszka 915f18dbd9 ivshmem-net: Switch to relative descriptor addresses
Make sure that we do not depend on identity-mapped shared memory
regions.

This also fixes an off-by-one in the range check of ivshm_net_desc_data.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit fe9c9dd6373892591a7d6b165c3c43045eb349c1)
2019-11-25 15:43:29 +08:00
Jan Kiszka f1e35f8583 ivshmem-net: Fix stuck state machine during setup
If the remote side is already in INIT state (or even higher) and has a
cached rstate of RESET, we won't make progress when signaling RESET
again because the remote side won't send a state update. Fix this by
enforcing a local check after probe completion.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit fceed9d0ab2486589c57c0793fbfbca4832442b9)
2019-11-25 15:43:28 +08:00
Jan Kiszka 9daf55a918 ivshmem-net: Add ethtool register dump
Helps debugging inconsistent states.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit 81674136b6936fb8219dac1dcdb6df8fe424143d)
2019-11-25 15:43:27 +08:00
Jan Kiszka 2219bf0ef9 ivshmem-net: Switch to reset state on each net stop and on driver removal
Improves the state signaling to the remote side after ifconfig down and
driver removal.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit d0f632b2830146d9892a2b1ab93f866f072412bb)
2019-11-25 15:43:27 +08:00
Jan Kiszka 6a8b7dac6c ivshmem-net: Improve identification of resources
Pass a device name consisting of driver name and PCI ID to request_irq
and alloc_ordered_workqueue. This helps correlating resources with
devices in case there are multiple of them.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit 43e2ff78b89cbdfaecba54601d85f3d40349a9b5)
2019-11-25 15:43:27 +08:00
Jan Kiszka 5de6a73541 ivshmem-net: Enable INTx
Activate INTx notification when it has to be used instead of MSI-X,
disable it after use.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit 8790717bdca6ea58f18baac1749ac347b23b7263)
2019-11-25 15:43:26 +08:00
Jan Kiszka 56c70c4ac1 ivshmem-net: Remove unused variable
Became unused by previous change.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit 3ea4b31deba3424784f0105c20dc90419e950e2c)
2019-11-25 15:43:25 +08:00
Mans Rullgard db011fdece ivshmem-net: fix race in state machine
(cherry picked from commit 5d663baed6a89d09bae4446f6509f9957c780bc7)
2019-11-25 15:43:25 +08:00
Jan Kiszka 874fde9266 ivshmem-net: Map shmem region as RAM
No need for special caching, simply map the shared memory region like
RAM, thus write-back. This gives us another order of magnitude in
throughput.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit af59c6541a65622cab498851e01653dd378cd9f8)
2019-11-25 15:43:24 +08:00
Mans Rullgard ecdcbc098b ivshmem-net: virtual network device for Jailhouse
Work in progress.

(cherry picked from commit ed818547b45e652db57d5966efe336ed646feb45)
2019-11-25 15:43:24 +08:00