diff mbox series

[v1,1/2] eal/x86: add WC store function

Message ID 1591870283-7776-1-git-send-email-radu.nicolau@intel.com (mailing list archive)
State Superseded, archived
Headers show
Series [v1,1/2] eal/x86: add WC store function | expand

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Radu Nicolau June 11, 2020, 10:11 a.m. UTC
Add rte_write32_wc function that implements a WC store
using movdiri instruction.

Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
---
 lib/librte_eal/x86/include/rte_io.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Jerin Jacob June 11, 2020, 12:23 p.m. UTC | #1
On Thu, Jun 11, 2020 at 3:41 PM Radu Nicolau <radu.nicolau@intel.com> wrote:
>
> Add rte_write32_wc function that implements a WC store
> using movdiri instruction.
>
> Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
> ---
>  lib/librte_eal/x86/include/rte_io.h | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
>
> diff --git a/lib/librte_eal/x86/include/rte_io.h b/lib/librte_eal/x86/include/rte_io.h
> index 2db71b1..3d74bec 100644
> --- a/lib/librte_eal/x86/include/rte_io.h
> +++ b/lib/librte_eal/x86/include/rte_io.h
> @@ -11,6 +11,26 @@ extern "C" {
>
>  #include "generic/rte_io.h"
>
> +/**
> + * Write a 32-bit value to I/O device memory address *addr*.
> + * Uses MOVDIRI instruction to perform a direct-store operation using WC
> + * memory write protocol.

It will be an x86 specific API, Please change the API name to reflect that.


> + *
> + * @param value
> + *  Value to write
> + * @param addr
> + *  I/O memory address to write the value to
> + */
> +static __rte_always_inline void
> +rte_write32_wc(uint32_t value, volatile void *addr)
> +{
> +       asm volatile("sfence\n\t"
> +               /* MOVDIRI */
> +               ".byte 0x40, 0x0f, 0x38, 0xf9, 0x02"
> +               :
> +               : "a" (value), "d" (addr));
> +}
> +
>  #ifdef __cplusplus
>  }
>  #endif
> --
> 2.7.4
>
Radu Nicolau June 11, 2020, 1:56 p.m. UTC | #2
On 6/11/2020 1:23 PM, Jerin Jacob wrote:
> On Thu, Jun 11, 2020 at 3:41 PM Radu Nicolau <radu.nicolau@intel.com> wrote:
>> Add rte_write32_wc function that implements a WC store
>> using movdiri instruction.
>>
>> Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
>> ---
>>   lib/librte_eal/x86/include/rte_io.h | 20 ++++++++++++++++++++
>>   1 file changed, 20 insertions(+)
>>
>> diff --git a/lib/librte_eal/x86/include/rte_io.h b/lib/librte_eal/x86/include/rte_io.h
>> index 2db71b1..3d74bec 100644
>> --- a/lib/librte_eal/x86/include/rte_io.h
>> +++ b/lib/librte_eal/x86/include/rte_io.h
>> @@ -11,6 +11,26 @@ extern "C" {
>>
>>   #include "generic/rte_io.h"
>>
>> +/**
>> + * Write a 32-bit value to I/O device memory address *addr*.
>> + * Uses MOVDIRI instruction to perform a direct-store operation using WC
>> + * memory write protocol.
> It will be an x86 specific API, Please change the API name to reflect that.
>
You mean something like rte_x86_write32_wc?
Jerin Jacob June 11, 2020, 3:33 p.m. UTC | #3
On Thu, Jun 11, 2020 at 7:26 PM Nicolau, Radu <radu.nicolau@intel.com> wrote:
>
>
> On 6/11/2020 1:23 PM, Jerin Jacob wrote:
> > On Thu, Jun 11, 2020 at 3:41 PM Radu Nicolau <radu.nicolau@intel.com> wrote:
> >> Add rte_write32_wc function that implements a WC store
> >> using movdiri instruction.
> >>
> >> Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
> >> ---
> >>   lib/librte_eal/x86/include/rte_io.h | 20 ++++++++++++++++++++
> >>   1 file changed, 20 insertions(+)
> >>
> >> diff --git a/lib/librte_eal/x86/include/rte_io.h b/lib/librte_eal/x86/include/rte_io.h
> >> index 2db71b1..3d74bec 100644
> >> --- a/lib/librte_eal/x86/include/rte_io.h
> >> +++ b/lib/librte_eal/x86/include/rte_io.h
> >> @@ -11,6 +11,26 @@ extern "C" {
> >>
> >>   #include "generic/rte_io.h"
> >>
> >> +/**
> >> + * Write a 32-bit value to I/O device memory address *addr*.
> >> + * Uses MOVDIRI instruction to perform a direct-store operation using WC
> >> + * memory write protocol.
> > It will be an x86 specific API, Please change the API name to reflect that.
> >
> You mean something like rte_x86_write32_wc?

Yes. Something like that...
Konstantin Ananyev June 15, 2020, 11:11 a.m. UTC | #4
Hi Radu,

> 
> Add rte_write32_wc function that implements a WC store
> using movdiri instruction.

Probably worth to add 1-2 lines of text
explaining what are the advantages (perf improvement or whatever). 

> 
> Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
> ---
>  lib/librte_eal/x86/include/rte_io.h | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/lib/librte_eal/x86/include/rte_io.h b/lib/librte_eal/x86/include/rte_io.h
> index 2db71b1..3d74bec 100644
> --- a/lib/librte_eal/x86/include/rte_io.h
> +++ b/lib/librte_eal/x86/include/rte_io.h
> @@ -11,6 +11,26 @@ extern "C" {
> 
>  #include "generic/rte_io.h"
> 
> +/**
> + * Write a 32-bit value to I/O device memory address *addr*.
> + * Uses MOVDIRI instruction to perform a direct-store operation using WC
> + * memory write protocol.
> + *
> + * @param value
> + *  Value to write
> + * @param addr
> + *  I/O memory address to write the value to
> + */
> +static __rte_always_inline void
> +rte_write32_wc(uint32_t value, volatile void *addr)
> +{
> +	asm volatile("sfence\n\t"

Why not rte_wmb()?

> +		/* MOVDIRI */
> +		".byte 0x40, 0x0f, 0x38, 0xf9, 0x02"
> +		:
> +		: "a" (value), "d" (addr));
> +}
> +
>  #ifdef __cplusplus
>  }
>  #endif
> --
> 2.7.4
diff mbox series

Patch

diff --git a/lib/librte_eal/x86/include/rte_io.h b/lib/librte_eal/x86/include/rte_io.h
index 2db71b1..3d74bec 100644
--- a/lib/librte_eal/x86/include/rte_io.h
+++ b/lib/librte_eal/x86/include/rte_io.h
@@ -11,6 +11,26 @@  extern "C" {
 
 #include "generic/rte_io.h"
 
+/**
+ * Write a 32-bit value to I/O device memory address *addr*.
+ * Uses MOVDIRI instruction to perform a direct-store operation using WC
+ * memory write protocol.
+ *
+ * @param value
+ *  Value to write
+ * @param addr
+ *  I/O memory address to write the value to
+ */
+static __rte_always_inline void
+rte_write32_wc(uint32_t value, volatile void *addr)
+{
+	asm volatile("sfence\n\t"
+		/* MOVDIRI */
+		".byte 0x40, 0x0f, 0x38, 0xf9, 0x02"
+		:
+		: "a" (value), "d" (addr));
+}
+
 #ifdef __cplusplus
 }
 #endif