[dpdk-dev,40/41] net/virtio: use contiguous allocation for DMA memory

Message ID a453d8a92a7d64db0e3d15af81406aac5f4dc0a6.1520083504.git.anatoly.burakov@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply patch file failure

Commit Message

Anatoly Burakov March 3, 2018, 1:46 p.m. UTC
  Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---

Notes:
    Not sure if virtio needs to allocate DMA-capable memory,
    being a software driver and all. Corrections welcome.

 drivers/net/virtio/virtio_ethdev.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Comments

Venkatesh Srinivas March 3, 2018, 4:52 p.m. UTC | #1
On Sat, Mar 3, 2018 at 7:46 AM, Anatoly Burakov
<anatoly.burakov@intel.com> wrote:
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
>
> Notes:
>     Not sure if virtio needs to allocate DMA-capable memory,
>     being a software driver and all. Corrections welcome.

Reviewed-by: Venkatesh Srinivas <venkateshs@google.com>

1. The first change is correct - virtio rings need to be contiguous in
guest physical address
    space.

2. The second change - virtio_tx_region contains both a virtio_net_hdr
and indirect table.
    virtio devices require virtio_net_hdr to be contiguous (in pre-1.0
devices w/o F_ANY_LAYOUT)
    but do not require the indirect table to be contiguous w/
virtio_net_hdr. You may want this to
    avoid splitting up the structure though.

HTH,
-- vs;
  

Patch

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 884f74a..35812e4 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -391,7 +391,7 @@  virtio_init_queue(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx)
 	PMD_INIT_LOG(DEBUG, "vring_size: %d, rounded_vring_size: %d",
 		     size, vq->vq_ring_size);
 
-	mz = rte_memzone_reserve_aligned(vq_name, vq->vq_ring_size,
+	mz = rte_memzone_reserve_aligned_contig(vq_name, vq->vq_ring_size,
 					 SOCKET_ID_ANY,
 					 0, VIRTIO_PCI_VRING_ALIGN);
 	if (mz == NULL) {
@@ -417,9 +417,9 @@  virtio_init_queue(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx)
 	if (sz_hdr_mz) {
 		snprintf(vq_hdr_name, sizeof(vq_hdr_name), "port%d_vq%d_hdr",
 			 dev->data->port_id, vtpci_queue_idx);
-		hdr_mz = rte_memzone_reserve_aligned(vq_hdr_name, sz_hdr_mz,
-						     SOCKET_ID_ANY, 0,
-						     RTE_CACHE_LINE_SIZE);
+		hdr_mz = rte_memzone_reserve_aligned_contig(vq_hdr_name,
+				sz_hdr_mz, SOCKET_ID_ANY, 0,
+				RTE_CACHE_LINE_SIZE);
 		if (hdr_mz == NULL) {
 			if (rte_errno == EEXIST)
 				hdr_mz = rte_memzone_lookup(vq_hdr_name);