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>
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>
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>
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>
The skb field has been removed by 4f296edeb9.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit 80c301552ec0b500dd46a2b4f0c9fef78a610ee6)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
Helps debugging inconsistent states.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit 81674136b6936fb8219dac1dcdb6df8fe424143d)
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)
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)
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)
Became unused by previous change.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit 3ea4b31deba3424784f0105c20dc90419e950e2c)
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)