From: Huawei Xie <huawei.xie@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 05/14] hpa region
Date: Mon, 20 Oct 2014 12:38:17 +0800 [thread overview]
Message-ID: <1413779906-28113-6-git-send-email-huawei.xie@intel.com> (raw)
In-Reply-To: <1413779906-28113-1-git-send-email-huawei.xie@intel.com>
add hpa(host physical address) region generation/destroy logic.
gpa<->hpa memory translation regions are generated at new_device, when a
virtio device is ready for packet processing.
Signed-off-by: Huawei Xie <huawei.xie@intel.com>
---
examples/vhost/main.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 03a0f48..e161282 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -2489,6 +2489,7 @@ destroy_device (volatile struct virtio_net *dev)
dev->device_fh);
mbuf_destroy_zcp(vpool);
+ rte_free(vdev->regions_hpa);
}
rte_free(vdev);
@@ -2652,7 +2653,7 @@ new_device (struct virtio_net *dev)
int lcore, core_add = 0;
uint32_t device_num_min = num_devices;
struct vhost_dev *vdev;
-
+ uint32_t regionidx;
vdev = rte_zmalloc("vhost device", sizeof(*vdev), CACHE_LINE_SIZE);
if (vdev == NULL) {
@@ -2663,12 +2664,49 @@ new_device (struct virtio_net *dev)
vdev->dev = dev;
dev->priv = vdev;
+ if (zero_copy) {
+ vdev->nregions_hpa = dev->mem->nregions;
+ for (regionidx = 0; regionidx < dev->mem->nregions; regionidx++) {
+ vdev->nregions_hpa
+ += check_hpa_regions(
+ dev->mem->regions[regionidx].guest_phys_address
+ + dev->mem->regions[regionidx].address_offset,
+ dev->mem->regions[regionidx].memory_size);
+
+ }
+
+ vdev->regions_hpa = (struct virtio_memory_regions_hpa *) rte_zmalloc("vhost hpa region",
+ sizeof(struct virtio_memory_regions_hpa) * vdev->nregions_hpa,
+ CACHE_LINE_SIZE);
+ if (vdev->regions_hpa == NULL) {
+ RTE_LOG(ERR, VHOST_CONFIG, "Cannot allocate memory for hpa region\n");
+ rte_free(vdev);
+ return -1;
+ }
+
+
+ if (fill_hpa_memory_regions(
+ vdev->regions_hpa, dev->mem
+ ) != vdev->nregions_hpa) {
+
+ RTE_LOG(ERR, VHOST_CONFIG,
+ "hpa memory regions number mismatch: "
+ "[%d]\n", vdev->nregions_hpa);
+ rte_free(vdev->regions_hpa);
+ rte_free(vdev);
+ return -1;
+ }
+ }
+
+
/* Add device to main ll */
ll_dev = get_data_ll_free_entry(&ll_root_free);
if (ll_dev == NULL) {
RTE_LOG(INFO, VHOST_DATA, "(%"PRIu64") No free entry found in linked list. Device limit "
"of %d devices per core has been reached\n",
dev->device_fh, num_devices);
+ if (vdev->regions_hpa)
+ rte_free(vdev->regions_hpa);
rte_free(vdev);
return -1;
}
@@ -2721,6 +2759,7 @@ new_device (struct virtio_net *dev)
dev->device_fh, vdev->vmdq_rx_q);
mbuf_destroy_zcp(vpool);
+ rte_free(vdev->regions_hpa);
rte_free(vdev);
return -1;
}
@@ -2743,6 +2782,7 @@ new_device (struct virtio_net *dev)
}
mbuf_destroy_zcp(vpool);
+ rte_free(vdev->regions_hpa);
rte_free(vdev);
return -1;
}
@@ -2767,6 +2807,8 @@ new_device (struct virtio_net *dev)
RTE_LOG(INFO, VHOST_DATA, "(%"PRIu64") Failed to add device to data core\n", dev->device_fh);
vdev->ready = DEVICE_SAFE_REMOVE;
destroy_device(dev);
+ if (vdev->regions_hpa)
+ rte_free(vdev->regions_hpa);
rte_free(vdev);
return -1;
}
--
1.8.1.4
next prev parent reply other threads:[~2014-10-20 4:30 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-20 4:38 [dpdk-dev] [PATCH 00/14] new vhost example Huawei Xie
2014-10-20 4:38 ` [dpdk-dev] [PATCH 01/14] copy old " Huawei Xie
2014-10-20 4:38 ` [dpdk-dev] [PATCH 02/14] remove virtio_dev_rx, virtio_dev_merge_rx, copy_from_mbuf_to_ring, virtio_dev_tx, virtio_dev_merge_tx Huawei Xie
2014-10-20 4:38 ` [dpdk-dev] [PATCH 03/14] add bak two hpa region functions Huawei Xie
2014-10-20 4:38 ` [dpdk-dev] [PATCH 04/14] dev->vdev Huawei Xie
2014-10-20 4:38 ` Huawei Xie [this message]
2014-10-20 4:38 ` [dpdk-dev] [PATCH 06/14] enqueue_burst, dequeue_burst, mac learning Huawei Xie
2014-10-20 4:38 ` [dpdk-dev] [PATCH 07/14] patch virtio_tx_route Huawei Xie
2014-10-20 4:38 ` [dpdk-dev] [PATCH 08/14] remove gpa_to_vva, base_index Huawei Xie
2014-10-23 9:43 ` Thomas Monjalon
2014-10-20 4:38 ` [dpdk-dev] [PATCH 09/14] other APIs Huawei Xie
2014-10-23 9:44 ` Thomas Monjalon
2014-10-20 4:38 ` [dpdk-dev] [PATCH 10/14] vmdq_rx_q Huawei Xie
2014-10-23 9:45 ` Thomas Monjalon
2014-10-20 4:38 ` [dpdk-dev] [PATCH 11/14] minor fixes Huawei Xie
2014-10-20 4:38 ` [dpdk-dev] [PATCH 12/14] add branch hint Huawei Xie
2014-10-20 4:38 ` [dpdk-dev] [PATCH 13/14] INC_VEC Huawei Xie
2014-10-20 4:38 ` [dpdk-dev] [PATCH 14/14] Makefile Huawei Xie
2014-10-23 9:48 ` Thomas Monjalon
2014-10-20 5:21 ` [dpdk-dev] [PATCH 00/14] new vhost example Ouyang, Changchun
2014-10-23 11:10 ` Thomas Monjalon
2014-10-23 16:17 ` Xie, Huawei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1413779906-28113-6-git-send-email-huawei.xie@intel.com \
--to=huawei.xie@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).