[dpdk-dev] net/ifcvf: do not panic in address translation

Message ID 20180420151524.36696-1-xiao.w.wang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Xiao Wang April 20, 2018, 3:15 p.m. UTC
  Driver should return error and report error message rather than call
rte_panic().

Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
---
 drivers/net/ifc/ifcvf_vdpa.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)
  

Comments

Ferruh Yigit April 23, 2018, 10:42 a.m. UTC | #1
On 4/20/2018 4:15 PM, Xiao Wang wrote:
> Driver should return error and report error message rather than call
> rte_panic().
> 
> Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>

Squashed into relevant commit in next-net [1], thanks.

[1]
3c67b5fca918 ("net/ifcvf: add ifcvf vdpa driver")
  

Patch

diff --git a/drivers/net/ifc/ifcvf_vdpa.c b/drivers/net/ifc/ifcvf_vdpa.c
index 27316a99f..26d70be18 100644
--- a/drivers/net/ifc/ifcvf_vdpa.c
+++ b/drivers/net/ifc/ifcvf_vdpa.c
@@ -226,8 +226,6 @@  qva_to_gpa(int vid, uint64_t qva)
 	}
 
 exit:
-	if (gpa == 0)
-		rte_panic("failed to get gpa\n");
 	if (mem)
 		free(mem);
 	return gpa;
@@ -240,6 +238,7 @@  vdpa_ifcvf_start(struct ifcvf_internal *internal)
 	int i, nr_vring;
 	int vid;
 	struct rte_vhost_vring vq;
+	uint64_t gpa;
 
 	vid = internal->vid;
 	nr_vring = rte_vhost_get_vring_num(vid);
@@ -247,12 +246,27 @@  vdpa_ifcvf_start(struct ifcvf_internal *internal)
 
 	for (i = 0; i < nr_vring; i++) {
 		rte_vhost_get_vhost_vring(vid, i, &vq);
-		hw->vring[i].desc = qva_to_gpa(vid,
-				(uint64_t)(uintptr_t)vq.desc);
-		hw->vring[i].avail = qva_to_gpa(vid,
-				(uint64_t)(uintptr_t)vq.avail);
-		hw->vring[i].used = qva_to_gpa(vid,
-				(uint64_t)(uintptr_t)vq.used);
+		gpa = qva_to_gpa(vid, (uint64_t)(uintptr_t)vq.desc);
+		if (gpa == 0) {
+			DRV_LOG(ERR, "Fail to get GPA for descriptor ring.");
+			return -1;
+		}
+		hw->vring[i].desc = gpa;
+
+		gpa = qva_to_gpa(vid, (uint64_t)(uintptr_t)vq.avail);
+		if (gpa == 0) {
+			DRV_LOG(ERR, "Fail to get GPA for available ring.");
+			return -1;
+		}
+		hw->vring[i].avail = gpa;
+
+		gpa = qva_to_gpa(vid, (uint64_t)(uintptr_t)vq.used);
+		if (gpa == 0) {
+			DRV_LOG(ERR, "Fail to get GPA for used ring.");
+			return -1;
+		}
+		hw->vring[i].used = gpa;
+
 		hw->vring[i].size = vq.size;
 		rte_vhost_get_vring_base(vid, i, &hw->vring[i].last_avail_idx,
 				&hw->vring[i].last_used_idx);