eal/x86: add WC store function
PATCH 1/2 eal/x86: add WC store function
Add rte_write32_wc function that implements a WC store using movdiri instruction.
--- lib/librte_eal/x86/include/rte_io.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
lib/librte_eal/x86/include/rte_io.h +20 -0
@@ -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) +{ + asmvolatile ("sfence\n\t" +/* MOVDIRI */ +".byte 0x40, 0x0f, 0x38, 0xf9, 0x02" + : + :"a" (value),"d" (addr)); +} + #ifdef __cplusplus }#endif
Signature · 1 line
2.7.4
PATCH 2/2 net/i40e: use movdiri to update queue tail registers
If available use movdiri instruction instead of a regular mmio write to update queue tail registers.
--- drivers/net/i40e/base/i40e_osdep.h | 20 ++++++++++++++++++++ drivers/net/i40e/i40e_ethdev_vf.c | 10 ++++++++++ drivers/net/i40e/i40e_fdir.c | 4 ++++ drivers/net/i40e/i40e_rxtx.c | 19 +++++++++++++++---- drivers/net/i40e/i40e_rxtx.h | 2 ++ drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 ++-- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 ++-- 7 files changed, 55 insertions(+), 8 deletions(-)
drivers/net/i40e/base/i40e_osdep.h +20 -0
@@ -138,6 +138,26 @@ static inline uint32_t i40e_read_addr(volatile void *addr)#define I40E_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#if defined(RTE_ARCH_X86 ) +#define I40E_PCI_REG_WC_WRITE (queue, reg, value, ...) \ + do { \ + uint32_t val = rte_cpu_to_le_32(value); \ + volatile void *addr = reg; \ + if (queue->use_movdiri) \ + rte_write32_wc(val, addr); \ + else \ + rte_write32##__VA_ARGS__(val, addr); \ + } while (0) +#define I40E_PCI_REG_WC_WRITE_RELAXED (queue, reg, value) \ + I40E_PCI_REG_WC_WRITE(queue, reg, value, _relaxed) +#else +#define I40E_PCI_REG_WC_WRITE (queue, reg, value) \ + I40E_PCI_REG_WRITE(reg, value) +#define I40E_PCI_REG_WC_WRITE_RELAXED (queue, reg, value) \ + I40E_PCI_REG_WRITE_RELAXED(reg, value) +#endif + +#define I40E_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_GLGEN_STAT)#define I40EVF_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_VFGEN_RSTAT)
drivers/net/i40e/i40e_ethdev_vf.c +10 -0
@@ -1790,6 +1790,11 @@ i40evf_rxq_init(struct rte_eth_dev *dev, struct i40e_rx_queue *rxq) rxq->max_pkt_len =RTE_MIN (len, dev_data->dev_conf.rxmode.max_rx_pkt_len); +#if defined(RTE_ARCH_X86 ) +/* use MOVDIRI if supported*/ + rxq->use_movdiri =rte_cpu_get_flag_enabled (RTE_CPUFLAG_MOVDIRI ); +#endif +/** * Check if the jumbo frame and maximum packet length are set correctly */
@@ -1855,6 +1860,11 @@ i40evf_tx_init(struct rte_eth_dev *dev)for (i =0 ; i < dev->data->nb_tx_queues; i++) txq[i]->qtx_tail = hw->hw_addr +I40E_QTX_TAIL1 (i); +#if defined(RTE_ARCH_X86 ) +/* use MOVDIRI if supported*/ + txq[i]->use_movdiri =rte_cpu_get_flag_enabled (RTE_CPUFLAG_MOVDIRI ); +#endif +i40e_set_tx_function (dev); }
drivers/net/i40e/i40e_fdir.c +4 -0
@@ -142,6 +142,10 @@ i40e_fdir_rx_queue_init(struct i40e_rx_queue *rxq) } rxq->qrx_tail = hw->hw_addr +I40E_QRX_TAIL (rxq->vsi->base_queue); +#if defined(RTE_ARCH_X86 ) +/* use MOVDIRI if supported*/ + rxq->use_movdiri =rte_cpu_get_flag_enabled (RTE_CPUFLAG_MOVDIRI ); +#endif rte_wmb ();/* Init the RX tail regieter. */
drivers/net/i40e/i40e_rxtx.c +15 -4
@@ -760,7 +760,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -938,7 +938,7 @@ i40e_recv_scattered_pkts(void *rx_queue,if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t )(rx_id ==0 ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -1249,7 +1249,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) (unsigned) tx_id, (unsigned) nb_tx);rte_cio_wmb (); -I40E_PCI_REG_WRITE_RELAXED (txq->qtx_tail, tx_id); +I40E_PCI_REG_WC_WRITE_RELAXED (txq, txq->qtx_tail, tx_id); txq->tx_tail = tx_id;return nb_tx;
@@ -1400,7 +1400,7 @@ tx_xmit_pkts(struct i40e_tx_queue *txq, txq->tx_tail =0 ;/* Update the tx tail register */ -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
@@ -2717,6 +2717,12 @@ i40e_tx_queue_init(struct i40e_tx_queue *txq) txq->qtx_tail = hw->hw_addr +I40E_QTX_TAIL (pf_q); +#if defined(RTE_ARCH_X86 ) +/* use MOVDIRI if supported*/ + txq->use_movdiri =rte_cpu_get_flag_enabled (RTE_CPUFLAG_MOVDIRI ); +#endif + +return err; }
@@ -2881,6 +2887,11 @@ i40e_rx_queue_init(struct i40e_rx_queue *rxq) rxq->qrx_tail = hw->hw_addr +I40E_QRX_TAIL (pf_q); +#if defined(RTE_ARCH_X86 ) +/* use MOVDIRI WC store if supported*/ + rxq->use_movdiri =rte_cpu_get_flag_enabled (RTE_CPUFLAG_MOVDIRI ); +#endif + buf_size = (uint16_t )(rte_pktmbuf_data_room_size (rxq->mp) -RTE_PKTMBUF_HEADROOM );
drivers/net/i40e/i40e_rxtx.h +2 -0
@@ -118,6 +118,7 @@ struct i40e_rx_queue {uint16_t rx_using_sse;/**<flag indicate the usage of vPMD for rx */ uint8_t dcb_tc;/**< Traffic class of rx queue */ uint64_t offloads;/**< Rx offload flags of DEV_RX_OFFLOAD_* */ +uint8_t use_movdiri;/**< use MOVDIRI if supported */ };struct i40e_tx_entry {
@@ -159,6 +160,7 @@ struct i40e_tx_queue {bool tx_deferred_start;/**< don't start this queue in dev start */ uint8_t dcb_tc;/**< Traffic class of tx queue */ uint64_t offloads;/**< Tx offload flags of DEV_RX_OFFLOAD_* */ +uint8_t use_movdiri;/**< use MOVDIRI if supported */ };/** Offload features */
drivers/net/i40e/i40e_rxtx_vec_avx2.c +2 -2
@@ -134,7 +134,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -921,7 +921,7 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_sse.c +2 -2
@@ -86,7 +86,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -733,7 +733,7 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.7.4
Quoted 14 lines · Radu Nicolau
Add
rte_write32_wcfunction that implements a WC store using movdiri instruction.Signed-off-by Radu Nicolau <[email protected]>--- lib/librte_eal/x86/include/rte_io.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)lib/librte_eal/x86/include/rte_io.h +0
-0
lib/librte_eal/x86/include/rte_io.h extern "C" { · line 17
Quoted 7 lines
lib/librte_eal/x86/include/rte_io.h +4
-0@@ -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.
Quoted 22 lines
lib/librte_eal/x86/include/rte_io.h +16
-1+* +* @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) +{ + asmvolatile ("sfence\n\t" +/* MOVDIRI */ +".byte 0x40, 0x0f, 0x38, 0xf9, 0x02" + : + :"a" (value),"d" (addr)); +} + #ifdef __cplusplus }#endif --2.7.4
Quoted 15 lines · Jerin Jacob
Quoted 14 lines · Radu Nicolau
Add
rte_write32_wcfunction that implements a WC store using movdiri instruction.Signed-off-by Radu Nicolau <[email protected]>--- lib/librte_eal/x86/include/rte_io.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)lib/librte_eal/x86/include/rte_io.h +0
-0@@ -11,6 +11,26 @@ extern "C" {
Quoted 8 lines
lib/librte_eal/x86/include/rte_io.h extern "C" { · line 17
Quoted 6 lines
lib/librte_eal/x86/include/rte_io.h +4
-0#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?
Quoted 20 lines · Radu
Quoted 17 lines · Jerin Jacob
Quoted 16 lines · Radu Nicolau
Add
rte_write32_wcfunction that implements a WC store using movdiri instruction.Signed-off-by Radu Nicolau <[email protected]>--- lib/librte_eal/x86/include/rte_io.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)lib/librte_eal/x86/include/rte_io.h +0
-0@@ -11,6 +11,26 @@ extern "C" {#include "generic/rte_io.h"
Quoted 7 lines
Quoted 6 lines
lib/librte_eal/x86/include/rte_io.h extern "C" { · line 17
Quoted 4 lines
lib/librte_eal/x86/include/rte_io.h +4
-0+/** +* 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...
Hi Radu,
Quoted 3 lines
Add
rte_write32_wcfunction 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).
Quoted 18 lines
Signed-off-by Radu Nicolau <[email protected]>--- lib/librte_eal/x86/include/rte_io.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)lib/librte_eal/x86/include/rte_io.h +4
-0@@ -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.
lib/librte_eal/x86/include/rte_io.h extern "C" { · line 27
Quoted 10 lines
lib/librte_eal/x86/include/rte_io.h +10
-0+* +* @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()?
Quoted 11 lines
lib/librte_eal/x86/include/rte_io.h +6
-1+/* MOVDIRI */ + ".byte 0x40, 0x0f, 0x38, 0xf9, 0x02" + : + : "a" (value), "d" (addr)); +} + #ifdef __cplusplus }#endif --2.7.4
PATCH v2 1/2 eal: add WC store functions
In reply to Radu NicolauAdd rte_write32_wc and rte_write32_wc_relaxed functions that implement 32bit stores using write combining memory protocol. Provided generic stubs and x86 implementation.
---
v2 rework new eal io functions
lib/librte_eal/include/generic/rte_io.h | 47 ++++++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 59 +++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+)
lib/librte_eal/include/generic/rte_io.h +47 -0
@@ -229,6 +229,39 @@ rte_write32(uint32_t value, volatile void *addr);static inline void rte_write64 (uint64_t value,volatile void *addr); +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write combining +* may not be available and/or may be treated as a hint and the behavior may +* fallback to a regular store. +* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to +*/ +static inline void +rte_write32_wc (uint32_t value,volatile void *addr); + +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write combining +* may not be available and/or may be treated as a hint and the behavior may +* fallback to a regular store. +* +* The relaxed version does not have additional I/O memory barrier, useful in +* accessing the device registers of integrated controllers which implicitly +* strongly ordered with respect to memory access. +* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to +*/ +static inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr); + +#endif /* __DOXYGEN__ */ #ifndef RTE_OVERRIDE_IO_H
@@ -345,6 +378,20 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +#ifndef RTE_NATIVE_WRITE32_WC +rte_write32_wc(uint32_t value, volatile void *addr) +{ +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +rte_write32_relaxed (value, addr); +} +#endif /* RTE_NATIVE_WRITE32_WC */ + +#endif /* RTE_OVERRIDE_IO_H */ #endif /* _RTE_IO_H_ */
lib/librte_eal/x86/include/rte_io.h +59 -0
67 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 2/2 net/i40e: use WC store to update queue tail registers
Performance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/net/i40e/base/i40e_osdep.h | 6 ++++++ drivers/net/i40e/i40e_rxtx.c | 8 ++++---- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 ++-- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 ++-- 4 files changed, 14 insertions(+), 8 deletions(-)
drivers/net/i40e/base/i40e_osdep.h +6 -0
@@ -138,6 +138,12 @@ static inline uint32_t i40e_read_addr(volatile void *addr)#define I40E_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE (queue, reg, value) \ + rte_write32_wc((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE_RELAXED (queue, reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) + +#define I40E_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_GLGEN_STAT)#define I40EVF_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_VFGEN_RSTAT)
drivers/net/i40e/i40e_rxtx.c +4 -4
@@ -760,7 +760,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -938,7 +938,7 @@ i40e_recv_scattered_pkts(void *rx_queue,if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t )(rx_id ==0 ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -1249,7 +1249,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) (unsigned) tx_id, (unsigned) nb_tx);rte_cio_wmb (); -I40E_PCI_REG_WRITE_RELAXED (txq->qtx_tail, tx_id); +I40E_PCI_REG_WC_WRITE_RELAXED (txq, txq->qtx_tail, tx_id); txq->tx_tail = tx_id;return nb_tx;
@@ -1400,7 +1400,7 @@ tx_xmit_pkts(struct i40e_tx_queue *txq, txq->tx_tail =0 ;/* Update the tx tail register */ -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_avx2.c +2 -2
@@ -134,7 +134,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -921,7 +921,7 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_sse.c +2 -2
@@ -86,7 +86,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -733,7 +733,7 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v2 2/2] net/i40e: use WC store to update queue tail registers
Quoted 6 lines · Radu Nicolau
Performance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
Signed-off-by Radu Nicolau <[email protected]>---
I assume there are plans to update other drivers similarly in future?
Re: [dpdk-dev] [PATCH v2 1/2] eal: add WC store functions
In reply to Radu NicolauQuoted 8 lines · Radu Nicolau
Add
rte_write32_wcandrte_write32_wc_relaxedfunctions that implement 32bit stores using write combining memory protocol. Provided generic stubs and x86 implementation.Signed-off-by Radu Nicolau <[email protected]>---
v2 rework new eal io functions
I think you need to add into the cover letter, as suggest on V1 by Konstantin, a bit about using WC memory for better performance.
Quoted 58 lines
lib/librte_eal/include/generic/rte_io.h | 47 ++++++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 59 +++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+)lib/librte_eal/include/generic/rte_io.h +39
-0@@ -229,6 +229,39 @@ rte_write32(uint32_t value, volatile void *addr);static inline void rte_write64 (uint64_t value,volatile void *addr); +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write combining +* may not be available and/or may be treated as a hint and the behavior may +* fallback to a regular store. +* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to +*/ +static inline void +rte_write32_wc (uint32_t value,volatile void *addr); + +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write combining +* may not be available and/or may be treated as a hint and the behavior may +* fallback to a regular store. +* +* The relaxed version does not have additional I/O memory barrier, useful in +* accessing the device registers of integrated controllers which implicitly +* strongly ordered with respect to memory access. +* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to +*/ +static inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr); + +#endif /* __DOXYGEN__ */ #ifndef RTE_OVERRIDE_IO_H @@ -345,6 +378,20 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +#ifndef RTE_NATIVE_WRITE32_WC +rte_write32_wc(uint32_t value, volatile void *addr) +{ +rte_write32 (value, addr); +} +
lib/librte_eal/include/generic/rte_io.h rte_write64(uint64_t value, volatile void *addr) · line 396
Quoted 10 lines
lib/librte_eal/include/generic/rte_io.h +8
-0+static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +rte_write32_relaxed (value, addr); +} +#endif /* RTE_NATIVE_WRITE32_WC */ + +#endif /* RTE_OVERRIDE_IO_H */
I like this approach, since it saves duplicating the non-overridden functions. Nice!
Quoted 60 lines
lib/librte_eal/include/generic/rte_io.h +0
-0#endif /* _RTE_IO_H_ */ lib/librte_eal/x86/include/rte_io.h +49
-0@@ -9,8 +9,67 @@extern "C" {#endif +#include "rte_cpuflags.h" + +#define RTE_NATIVE_WRITE32_WC #include "generic/rte_io.h" +/** +* @internal +* MOVDIRI wrapper. +*/ +static __rte_always_inline void +_rte_x86_movdiri (uint32_t value,volatile void *addr) +{ + asmvolatile ( +/* MOVDIRI */ +".byte 0x40, 0x0f, 0x38, 0xf9, 0x02" + : + :"a" (value),"d" (addr)); +} + +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) +{ +static int _x86_movdiri_flag =-1 ; +if (_x86_movdiri_flag ==1 ) { +rte_wmb (); +_rte_x86_movdiri (value, addr); + }else if (_x86_movdiri_flag ==0 ) { +rte_write32 (value, addr); + }else { + _x86_movdiri_flag = + (rte_cpu_get_flag_enabled (RTE_CPUFLAG_MOVDIRI ) >0 ); +if (_x86_movdiri_flag ==1 ) { +rte_wmb (); +_rte_x86_movdiri (value, addr); + }else { +rte_write32 (value, addr); + } + } +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +static int _x86_movdiri_flag =-1 ; +if (_x86_movdiri_flag ==1 ) { +_rte_x86_movdiri (value, addr); + }else if (_x86_movdiri_flag ==0 ) { +rte_write32_relaxed (value, addr); + }else { + _x86_movdiri_flag = + (rte_cpu_get_flag_enabled (RTE_CPUFLAG_MOVDIRI ) >0 );
lib/librte_eal/x86/include/rte_io.h line 72
Quoted 10 lines
lib/librte_eal/x86/include/rte_io.h +10
-0+if (_x86_movdiri_flag ==1 ) +_rte_x86_movdiri (value, addr); +else +rte_write32_relaxed (value, addr); + } +} + + + +
Rather a lot of whitespace here.
Quoted 5 lines
lib/librte_eal/x86/include/rte_io.h +0
-0#ifdef __cplusplus }#endif Signature · 1 line
2.7.4
With the nits called out above fixed:
v3 cover eal: add WC store functions
In reply to Radu NicolauImplement 2 new functions that will enable write combining stores depending on architecture. The functions are provided as a generic stub and a x86 specific implementation.
The reason to implement these functions is to improve performance by reducing the overhead associated with regular mmio writes when updating the hardware queue tails and doorbells.
With this patch set the I40E PMD is updated to use the write combining store functions with other PMDs to follow.
Radu Nicolau (2):
eal: add WC store functions
net/i40e: use WC store to update queue tail registers
drivers/net/i40e/base/i40e_osdep.h | 6 ++++ drivers/net/i40e/i40e_rxtx.c | 8 ++--- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 +-- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 +-- lib/librte_eal/include/generic/rte_io.h | 47 +++++++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 56 +++++++++++++++++++++++++++++++++ 6 files changed, 117 insertions(+), 8 deletions(-)
Signature · 1 line
2.7.4
PATCH v3 1/2 eal: add WC store functions
Add rte_write32_wc and rte_write32_wc_relaxed functions that implement 32bit stores using write combining memory protocol. Provided generic stubs and x86 implementation.
--- lib/librte_eal/include/generic/rte_io.h | 47 +++++++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 56 +++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+)
lib/librte_eal/include/generic/rte_io.h +47 -0
@@ -229,6 +229,39 @@ rte_write32(uint32_t value, volatile void *addr);static inline void rte_write64 (uint64_t value,volatile void *addr); +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write combining +* may not be available and/or may be treated as a hint and the behavior may +* fallback to a regular store. +* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to +*/ +static inline void +rte_write32_wc (uint32_t value,volatile void *addr); + +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write combining +* may not be available and/or may be treated as a hint and the behavior may +* fallback to a regular store. +* +* The relaxed version does not have additional I/O memory barrier, useful in +* accessing the device registers of integrated controllers which implicitly +* strongly ordered with respect to memory access. +* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to +*/ +static inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr); + +#endif /* __DOXYGEN__ */ #ifndef RTE_OVERRIDE_IO_H
@@ -345,6 +378,20 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +#ifndef RTE_NATIVE_WRITE32_WC +rte_write32_wc(uint32_t value, volatile void *addr) +{ +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +rte_write32_relaxed (value, addr); +} +#endif /* RTE_NATIVE_WRITE32_WC */ + +#endif /* RTE_OVERRIDE_IO_H */ #endif /* _RTE_IO_H_ */
lib/librte_eal/x86/include/rte_io.h +56 -0
64 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v3 2/2 net/i40e: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/net/i40e/base/i40e_osdep.h | 6 ++++++ drivers/net/i40e/i40e_rxtx.c | 8 ++++---- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 ++-- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 ++-- 4 files changed, 14 insertions(+), 8 deletions(-)
drivers/net/i40e/base/i40e_osdep.h +6 -0
@@ -138,6 +138,12 @@ static inline uint32_t i40e_read_addr(volatile void *addr)#define I40E_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE (queue, reg, value) \ + rte_write32_wc((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE_RELAXED (queue, reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) + +#define I40E_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_GLGEN_STAT)#define I40EVF_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_VFGEN_RSTAT)
drivers/net/i40e/i40e_rxtx.c +4 -4
@@ -760,7 +760,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -938,7 +938,7 @@ i40e_recv_scattered_pkts(void *rx_queue,if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t )(rx_id ==0 ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -1249,7 +1249,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) (unsigned) tx_id, (unsigned) nb_tx);rte_cio_wmb (); -I40E_PCI_REG_WRITE_RELAXED (txq->qtx_tail, tx_id); +I40E_PCI_REG_WC_WRITE_RELAXED (txq, txq->qtx_tail, tx_id); txq->tx_tail = tx_id;return nb_tx;
@@ -1400,7 +1400,7 @@ tx_xmit_pkts(struct i40e_tx_queue *txq, txq->tx_tail =0 ;/* Update the tx tail register */ -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_avx2.c +2 -2
@@ -134,7 +134,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -921,7 +921,7 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_sse.c +2 -2
@@ -86,7 +86,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -733,7 +733,7 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.7.4
v4 cover eal: add WC store functions
In reply to Radu NicolauImplement 2 new functions that will enable write combining stores depending on architecture. The functions are provided as a generic stub and a x86 specific implementation.
The reason to implement these functions is to improve performance by reducing the overhead associated with regular mmio writes when updating the hardware queue tails and doorbells.
With this patch set the I40E PMD is updated to use the write combining store functions with other PMDs to follow.
Radu Nicolau (2):
eal: add WC store functions
net/i40e: use WC store to update queue tail registers
drivers/net/i40e/base/i40e_osdep.h | 6 ++++ drivers/net/i40e/i40e_rxtx.c | 8 ++--- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 +-- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 +-- lib/librte_eal/include/generic/rte_io.h | 47 +++++++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 56 +++++++++++++++++++++++++++++++++ 6 files changed, 117 insertions(+), 8 deletions(-)
Signature · 1 line
2.7.4
PATCH v4 1/2 eal: add WC store functions
Add rte_write32_wc and rte_write32_wc_relaxed functions that implement 32bit stores using write combining memory protocol. Provided generic stubs and x86 implementation.
---
v4: address feedback and include ack
lib/librte_eal/include/generic/rte_io.h | 47 +++++++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 56 +++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+)
lib/librte_eal/include/generic/rte_io.h +47 -0
@@ -229,6 +229,39 @@ rte_write32(uint32_t value, volatile void *addr);static inline void rte_write64 (uint64_t value,volatile void *addr); +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write combining +* may not be available and/or may be treated as a hint and the behavior may +* fallback to a regular store. +* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to +*/ +static inline void +rte_write32_wc (uint32_t value,volatile void *addr); + +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write combining +* may not be available and/or may be treated as a hint and the behavior may +* fallback to a regular store. +* +* The relaxed version does not have additional I/O memory barrier, useful in +* accessing the device registers of integrated controllers which implicitly +* strongly ordered with respect to memory access. +* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to +*/ +static inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr); + +#endif /* __DOXYGEN__ */ #ifndef RTE_OVERRIDE_IO_H
@@ -345,6 +378,20 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +#ifndef RTE_NATIVE_WRITE32_WC +rte_write32_wc(uint32_t value, volatile void *addr) +{ +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +rte_write32_relaxed (value, addr); +} +#endif /* RTE_NATIVE_WRITE32_WC */ + +#endif /* RTE_OVERRIDE_IO_H */ #endif /* _RTE_IO_H_ */
lib/librte_eal/x86/include/rte_io.h +56 -0
64 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v4 1/2] eal: add WC store functions
Quoted 25 lines · Radu Nicolau
Add
rte_write32_wcandrte_write32_wc_relaxedfunctions that implement 32bit stores using write combining memory protocol. Provided generic stubs and x86 implementation.Signed-off-by Radu Nicolau <[email protected]>Acked-by Bruce Richardson <[email protected]>---
v4: address feedback and include acklib/librte_eal/include/generic/rte_io.h | 47 +++++++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 56 +++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+)lib/librte_eal/include/generic/rte_io.h +3
-0@@ -229,6 +229,39 @@ rte_write32(uint32_t value, volatile void *addr);static inline void rte_write64 (uint64_t value,volatile void *addr); +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write combining
lib/librte_eal/include/generic/rte_io.h rte_write32(uint32_t value, volatile void *addr); · line 244
Quoted 10 lines
lib/librte_eal/include/generic/rte_io.h +10
-0+* may not be available and/or may be treated as a hint and the behavior may +* fallback to a regular store. +* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to +*/ +static inline void +rte_write32_wc (uint32_t value,volatile void *addr);
This is a new API, and even if inlined, it should be marked experimental.
Is volatile necessary?
Quoted 10 lines
lib/librte_eal/include/generic/rte_io.h +10
-0+ +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write combining +* may not be available and/or may be treated as a hint and the behavior may +* fallback to a regular store. +* +* The relaxed version does not have additional I/O memory barrier, useful in +* accessing the device registers of integrated controllers which implicitly +* strongly ordered with respect to memory access.
lib/librte_eal/include/generic/rte_io.h rte_write32(uint32_t value, volatile void *addr); · line 264
Quoted 10 lines
lib/librte_eal/include/generic/rte_io.h +10
-0+* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to +*/ +static inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr); + +
Double empty line (there are some other in this patch that I won't flag again).
lib/librte_eal/include/generic/rte_io.h rte_write64(uint64_t value, volatile void *addr) · line 381
Quoted 8 lines
lib/librte_eal/include/generic/rte_io.h +1
-0#endif /* __DOXYGEN__ */ #ifndef RTE_OVERRIDE_IO_H @@ -345,6 +378,20 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +#ifndef RTE_NATIVE_WRITE32_WC
Missing return type, this causes build failure on anything but x86.
Quoted 21 lines
lib/librte_eal/include/generic/rte_io.h +13
-0+rte_write32_wc(uint32_t value, volatile void *addr) +{ +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +rte_write32_relaxed (value, addr); +} +#endif /* RTE_NATIVE_WRITE32_WC */ + +#endif /* RTE_OVERRIDE_IO_H */ #endif /* _RTE_IO_H_ */ lib/librte_eal/x86/include/rte_io.h +0
-0
lib/librte_eal/x86/include/rte_io.h line 12
Quoted 4 lines
lib/librte_eal/x86/include/rte_io.h +1
-0@@ -9,8 +9,64 @@extern "C" {#endif +#include "rte_cpuflags.h"
Inclusion of this header should be out of the extern "C" block.
Quoted 20 lines
lib/librte_eal/x86/include/rte_io.h +18
-0+ +#define RTE_NATIVE_WRITE32_WC #include "generic/rte_io.h" +/** +* @internal +* MOVDIRI wrapper. +*/ +static __rte_always_inline void +_rte_x86_movdiri (uint32_t value,volatile void *addr) +{ + asmvolatile ( +/* MOVDIRI */ +".byte 0x40, 0x0f, 0x38, 0xf9, 0x02" + : + :"a" (value),"d" (addr)); +} + +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr)
lib/librte_eal/x86/include/rte_io.h line 42
Quoted 10 lines
lib/librte_eal/x86/include/rte_io.h +10
-0+{ +static int _x86_movdiri_flag =-1 ; +if (_x86_movdiri_flag ==1 ) { +rte_wmb (); +_rte_x86_movdiri (value, addr); + }else if (_x86_movdiri_flag ==0 ) { +rte_write32 (value, addr); + }else { + _x86_movdiri_flag = + (rte_cpu_get_flag_enabled (RTE_CPUFLAG_MOVDIRI ) >0 );
Can't this cpu flag check be moved in a constructor? This would avoid this copy/paste.
lib/librte_eal/x86/include/rte_io.h line 55
Quoted 13 lines
lib/librte_eal/x86/include/rte_io.h +13
-0+if (_x86_movdiri_flag ==1 ) { +rte_wmb (); +_rte_x86_movdiri (value, addr); + }else { +rte_write32 (value, addr); + } + } +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +static int _x86_movdiri_flag =-1 ;
Same check with a static variable with the same name.
I wonder if wrapping all of this in a single function would be more elegant. Then rte_write32_wc(|_relaxed) would call it with a flag.
Quoted 20 lines
lib/librte_eal/x86/include/rte_io.h +14
-1+if (_x86_movdiri_flag ==1 ) { +_rte_x86_movdiri (value, addr); + }else if (_x86_movdiri_flag ==0 ) { +rte_write32_relaxed (value, addr); + }else { + _x86_movdiri_flag = + (rte_cpu_get_flag_enabled (RTE_CPUFLAG_MOVDIRI ) >0 ); +if (_x86_movdiri_flag ==1 ) +_rte_x86_movdiri (value, addr); +else +rte_write32_relaxed (value, addr); + } +} + #ifdef __cplusplus }#endif --2.7.4
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v4 1/2] eal: add WC store functions
Hi David, thanks for reviewing!
Some comments inline.
Quoted 4 lines · David Marchand
lib/librte_eal/include/generic/rte_io.h rte_write32(uint32_t value, volatile void *addr); · line 244
Quoted 2 lines · Radu Nicolau
lib/librte_eal/include/generic/rte_io.h +2
-0+static inline void +rte_write32_wc (uint32_t value,volatile void *addr);This is a new API, and even if inlined, it should be marked experimental.
Will do.
Quoted 1 line
Is volatile necessary?
Yes, most of these functions will be called on mmio addresses/volatile pointers. All other io functions have it.
Quoted 6 lines
lib/librte_eal/include/generic/rte_io.h +4
-0+static inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr); + +Double empty line (there are some other in this patch that I won't flag again).
I will check all occurrences.
Quoted 11 lines
lib/librte_eal/include/generic/rte_io.h rte_write64(uint64_t value, volatile void *addr) · line 381
Quoted 10 lines
#endif /* __DOXYGEN__ */ #ifndef RTE_OVERRIDE_IO_Hlib/librte_eal/include/generic/rte_io.h +1
-0@@ -345,6 +378,20 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +#ifndef RTE_NATIVE_WRITE32_WC Missing return type, this causes build failure on anything but x86.
Yes, got lost in the copy/paste. I will fix it in the next version
Quoted 26 lines
Quoted 26 lines
lib/librte_eal/include/generic/rte_io.h +13
-0+rte_write32_wc(uint32_t value, volatile void *addr) +{ +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +rte_write32_relaxed (value, addr); +} +#endif /* RTE_NATIVE_WRITE32_WC */ + +#endif /* RTE_OVERRIDE_IO_H */ #endif /* _RTE_IO_H_ */ lib/librte_eal/x86/include/rte_io.h +0
-0@@ -9,8 +9,64 @@extern "C" {#endif
Quoted 2 lines
lib/librte_eal/x86/include/rte_io.h line 12
Quoted 1 line
lib/librte_eal/x86/include/rte_io.h +1
-0+#include "rte_cpuflags.h" Inclusion of this header should be out of the extern "C" block.
Why? It is used elsewhere inside the extern "C" block e.g. x86/rte_spinlock.h
Quoted 26 lines
Quoted 26 lines
lib/librte_eal/x86/include/rte_io.h +22
-0+ +#define RTE_NATIVE_WRITE32_WC #include "generic/rte_io.h" +/** +* @internal +* MOVDIRI wrapper. +*/ +static __rte_always_inline void +_rte_x86_movdiri (uint32_t value,volatile void *addr) +{ + asmvolatile ( +/* MOVDIRI */ +".byte 0x40, 0x0f, 0x38, 0xf9, 0x02" + : + :"a" (value),"d" (addr)); +} + +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) +{ +static int _x86_movdiri_flag =-1 ; +if (_x86_movdiri_flag ==1 ) { +rte_wmb ();
Quoted 8 lines
lib/librte_eal/x86/include/rte_io.h line 42
Quoted 6 lines
lib/librte_eal/x86/include/rte_io.h +6
-0+_rte_x86_movdiri (value, addr); + }else if (_x86_movdiri_flag ==0 ) { +rte_write32 (value, addr); + }else { + _x86_movdiri_flag = + (rte_cpu_get_flag_enabled (RTE_CPUFLAG_MOVDIRI ) >0 );Can't this cpu flag check be moved in a constructor? This would avoid this copy/paste.
We evaluated this approach but it creates more problems than if fixes - it will need a variable that needs to be exported and there is no good place to put it.
Quoted 16 lines
Quoted 5 lines
lib/librte_eal/x86/include/rte_io.h +3
-0+if (_x86_movdiri_flag ==1 ) { +rte_wmb (); +_rte_x86_movdiri (value, addr);lib/librte_eal/x86/include/rte_io.h line 55
Quoted 10 lines
lib/librte_eal/x86/include/rte_io.h +10
-0+ }else { +rte_write32 (value, addr); + } + } +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +static int _x86_movdiri_flag =-1 ;Same check with a static variable with the same name.
It should be no problem, they are static local variables.
Quoted 4 lines
I wonder if wrapping all of this in a single function would be more elegant. Then
rte_write32_wc(|_relaxed)would call it with a flag.
Yes, it will be more elegant but also it will cost more, it was written like this to minimize the number of branches taken for the movdiri path.
PATCH v4 2/2 net/i40e: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
---
v4: include ack
drivers/net/i40e/base/i40e_osdep.h | 6 ++++++ drivers/net/i40e/i40e_rxtx.c | 8 ++++---- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 ++-- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 ++-- 4 files changed, 14 insertions(+), 8 deletions(-)
drivers/net/i40e/base/i40e_osdep.h +6 -0
@@ -138,6 +138,12 @@ static inline uint32_t i40e_read_addr(volatile void *addr)#define I40E_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE (queue, reg, value) \ + rte_write32_wc((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE_RELAXED (queue, reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) + +#define I40E_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_GLGEN_STAT)#define I40EVF_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_VFGEN_RSTAT)
drivers/net/i40e/i40e_rxtx.c +4 -4
@@ -760,7 +760,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -938,7 +938,7 @@ i40e_recv_scattered_pkts(void *rx_queue,if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t )(rx_id ==0 ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -1249,7 +1249,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) (unsigned) tx_id, (unsigned) nb_tx);rte_cio_wmb (); -I40E_PCI_REG_WRITE_RELAXED (txq->qtx_tail, tx_id); +I40E_PCI_REG_WC_WRITE_RELAXED (txq, txq->qtx_tail, tx_id); txq->tx_tail = tx_id;return nb_tx;
@@ -1400,7 +1400,7 @@ tx_xmit_pkts(struct i40e_tx_queue *txq, txq->tx_tail =0 ;/* Update the tx tail register */ -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_avx2.c +2 -2
@@ -134,7 +134,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -921,7 +921,7 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_sse.c +2 -2
@@ -86,7 +86,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -733,7 +733,7 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.7.4
v5 cover eal: add WC store functions
In reply to Radu NicolauImplement 2 new functions that will enable write combining stores depending on architecture. The functions are provided as a generic stub and a x86 specific implementation.
The reason to implement these functions is to improve performance by reducing the overhead associated with regular mmio writes when updating the hardware queue tails and doorbells.
With this patch set the I40E PMD is updated to use the write combining store functions with other PMDs to follow.
Radu Nicolau (2):
eal: add WC store functions
net/i40e: use WC store to update queue tail registers
drivers/net/i40e/base/i40e_osdep.h | 5 +++ drivers/net/i40e/i40e_rxtx.c | 8 ++--- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 +-- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 +-- lib/librte_eal/include/generic/rte_io.h | 48 ++++++++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 56 +++++++++++++++++++++++++++++++++ 6 files changed, 117 insertions(+), 8 deletions(-)
Signature · 1 line
2.7.4
PATCH v5 1/2 eal: add WC store functions
Add rte_write32_wc and rte_write32_wc_relaxed functions that implement 32bit stores using write combining memory protocol. Provided generic stubs and x86 implementation.
---
v5: small fixes after feedback
lib/librte_eal/include/generic/rte_io.h | 48 ++++++++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 56 +++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+)
lib/librte_eal/include/generic/rte_io.h +48 -0
@@ -229,6 +229,40 @@ rte_write32(uint32_t value, volatile void *addr);static inline void rte_write64 (uint64_t value,volatile void *addr); +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write combining +* may not be available and/or may be treated as a hint and the behavior may +* fallback to a regular store. +* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to +*/ +__rte_experimental +static inline void +rte_write32_wc (uint32_t value,volatile void *addr); + +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write combining +* may not be available and/or may be treated as a hint and the behavior may +* fallback to a regular store. +* +* The relaxed version does not have additional I/O memory barrier, useful in +* accessing the device registers of integrated controllers which implicitly +* strongly ordered with respect to memory access. +* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to +*/ +__rte_experimental +static inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr); +#endif /* __DOXYGEN__ */ #ifndef RTE_OVERRIDE_IO_H
@@ -345,6 +379,20 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +#ifndef RTE_NATIVE_WRITE32_WC +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) +{ +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +rte_write32_relaxed (value, addr); +} +#endif /* RTE_NATIVE_WRITE32_WC */ +#endif /* RTE_OVERRIDE_IO_H */ #endif /* _RTE_IO_H_ */
lib/librte_eal/x86/include/rte_io.h +56 -0
64 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v5 2/2 net/i40e: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
---
v5: small fixes after feedback
drivers/net/i40e/base/i40e_osdep.h | 5 +++++ drivers/net/i40e/i40e_rxtx.c | 8 ++++---- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 ++-- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-)
drivers/net/i40e/base/i40e_osdep.h +5 -0
@@ -138,6 +138,11 @@ static inline uint32_t i40e_read_addr(volatile void *addr)#define I40E_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE (queue, reg, value) \ + rte_write32_wc((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE_RELAXED (queue, reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_GLGEN_STAT)#define I40EVF_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_VFGEN_RSTAT)
drivers/net/i40e/i40e_rxtx.c +4 -4
@@ -760,7 +760,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -938,7 +938,7 @@ i40e_recv_scattered_pkts(void *rx_queue,if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t )(rx_id ==0 ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -1249,7 +1249,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) (unsigned) tx_id, (unsigned) nb_tx);rte_cio_wmb (); -I40E_PCI_REG_WRITE_RELAXED (txq->qtx_tail, tx_id); +I40E_PCI_REG_WC_WRITE_RELAXED (txq, txq->qtx_tail, tx_id); txq->tx_tail = tx_id;return nb_tx;
@@ -1400,7 +1400,7 @@ tx_xmit_pkts(struct i40e_tx_queue *txq, txq->tx_tail =0 ;/* Update the tx tail register */ -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_avx2.c +2 -2
@@ -134,7 +134,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -921,7 +921,7 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_sse.c +2 -2
@@ -86,7 +86,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -733,7 +733,7 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.7.4
v6 cover eal: add WC store functions
In reply to Radu NicolauImplement 2 new functions that will enable write combining stores depending on architecture. The functions are provided as a generic stub and a x86 specific implementation.
The reason to implement these functions is to improve performance by reducing the overhead associated with regular mmio writes when updating the hardware queue tails and doorbells.
With this patch set the I40E, IXGBE and QAT PMDs are updated to use the write combining store functions with other PMDs to follow.
Radu Nicolau (4):
eal: add WC store functions
net/i40e: use WC store to update queue tail registers
qat: use WC store to update queue tail registers net/ixgbe: use WC store to update doorbell register
.../qat/qat_adf/adf_transport_access_macros.h | 6 ++- drivers/net/i40e/base/i40e_osdep.h | 5 ++ drivers/net/i40e/i40e_rxtx.c | 8 ++-- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 +- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 +- drivers/net/ixgbe/base/ixgbe_osdep.h | 6 +++ drivers/net/ixgbe/ixgbe_rxtx.c | 4 +- drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 4 +- lib/librte_eal/include/generic/rte_io.h | 48 +++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 56 ++++++++++++++++++++++ 10 files changed, 131 insertions(+), 14 deletions(-)
Signature · 1 line
2.7.4
PATCH v6 1/4 eal: add WC store functions
Add rte_write32_wc and rte_write32_wc_relaxed functions that implement 32bit stores using write combining memory protocol. Provided generic stubs and x86 implementation.
---
v6: add QAT and IXGBE updates
lib/librte_eal/include/generic/rte_io.h | 48 ++++++++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 56 +++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+)
lib/librte_eal/include/generic/rte_io.h +48 -0
@@ -229,6 +229,40 @@ rte_write32(uint32_t value, volatile void *addr);static inline void rte_write64 (uint64_t value,volatile void *addr); +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write combining +* may not be available and/or may be treated as a hint and the behavior may +* fallback to a regular store. +* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to +*/ +__rte_experimental +static inline void +rte_write32_wc (uint32_t value,volatile void *addr); + +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write combining +* may not be available and/or may be treated as a hint and the behavior may +* fallback to a regular store. +* +* The relaxed version does not have additional I/O memory barrier, useful in +* accessing the device registers of integrated controllers which implicitly +* strongly ordered with respect to memory access. +* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to +*/ +__rte_experimental +static inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr); +#endif /* __DOXYGEN__ */ #ifndef RTE_OVERRIDE_IO_H
@@ -345,6 +379,20 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +#ifndef RTE_NATIVE_WRITE32_WC +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) +{ +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +rte_write32_relaxed (value, addr); +} +#endif /* RTE_NATIVE_WRITE32_WC */ +#endif /* RTE_OVERRIDE_IO_H */ #endif /* _RTE_IO_H_ */
lib/librte_eal/x86/include/rte_io.h +56 -0
64 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v6 2/4 net/i40e: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/net/i40e/base/i40e_osdep.h | 5 +++++ drivers/net/i40e/i40e_rxtx.c | 8 ++++---- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 ++-- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-)
drivers/net/i40e/base/i40e_osdep.h +5 -0
@@ -138,6 +138,11 @@ static inline uint32_t i40e_read_addr(volatile void *addr)#define I40E_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE (queue, reg, value) \ + rte_write32_wc((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE_RELAXED (queue, reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_GLGEN_STAT)#define I40EVF_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_VFGEN_RSTAT)
drivers/net/i40e/i40e_rxtx.c +4 -4
@@ -760,7 +760,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -938,7 +938,7 @@ i40e_recv_scattered_pkts(void *rx_queue,if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t )(rx_id ==0 ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -1249,7 +1249,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) (unsigned) tx_id, (unsigned) nb_tx);rte_cio_wmb (); -I40E_PCI_REG_WRITE_RELAXED (txq->qtx_tail, tx_id); +I40E_PCI_REG_WC_WRITE_RELAXED (txq, txq->qtx_tail, tx_id); txq->tx_tail = tx_id;return nb_tx;
@@ -1400,7 +1400,7 @@ tx_xmit_pkts(struct i40e_tx_queue *txq, txq->tx_tail =0 ;/* Update the tx tail register */ -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_avx2.c +2 -2
@@ -134,7 +134,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -921,7 +921,7 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_sse.c +2 -2
@@ -86,7 +86,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -733,7 +733,7 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.7.4
PATCH v6 3/4 qat: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/common/qat/qat_adf/adf_transport_access_macros.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/common/qat/qat_adf/adf_transport_access_macros.h +4 -2
@@ -9,6 +9,8 @@/* CSR write macro */ #define ADF_CSR_WR (csrAddr, csrOffset, val) \ rte_write32(val, (((uint8_t *)csrAddr) + csrOffset)) +#define ADF_CSR_WC_WR (csrAddr, csrOffset, val) \ + rte_write32_wc(val, (((uint8_t *)csrAddr) + csrOffset))/* CSR read macro */ #define ADF_CSR_RD (csrAddr, csrOffset) \
@@ -110,10 +112,10 @@ do { \ ADF_RING_CSR_RING_UBASE + (ring << 2), u_base); \ } while (0)#define WRITE_CSR_RING_HEAD (csr_base_addr, bank, ring, value) \ - ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ + ADF_CSR_WC_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ ADF_RING_CSR_RING_HEAD + (ring << 2), value)#define WRITE_CSR_RING_TAIL (csr_base_addr, bank, ring, value) \ - ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ + ADF_CSR_WC_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ ADF_RING_CSR_RING_TAIL + (ring << 2), value)#define WRITE_CSR_INT_SRCSEL (csr_base_addr, bank) \ do { \
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v6 3/4] qat: use WC store to update queue tail registers
Quoted 6 lines · Radu Nicolau
Performance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
Signed-off-by Radu Nicolau <[email protected]>---
minor nit, I think the subject prefix on the patch should be crypto/qat.
Re: [dpdk-dev] [PATCH v6 3/4] qat: use WC store to update queue tail registers
Quoted 11 lines
-----Original Message-----
From: Bruce Richardson <[email protected]>
Sent: Monday, July 13, 2020 1:45 PM
To: Nicolau, Radu <[email protected]>
Cc: [email protected]; Xing, Beilei <[email protected]>; Guo, Jia <[email protected]>; Ananyev, Konstantin <[email protected]>; [email protected]; [email protected]; Trahe, Fiona <[email protected]>; Zhao1, Wei <[email protected]>
Subject: Re: [PATCH v6 3/4] qat: use WC store to update queue tail registers
Quoted 8 lines
Quoted 6 lines · Radu Nicolau
Performance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
Signed-off-by Radu Nicolau <[email protected]>---
minor nit, I think the subject prefix on the patch should be
crypto/qat.
when it affects all qat PMDs, i.e. crypto sym, crypto asym and compression, as this does we usually use drivers/qat
Re: [dpdk-dev] [PATCH v6 3/4] qat: use WC store to update queue tail registers
Quoted 16 lines · Fiona
Quoted 16 lines
-----Original Message-----
From: Bruce Richardson <[email protected]>
Sent: Monday, July 13, 2020 1:45 PM
To: Nicolau, Radu <[email protected]>
Cc: [email protected]; Xing, Beilei <[email protected]>; Guo, Jia <[email protected]>; Ananyev, Konstantin <[email protected]>; [email protected]; [email protected]; Trahe, Fiona <[email protected]>; Zhao1, Wei <[email protected]>
Subject: Re: [PATCH v6 3/4] qat: use WC store to update queue tail registersQuoted 4 lines · Radu Nicolau
Performance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
Signed-off-by Radu Nicolau <[email protected]>---
minor nit, I think the subject prefix on the patch should be
crypto/qat.when it affects all qat PMDs, i.e. crypto sym, crypto asym and compression, as this does we usually use
drivers/qat
Ah, yes, sorry, I forgot that there was more than one qat directory in drivers. In this case, the changes are in common only, so common/qat would seem to be the right prefix. Not that it matters to the patch functionality, mind... :-)
PATCH v6 4/4 net/ixgbe: use WC store to update doorbell register
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/net/ixgbe/base/ixgbe_osdep.h | 6 ++++++ drivers/net/ixgbe/ixgbe_rxtx.c | 4 ++-- drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-)
drivers/net/ixgbe/base/ixgbe_osdep.h +6 -0
@@ -105,6 +105,12 @@ static inline uint32_t ixgbe_read_addr(volatile void* addr)#define IXGBE_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#define IXGBE_PCI_REG_WC_WRITE (reg, value) \ + rte_write32_wc((rte_cpu_to_le_32(value)), reg) + +#define IXGBE_PCI_REG_WC_WRITE_RELAXED (reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) +#define IXGBE_PCI_REG_ADDR (hw, reg) \ ((volatile uint32_t *)((char *)(hw)->hw_addr + (reg)))
drivers/net/ixgbe/ixgbe_rxtx.c +2 -2
@@ -308,7 +308,7 @@ tx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,/* update tail pointer */ rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (txq->tdt_reg_addr, txq->tx_tail); +IXGBE_PCI_REG_WC_WRITE_RELAXED (txq->tdt_reg_addr, txq->tx_tail);return nb_pkts; }
@@ -1918,7 +1918,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, (unsigned) nb_rx); rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -IXGBE_PCI_REG_WRITE (rxq->rdt_reg_addr, rx_id); +IXGBE_PCI_REG_WC_WRITE (rxq->rdt_reg_addr, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +2 -2
@@ -90,7 +90,7 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -IXGBE_PCI_REG_WRITE (rxq->rdt_reg_addr, rx_id); +IXGBE_PCI_REG_WC_WRITE (rxq->rdt_reg_addr, rx_id); }#ifdef RTE_LIBRTE_SECURITY
@@ -697,7 +697,7 @@ ixgbe_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -IXGBE_PCI_REG_WRITE (txq->tdt_reg_addr, txq->tx_tail); +IXGBE_PCI_REG_WC_WRITE (txq->tdt_reg_addr, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.7.4
v7 cover eal: add WC store functions
In reply to Radu NicolauImplement 2 new functions that will enable write combining stores depending on architecture. The functions are provided as a generic stub and a x86 specific implementation.
The reason to implement these functions is to improve performance by reducing the overhead associated with regular mmio writes when updating the hardware queue tails and doorbells.
With this patch set the I40E, IXGBE and QAT PMDs are updated to use the write combining store functions with other PMDs to follow.
Radu Nicolau (4):
eal: add WC store functions
net/i40e: use WC store to update queue tail registers common/qat: use WC store to update queue tail registers net/ixgbe: use WC store to update doorbell register
.../qat/qat_adf/adf_transport_access_macros.h | 6 ++- drivers/net/i40e/base/i40e_osdep.h | 5 ++ drivers/net/i40e/i40e_rxtx.c | 8 ++-- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 +- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 +- drivers/net/ixgbe/base/ixgbe_osdep.h | 6 +++ drivers/net/ixgbe/ixgbe_rxtx.c | 4 +- drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 4 +- lib/librte_eal/arm/include/rte_io_64.h | 12 +++++ lib/librte_eal/include/generic/rte_io.h | 48 +++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 56 ++++++++++++++++++++++ 11 files changed, 143 insertions(+), 14 deletions(-)
Signature · 1 line
2.7.4
PATCH v7 1/4 eal: add WC store functions
Add rte_write32_wc and rte_write32_wc_relaxed functions that implement 32bit stores using write combining memory protocol. Provided generic stubs and x86 implementation.
---
v7: fix ARM64 build
lib/librte_eal/arm/include/rte_io_64.h | 12 +++++++ lib/librte_eal/include/generic/rte_io.h | 48 ++++++++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 56 +++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+)
lib/librte_eal/arm/include/rte_io_64.h +12 -0
@@ -164,6 +164,18 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) +{ +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +rte_write32_relaxed (value, addr); +} + #ifdef __cplusplus }#endif
lib/librte_eal/include/generic/rte_io.h +48 -0
60 lines not on this page · raw message
lib/librte_eal/x86/include/rte_io.h +56 -0
64 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v7 2/4 net/i40e: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/net/i40e/base/i40e_osdep.h | 5 +++++ drivers/net/i40e/i40e_rxtx.c | 8 ++++---- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 ++-- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-)
drivers/net/i40e/base/i40e_osdep.h +5 -0
@@ -138,6 +138,11 @@ static inline uint32_t i40e_read_addr(volatile void *addr)#define I40E_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE (queue, reg, value) \ + rte_write32_wc((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE_RELAXED (queue, reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_GLGEN_STAT)#define I40EVF_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_VFGEN_RSTAT)
drivers/net/i40e/i40e_rxtx.c +4 -4
@@ -760,7 +760,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -938,7 +938,7 @@ i40e_recv_scattered_pkts(void *rx_queue,if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t )(rx_id ==0 ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -1249,7 +1249,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) (unsigned) tx_id, (unsigned) nb_tx);rte_cio_wmb (); -I40E_PCI_REG_WRITE_RELAXED (txq->qtx_tail, tx_id); +I40E_PCI_REG_WC_WRITE_RELAXED (txq, txq->qtx_tail, tx_id); txq->tx_tail = tx_id;return nb_tx;
@@ -1400,7 +1400,7 @@ tx_xmit_pkts(struct i40e_tx_queue *txq, txq->tx_tail =0 ;/* Update the tx tail register */ -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_avx2.c +2 -2
@@ -134,7 +134,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -921,7 +921,7 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_sse.c +2 -2
@@ -86,7 +86,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -733,7 +733,7 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.7.4
PATCH v7 3/4 common/qat: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/common/qat/qat_adf/adf_transport_access_macros.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/common/qat/qat_adf/adf_transport_access_macros.h +4 -2
@@ -9,6 +9,8 @@/* CSR write macro */ #define ADF_CSR_WR (csrAddr, csrOffset, val) \ rte_write32(val, (((uint8_t *)csrAddr) + csrOffset)) +#define ADF_CSR_WC_WR (csrAddr, csrOffset, val) \ + rte_write32_wc(val, (((uint8_t *)csrAddr) + csrOffset))/* CSR read macro */ #define ADF_CSR_RD (csrAddr, csrOffset) \
@@ -110,10 +112,10 @@ do { \ ADF_RING_CSR_RING_UBASE + (ring << 2), u_base); \ } while (0)#define WRITE_CSR_RING_HEAD (csr_base_addr, bank, ring, value) \ - ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ + ADF_CSR_WC_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ ADF_RING_CSR_RING_HEAD + (ring << 2), value)#define WRITE_CSR_RING_TAIL (csr_base_addr, bank, ring, value) \ - ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ + ADF_CSR_WC_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ ADF_RING_CSR_RING_TAIL + (ring << 2), value)#define WRITE_CSR_INT_SRCSEL (csr_base_addr, bank) \ do { \
Signature · 1 line
2.7.4
PATCH v7 4/4 net/ixgbe: use WC store to update doorbell register
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/net/ixgbe/base/ixgbe_osdep.h | 6 ++++++ drivers/net/ixgbe/ixgbe_rxtx.c | 4 ++-- drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-)
drivers/net/ixgbe/base/ixgbe_osdep.h +6 -0
@@ -105,6 +105,12 @@ static inline uint32_t ixgbe_read_addr(volatile void* addr)#define IXGBE_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#define IXGBE_PCI_REG_WC_WRITE (reg, value) \ + rte_write32_wc((rte_cpu_to_le_32(value)), reg) + +#define IXGBE_PCI_REG_WC_WRITE_RELAXED (reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) +#define IXGBE_PCI_REG_ADDR (hw, reg) \ ((volatile uint32_t *)((char *)(hw)->hw_addr + (reg)))
drivers/net/ixgbe/ixgbe_rxtx.c +2 -2
@@ -308,7 +308,7 @@ tx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,/* update tail pointer */ rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (txq->tdt_reg_addr, txq->tx_tail); +IXGBE_PCI_REG_WC_WRITE_RELAXED (txq->tdt_reg_addr, txq->tx_tail);return nb_pkts; }
@@ -1918,7 +1918,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, (unsigned) nb_rx); rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -IXGBE_PCI_REG_WRITE (rxq->rdt_reg_addr, rx_id); +IXGBE_PCI_REG_WC_WRITE (rxq->rdt_reg_addr, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +2 -2
@@ -90,7 +90,7 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -IXGBE_PCI_REG_WRITE (rxq->rdt_reg_addr, rx_id); +IXGBE_PCI_REG_WC_WRITE (rxq->rdt_reg_addr, rx_id); }#ifdef RTE_LIBRTE_SECURITY
@@ -697,7 +697,7 @@ ixgbe_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -IXGBE_PCI_REG_WRITE (txq->tdt_reg_addr, txq->tx_tail); +IXGBE_PCI_REG_WC_WRITE (txq->tdt_reg_addr, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.7.4
v8 cover eal: add WC store functions
In reply to Radu NicolauImplement 2 new functions that will enable write combining stores depending on architecture. The functions are provided as a generic stub and a x86 specific implementation.
The reason to implement these functions is to improve performance by reducing the overhead associated with regular mmio writes when updating the hardware queue tails and doorbells.
With this patch set the I40E, IXGBE and QAT PMDs are updated to use the write combining store functions with other PMDs to follow.
Radu Nicolau (4):
eal: add WC store functions
net/i40e: use WC store to update queue tail registers common/qat: use WC store to update queue tail registers net/ixgbe: use WC store to update queue tail registers
.../qat/qat_adf/adf_transport_access_macros.h | 6 ++- drivers/net/i40e/base/i40e_osdep.h | 5 ++ drivers/net/i40e/i40e_rxtx.c | 8 ++-- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 +- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 +- drivers/net/ixgbe/base/ixgbe_osdep.h | 6 +++ drivers/net/ixgbe/ixgbe_rxtx.c | 12 ++--- drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 4 +- lib/librte_eal/arm/include/rte_io_64.h | 12 +++++ lib/librte_eal/include/generic/rte_io.h | 48 +++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 56 ++++++++++++++++++++++ 11 files changed, 147 insertions(+), 18 deletions(-)
Signature · 1 line
2.7.4
PATCH v8 1/4 eal: add WC store functions
Add rte_write32_wc and rte_write32_wc_relaxed functions that implement 32bit stores using write combining memory protocol. Provided generic stubs and x86 implementation.
--- lib/librte_eal/arm/include/rte_io_64.h | 12 +++++++ lib/librte_eal/include/generic/rte_io.h | 48 ++++++++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 56 +++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+)
lib/librte_eal/arm/include/rte_io_64.h +12 -0
@@ -164,6 +164,18 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) +{ +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +rte_write32_relaxed (value, addr); +} + #ifdef __cplusplus }#endif
lib/librte_eal/include/generic/rte_io.h +48 -0
60 lines not on this page · raw message
lib/librte_eal/x86/include/rte_io.h +56 -0
64 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v8 1/4] eal: add WC store functions
Quoted 54 lines
-----Original Message-----
From: Radu Nicolau <[email protected]>
Sent: Friday, July 17, 2020 6:50 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ruifeng Wang <[email protected]>; Radu Nicolau <[email protected]>
Subject: [PATCH v8 1/4] eal: add WC store functionsAdd
rte_write32_wcandrte_write32_wc_relaxedfunctions that implement 32bit stores using write combining memory protocol. Provided generic stubs and x86 implementation.Signed-off-by Radu Nicolau <[email protected]>Acked-by Bruce Richardson <[email protected]>--- lib/librte_eal/arm/include/rte_io_64.h | 12 +++++++ lib/librte_eal/include/generic/rte_io.h | 48 ++++++++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 56 +++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+)lib/librte_eal/arm/include/rte_io_64.h +10
-0@@ -164,6 +164,18 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) { +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) { +rte_write32_relaxed (value, addr); +} + #ifdef __cplusplus }#endif lib/librte_eal/include/generic/rte_io.h +0
-0
lib/librte_eal/include/generic/rte_io.h rte_write32(uint32_t value, volatile void *addr); · line 237
Quoted 9 lines
lib/librte_eal/include/generic/rte_io.h +7
-0@@ -229,6 +229,40 @@ rte_write32(uint32_t value, volatile void *addr);static inline void rte_write64 (uint64_t value,volatile void *addr); +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write +combining +* may not be available and/or may be treated as a hint and the +behavior may +* fallback to a regular store.
I'm trying to understand write combining use cases here. Is it applicable for all MMIO writes?
How to identify where to use rte_write32_wc(_relaxed)?
Thanks.
/Ruifeng
Quoted 121 lines
lib/librte_eal/include/generic/rte_io.h +40
-0+* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to */ __rte_experimental +static inline void rte_write32_wc(uint32_t value, volatile void *addr); + +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write +combining +* may not be available and/or may be treated as a hint and the +behavior may +* fallback to a regular store. +* +* The relaxed version does not have additional I/O memory barrier, +useful in +* accessing the device registers of integrated controllers which +implicitly +* strongly ordered with respect to memory access. +* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to */ __rte_experimental +static inline void rte_write32_wc_relaxed(uint32_t value, volatile void +*addr); +#endif /* __DOXYGEN__ */ #ifndef RTE_OVERRIDE_IO_H @@ -345,6 +379,20 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +#ifndef RTE_NATIVE_WRITE32_WC +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) { +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) { +rte_write32_relaxed (value, addr); +} +#endif /* RTE_NATIVE_WRITE32_WC */ +#endif /* RTE_OVERRIDE_IO_H */ #endif /* _RTE_IO_H_ */ lib/librte_eal/x86/include/rte_io.h +53
-1@@ -9,8 +9,64 @@extern "C" {#endif +#include "rte_cpuflags.h" + +#define RTE_NATIVE_WRITE32_WC #include "generic/rte_io.h" +/** +* @internal +* MOVDIRI wrapper. +*/ +static __rte_always_inline void +_rte_x86_movdiri (uint32_t value,volatile void *addr) { + asmvolatile ( +/* MOVDIRI */ +".byte 0x40, 0x0f, 0x38, 0xf9, 0x02" + : + :"a" (value),"d" (addr)); +} + +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) { +static int _x86_movdiri_flag =-1 ; +if (_x86_movdiri_flag ==1 ) { +rte_wmb (); +_rte_x86_movdiri (value, addr); + }else if (_x86_movdiri_flag ==0 ) { +rte_write32 (value, addr); + }else { + _x86_movdiri_flag = + (rte_cpu_get_flag_enabled (RTE_CPUFLAG_MOVDIRI ) >0 ); +if (_x86_movdiri_flag ==1 ) { +rte_wmb (); +_rte_x86_movdiri (value, addr); + }else { +rte_write32 (value, addr); + } + } +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) { +static int _x86_movdiri_flag =-1 ; +if (_x86_movdiri_flag ==1 ) { +_rte_x86_movdiri (value, addr); + }else if (_x86_movdiri_flag ==0 ) { +rte_write32_relaxed (value, addr); + }else { + _x86_movdiri_flag = + (rte_cpu_get_flag_enabled (RTE_CPUFLAG_MOVDIRI ) >0 ); +if (_x86_movdiri_flag ==1 ) +_rte_x86_movdiri (value, addr); +else +rte_write32_relaxed (value, addr); + } +} + #ifdef __cplusplus }#endif --2.7.4
Re: [dpdk-dev] [PATCH v8 1/4] eal: add WC store functions
Quoted 55 lines · Ruifeng Wang
Quoted 55 lines
-----Original Message-----
From: Radu Nicolau <[email protected]>
Sent: Friday, July 17, 2020 6:50 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ruifeng Wang <[email protected]>; Radu Nicolau <[email protected]>
Subject: [PATCH v8 1/4] eal: add WC store functionsAdd
rte_write32_wcandrte_write32_wc_relaxedfunctions that implement 32bit stores using write combining memory protocol. Provided generic stubs and x86 implementation.Signed-off-by Radu Nicolau <[email protected]>Acked-by Bruce Richardson <[email protected]>--- lib/librte_eal/arm/include/rte_io_64.h | 12 +++++++ lib/librte_eal/include/generic/rte_io.h | 48 ++++++++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 56 +++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+)lib/librte_eal/arm/include/rte_io_64.h +10
-0@@ -164,6 +164,18 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) { +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) { +rte_write32_relaxed (value, addr); +} + #ifdef __cplusplus }#endif lib/librte_eal/include/generic/rte_io.h +0
-0@@ -229,6 +229,40 @@ rte_write32(uint32_t value, volatile void *addr);static inline void rte_write64 (uint64_t value,volatile void *addr);
Quoted 9 lines
lib/librte_eal/include/generic/rte_io.h rte_write32(uint32_t value, volatile void *addr); · line 237
Quoted 7 lines
lib/librte_eal/include/generic/rte_io.h +7
-0+/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write +combining +* may not be available and/or may be treated as a hint and the +behavior may +* fallback to a regular store. I'm trying to understand write combining use cases here. Is it applicable for all MMIO writes?
It's dependant on the architecture and specific use case, but generally this is a good usecase, updating the tail registers. It has some particularities that prevents it to be a replacement for mmio writes, it is weakly ordered and it will bypass the cache hierarchy.
Quoted 1 line
How to identify where to use
rte_write32_wc(_relaxed)?
The relaxed version can be used is sections of the code that already have the proper fencing, as to avoid having a redundant memory fence, or when there is no need to have a memory fence at all.
Quoted 124 lines
Thanks.
/RuifengQuoted 121 lines
lib/librte_eal/include/generic/rte_io.h +40
-0+* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to */ __rte_experimental +static inline void rte_write32_wc(uint32_t value, volatile void *addr); + +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write +combining +* may not be available and/or may be treated as a hint and the +behavior may +* fallback to a regular store. +* +* The relaxed version does not have additional I/O memory barrier, +useful in +* accessing the device registers of integrated controllers which +implicitly +* strongly ordered with respect to memory access. +* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to */ __rte_experimental +static inline void rte_write32_wc_relaxed(uint32_t value, volatile void +*addr); +#endif /* __DOXYGEN__ */ #ifndef RTE_OVERRIDE_IO_H @@ -345,6 +379,20 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +#ifndef RTE_NATIVE_WRITE32_WC +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) { +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) { +rte_write32_relaxed (value, addr); +} +#endif /* RTE_NATIVE_WRITE32_WC */ +#endif /* RTE_OVERRIDE_IO_H */ #endif /* _RTE_IO_H_ */ lib/librte_eal/x86/include/rte_io.h +53
-1@@ -9,8 +9,64 @@extern "C" {#endif +#include "rte_cpuflags.h" + +#define RTE_NATIVE_WRITE32_WC #include "generic/rte_io.h" +/** +* @internal +* MOVDIRI wrapper. +*/ +static __rte_always_inline void +_rte_x86_movdiri (uint32_t value,volatile void *addr) { + asmvolatile ( +/* MOVDIRI */ +".byte 0x40, 0x0f, 0x38, 0xf9, 0x02" + : + :"a" (value),"d" (addr)); +} + +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) { +static int _x86_movdiri_flag =-1 ; +if (_x86_movdiri_flag ==1 ) { +rte_wmb (); +_rte_x86_movdiri (value, addr); + }else if (_x86_movdiri_flag ==0 ) { +rte_write32 (value, addr); + }else { + _x86_movdiri_flag = + (rte_cpu_get_flag_enabled (RTE_CPUFLAG_MOVDIRI ) >0 ); +if (_x86_movdiri_flag ==1 ) { +rte_wmb (); +_rte_x86_movdiri (value, addr); + }else { +rte_write32 (value, addr); + } + } +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) { +static int _x86_movdiri_flag =-1 ; +if (_x86_movdiri_flag ==1 ) { +_rte_x86_movdiri (value, addr); + }else if (_x86_movdiri_flag ==0 ) { +rte_write32_relaxed (value, addr); + }else { + _x86_movdiri_flag = + (rte_cpu_get_flag_enabled (RTE_CPUFLAG_MOVDIRI ) >0 ); +if (_x86_movdiri_flag ==1 ) +_rte_x86_movdiri (value, addr); +else +rte_write32_relaxed (value, addr); + } +} + #ifdef __cplusplus }#endif --2.7.4
PATCH v8 2/4 net/i40e: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/net/i40e/base/i40e_osdep.h | 5 +++++ drivers/net/i40e/i40e_rxtx.c | 8 ++++---- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 ++-- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-)
drivers/net/i40e/base/i40e_osdep.h +5 -0
@@ -138,6 +138,11 @@ static inline uint32_t i40e_read_addr(volatile void *addr)#define I40E_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE (queue, reg, value) \ + rte_write32_wc((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE_RELAXED (queue, reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_GLGEN_STAT)#define I40EVF_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_VFGEN_RSTAT)
drivers/net/i40e/i40e_rxtx.c +4 -4
@@ -760,7 +760,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -938,7 +938,7 @@ i40e_recv_scattered_pkts(void *rx_queue,if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t )(rx_id ==0 ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -1249,7 +1249,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) (unsigned) tx_id, (unsigned) nb_tx);rte_cio_wmb (); -I40E_PCI_REG_WRITE_RELAXED (txq->qtx_tail, tx_id); +I40E_PCI_REG_WC_WRITE_RELAXED (txq, txq->qtx_tail, tx_id); txq->tx_tail = tx_id;return nb_tx;
@@ -1400,7 +1400,7 @@ tx_xmit_pkts(struct i40e_tx_queue *txq, txq->tx_tail =0 ;/* Update the tx tail register */ -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_avx2.c +2 -2
@@ -134,7 +134,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -921,7 +921,7 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_sse.c +2 -2
@@ -86,7 +86,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -733,7 +733,7 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v8 2/4] net/i40e: use WC store to update queue tail registers
Quoted 30 lines
-----Original Message-----
From: Radu Nicolau <[email protected]>
Sent: Friday, July 17, 2020 6:50 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ruifeng Wang <[email protected]>; Radu Nicolau <[email protected]>
Subject: [PATCH v8 2/4] net/i40e: use WC store to update queue tail registersPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
Signed-off-by Radu Nicolau <[email protected]>Acked-by Bruce Richardson <[email protected]>--- drivers/net/i40e/base/i40e_osdep.h | 5 +++++ drivers/net/i40e/i40e_rxtx.c | 8 ++++---- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 ++-- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-)drivers/net/i40e/base/i40e_osdep.h +0
-0
drivers/net/i40e/base/i40e_osdep.h static inline uint32_t i40e_read_addr(volatile void · line 142
Quoted 5 lines
drivers/net/i40e/base/i40e_osdep.h +1
-0@@ -138,6 +138,11 @@ static inline uint32_t i40e_read_addr(volatile void *addr)#define I40E_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE (queue, reg, value) \
'queue' is not necessary since it will not be used. It can be removed?
Thanks.
/Ruifeng
Quoted 99 lines
drivers/net/i40e/base/i40e_osdep.h +4
-0+ rte_write32_wc((rte_cpu_to_le_32(value)), reg) #define +I40E_PCI_REG_WC_WRITE_RELAXED (queue, reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_GLGEN_STAT)#define I40EVF_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_VFGEN_RSTAT)drivers/net/i40e/i40e_rxtx.c index renamed from drivers/net/i40e/i40e_rxtx.c +0
-0840b6f3..64e43ac 100644
drivers/net/i40e/i40e_rxtx.c +1
-1@@ -760,7 +760,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); nb_hold =0 ; }drivers/net/i40e/i40e_rxtx.c +2
-2rxq->nb_rx_hold = nb_hold;@@ -938,7 +938,7 @@ i40e_recv_scattered_pkts(void *rx_queue,if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t )(rx_id ==0 ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;@@ -1249,7 +1249,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) (unsigned) tx_id, (unsigned) nb_tx);rte_cio_wmb (); -I40E_PCI_REG_WRITE_RELAXED (txq->qtx_tail, tx_id); +I40E_PCI_REG_WC_WRITE_RELAXED (txq, txq->qtx_tail, tx_id); txq->tx_tail = tx_id;drivers/net/i40e/i40e_rxtx.c +1
-1return nb_tx;@@ -1400,7 +1400,7 @@ tx_xmit_pkts(struct i40e_tx_queue *txq, txq->tx_tail =0 ;/* Update the tx tail register */ -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }drivers/net/i40e/i40e_rxtx_vec_avx2.c +2
-2@@ -134,7 +134,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC @@ -921,7 +921,7 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue,struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts;}
drivers/net/i40e/i40e_rxtx_vec_sse.c +2
-2@@ -86,7 +86,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC @@ -733,7 +733,7 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts;}
--
2.7.4
Re: [dpdk-dev] [PATCH v8 2/4] net/i40e: use WC store to update queue tail registers
Quoted 33 lines · Ruifeng Wang
Quoted 33 lines
-----Original Message-----
From: Radu Nicolau <[email protected]>
Sent: Friday, July 17, 2020 6:50 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ruifeng Wang <[email protected]>; Radu Nicolau <[email protected]>
Subject: [PATCH v8 2/4] net/i40e: use WC store to update queue tail registersPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
Signed-off-by Radu Nicolau <[email protected]>Acked-by Bruce Richardson <[email protected]>--- drivers/net/i40e/base/i40e_osdep.h | 5 +++++ drivers/net/i40e/i40e_rxtx.c | 8 ++++---- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 ++-- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-)drivers/net/i40e/base/i40e_osdep.h +0
-0@@ -138,6 +138,11 @@ static inline uint32_t i40e_read_addr(volatile void *addr)#define I40E_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg)
Quoted 2 lines
drivers/net/i40e/base/i40e_osdep.h static inline uint32_t i40e_read_addr(volatile void *addr) · line 141
Quoted 1 line
drivers/net/i40e/base/i40e_osdep.h +1
-0+#define I40E_PCI_REG_WC_WRITE (queue, reg, value) \'queue' is not necessary since it will not be used. It can be removed?
Yes, I will remove it - in the first version we had a flag in the queue struct, and this macro was not properly updated.
Quoted 102 lines
Thanks.
/RuifengQuoted 99 lines
drivers/net/i40e/base/i40e_osdep.h +4
-0+ rte_write32_wc((rte_cpu_to_le_32(value)), reg) #define +I40E_PCI_REG_WC_WRITE_RELAXED (queue, reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_GLGEN_STAT)#define I40EVF_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_VFGEN_RSTAT)drivers/net/i40e/i40e_rxtx.c index renamed from drivers/net/i40e/i40e_rxtx.c +0
-0840b6f3..64e43ac 100644
drivers/net/i40e/i40e_rxtx.c +1
-1@@ -760,7 +760,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); nb_hold =0 ; }rxq->nb_rx_hold = nb_hold;drivers/net/i40e/i40e_rxtx.c +2
-2@@ -938,7 +938,7 @@ i40e_recv_scattered_pkts(void *rx_queue,if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t )(rx_id ==0 ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;@@ -1249,7 +1249,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) (unsigned) tx_id, (unsigned) nb_tx);rte_cio_wmb (); -I40E_PCI_REG_WRITE_RELAXED (txq->qtx_tail, tx_id); +I40E_PCI_REG_WC_WRITE_RELAXED (txq, txq->qtx_tail, tx_id); txq->tx_tail = tx_id;return
nb_tx;drivers/net/i40e/i40e_rxtx.c +1
-1@@ -1400,7 +1400,7 @@ tx_xmit_pkts(struct i40e_tx_queue *txq, txq->tx_tail =0 ;/* Update the tx tail register */ -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts; }drivers/net/i40e/i40e_rxtx_vec_avx2.c +2
-2@@ -134,7 +134,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC @@ -921,7 +921,7 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue,struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts;}drivers/net/i40e/i40e_rxtx_vec_sse.c +2
-2@@ -86,7 +86,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq, rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC @@ -733,7 +733,7 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq, txq->qtx_tail, txq->tx_tail);return nb_pkts;}
--
2.7.4
PATCH v8 3/4 common/qat: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/common/qat/qat_adf/adf_transport_access_macros.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/common/qat/qat_adf/adf_transport_access_macros.h +4 -2
@@ -9,6 +9,8 @@/* CSR write macro */ #define ADF_CSR_WR (csrAddr, csrOffset, val) \ rte_write32(val, (((uint8_t *)csrAddr) + csrOffset)) +#define ADF_CSR_WC_WR (csrAddr, csrOffset, val) \ + rte_write32_wc(val, (((uint8_t *)csrAddr) + csrOffset))/* CSR read macro */ #define ADF_CSR_RD (csrAddr, csrOffset) \
@@ -110,10 +112,10 @@ do { \ ADF_RING_CSR_RING_UBASE + (ring << 2), u_base); \ } while (0)#define WRITE_CSR_RING_HEAD (csr_base_addr, bank, ring, value) \ - ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ + ADF_CSR_WC_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ ADF_RING_CSR_RING_HEAD + (ring << 2), value)#define WRITE_CSR_RING_TAIL (csr_base_addr, bank, ring, value) \ - ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ + ADF_CSR_WC_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ ADF_RING_CSR_RING_TAIL + (ring << 2), value)#define WRITE_CSR_INT_SRCSEL (csr_base_addr, bank) \ do { \
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v8 3/4] common/qat: use WC store to update queue tail registers
Quoted 12 lines
-----Original Message-----
From: Nicolau, Radu <[email protected]>
Sent: Friday, July 17, 2020 11:50 AM
To: [email protected]
Cc: Xing, Beilei <[email protected]>; Guo, Jia <[email protected]>; Richardson, Bruce <[email protected]>; Ananyev, Konstantin <[email protected]>; [email protected]; [email protected]; Trahe, Fiona <[email protected]>; Zhao1, Wei <[email protected]>; [email protected]; Nicolau, Radu <[email protected]>
Subject: [PATCH v8 3/4] common/qat: use WC store to update queue tail registers
Quoted 5 lines
Performance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
Signed-off-by Radu Nicolau <[email protected]>
PATCH v8 4/4 net/ixgbe: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/net/ixgbe/base/ixgbe_osdep.h | 6 ++++++ drivers/net/ixgbe/ixgbe_rxtx.c | 12 ++++++------ drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-)
drivers/net/ixgbe/base/ixgbe_osdep.h +6 -0
@@ -105,6 +105,12 @@ static inline uint32_t ixgbe_read_addr(volatile void* addr)#define IXGBE_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#define IXGBE_PCI_REG_WC_WRITE (reg, value) \ + rte_write32_wc((rte_cpu_to_le_32(value)), reg) + +#define IXGBE_PCI_REG_WC_WRITE_RELAXED (reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) +#define IXGBE_PCI_REG_ADDR (hw, reg) \ ((volatile uint32_t *)((char *)(hw)->hw_addr + (reg)))
drivers/net/ixgbe/ixgbe_rxtx.c +6 -6
@@ -308,7 +308,7 @@ tx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,/* update tail pointer */ rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (txq->tdt_reg_addr, txq->tx_tail); +IXGBE_PCI_REG_WC_WRITE_RELAXED (txq->tdt_reg_addr, txq->tx_tail);return nb_pkts; }
@@ -946,7 +946,7 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u tx_tail=%u nb_tx=%u" , (unsigned ) txq->port_id, (unsigned ) txq->queue_id, (unsigned ) tx_id, (unsigned ) nb_tx); -IXGBE_PCI_REG_WRITE_RELAXED (txq->tdt_reg_addr, tx_id); +IXGBE_PCI_REG_WC_WRITE_RELAXED (txq->tdt_reg_addr, tx_id); txq->tx_tail = tx_id;return nb_tx;
@@ -1692,7 +1692,7 @@ rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,/* update tail pointer */ rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (rxq->rdt_reg_addr, +IXGBE_PCI_REG_WC_WRITE_RELAXED (rxq->rdt_reg_addr, cur_free_trigger); }
@@ -1918,7 +1918,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, (unsigned) nb_rx); rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -IXGBE_PCI_REG_WRITE (rxq->rdt_reg_addr, rx_id); +IXGBE_PCI_REG_WC_WRITE (rxq->rdt_reg_addr, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -2096,7 +2096,7 @@ ixgbe_recv_pkts_lro(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts,if (!ixgbe_rx_alloc_bufs (rxq, false)) {rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (rxq->rdt_reg_addr, +IXGBE_PCI_REG_WC_WRITE_RELAXED (rxq->rdt_reg_addr, next_rdt); nb_hold -= rxq->rx_free_thresh; }else {
@@ -2262,7 +2262,7 @@ ixgbe_recv_pkts_lro(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts, rxq->port_id, rxq->queue_id, rx_id, nb_hold, nb_rx);rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (rxq->rdt_reg_addr, prev_id); +IXGBE_PCI_REG_WC_WRITE_RELAXED (rxq->rdt_reg_addr, prev_id); nb_hold =0 ; }
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +2 -2
@@ -90,7 +90,7 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -IXGBE_PCI_REG_WRITE (rxq->rdt_reg_addr, rx_id); +IXGBE_PCI_REG_WC_WRITE (rxq->rdt_reg_addr, rx_id); }#ifdef RTE_LIBRTE_SECURITY
@@ -697,7 +697,7 @@ ixgbe_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -IXGBE_PCI_REG_WRITE (txq->tdt_reg_addr, txq->tx_tail); +IXGBE_PCI_REG_WC_WRITE (txq->tdt_reg_addr, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v8 4/4] net/ixgbe: use WC store to update queue tail registers
Quoted 101 lines
Performance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
Signed-off-by Radu Nicolau <[email protected]>--- drivers/net/ixgbe/base/ixgbe_osdep.h | 6 ++++++ drivers/net/ixgbe/ixgbe_rxtx.c | 12 ++++++------ drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-)drivers/net/ixgbe/base/ixgbe_osdep.h +6
-0@@ -105,6 +105,12 @@ static inline uint32_t ixgbe_read_addr(volatile void* addr)#define IXGBE_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#define IXGBE_PCI_REG_WC_WRITE (reg, value) \ + rte_write32_wc((rte_cpu_to_le_32(value)), reg) + +#define IXGBE_PCI_REG_WC_WRITE_RELAXED (reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) +#define IXGBE_PCI_REG_ADDR (hw, reg) \ ((volatile uint32_t *)((char *)(hw)->hw_addr + (reg)))drivers/net/ixgbe/ixgbe_rxtx.c +6
-6@@ -308,7 +308,7 @@ tx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,/* update tail pointer */ rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (txq->tdt_reg_addr, txq->tx_tail); +IXGBE_PCI_REG_WC_WRITE_RELAXED (txq->tdt_reg_addr, txq->tx_tail);return nb_pkts; }@@ -946,7 +946,7 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u tx_tail=%u nb_tx=%u" , (unsigned ) txq->port_id, (unsigned ) txq->queue_id, (unsigned ) tx_id, (unsigned ) nb_tx); -IXGBE_PCI_REG_WRITE_RELAXED (txq->tdt_reg_addr, tx_id); +IXGBE_PCI_REG_WC_WRITE_RELAXED (txq->tdt_reg_addr, tx_id); txq->tx_tail = tx_id;return nb_tx;@@ -1692,7 +1692,7 @@ rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,/* update tail pointer */ rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (rxq->rdt_reg_addr, +IXGBE_PCI_REG_WC_WRITE_RELAXED (rxq->rdt_reg_addr, cur_free_trigger); }@@ -1918,7 +1918,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, (unsigned) nb_rx); rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -IXGBE_PCI_REG_WRITE (rxq->rdt_reg_addr, rx_id); +IXGBE_PCI_REG_WC_WRITE (rxq->rdt_reg_addr, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;@@ -2096,7 +2096,7 @@ ixgbe_recv_pkts_lro(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts,if (!ixgbe_rx_alloc_bufs (rxq, false)) {rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (rxq->rdt_reg_addr, +IXGBE_PCI_REG_WC_WRITE_RELAXED (rxq->rdt_reg_addr, next_rdt); nb_hold -= rxq->rx_free_thresh; }else {@@ -2262,7 +2262,7 @@ ixgbe_recv_pkts_lro(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts, rxq->port_id, rxq->queue_id, rx_id, nb_hold, nb_rx);rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (rxq->rdt_reg_addr, prev_id); +IXGBE_PCI_REG_WC_WRITE_RELAXED (rxq->rdt_reg_addr, prev_id); nb_hold =0 ; }drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +1
-1@@ -90,7 +90,7 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -IXGBE_PCI_REG_WRITE (rxq->rdt_reg_addr, rx_id); +IXGBE_PCI_REG_WC_WRITE (rxq->rdt_reg_addr, rx_id); }#ifdef RTE_LIBRTE_SECURITY
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c ixgbe_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
Quoted 9 lines
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +1
-2@@ -697,7 +697,7 @@ ixgbe_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -IXGBE_PCI_REG_WRITE (txq->tdt_reg_addr, txq->tx_tail); +IXGBE_PCI_REG_WC_WRITE (txq->tdt_reg_addr, txq->tx_tail);return nb_pkts; } --
Quoted 1 line
2.7.4
v9 cover eal: add WC store functions
In reply to Radu NicolauImplement 2 new functions that will enable write combining stores depending on architecture. The functions are provided as a generic stub and a x86 specific implementation.
The reason to implement these functions is to improve performance by reducing the overhead associated with regular mmio writes when updating the hardware queue tails and doorbells.
With this patch set the I40E, IXGBE and QAT PMDs are updated to use the write combining store functions with other PMDs to follow.
Radu Nicolau (4):
eal: add WC store functions
net/i40e: use WC store to update queue tail registers common/qat: use WC store to update queue tail registers net/ixgbe: use WC store to update queue tail registers
.../qat/qat_adf/adf_transport_access_macros.h | 6 ++- drivers/net/i40e/base/i40e_osdep.h | 5 ++ drivers/net/i40e/i40e_rxtx.c | 8 ++-- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 +- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 +- drivers/net/ixgbe/base/ixgbe_osdep.h | 6 +++ drivers/net/ixgbe/ixgbe_rxtx.c | 15 +++--- drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 4 +- lib/librte_eal/arm/include/rte_io_64.h | 12 +++++ lib/librte_eal/include/generic/rte_io.h | 48 +++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 56 ++++++++++++++++++++++ 11 files changed, 149 insertions(+), 19 deletions(-)
Signature · 1 line
2.7.4
PATCH v9 1/4 eal: add WC store functions
Add rte_write32_wc and rte_write32_wc_relaxed functions that implement 32bit stores using write combining memory protocol. Provided generic stubs and x86 implementation.
--- lib/librte_eal/arm/include/rte_io_64.h | 12 +++++++ lib/librte_eal/include/generic/rte_io.h | 48 ++++++++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 56 +++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+)
lib/librte_eal/arm/include/rte_io_64.h +12 -0
@@ -164,6 +164,18 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) +{ +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +rte_write32_relaxed (value, addr); +} + #ifdef __cplusplus }#endif
lib/librte_eal/include/generic/rte_io.h +48 -0
60 lines not on this page · raw message
lib/librte_eal/x86/include/rte_io.h +56 -0
64 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH v9 1/4] eal: add WC store functions
Quoted 4 lines · Radu Nicolau
Add
rte_write32_wcandrte_write32_wc_relaxedfunctions that implement 32bit stores using write combining memory protocol. Provided generic stubs and x86 implementation.
What is the difference of using this new API when compared to the existing pci driver flag RTE_PCI_DRV_WC_ACTIVATE?
Do we have some overlap between the two?
This commitlog is quite short for something that touches performance. I saw a question from Ruifeng, it is worth adding this to the commitlog.
Which x86 platforms will benefit from it?
What is the impact on performance for existing platforms that have no MOVDIRI support?
Quoted 19 lines
Signed-off-by Radu Nicolau <[email protected]>Acked-by Bruce Richardson <[email protected]>--- lib/librte_eal/arm/include/rte_io_64.h | 12 +++++++ lib/librte_eal/include/generic/rte_io.h | 48 ++++++++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 56 +++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+)lib/librte_eal/arm/include/rte_io_64.h +2
-0@@ -164,6 +164,18 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr)
lib/librte_eal/arm/include/rte_io_64.h rte_write64(uint64_t value, volatile void *addr) · line 178
Quoted 10 lines
lib/librte_eal/arm/include/rte_io_64.h +10
-0+{ +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +rte_write32_relaxed (value, addr); +} +
We were using a single knob RTE_OVERRIDE_IO_H for overriding the whole rte_io.h. Now we would have a special case for an API for x86 and the code is copy/pasted in the ARM header and keeping the "whole" override mode.
This leaves an unfinished taste.
Why did you not flag all relevant "native" helpers? This would factor some code from the ARM header.
Quoted 25 lines
lib/librte_eal/arm/include/rte_io_64.h +0
-0#ifdef __cplusplus }#endif lib/librte_eal/include/generic/rte_io.h +14
-0@@ -229,6 +229,40 @@ rte_write32(uint32_t value, volatile void *addr);static inline void rte_write64 (uint64_t value,volatile void *addr); +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write combining +* may not be available and/or may be treated as a hint and the behavior may +* fallback to a regular store. +* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to +*/ +__rte_experimental +static inline void +rte_write32_wc (uint32_t value,volatile void *addr);
lib/librte_eal/include/generic/rte_io.h rte_write32(uint32_t value, volatile void *addr); · line 255
Quoted 10 lines
lib/librte_eal/include/generic/rte_io.h +10
-0+ +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write combining +* may not be available and/or may be treated as a hint and the behavior may +* fallback to a regular store. +* +* The relaxed version does not have additional I/O memory barrier, useful in +* accessing the device registers of integrated controllers which implicitly +* strongly ordered with respect to memory access.
It might be just me, but I have trouble reading the last part of this sentence. Maybe remove "with respect to"?
Quoted 90 lines
lib/librte_eal/include/generic/rte_io.h +24
-0+* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to +*/ +__rte_experimental +static inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr); +#endif /* __DOXYGEN__ */ #ifndef RTE_OVERRIDE_IO_H @@ -345,6 +379,20 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +#ifndef RTE_NATIVE_WRITE32_WC +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) +{ +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +rte_write32_relaxed (value, addr); +} +#endif /* RTE_NATIVE_WRITE32_WC */ +#endif /* RTE_OVERRIDE_IO_H */ #endif /* _RTE_IO_H_ */ lib/librte_eal/x86/include/rte_io.h +46
-0@@ -9,8 +9,64 @@extern "C" {#endif +#include "rte_cpuflags.h" + +#define RTE_NATIVE_WRITE32_WC #include "generic/rte_io.h" +/** +* @internal +* MOVDIRI wrapper. +*/ +static __rte_always_inline void +_rte_x86_movdiri (uint32_t value,volatile void *addr) +{ + asmvolatile ( +/* MOVDIRI */ +".byte 0x40, 0x0f, 0x38, 0xf9, 0x02" + : + :"a" (value),"d" (addr)); +} + +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) +{ +static int _x86_movdiri_flag =-1 ; +if (_x86_movdiri_flag ==1 ) { +rte_wmb (); +_rte_x86_movdiri (value, addr); + }else if (_x86_movdiri_flag ==0 ) { +rte_write32 (value, addr); + }else { + _x86_movdiri_flag = + (rte_cpu_get_flag_enabled (RTE_CPUFLAG_MOVDIRI ) >0 ); +if (_x86_movdiri_flag ==1 ) { +rte_wmb (); +_rte_x86_movdiri (value, addr); + }else { +rte_write32 (value, addr); + } + } +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +static int _x86_movdiri_flag =-1 ; +if (_x86_movdiri_flag ==1 ) { +_rte_x86_movdiri (value, addr); + }else if (_x86_movdiri_flag ==0 ) { +rte_write32_relaxed (value, addr);
lib/librte_eal/x86/include/rte_io.h line 69
Quoted 10 lines
lib/librte_eal/x86/include/rte_io.h +10
-0+ }else { + _x86_movdiri_flag = + (rte_cpu_get_flag_enabled (RTE_CPUFLAG_MOVDIRI ) >0 ); +if (_x86_movdiri_flag ==1 ) +_rte_x86_movdiri (value, addr); +else +rte_write32_relaxed (value, addr); + } +} +
Repeating some comments I made earlier.
- If a single helper called by both rte_write32_wc and rte_write32_wc_relaxed with a _constant_ flag is not to your liking (I don't see where it would have an impact on performance), then maybe rte_write32_wc() can be simply implemented as:
+static __rte_always_inline void +rte_write32_wc(uint32_t value, volatile void *addr) +{
+ rte_wmb();
+ rte_write32_wc_relaxed(value, addr);
+}
+
- Looking at this above suggestion, I wonder about the non-relaxed case. Is rte_io_wmb() not enough?
- The cpuflag check can be resolved at init once and for all. By this, I mean in lib/librte_eal/x86/rte_cpuflags.c:
+int rte_x86_movdiri_flag = -1;
+
+RTE_INIT(rte_x86_movdiri_init)
+{
+ rte_x86_movdiri_flag =
+ (rte_cpu_get_flag_enabled(RTE_CPUFLAG_MOVDIRI) > 0);
+}
The variable can be exported in lib/librte_eal/x86/include/rte_cpuflags.h.
Then rte_write32_wc_relaxed() becomes:
+static __rte_always_inline void +rte_write32_wc_relaxed(uint32_t value, volatile void *addr) +{
+ if (rte_x86_movdiri_flag == 1) {
+ asm volatile(
+ /* MOVDIRI */ + ".byte 0x40, 0x0f, 0x38, 0xf9, 0x02" + : + : "a" (value), "d" (addr));
+ return;
+ }
+
+ rte_write32_relaxed(value, addr);
+}
+
Thanks.
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v9 1/4] eal: add WC store functions
Quoted 7 lines · David Marchand
Quoted 3 lines · Radu Nicolau
Add
rte_write32_wcandrte_write32_wc_relaxedfunctions that implement 32bit stores using write combining memory protocol. Provided generic stubs and x86 implementation.What is the difference of using this new API when compared to the existing pci driver flag
RTE_PCI_DRV_WC_ACTIVATE?
Do we have some overlap between the two?
No, the RTE_PCI_DRV_WC_ACTIVATE define will map the BARs as write combining, whereas these functions will use the WC regardless of the mapping, and they can be used for memory areas that won't be mapped using the PCI infrastructure.
Quoted 3 lines
This commitlog is quite short for something that touches performance. I saw a question from Ruifeng, it is worth adding this to the commitlog.
Strictly speaking, this patch only enables support for WC stores, and it does not have any performance implications on its own. I think a fair assumption is that if someone is looking to use WC stores they will know exactly how and where they can be used.
Quoted 4 lines
Which x86 platforms will benefit from it?
What is the impact on performance for existing platforms that have no MOVDIRI support?
x86 platforms supporting MOVDIRI instruction with this particular patch, and any other platform that have similar instructions if they were to be enabled.
There is no impact for the ones that don't support it.
Quoted 34 lines
Quoted 20 lines
Signed-off-by Radu Nicolau <[email protected]>Acked-by Bruce Richardson <[email protected]>--- lib/librte_eal/arm/include/rte_io_64.h | 12 +++++++ lib/librte_eal/include/generic/rte_io.h | 48 ++++++++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 56 +++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+)lib/librte_eal/arm/include/rte_io_64.h +2
-0@@ -164,6 +164,18 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr)lib/librte_eal/arm/include/rte_io_64.h rte_write64(uint64_t value, volatile void *addr) · line 178
Quoted 10 lines
lib/librte_eal/arm/include/rte_io_64.h +10
-0+{ +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +rte_write32_relaxed (value, addr); +} +We were using a single knob
RTE_OVERRIDE_IO_Hfor overriding the wholerte_io.h. Now we would have a special case for an API for x86 and the code is copy/pasted in the ARM header and keeping the "whole" override mode.
Quoted 4 lines
This leaves an unfinished taste.
Why did you not flag all relevant "native" helpers? This would factor some code from the ARM header.
I agree that having a more granular approach is better, having a single knob is why ARM header had about half of the functions overridden and half copied and pasted before this patch. But this is outside the scope of this patch.
Quoted 31 lines
Quoted 31 lines
lib/librte_eal/arm/include/rte_io_64.h +0
-0#ifdef __cplusplus }#endif lib/librte_eal/include/generic/rte_io.h +18
-0@@ -229,6 +229,40 @@ rte_write32(uint32_t value, volatile void *addr);static inline void rte_write64 (uint64_t value,volatile void *addr); +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write combining +* may not be available and/or may be treated as a hint and the behavior may +* fallback to a regular store. +* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to +*/ +__rte_experimental +static inline void +rte_write32_wc (uint32_t value,volatile void *addr); + +/** +* Write a 32-bit value to I/O device memory address addr using write +* combining memory write protocol. Depending on the platform write combining
Quoted 8 lines
lib/librte_eal/include/generic/rte_io.h rte_write32(uint32_t value, volatile void *addr); · line 255
Quoted 6 lines
lib/librte_eal/include/generic/rte_io.h +6
-0+* may not be available and/or may be treated as a hint and the behavior may +* fallback to a regular store. +* +* The relaxed version does not have additional I/O memory barrier, useful in +* accessing the device registers of integrated controllers which implicitly +* strongly ordered with respect to memory access. It might be just me, but I have trouble reading the last part of this sentence. Maybe remove "with respect to"?
It was copied and pasted from the other _relaxed functions for consistency reasons.
Quoted 109 lines
Quoted 92 lines
lib/librte_eal/include/generic/rte_io.h +24
-0+* +* @param value +* Value to write +* @param addr +* I/O memory address to write the value to +*/ +__rte_experimental +static inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr); +#endif /* __DOXYGEN__ */ #ifndef RTE_OVERRIDE_IO_H @@ -345,6 +379,20 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +#ifndef RTE_NATIVE_WRITE32_WC +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) +{ +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +rte_write32_relaxed (value, addr); +} +#endif /* RTE_NATIVE_WRITE32_WC */ +#endif /* RTE_OVERRIDE_IO_H */ #endif /* _RTE_IO_H_ */ lib/librte_eal/x86/include/rte_io.h +46
-0@@ -9,8 +9,64 @@extern "C" {#endif +#include "rte_cpuflags.h" + +#define RTE_NATIVE_WRITE32_WC #include "generic/rte_io.h" +/** +* @internal +* MOVDIRI wrapper. +*/ +static __rte_always_inline void +_rte_x86_movdiri (uint32_t value,volatile void *addr) +{ + asmvolatile ( +/* MOVDIRI */ +".byte 0x40, 0x0f, 0x38, 0xf9, 0x02" + : + :"a" (value),"d" (addr)); +} + +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) +{ +static int _x86_movdiri_flag =-1 ; +if (_x86_movdiri_flag ==1 ) { +rte_wmb (); +_rte_x86_movdiri (value, addr); + }else if (_x86_movdiri_flag ==0 ) { +rte_write32 (value, addr); + }else { + _x86_movdiri_flag = + (rte_cpu_get_flag_enabled (RTE_CPUFLAG_MOVDIRI ) >0 ); +if (_x86_movdiri_flag ==1 ) { +rte_wmb (); +_rte_x86_movdiri (value, addr); + }else { +rte_write32 (value, addr); + } + } +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +static int _x86_movdiri_flag =-1 ; +if (_x86_movdiri_flag ==1 ) { +_rte_x86_movdiri (value, addr); + }else if (_x86_movdiri_flag ==0 ) { +rte_write32_relaxed (value, addr);lib/librte_eal/x86/include/rte_io.h line 69
Quoted 10 lines
lib/librte_eal/x86/include/rte_io.h +10
-0+ }else { + _x86_movdiri_flag = + (rte_cpu_get_flag_enabled (RTE_CPUFLAG_MOVDIRI ) >0 ); +if (_x86_movdiri_flag ==1 ) +_rte_x86_movdiri (value, addr); +else +rte_write32_relaxed (value, addr); + } +} +Repeating some comments I made earlier.
- If a single helper called by both
rte_write32_wcandrte_write32_wc_relaxedwith a _constant_ flag is not to your liking (I don't see where it would have an impact on performance), then mayberte_write32_wc()can be simply implemented as:
lib/librte_eal/x86/include/rte_io.h line 51
Quoted 7 lines
lib/librte_eal/x86/include/rte_io.h +7
-0+static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) +{ +rte_wmb (); +rte_write32_wc_relaxed (value, addr); +} +
Yes, it can be written as such, I will update the patch.
Quoted 3 lines
- Looking at this above suggestion, I wonder about the non-relaxed case. Is
rte_io_wmb()not enough?
No, we need an actual memory fence, on x86 rte_io_wmb() is defined as rte_compiler_barrier()
Quoted 22 lines
- The cpuflag check can be resolved at init once and for all. By this, I mean in
lib/librte_eal/x86/rte_cpuflags.c:lib/librte_eal/x86/include/rte_io.h +7
-0+int rte_x86_movdiri_flag =-1 ; + +RTE_INIT (rte_x86_movdiri_init) +{ + rte_x86_movdiri_flag = + (rte_cpu_get_flag_enabled (RTE_CPUFLAG_MOVDIRI ) >0 ); +}The variable can be exported in
lib/librte_eal/x86/include/rte_cpuflags.h.Then
rte_write32_wc_relaxed()becomes:lib/librte_eal/x86/include/rte_io.h +5
-0+static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +if (rte_x86_movdiri_flag ==1 ) { + asm volatile(
lib/librte_eal/x86/include/rte_io.h line 69
Quoted 10 lines
lib/librte_eal/x86/include/rte_io.h +10
-0+/* MOVDIRI */ + ".byte 0x40, 0x0f, 0x38, 0xf9, 0x02" + : + : "a" (value), "d" (addr)); +return ; + } + +rte_write32_relaxed (value, addr); +} +
I tried this before sending the patch, there is an issue when linking the shared library version with the --no-undefined flag. This will require to have the variable exported in the overall map file, requiring a change across all platforms for something that is very x86 specific.
Quoted 3 lines
Thanks.
PATCH v9 2/4 net/i40e: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/net/i40e/base/i40e_osdep.h | 5 +++++ drivers/net/i40e/i40e_rxtx.c | 8 ++++---- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 ++-- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-)
drivers/net/i40e/base/i40e_osdep.h +5 -0
@@ -138,6 +138,11 @@ static inline uint32_t i40e_read_addr(volatile void *addr)#define I40E_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE (reg, value) \ + rte_write32_wc((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE_RELAXED (reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_GLGEN_STAT)#define I40EVF_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_VFGEN_RSTAT)
drivers/net/i40e/i40e_rxtx.c +4 -4
@@ -760,7 +760,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -938,7 +938,7 @@ i40e_recv_scattered_pkts(void *rx_queue,if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t )(rx_id ==0 ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -1249,7 +1249,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) (unsigned) tx_id, (unsigned) nb_tx);rte_cio_wmb (); -I40E_PCI_REG_WRITE_RELAXED (txq->qtx_tail, tx_id); +I40E_PCI_REG_WC_WRITE_RELAXED (txq->qtx_tail, tx_id); txq->tx_tail = tx_id;return nb_tx;
@@ -1400,7 +1400,7 @@ tx_xmit_pkts(struct i40e_tx_queue *txq, txq->tx_tail =0 ;/* Update the tx tail register */ -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_avx2.c +2 -2
@@ -134,7 +134,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -921,7 +921,7 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_sse.c +2 -2
@@ -86,7 +86,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -733,7 +733,7 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq->qtx_tail, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.7.4
PATCH v9 3/4 common/qat: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/common/qat/qat_adf/adf_transport_access_macros.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/common/qat/qat_adf/adf_transport_access_macros.h +4 -2
@@ -9,6 +9,8 @@/* CSR write macro */ #define ADF_CSR_WR (csrAddr, csrOffset, val) \ rte_write32(val, (((uint8_t *)csrAddr) + csrOffset)) +#define ADF_CSR_WC_WR (csrAddr, csrOffset, val) \ + rte_write32_wc(val, (((uint8_t *)csrAddr) + csrOffset))/* CSR read macro */ #define ADF_CSR_RD (csrAddr, csrOffset) \
@@ -110,10 +112,10 @@ do { \ ADF_RING_CSR_RING_UBASE + (ring << 2), u_base); \ } while (0)#define WRITE_CSR_RING_HEAD (csr_base_addr, bank, ring, value) \ - ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ + ADF_CSR_WC_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ ADF_RING_CSR_RING_HEAD + (ring << 2), value)#define WRITE_CSR_RING_TAIL (csr_base_addr, bank, ring, value) \ - ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ + ADF_CSR_WC_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ ADF_RING_CSR_RING_TAIL + (ring << 2), value)#define WRITE_CSR_INT_SRCSEL (csr_base_addr, bank) \ do { \
Signature · 1 line
2.7.4
PATCH v9 4/4 net/ixgbe: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/net/ixgbe/base/ixgbe_osdep.h | 6 ++++++ drivers/net/ixgbe/ixgbe_rxtx.c | 15 ++++++++------- drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 4 ++-- 3 files changed, 16 insertions(+), 9 deletions(-)
drivers/net/ixgbe/base/ixgbe_osdep.h +6 -0
@@ -105,6 +105,12 @@ static inline uint32_t ixgbe_read_addr(volatile void* addr)#define IXGBE_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#define IXGBE_PCI_REG_WC_WRITE (reg, value) \ + rte_write32_wc((rte_cpu_to_le_32(value)), reg) + +#define IXGBE_PCI_REG_WC_WRITE_RELAXED (reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) +#define IXGBE_PCI_REG_ADDR (hw, reg) \ ((volatile uint32_t *)((char *)(hw)->hw_addr + (reg)))
drivers/net/ixgbe/ixgbe_rxtx.c +8 -7
@@ -308,7 +308,7 @@ tx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,/* update tail pointer */ rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (txq->tdt_reg_addr, txq->tx_tail); +IXGBE_PCI_REG_WC_WRITE_RELAXED (txq->tdt_reg_addr, txq->tx_tail);return nb_pkts; }
@@ -946,7 +946,7 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u tx_tail=%u nb_tx=%u" , (unsigned ) txq->port_id, (unsigned ) txq->queue_id, (unsigned ) tx_id, (unsigned ) nb_tx); -IXGBE_PCI_REG_WRITE_RELAXED (txq->tdt_reg_addr, tx_id); +IXGBE_PCI_REG_WC_WRITE_RELAXED (txq->tdt_reg_addr, tx_id); txq->tx_tail = tx_id;return nb_tx;
@@ -1692,7 +1692,7 @@ rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,/* update tail pointer */ rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (rxq->rdt_reg_addr, +IXGBE_PCI_REG_WC_WRITE_RELAXED (rxq->rdt_reg_addr, cur_free_trigger); }
@@ -1918,7 +1918,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, (unsigned) nb_rx); rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -IXGBE_PCI_REG_WRITE (rxq->rdt_reg_addr, rx_id); +IXGBE_PCI_REG_WC_WRITE (rxq->rdt_reg_addr, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -2096,8 +2096,9 @@ ixgbe_recv_pkts_lro(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts,if (!ixgbe_rx_alloc_bufs (rxq, false)) {rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (rxq->rdt_reg_addr, - next_rdt); +IXGBE_PCI_REG_WC_WRITE_RELAXED ( + rxq->rdt_reg_addr, + next_rdt); nb_hold -= rxq->rx_free_thresh; }else { PMD_RX_LOG(DEBUG, "RX bulk alloc failed "
@@ -2262,7 +2263,7 @@ ixgbe_recv_pkts_lro(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts, rxq->port_id, rxq->queue_id, rx_id, nb_hold, nb_rx);rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (rxq->rdt_reg_addr, prev_id); +IXGBE_PCI_REG_WC_WRITE_RELAXED (rxq->rdt_reg_addr, prev_id); nb_hold =0 ; }
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +2 -2
@@ -90,7 +90,7 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -IXGBE_PCI_REG_WRITE (rxq->rdt_reg_addr, rx_id); +IXGBE_PCI_REG_WC_WRITE (rxq->rdt_reg_addr, rx_id); }#ifdef RTE_LIBRTE_SECURITY
@@ -697,7 +697,7 @@ ixgbe_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -IXGBE_PCI_REG_WRITE (txq->tdt_reg_addr, txq->tx_tail); +IXGBE_PCI_REG_WC_WRITE (txq->tdt_reg_addr, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.7.4
v10 cover eal: add WC store functions
In reply to Radu NicolauImplement 2 new functions that will enable write combining stores depending on architecture. The functions are provided as a generic stub and a x86 specific implementation.
The reason to implement these functions is to improve performance by reducing the overhead associated with regular mmio writes when updating the hardware queue tails and doorbells.
With this patch set the I40E, IXGBE and QAT PMDs are updated to use the write combining store functions with other PMDs to follow.
Radu Nicolau (4):
eal: add WC store functions
net/i40e: use WC store to update queue tail registers common/qat: use WC store to update queue tail registers net/ixgbe: use WC store to update queue tail registers
.../qat/qat_adf/adf_transport_access_macros.h | 6 ++- drivers/net/i40e/base/i40e_osdep.h | 5 +++ drivers/net/i40e/i40e_rxtx.c | 8 ++-- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 +- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 +- drivers/net/ixgbe/base/ixgbe_osdep.h | 6 +++ drivers/net/ixgbe/ixgbe_rxtx.c | 15 +++---- drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 4 +- lib/librte_eal/arm/include/rte_io_64.h | 12 ++++++ lib/librte_eal/include/generic/rte_io.h | 48 ++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 42 +++++++++++++++++++ 11 files changed, 135 insertions(+), 19 deletions(-)
Signature · 1 line
2.7.4
PATCH v10 1/4 eal: add WC store functions
Add rte_write32_wc and rte_write32_wc_relaxed functions that implement 32bit stores using write combining memory protocol. Provided generic stubs and x86 implementation.
--- lib/librte_eal/arm/include/rte_io_64.h | 12 +++++++++ lib/librte_eal/include/generic/rte_io.h | 48 +++++++++++++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 42 +++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+)
lib/librte_eal/arm/include/rte_io_64.h +12 -0
@@ -164,6 +164,18 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) +{ +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +rte_write32_relaxed (value, addr); +} + #ifdef __cplusplus }#endif
lib/librte_eal/include/generic/rte_io.h +48 -0
60 lines not on this page · raw message
lib/librte_eal/x86/include/rte_io.h +42 -0
50 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v10 2/4 net/i40e: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/net/i40e/base/i40e_osdep.h | 5 +++++ drivers/net/i40e/i40e_rxtx.c | 8 ++++---- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 ++-- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-)
drivers/net/i40e/base/i40e_osdep.h +5 -0
@@ -138,6 +138,11 @@ static inline uint32_t i40e_read_addr(volatile void *addr)#define I40E_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE (reg, value) \ + rte_write32_wc((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE_RELAXED (reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_GLGEN_STAT)#define I40EVF_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_VFGEN_RSTAT)
drivers/net/i40e/i40e_rxtx.c +4 -4
@@ -760,7 +760,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -938,7 +938,7 @@ i40e_recv_scattered_pkts(void *rx_queue,if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t )(rx_id ==0 ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -1249,7 +1249,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) (unsigned) tx_id, (unsigned) nb_tx);rte_cio_wmb (); -I40E_PCI_REG_WRITE_RELAXED (txq->qtx_tail, tx_id); +I40E_PCI_REG_WC_WRITE_RELAXED (txq->qtx_tail, tx_id); txq->tx_tail = tx_id;return nb_tx;
@@ -1400,7 +1400,7 @@ tx_xmit_pkts(struct i40e_tx_queue *txq, txq->tx_tail =0 ;/* Update the tx tail register */ -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_avx2.c +2 -2
@@ -134,7 +134,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -921,7 +921,7 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_sse.c +2 -2
@@ -86,7 +86,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -733,7 +733,7 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq->qtx_tail, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.7.4
PATCH v10 3/4 common/qat: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/common/qat/qat_adf/adf_transport_access_macros.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/common/qat/qat_adf/adf_transport_access_macros.h +4 -2
@@ -9,6 +9,8 @@/* CSR write macro */ #define ADF_CSR_WR (csrAddr, csrOffset, val) \ rte_write32(val, (((uint8_t *)csrAddr) + csrOffset)) +#define ADF_CSR_WC_WR (csrAddr, csrOffset, val) \ + rte_write32_wc(val, (((uint8_t *)csrAddr) + csrOffset))/* CSR read macro */ #define ADF_CSR_RD (csrAddr, csrOffset) \
@@ -110,10 +112,10 @@ do { \ ADF_RING_CSR_RING_UBASE + (ring << 2), u_base); \ } while (0)#define WRITE_CSR_RING_HEAD (csr_base_addr, bank, ring, value) \ - ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ + ADF_CSR_WC_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ ADF_RING_CSR_RING_HEAD + (ring << 2), value)#define WRITE_CSR_RING_TAIL (csr_base_addr, bank, ring, value) \ - ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ + ADF_CSR_WC_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ ADF_RING_CSR_RING_TAIL + (ring << 2), value)#define WRITE_CSR_INT_SRCSEL (csr_base_addr, bank) \ do { \
Signature · 1 line
2.7.4
PATCH v10 4/4 net/ixgbe: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/net/ixgbe/base/ixgbe_osdep.h | 6 ++++++ drivers/net/ixgbe/ixgbe_rxtx.c | 15 ++++++++------- drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 4 ++-- 3 files changed, 16 insertions(+), 9 deletions(-)
drivers/net/ixgbe/base/ixgbe_osdep.h +6 -0
@@ -105,6 +105,12 @@ static inline uint32_t ixgbe_read_addr(volatile void* addr)#define IXGBE_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#define IXGBE_PCI_REG_WC_WRITE (reg, value) \ + rte_write32_wc((rte_cpu_to_le_32(value)), reg) + +#define IXGBE_PCI_REG_WC_WRITE_RELAXED (reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) +#define IXGBE_PCI_REG_ADDR (hw, reg) \ ((volatile uint32_t *)((char *)(hw)->hw_addr + (reg)))
drivers/net/ixgbe/ixgbe_rxtx.c +8 -7
@@ -308,7 +308,7 @@ tx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,/* update tail pointer */ rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (txq->tdt_reg_addr, txq->tx_tail); +IXGBE_PCI_REG_WC_WRITE_RELAXED (txq->tdt_reg_addr, txq->tx_tail);return nb_pkts; }
@@ -946,7 +946,7 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u tx_tail=%u nb_tx=%u" , (unsigned ) txq->port_id, (unsigned ) txq->queue_id, (unsigned ) tx_id, (unsigned ) nb_tx); -IXGBE_PCI_REG_WRITE_RELAXED (txq->tdt_reg_addr, tx_id); +IXGBE_PCI_REG_WC_WRITE_RELAXED (txq->tdt_reg_addr, tx_id); txq->tx_tail = tx_id;return nb_tx;
@@ -1692,7 +1692,7 @@ rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,/* update tail pointer */ rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (rxq->rdt_reg_addr, +IXGBE_PCI_REG_WC_WRITE_RELAXED (rxq->rdt_reg_addr, cur_free_trigger); }
@@ -1918,7 +1918,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, (unsigned) nb_rx); rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -IXGBE_PCI_REG_WRITE (rxq->rdt_reg_addr, rx_id); +IXGBE_PCI_REG_WC_WRITE (rxq->rdt_reg_addr, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -2096,8 +2096,9 @@ ixgbe_recv_pkts_lro(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts,if (!ixgbe_rx_alloc_bufs (rxq, false)) {rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (rxq->rdt_reg_addr, - next_rdt); +IXGBE_PCI_REG_WC_WRITE_RELAXED ( + rxq->rdt_reg_addr, + next_rdt); nb_hold -= rxq->rx_free_thresh; }else { PMD_RX_LOG(DEBUG, "RX bulk alloc failed "
@@ -2262,7 +2263,7 @@ ixgbe_recv_pkts_lro(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts, rxq->port_id, rxq->queue_id, rx_id, nb_hold, nb_rx);rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (rxq->rdt_reg_addr, prev_id); +IXGBE_PCI_REG_WC_WRITE_RELAXED (rxq->rdt_reg_addr, prev_id); nb_hold =0 ; }
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +2 -2
@@ -90,7 +90,7 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -IXGBE_PCI_REG_WRITE (rxq->rdt_reg_addr, rx_id); +IXGBE_PCI_REG_WC_WRITE (rxq->rdt_reg_addr, rx_id); }#ifdef RTE_LIBRTE_SECURITY
@@ -697,7 +697,7 @@ ixgbe_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -IXGBE_PCI_REG_WRITE (txq->tdt_reg_addr, txq->tx_tail); +IXGBE_PCI_REG_WC_WRITE (txq->tdt_reg_addr, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.7.4
v11 cover eal: add WC store functions
In reply to Radu NicolauImplement 2 new functions that will enable write combining stores depending on architecture. The functions are provided as a generic stub and a x86 specific implementation.
The reason to implement these functions is to improve performance by reducing the overhead associated with regular mmio writes when updating the hardware queue tails and doorbells.
With this patch set the I40E, ICE, IXGBE and QAT PMDs are updated to use the write combining store functions with other PMDs to follow.
Radu Nicolau (5):
eal: add WC store functions
net/i40e: use WC store to update queue tail registers common/qat: use WC store to update queue tail registers net/ixgbe: use WC store to update queue tail registers net/ice: use WC store to update queue tail registers
.../qat/qat_adf/adf_transport_access_macros.h | 6 ++- drivers/net/i40e/base/i40e_osdep.h | 5 ++ drivers/net/i40e/i40e_rxtx.c | 8 ++-- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 +- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 +- drivers/net/ice/base/ice_osdep.h | 1 + drivers/net/ice/ice_rxtx.c | 6 +-- drivers/net/ice/ice_rxtx_vec_avx2.c | 4 +- drivers/net/ice/ice_rxtx_vec_sse.c | 4 +- drivers/net/ixgbe/base/ixgbe_osdep.h | 6 +++ drivers/net/ixgbe/ixgbe_rxtx.c | 15 +++--- drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 4 +- lib/librte_eal/arm/include/rte_io_64.h | 12 +++++ lib/librte_eal/include/generic/rte_io.h | 48 +++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 42 ++++++++++++++++ 15 files changed, 143 insertions(+), 26 deletions(-)
Signature · 1 line
2.17.1
PATCH v11 1/5 eal: add WC store functions
Add rte_write32_wc and rte_write32_wc_relaxed functions that implement 32bit stores using write combining memory protocol. Provided generic stubs and x86 implementation.
--- lib/librte_eal/arm/include/rte_io_64.h | 12 +++++++ lib/librte_eal/include/generic/rte_io.h | 48 +++++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 42 ++++++++++++++++++++++ 3 files changed, 102 insertions(+)
lib/librte_eal/arm/include/rte_io_64.h +12 -0
@@ -164,6 +164,18 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) +{ +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +rte_write32_relaxed (value, addr); +} + #ifdef __cplusplus }#endif
lib/librte_eal/include/generic/rte_io.h +48 -0
60 lines not on this page · raw message
lib/librte_eal/x86/include/rte_io.h +42 -0
50 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v11 2/5 net/i40e: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/net/i40e/base/i40e_osdep.h | 5 +++++ drivers/net/i40e/i40e_rxtx.c | 8 ++++---- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 ++-- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-)
drivers/net/i40e/base/i40e_osdep.h +5 -0
@@ -138,6 +138,11 @@ static inline uint32_t i40e_read_addr(volatile void *addr)#define I40E_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE (reg, value) \ + rte_write32_wc((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE_RELAXED (reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_GLGEN_STAT)#define I40EVF_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_VFGEN_RSTAT)
drivers/net/i40e/i40e_rxtx.c +4 -4
@@ -760,7 +760,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -938,7 +938,7 @@ i40e_recv_scattered_pkts(void *rx_queue,if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t )(rx_id ==0 ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -1249,7 +1249,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) (unsigned) tx_id, (unsigned) nb_tx);rte_cio_wmb (); -I40E_PCI_REG_WRITE_RELAXED (txq->qtx_tail, tx_id); +I40E_PCI_REG_WC_WRITE_RELAXED (txq->qtx_tail, tx_id); txq->tx_tail = tx_id;return nb_tx;
@@ -1400,7 +1400,7 @@ tx_xmit_pkts(struct i40e_tx_queue *txq, txq->tx_tail =0 ;/* Update the tx tail register */ -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_avx2.c +2 -2
@@ -134,7 +134,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -921,7 +921,7 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_sse.c +2 -2
@@ -86,7 +86,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -733,7 +733,7 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq->qtx_tail, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v11 2/5] net/i40e: use WC store to update queue tail registers
Hi,
Quoted 14 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Radu Nicolau
Sent: Wednesday, August 26, 2020 5:56 PM
To: [email protected]
Cc: Xing, Beilei <[email protected]>; Guo, Jia <[email protected]>; Richardson, Bruce <[email protected]>; Ananyev, Konstantin <[email protected]>; [email protected]; [email protected]; Trahe, Fiona <[email protected]>; Zhao1, Wei <[email protected]>; [email protected]; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Nicolau, Radu <[email protected]>
Subject: [dpdk-dev] [PATCH v11 2/5] net/i40e: use WC store to update queue tail registers
Quoted 5 lines
Performance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
Signed-off-by Radu Nicolau <[email protected]>Acked-by Bruce Richardson <[email protected]>
PATCH v11 3/5 common/qat: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/common/qat/qat_adf/adf_transport_access_macros.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/common/qat/qat_adf/adf_transport_access_macros.h +4 -2
@@ -9,6 +9,8 @@/* CSR write macro */ #define ADF_CSR_WR (csrAddr, csrOffset, val) \ rte_write32(val, (((uint8_t *)csrAddr) + csrOffset)) +#define ADF_CSR_WC_WR (csrAddr, csrOffset, val) \ + rte_write32_wc(val, (((uint8_t *)csrAddr) + csrOffset))/* CSR read macro */ #define ADF_CSR_RD (csrAddr, csrOffset) \
@@ -110,10 +112,10 @@ do { \ ADF_RING_CSR_RING_UBASE + (ring << 2), u_base); \ } while (0)#define WRITE_CSR_RING_HEAD (csr_base_addr, bank, ring, value) \ - ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ + ADF_CSR_WC_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ ADF_RING_CSR_RING_HEAD + (ring << 2), value)#define WRITE_CSR_RING_TAIL (csr_base_addr, bank, ring, value) \ - ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ + ADF_CSR_WC_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ ADF_RING_CSR_RING_TAIL + (ring << 2), value)#define WRITE_CSR_INT_SRCSEL (csr_base_addr, bank) \ do { \
Signature · 1 line
2.17.1
PATCH v11 4/5 net/ixgbe: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/net/ixgbe/base/ixgbe_osdep.h | 6 ++++++ drivers/net/ixgbe/ixgbe_rxtx.c | 15 ++++++++------- drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 4 ++-- 3 files changed, 16 insertions(+), 9 deletions(-)
drivers/net/ixgbe/base/ixgbe_osdep.h +6 -0
@@ -105,6 +105,12 @@ static inline uint32_t ixgbe_read_addr(volatile void* addr)#define IXGBE_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#define IXGBE_PCI_REG_WC_WRITE (reg, value) \ + rte_write32_wc((rte_cpu_to_le_32(value)), reg) + +#define IXGBE_PCI_REG_WC_WRITE_RELAXED (reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) +#define IXGBE_PCI_REG_ADDR (hw, reg) \ ((volatile uint32_t *)((char *)(hw)->hw_addr + (reg)))
drivers/net/ixgbe/ixgbe_rxtx.c +8 -7
@@ -308,7 +308,7 @@ tx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,/* update tail pointer */ rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (txq->tdt_reg_addr, txq->tx_tail); +IXGBE_PCI_REG_WC_WRITE_RELAXED (txq->tdt_reg_addr, txq->tx_tail);return nb_pkts; }
@@ -946,7 +946,7 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u tx_tail=%u nb_tx=%u" , (unsigned ) txq->port_id, (unsigned ) txq->queue_id, (unsigned ) tx_id, (unsigned ) nb_tx); -IXGBE_PCI_REG_WRITE_RELAXED (txq->tdt_reg_addr, tx_id); +IXGBE_PCI_REG_WC_WRITE_RELAXED (txq->tdt_reg_addr, tx_id); txq->tx_tail = tx_id;return nb_tx;
@@ -1692,7 +1692,7 @@ rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,/* update tail pointer */ rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (rxq->rdt_reg_addr, +IXGBE_PCI_REG_WC_WRITE_RELAXED (rxq->rdt_reg_addr, cur_free_trigger); }
@@ -1918,7 +1918,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, (unsigned) nb_rx); rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -IXGBE_PCI_REG_WRITE (rxq->rdt_reg_addr, rx_id); +IXGBE_PCI_REG_WC_WRITE (rxq->rdt_reg_addr, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -2096,8 +2096,9 @@ ixgbe_recv_pkts_lro(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts,if (!ixgbe_rx_alloc_bufs (rxq, false)) {rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (rxq->rdt_reg_addr, - next_rdt); +IXGBE_PCI_REG_WC_WRITE_RELAXED ( + rxq->rdt_reg_addr, + next_rdt); nb_hold -= rxq->rx_free_thresh; }else { PMD_RX_LOG(DEBUG, "RX bulk alloc failed "
@@ -2262,7 +2263,7 @@ ixgbe_recv_pkts_lro(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts, rxq->port_id, rxq->queue_id, rx_id, nb_hold, nb_rx);rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (rxq->rdt_reg_addr, prev_id); +IXGBE_PCI_REG_WC_WRITE_RELAXED (rxq->rdt_reg_addr, prev_id); nb_hold =0 ; }
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +2 -2
@@ -90,7 +90,7 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -IXGBE_PCI_REG_WRITE (rxq->rdt_reg_addr, rx_id); +IXGBE_PCI_REG_WC_WRITE (rxq->rdt_reg_addr, rx_id); }#ifdef RTE_LIBRTE_SECURITY
@@ -697,7 +697,7 @@ ixgbe_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -IXGBE_PCI_REG_WRITE (txq->tdt_reg_addr, txq->tx_tail); +IXGBE_PCI_REG_WC_WRITE (txq->tdt_reg_addr, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v11 4/5] net/ixgbe: use WC store to update queue tail registers
Hi,
Quoted 14 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Radu Nicolau
Sent: Wednesday, August 26, 2020 5:56 PM
To: [email protected]
Cc: Xing, Beilei <[email protected]>; Guo, Jia <[email protected]>; Richardson, Bruce <[email protected]>; Ananyev, Konstantin <[email protected]>; [email protected]; [email protected]; Trahe, Fiona <[email protected]>; Zhao1, Wei <[email protected]>; [email protected]; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Nicolau, Radu <[email protected]>
Subject: [dpdk-dev] [PATCH v11 4/5] net/ixgbe: use WC store to update queue tail registers
Quoted 5 lines
Performance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
Signed-off-by Radu Nicolau <[email protected]>
PATCH v11 5/5 net/ice: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- drivers/net/ice/base/ice_osdep.h | 1 + drivers/net/ice/ice_rxtx.c | 6 +++--- drivers/net/ice/ice_rxtx_vec_avx2.c | 4 ++-- drivers/net/ice/ice_rxtx_vec_sse.c | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-)
drivers/net/ice/base/ice_osdep.h +1 -0
@@ -165,6 +165,7 @@ do { \#endif #define ICE_PCI_REG_WRITE (reg, value) writel(value, reg) +#define ICE_PCI_REG_WC_WRITE (reg, value) rte_write32_wc(value, reg)#define ICE_READ_REG (hw, reg) rd32(hw, reg)#define ICE_WRITE_REG (hw, reg, value) wr32(hw, reg, value)
drivers/net/ice/ice_rxtx.c +3 -3
@@ -1741,7 +1741,7 @@ ice_recv_scattered_pkts(void *rx_queue, rx_id = (uint16_t )(rx_id ==0 ? (rxq->nb_rx_desc -1 ) : (rx_id -1 ));/* write TAIL register */ -ICE_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +ICE_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -2131,7 +2131,7 @@ ice_recv_pkts(void *rx_queue, rx_id = (uint16_t )(rx_id ==0 ? (rxq->nb_rx_desc -1 ) : (rx_id -1 ));/* write TAIL register */ -ICE_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +ICE_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -2846,7 +2846,7 @@ tx_xmit_pkts(struct ice_tx_queue *txq, txq->tx_tail =0 ;/* Update the tx tail register */ -ICE_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +ICE_PCI_REG_WC_WRITE (txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/ice/ice_rxtx_vec_avx2.c +2 -2
@@ -129,7 +129,7 @@ ice_rxq_rearm(struct ice_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -ICE_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +ICE_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); } static inline uint16_t
@@ -810,7 +810,7 @@ ice_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -ICE_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +ICE_PCI_REG_WC_WRITE (txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/ice/ice_rxtx_vec_sse.c +2 -2
@@ -78,7 +78,7 @@ ice_rxq_rearm(struct ice_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -ICE_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +ICE_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); } static inline void
@@ -583,7 +583,7 @@ ice_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -ICE_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +ICE_PCI_REG_WC_WRITE (txq->qtx_tail, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v11 5/5] net/ice: use WC store to update queue tail registers
Hi,
Quoted 14 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Radu Nicolau
Sent: Wednesday, August 26, 2020 5:56 PM
To: [email protected]
Cc: Xing, Beilei <[email protected]>; Guo, Jia <[email protected]>; Richardson, Bruce <[email protected]>; Ananyev, Konstantin <[email protected]>; [email protected]; [email protected]; Trahe, Fiona <[email protected]>; Zhao1, Wei <[email protected]>; [email protected]; Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Nicolau, Radu <[email protected]>
Subject: [dpdk-dev] [PATCH v11 5/5] net/ice: use WC store to update queue tail registers
Quoted 4 lines
Performance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
Signed-off-by Radu Nicolau <[email protected]>
v12 cover eal: add WC store functions
In reply to Radu NicolauImplement 2 new functions that will enable write combining stores depending on architecture. The functions are provided as a generic stub and a x86 specific implementation.
The reason to implement these functions is to improve performance by reducing the overhead associated with regular mmio writes when updating the hardware queue tails and doorbells.
With this patch set the I40E, ICE, IXGBE and QAT PMDs are updated to use the write combining store functions with other PMDs to follow.
Radu Nicolau (5):
eal: add WC store functions
net/i40e: use WC store to update queue tail registers common/qat: use WC store to update queue tail registers net/ixgbe: use WC store to update queue tail registers net/ice: use WC store to update queue tail registers
doc/guides/rel_notes/release_20_11.rst | 22 +++++++++ .../qat/qat_adf/adf_transport_access_macros.h | 6 ++- drivers/net/i40e/base/i40e_osdep.h | 5 ++ drivers/net/i40e/i40e_rxtx.c | 8 ++-- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 +- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 +- drivers/net/ice/base/ice_osdep.h | 1 + drivers/net/ice/ice_rxtx.c | 6 +-- drivers/net/ice/ice_rxtx_vec_avx2.c | 4 +- drivers/net/ice/ice_rxtx_vec_sse.c | 4 +- drivers/net/ixgbe/base/ixgbe_osdep.h | 6 +++ drivers/net/ixgbe/ixgbe_rxtx.c | 15 +++--- drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 4 +- lib/librte_eal/arm/include/rte_io_64.h | 12 +++++ lib/librte_eal/include/generic/rte_io.h | 48 +++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 42 ++++++++++++++++ 16 files changed, 165 insertions(+), 26 deletions(-)
Signature · 1 line
2.17.1
PATCH v12 1/5 eal: add WC store functions
Add rte_write32_wc and rte_write32_wc_relaxed functions that implement 32bit stores using write combining memory protocol. Provided generic stubs and x86 implementation.
--- doc/guides/rel_notes/release_20_11.rst | 6 ++++ lib/librte_eal/arm/include/rte_io_64.h | 12 +++++++ lib/librte_eal/include/generic/rte_io.h | 48 +++++++++++++++++++++++++ lib/librte_eal/x86/include/rte_io.h | 42 ++++++++++++++++++++++ 4 files changed, 108 insertions(+)
doc/guides/rel_notes/release_20_11.rst +6 -0
@@ -78,6 +78,12 @@ New Features ``--portmask=N`` where N represents the hexadecimal bitmask of ports used. +* **Added write combining store APIs.** + + Added ``rte_write32_wc`` and ``rte_write32_wc_relaxed`` APIs + that enable write combining stores (depending on architecture). + The functions are provided as a generic stubs and + x86 specific implementation. Removed Items -------------
lib/librte_eal/arm/include/rte_io_64.h +12 -0
@@ -164,6 +164,18 @@ rte_write64(uint64_t value, volatile void *addr)rte_write64_relaxed (value, addr); } +static __rte_always_inline void +rte_write32_wc (uint32_t value,volatile void *addr) +{ +rte_write32 (value, addr); +} + +static __rte_always_inline void +rte_write32_wc_relaxed (uint32_t value,volatile void *addr) +{ +rte_write32_relaxed (value, addr); +} + #ifdef __cplusplus }#endif
lib/librte_eal/include/generic/rte_io.h +48 -0
60 lines not on this page · raw message
lib/librte_eal/x86/include/rte_io.h +42 -0
50 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v12 2/5 net/i40e: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- doc/guides/rel_notes/release_20_11.rst | 4 ++++ drivers/net/i40e/base/i40e_osdep.h | 5 +++++ drivers/net/i40e/i40e_rxtx.c | 8 ++++---- drivers/net/i40e/i40e_rxtx_vec_avx2.c | 4 ++-- drivers/net/i40e/i40e_rxtx_vec_sse.c | 4 ++-- 5 files changed, 17 insertions(+), 8 deletions(-)
doc/guides/rel_notes/release_20_11.rst +4 -0
@@ -85,6 +85,10 @@ New Features The functions are provided as a generic stubs and x86 specific implementation. +* **Updated Intel i40e driver.** + + Updated the Intel i40e driver to use write combining stores. + Removed Items -------------
drivers/net/i40e/base/i40e_osdep.h +5 -0
@@ -138,6 +138,11 @@ static inline uint32_t i40e_read_addr(volatile void *addr)#define I40E_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE (reg, value) \ + rte_write32_wc((rte_cpu_to_le_32(value)), reg) +#define I40E_PCI_REG_WC_WRITE_RELAXED (reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) +#define I40E_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_GLGEN_STAT)#define I40EVF_WRITE_FLUSH (a) I40E_READ_REG(a, I40E_VFGEN_RSTAT)
drivers/net/i40e/i40e_rxtx.c +4 -4
@@ -760,7 +760,7 @@ i40e_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -938,7 +938,7 @@ i40e_recv_scattered_pkts(void *rx_queue,if (nb_hold > rxq->rx_free_thresh) { rx_id = (uint16_t )(rx_id ==0 ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -1249,7 +1249,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) (unsigned) tx_id, (unsigned) nb_tx);rte_cio_wmb (); -I40E_PCI_REG_WRITE_RELAXED (txq->qtx_tail, tx_id); +I40E_PCI_REG_WC_WRITE_RELAXED (txq->qtx_tail, tx_id); txq->tx_tail = tx_id;return nb_tx;
@@ -1400,7 +1400,7 @@ tx_xmit_pkts(struct i40e_tx_queue *txq, txq->tx_tail =0 ;/* Update the tx tail register */ -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_avx2.c +2 -2
@@ -134,7 +134,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -921,7 +921,7 @@ i40e_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/i40e/i40e_rxtx_vec_sse.c +2 -2
@@ -86,7 +86,7 @@ i40e_rxq_rearm(struct i40e_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -I40E_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +I40E_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); }#ifndef RTE_LIBRTE_I40E_16BYTE_RX_DESC
@@ -733,7 +733,7 @@ i40e_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -I40E_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +I40E_PCI_REG_WC_WRITE (txq->qtx_tail, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.17.1
PATCH v12 3/5 common/qat: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- doc/guides/rel_notes/release_20_11.rst | 4 ++++ drivers/common/qat/qat_adf/adf_transport_access_macros.h | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-)
doc/guides/rel_notes/release_20_11.rst +4 -0
@@ -89,6 +89,10 @@ New Features Updated the Intel i40e driver to use write combining stores. +* **Updated Intel qat driver.** + + Updated the Intel qat driver to use write combining stores. + Removed Items -------------
drivers/common/qat/qat_adf/adf_transport_access_macros.h +4 -2
@@ -9,6 +9,8 @@/* CSR write macro */ #define ADF_CSR_WR (csrAddr, csrOffset, val) \ rte_write32(val, (((uint8_t *)csrAddr) + csrOffset)) +#define ADF_CSR_WC_WR (csrAddr, csrOffset, val) \ + rte_write32_wc(val, (((uint8_t *)csrAddr) + csrOffset))/* CSR read macro */ #define ADF_CSR_RD (csrAddr, csrOffset) \
@@ -110,10 +112,10 @@ do { \ ADF_RING_CSR_RING_UBASE + (ring << 2), u_base); \ } while (0)#define WRITE_CSR_RING_HEAD (csr_base_addr, bank, ring, value) \ - ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ + ADF_CSR_WC_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ ADF_RING_CSR_RING_HEAD + (ring << 2), value)#define WRITE_CSR_RING_TAIL (csr_base_addr, bank, ring, value) \ - ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ + ADF_CSR_WC_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \ ADF_RING_CSR_RING_TAIL + (ring << 2), value)#define WRITE_CSR_INT_SRCSEL (csr_base_addr, bank) \ do { \
Signature · 1 line
2.17.1
PATCH v12 4/5 net/ixgbe: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- doc/guides/rel_notes/release_20_11.rst | 4 ++++ drivers/net/ixgbe/base/ixgbe_osdep.h | 6 ++++++ drivers/net/ixgbe/ixgbe_rxtx.c | 15 ++++++++------- drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c | 4 ++-- 4 files changed, 20 insertions(+), 9 deletions(-)
doc/guides/rel_notes/release_20_11.rst +4 -0
@@ -93,6 +93,10 @@ New Features Updated the Intel qat driver to use write combining stores. +* **Updated Intel ixgbe driver.** + + Updated the Intel ixgbe driver to use write combining stores. + Removed Items -------------
drivers/net/ixgbe/base/ixgbe_osdep.h +6 -0
@@ -105,6 +105,12 @@ static inline uint32_t ixgbe_read_addr(volatile void* addr)#define IXGBE_PCI_REG_WRITE_RELAXED (reg, value) \ rte_write32_relaxed((rte_cpu_to_le_32(value)), reg) +#define IXGBE_PCI_REG_WC_WRITE (reg, value) \ + rte_write32_wc((rte_cpu_to_le_32(value)), reg) + +#define IXGBE_PCI_REG_WC_WRITE_RELAXED (reg, value) \ + rte_write32_wc_relaxed((rte_cpu_to_le_32(value)), reg) +#define IXGBE_PCI_REG_ADDR (hw, reg) \ ((volatile uint32_t *)((char *)(hw)->hw_addr + (reg)))
drivers/net/ixgbe/ixgbe_rxtx.c +8 -7
@@ -308,7 +308,7 @@ tx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,/* update tail pointer */ rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (txq->tdt_reg_addr, txq->tx_tail); +IXGBE_PCI_REG_WC_WRITE_RELAXED (txq->tdt_reg_addr, txq->tx_tail);return nb_pkts; }
@@ -946,7 +946,7 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,PMD_TX_LOG (DEBUG ,"port_id=%u queue_id=%u tx_tail=%u nb_tx=%u" , (unsigned ) txq->port_id, (unsigned ) txq->queue_id, (unsigned ) tx_id, (unsigned ) nb_tx); -IXGBE_PCI_REG_WRITE_RELAXED (txq->tdt_reg_addr, tx_id); +IXGBE_PCI_REG_WC_WRITE_RELAXED (txq->tdt_reg_addr, tx_id); txq->tx_tail = tx_id;return nb_tx;
@@ -1692,7 +1692,7 @@ rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,/* update tail pointer */ rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (rxq->rdt_reg_addr, +IXGBE_PCI_REG_WC_WRITE_RELAXED (rxq->rdt_reg_addr, cur_free_trigger); }
@@ -1918,7 +1918,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, (unsigned) nb_rx); rx_id = (uint16_t ) ((rx_id ==0 ) ? (rxq->nb_rx_desc -1 ) : (rx_id -1 )); -IXGBE_PCI_REG_WRITE (rxq->rdt_reg_addr, rx_id); +IXGBE_PCI_REG_WC_WRITE (rxq->rdt_reg_addr, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -2096,8 +2096,9 @@ ixgbe_recv_pkts_lro(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts,if (!ixgbe_rx_alloc_bufs (rxq, false)) {rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (rxq->rdt_reg_addr, - next_rdt); +IXGBE_PCI_REG_WC_WRITE_RELAXED ( + rxq->rdt_reg_addr, + next_rdt); nb_hold -= rxq->rx_free_thresh; }else { PMD_RX_LOG(DEBUG, "RX bulk alloc failed "
@@ -2262,7 +2263,7 @@ ixgbe_recv_pkts_lro(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts, rxq->port_id, rxq->queue_id, rx_id, nb_hold, nb_rx);rte_wmb (); -IXGBE_PCI_REG_WRITE_RELAXED (rxq->rdt_reg_addr, prev_id); +IXGBE_PCI_REG_WC_WRITE_RELAXED (rxq->rdt_reg_addr, prev_id); nb_hold =0 ; }
drivers/net/ixgbe/ixgbe_rxtx_vec_sse.c +2 -2
@@ -90,7 +90,7 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -IXGBE_PCI_REG_WRITE (rxq->rdt_reg_addr, rx_id); +IXGBE_PCI_REG_WC_WRITE (rxq->rdt_reg_addr, rx_id); }#ifdef RTE_LIBRTE_SECURITY
@@ -697,7 +697,7 @@ ixgbe_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -IXGBE_PCI_REG_WRITE (txq->tdt_reg_addr, txq->tx_tail); +IXGBE_PCI_REG_WC_WRITE (txq->tdt_reg_addr, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.17.1
PATCH v12 5/5 net/ice: use WC store to update queue tail registers
In reply to Radu NicolauPerformance improvement: use a write combining store instead of a regular mmio write to update queue tail registers.
--- doc/guides/rel_notes/release_20_11.rst | 4 ++++ drivers/net/ice/base/ice_osdep.h | 1 + drivers/net/ice/ice_rxtx.c | 6 +++--- drivers/net/ice/ice_rxtx_vec_avx2.c | 4 ++-- drivers/net/ice/ice_rxtx_vec_sse.c | 4 ++-- 5 files changed, 12 insertions(+), 7 deletions(-)
doc/guides/rel_notes/release_20_11.rst +4 -0
@@ -97,6 +97,10 @@ New Features Updated the Intel ixgbe driver to use write combining stores. +* **Updated Intel ice driver.** + + Updated the Intel ice driver to use write combining stores. + Removed Items -------------
drivers/net/ice/base/ice_osdep.h +1 -0
@@ -165,6 +165,7 @@ do { \#endif #define ICE_PCI_REG_WRITE (reg, value) writel(value, reg) +#define ICE_PCI_REG_WC_WRITE (reg, value) rte_write32_wc(value, reg)#define ICE_READ_REG (hw, reg) rd32(hw, reg)#define ICE_WRITE_REG (hw, reg, value) wr32(hw, reg, value)
drivers/net/ice/ice_rxtx.c +3 -3
@@ -1788,7 +1788,7 @@ ice_recv_scattered_pkts(void *rx_queue, rx_id = (uint16_t )(rx_id ==0 ? (rxq->nb_rx_desc -1 ) : (rx_id -1 ));/* write TAIL register */ -ICE_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +ICE_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -2178,7 +2178,7 @@ ice_recv_pkts(void *rx_queue, rx_id = (uint16_t )(rx_id ==0 ? (rxq->nb_rx_desc -1 ) : (rx_id -1 ));/* write TAIL register */ -ICE_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +ICE_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); nb_hold =0 ; } rxq->nb_rx_hold = nb_hold;
@@ -2893,7 +2893,7 @@ tx_xmit_pkts(struct ice_tx_queue *txq, txq->tx_tail =0 ;/* Update the tx tail register */ -ICE_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +ICE_PCI_REG_WC_WRITE (txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/ice/ice_rxtx_vec_avx2.c +2 -2
@@ -129,7 +129,7 @@ ice_rxq_rearm(struct ice_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -ICE_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +ICE_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); } static inline __m256i
@@ -962,7 +962,7 @@ ice_xmit_fixed_burst_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -ICE_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +ICE_PCI_REG_WC_WRITE (txq->qtx_tail, txq->tx_tail);return nb_pkts; }
drivers/net/ice/ice_rxtx_vec_sse.c +2 -2
@@ -97,7 +97,7 @@ ice_rxq_rearm(struct ice_rx_queue *rxq) (rxq->nb_rx_desc - 1) : (rxq->rxrearm_start - 1));/* Update the tail pointer on the NIC */ -ICE_PCI_REG_WRITE (rxq->qrx_tail, rx_id); +ICE_PCI_REG_WC_WRITE (rxq->qrx_tail, rx_id); } static inline void
@@ -689,7 +689,7 @@ ice_xmit_fixed_burst_vec(void *tx_queue, struct rte_mbuf **tx_pkts, txq->tx_tail = tx_id; -ICE_PCI_REG_WRITE (txq->qtx_tail, txq->tx_tail); +ICE_PCI_REG_WC_WRITE (txq->qtx_tail, txq->tx_tail);return nb_pkts; }
Signature · 1 line
2.17.1
Re: [dpdk-dev] [PATCH v12 0/5] eal: add WC store functions
In reply to Radu NicolauQuoted 8 lines · Radu Nicolau
Implement 2 new functions that will enable write combining stores depending on architecture. The functions are provided as a generic stub and a x86 specific implementation.
The reason to implement these functions is to improve performance by reducing the overhead associated with regular mmio writes when updating the hardware queue tails and doorbells.
For the record, on which CPU/platform was this tested and how much of an improvement did you get with this?
I did not see review/ack tokens from other arch maintainers, but since it has been on the ml for a while, I guess I can proceed as is.
Quoted 3 lines
With this patch set the I40E, ICE, IXGBE and QAT PMDs are updated to use the write combining store functions with other PMDs to follow.
This series will go through the main repo: copying Ferruh and Akhil for info.
Signature · 1 line
David Marchand
Re: [dpdk-dev] [PATCH v12 0/5] eal: add WC store functions
Quoted 10 lines · David Marchand
Quoted 7 lines · Radu Nicolau
Implement 2 new functions that will enable write combining stores depending on architecture. The functions are provided as a generic stub and a x86 specific implementation.
The reason to implement these functions is to improve performance by reducing the overhead associated with regular mmio writes when updating the hardware queue tails and doorbells.
For the record, on which CPU/platform was this tested and how much of an improvement did you get with this?
The improvement varies a lot with the particular usecase and the PMD, so it's difficult to state a number, but there were cases with performance improvements going well into the double digits, with very small bursts applications seeing the most benefits. Tests were done on a Snow Ridge platform.
Quoted 10 lines
I did not see review/ack tokens from other arch maintainers, but since it has been on the ml for a while, I guess I can proceed as is.
Quoted 2 lines
With this patch set the I40E, ICE, IXGBE and QAT PMDs are updated to use the write combining store functions with other PMDs to follow.
This series will go through the main repo: copying Ferruh and Akhil for info.
Re: [dpdk-dev] [PATCH v12 0/5] eal: add WC store functions
In reply to David MarchandQuoted 18 lines · David Marchand
Quoted 8 lines · Radu Nicolau
Implement 2 new functions that will enable write combining stores depending on architecture. The functions are provided as a generic stub and a x86 specific implementation.
The reason to implement these functions is to improve performance by reducing the overhead associated with regular mmio writes when updating the hardware queue tails and doorbells.
For the record, on which CPU/platform was this tested and how much of an improvement did you get with this?
I did not see review/ack tokens from other arch maintainers, but since it has been on the ml for a while, I guess I can proceed as is.
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
With this patch set the I40E, ICE, IXGBE and QAT PMDs are updated to use the write combining store functions with other PMDs to follow.
This series will go through the main repo: copying Ferruh and Akhil for info.
Sounds good to me, +1 to not separate the driver implementation from actual change.
Re: [dpdk-dev] [PATCH v12 0/5] eal: add WC store functions
In reply to Radu NicolauQuoted 13 lines · Radu Nicolau
Implement 2 new functions that will enable write combining stores depending on architecture. The functions are provided as a generic stub and a x86 specific implementation.
The reason to implement these functions is to improve performance by reducing the overhead associated with regular mmio writes when updating the hardware queue tails and doorbells.
With this patch set the I40E, ICE, IXGBE and QAT PMDs are updated to use the write combining store functions with other PMDs to follow.
Quoted 6 lines
Radu Nicolau (5):
eal: add WC store functions
net/i40e: use WC store to update queue tail registers common/qat: use WC store to update queue tail registers net/ixgbe: use WC store to update queue tail registers net/ice: use WC store to update queue tail registers
Series applied.
Signature · 1 line
David Marchand