virtio/net: fix processing of merged RX buffers #2103
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When the virtio net feature that allows merging of RX buffers is enabled, buffers belonging to a merged set must be processed in strict sequential order; to achieve this, the seqno field of the vnet_rx structure is used to prevent different CPUS from processing RX buffers simultaneously.
This change set fixes a few flaws in the implementation of the critical section which can cause corruption of the pbuf structure holding received data, and can lead to failure to process incoming network traffic. The memory barriers needed to ensure correct synchronization between CPUs have been added via the newly defined smp_read_barrier() and smp_write_barrier() macros, which are more efficient than read_barrier() and write_barrier() on architectures (such as x86) with strong memory ordering. As part of the commit that introduces these new macros, existing calls to read_barrier() and write_barrier() have been replaced by calls to smp_read_barrier() and smp_write_barrier() where appropriate (i.e where memory is not used for device I/O).
Closes #2099.