DPDK patches and discussions
 help / color / mirror / Atom feed
From: Xiao Wang <xiao.w.wang@intel.com>
To: ferruh.yigit@intel.com
Cc: dev@dpdk.org, Xiao Wang <xiao.w.wang@intel.com>
Subject: [dpdk-dev] [PATCH] net/ifcvf: do not panic in address translation
Date: Fri, 20 Apr 2018 23:15:24 +0800	[thread overview]
Message-ID: <20180420151524.36696-1-xiao.w.wang@intel.com> (raw)

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(-)

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);
-- 
2.15.1

             reply	other threads:[~2018-04-20 15:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-20 15:15 Xiao Wang [this message]
2018-04-23 10:42 ` Ferruh Yigit

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=20180420151524.36696-1-xiao.w.wang@intel.com \
    --to=xiao.w.wang@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    /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).