* [dpdk-dev] [PATCH] Enhance code readability when dma_map in ifc/ifcvp_vdpa @ 2021-09-26 16:45 jilei chen 2021-09-27 2:09 ` Wang, Xiao W 2021-09-27 5:17 ` [dpdk-dev] [PATCH] vdpa/ifc: increase readability in function jilei chen 0 siblings, 2 replies; 6+ messages in thread From: jilei chen @ 2021-09-26 16:45 UTC (permalink / raw) To: xiao.w.wang; +Cc: dev Signed-off-by: jilei chen <chenjilei@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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] Enhance code readability when dma_map in ifc/ifcvp_vdpa 2021-09-26 16:45 [dpdk-dev] [PATCH] Enhance code readability when dma_map in ifc/ifcvp_vdpa jilei chen @ 2021-09-27 2:09 ` Wang, Xiao W 2021-09-27 5:17 ` [dpdk-dev] [PATCH] vdpa/ifc: increase readability in function jilei chen 1 sibling, 0 replies; 6+ messages in thread From: Wang, Xiao W @ 2021-09-27 2:09 UTC (permalink / raw) To: jilei chen; +Cc: dev Hi Jilei, Please notice the patch format requirement, the subject of the patch should start with "vdpa/ifc: ". You also need to keep it concise, around ~50 characters. Refer " doc/guides/contributing/patches.rst" for more detail. Back to this patch, it looks we can just change function ifcvf_dma_map(struct ifcvf_internal *internal, int do_map) to ifcvf_dma_map(struct ifcvf_internal *internal, bool do_map), and use "true" or "false" when calling it. This would align with vdpa_enable_vfio_intr(). In your next version patch, you can also change the "1", "0" parameter to "true", "false" when calling vdpa_enable_vfio_intr(). BRs, Xiao > -----Original Message----- > From: jilei chen <chenjilei@cmss.chinamobile.com> > Sent: Monday, September 27, 2021 12:45 AM > To: Wang, Xiao W <xiao.w.wang@intel.com> > Cc: dev@dpdk.org > Subject: [PATCH] Enhance code readability when dma_map in > ifc/ifcvp_vdpa > > Signed-off-by: jilei chen <chenjilei@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 > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH] vdpa/ifc: increase readability in function 2021-09-26 16:45 [dpdk-dev] [PATCH] Enhance code readability when dma_map in ifc/ifcvp_vdpa jilei chen 2021-09-27 2:09 ` Wang, Xiao W @ 2021-09-27 5:17 ` jilei chen 2021-09-27 10:17 ` [dpdk-dev] [PATCH] [v3] " jilei chen 1 sibling, 1 reply; 6+ messages in thread From: jilei chen @ 2021-09-27 5:17 UTC (permalink / raw) To: xiao.w.wang; +Cc: dev Optimize several parameters form order to better readability Signed-off-by: jilei chen <chenjilei@cmss.chinamobile.com> --- drivers/vdpa/ifc/ifcvf_vdpa.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c index 1dc813d0a3..365da2a8b9 100644 --- a/drivers/vdpa/ifc/ifcvf_vdpa.c +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c @@ -182,7 +182,7 @@ ifcvf_vfio_setup(struct ifcvf_internal *internal) } static int -ifcvf_dma_map(struct ifcvf_internal *internal, int do_map) +ifcvf_dma_map(struct ifcvf_internal *internal, bool do_map) { uint32_t i; int ret; @@ -538,11 +538,11 @@ 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, true); if (ret) goto err; - ret = vdpa_enable_vfio_intr(internal, 0); + ret = vdpa_enable_vfio_intr(internal, false); if (ret) goto err; @@ -568,7 +568,7 @@ update_datapath(struct ifcvf_internal *internal) if (ret) goto err; - ret = ifcvf_dma_map(internal, 0); + ret = ifcvf_dma_map(internal, false); if (ret) goto err; @@ -850,7 +850,7 @@ ifcvf_sw_fallback_switchover(struct ifcvf_internal *internal) goto error; /* set up interrupt for interrupt relay */ - ret = vdpa_enable_vfio_intr(internal, 1); + ret = vdpa_enable_vfio_intr(internal, true); if (ret) goto unmap; @@ -875,7 +875,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, false); error: return -1; } @@ -934,7 +934,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, false); internal->sw_fallback_running = false; } else { @@ -1130,7 +1130,7 @@ ifcvf_set_vring_state(int vid, int vring, int state) } if (state && !hw->vring[vring].enable) { - ret = vdpa_enable_vfio_intr(internal, 0); + ret = vdpa_enable_vfio_intr(internal, false); if (ret) return ret; } -- 2.12.2 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH] [v3] vdpa/ifc: increase readability in function 2021-09-27 5:17 ` [dpdk-dev] [PATCH] vdpa/ifc: increase readability in function jilei chen @ 2021-09-27 10:17 ` jilei chen 2021-09-28 2:22 ` Wang, Xiao W 0 siblings, 1 reply; 6+ messages in thread From: jilei chen @ 2021-09-27 10:17 UTC (permalink / raw) To: xiao.w.wang; +Cc: dev Use bool type for function's switch parameter, this could avoid passing "1" or "0" which is not reader friendly. Signed-off-by: jilei chen <chenjilei@cmss.chinamobile.com> --- v3: * Update inappropriate description v2: * Concise subject of the patch * Optimize function parameters --- drivers/vdpa/ifc/ifcvf_vdpa.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c index 1dc813d0a3..365da2a8b9 100644 --- a/drivers/vdpa/ifc/ifcvf_vdpa.c +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c @@ -182,7 +182,7 @@ ifcvf_vfio_setup(struct ifcvf_internal *internal) } static int -ifcvf_dma_map(struct ifcvf_internal *internal, int do_map) +ifcvf_dma_map(struct ifcvf_internal *internal, bool do_map) { uint32_t i; int ret; @@ -538,11 +538,11 @@ 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, true); if (ret) goto err; - ret = vdpa_enable_vfio_intr(internal, 0); + ret = vdpa_enable_vfio_intr(internal, false); if (ret) goto err; @@ -568,7 +568,7 @@ update_datapath(struct ifcvf_internal *internal) if (ret) goto err; - ret = ifcvf_dma_map(internal, 0); + ret = ifcvf_dma_map(internal, false); if (ret) goto err; @@ -850,7 +850,7 @@ ifcvf_sw_fallback_switchover(struct ifcvf_internal *internal) goto error; /* set up interrupt for interrupt relay */ - ret = vdpa_enable_vfio_intr(internal, 1); + ret = vdpa_enable_vfio_intr(internal, true); if (ret) goto unmap; @@ -875,7 +875,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, false); error: return -1; } @@ -934,7 +934,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, false); internal->sw_fallback_running = false; } else { @@ -1130,7 +1130,7 @@ ifcvf_set_vring_state(int vid, int vring, int state) } if (state && !hw->vring[vring].enable) { - ret = vdpa_enable_vfio_intr(internal, 0); + ret = vdpa_enable_vfio_intr(internal, false); if (ret) return ret; } -- 2.12.2 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] [v3] vdpa/ifc: increase readability in function 2021-09-27 10:17 ` [dpdk-dev] [PATCH] [v3] " jilei chen @ 2021-09-28 2:22 ` Wang, Xiao W 2021-09-30 17:24 ` Ferruh Yigit 0 siblings, 1 reply; 6+ messages in thread From: Wang, Xiao W @ 2021-09-28 2:22 UTC (permalink / raw) To: jilei chen; +Cc: dev Hi, > -----Original Message----- > From: jilei chen <chenjilei@cmss.chinamobile.com> > Sent: Monday, September 27, 2021 6:18 PM > To: Wang, Xiao W <xiao.w.wang@intel.com> > Cc: dev@dpdk.org > Subject: [PATCH] [v3] vdpa/ifc: increase readability in function > > Use bool type for function's switch parameter, > this could avoid passing "1" or "0" which is not reader friendly. > > Signed-off-by: jilei chen <chenjilei@cmss.chinamobile.com> > --- > v3: > * Update inappropriate description > > v2: > * Concise subject of the patch > * Optimize function parameters > --- > drivers/vdpa/ifc/ifcvf_vdpa.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c > index 1dc813d0a3..365da2a8b9 100644 > --- a/drivers/vdpa/ifc/ifcvf_vdpa.c > +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c > @@ -182,7 +182,7 @@ ifcvf_vfio_setup(struct ifcvf_internal *internal) > } > > static int > -ifcvf_dma_map(struct ifcvf_internal *internal, int do_map) > +ifcvf_dma_map(struct ifcvf_internal *internal, bool do_map) > { > uint32_t i; > int ret; > @@ -538,11 +538,11 @@ 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, true); > if (ret) > goto err; > > - ret = vdpa_enable_vfio_intr(internal, 0); > + ret = vdpa_enable_vfio_intr(internal, false); > if (ret) > goto err; > > @@ -568,7 +568,7 @@ update_datapath(struct ifcvf_internal *internal) > if (ret) > goto err; > > - ret = ifcvf_dma_map(internal, 0); > + ret = ifcvf_dma_map(internal, false); > if (ret) > goto err; > > @@ -850,7 +850,7 @@ ifcvf_sw_fallback_switchover(struct ifcvf_internal > *internal) > goto error; > > /* set up interrupt for interrupt relay */ > - ret = vdpa_enable_vfio_intr(internal, 1); > + ret = vdpa_enable_vfio_intr(internal, true); > if (ret) > goto unmap; > > @@ -875,7 +875,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, false); > error: > return -1; > } > @@ -934,7 +934,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, false); > > internal->sw_fallback_running = false; > } else { > @@ -1130,7 +1130,7 @@ ifcvf_set_vring_state(int vid, int vring, int state) > } > > if (state && !hw->vring[vring].enable) { > - ret = vdpa_enable_vfio_intr(internal, 0); > + ret = vdpa_enable_vfio_intr(internal, false); > if (ret) > return ret; > } > -- > 2.12.2 > > Acked-by: Xiao Wang <xiao.w.wang@intel.com> BRs, Xiao ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] [v3] vdpa/ifc: increase readability in function 2021-09-28 2:22 ` Wang, Xiao W @ 2021-09-30 17:24 ` Ferruh Yigit 0 siblings, 0 replies; 6+ messages in thread From: Ferruh Yigit @ 2021-09-30 17:24 UTC (permalink / raw) To: Wang, Xiao W, jilei chen; +Cc: dev On 9/28/2021 3:22 AM, Wang, Xiao W wrote: > Hi, > >> -----Original Message----- >> From: jilei chen <chenjilei@cmss.chinamobile.com> >> Sent: Monday, September 27, 2021 6:18 PM >> To: Wang, Xiao W <xiao.w.wang@intel.com> >> Cc: dev@dpdk.org >> Subject: [PATCH] [v3] vdpa/ifc: increase readability in function >> >> Use bool type for function's switch parameter, >> this could avoid passing "1" or "0" which is not reader friendly. >> >> Signed-off-by: jilei chen <chenjilei@cmss.chinamobile.com>> > Acked-by: Xiao Wang <xiao.w.wang@intel.com> > Applied to dpdk-next-net/main, thanks. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-09-30 17:24 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-09-26 16:45 [dpdk-dev] [PATCH] Enhance code readability when dma_map in ifc/ifcvp_vdpa jilei chen 2021-09-27 2:09 ` Wang, Xiao W 2021-09-27 5:17 ` [dpdk-dev] [PATCH] vdpa/ifc: increase readability in function jilei chen 2021-09-27 10:17 ` [dpdk-dev] [PATCH] [v3] " jilei chen 2021-09-28 2:22 ` Wang, Xiao W 2021-09-30 17:24 ` Ferruh Yigit
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).