[dpdk-dev] [PATCH] Enhance code readability when dma_map in ifc/ifcvp_vdpa

jilei chen chenjilei at cmss.chinamobile.com
Sun Sep 26 18:45:18 CEST 2021


Signed-off-by: jilei chen <chenjilei at cmss.chinamobile.com>
---
 drivers/vdpa/ifc/ifcvf_vdpa.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index 1dc813d0a3..c2bf26f2b7 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -36,6 +36,8 @@ RTE_LOG_REGISTER(ifcvf_vdpa_logtype, pmd.vdpa.ifcvf, NOTICE);
 
 #define IFCVF_VDPA_MODE		"vdpa"
 #define IFCVF_SW_FALLBACK_LM	"sw-live-migration"
+#define IFCVF_MAP	1
+#define IFCVF_UNMAP	0
 
 #define THREAD_NAME_LEN	16
 
@@ -538,7 +540,7 @@ update_datapath(struct ifcvf_internal *internal)
 	if (!rte_atomic32_read(&internal->running) &&
 	    (rte_atomic32_read(&internal->started) &&
 	     rte_atomic32_read(&internal->dev_attached))) {
-		ret = ifcvf_dma_map(internal, 1);
+		ret = ifcvf_dma_map(internal, IFCVF_MAP);
 		if (ret)
 			goto err;
 
@@ -568,7 +570,7 @@ update_datapath(struct ifcvf_internal *internal)
 		if (ret)
 			goto err;
 
-		ret = ifcvf_dma_map(internal, 0);
+		ret = ifcvf_dma_map(internal, IFCVF_UNMAP);
 		if (ret)
 			goto err;
 
@@ -875,7 +877,7 @@ ifcvf_sw_fallback_switchover(struct ifcvf_internal *internal)
 unset_intr:
 	vdpa_disable_vfio_intr(internal);
 unmap:
-	ifcvf_dma_map(internal, 0);
+	ifcvf_dma_map(internal, IFCVF_UNMAP);
 error:
 	return -1;
 }
@@ -934,7 +936,7 @@ ifcvf_dev_close(int vid)
 		vdpa_disable_vfio_intr(internal);
 
 		/* unset DMA map for guest memory */
-		ifcvf_dma_map(internal, 0);
+		ifcvf_dma_map(internal, IFCVF_UNMAP);
 
 		internal->sw_fallback_running = false;
 	} else {
-- 
2.12.2





More information about the dev mailing list