A device with addressing limitations will invoke this function
for setting a dma mask. It has no effect if there is another
dma mask already set and more restrictive than this one.

Signed-off-by: Alejandro Lucero <alejandro.luc...@netronome.com>
---
 lib/librte_eal/common/eal_common_memory.c  | 15 +++++++++++++++
 lib/librte_eal/common/include/rte_memory.h |  3 +++
 2 files changed, 18 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_memory.c 
b/lib/librte_eal/common/eal_common_memory.c
index fc6c44d..39bf98c 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -109,6 +109,21 @@
        }
 }
 
+/* set global dma mask based on device dma mask */
+void
+rte_eal_set_dma_mask(uint8_t maskbits) {
+
+       /* If no dma mask yet this is the new one */
+       if (!internal_config.dma_mask) {
+               internal_config.dma_mask = maskbits;
+               return;
+       }
+
+       /* Set dma mask just if more restrictive than current one */
+       if (internal_config.dma_mask > maskbits)
+               internal_config.dma_mask = maskbits;
+}
+
 /* return the number of memory channels */
 unsigned rte_memory_get_nchannel(void)
 {
diff --git a/lib/librte_eal/common/include/rte_memory.h 
b/lib/librte_eal/common/include/rte_memory.h
index 80a8fc0..a078c31 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -209,6 +209,9 @@ struct rte_memseg {
  */
 unsigned rte_memory_get_nrank(void);
 
+/* set global dma mask based on a specific device dma mask */
+void rte_eal_set_dma_mask(uint8_t maskbits);
+
 /**
  * Drivers based on uio will not load unless physical
  * addresses are obtainable. It is only possible to get
-- 
1.9.1

Reply via email to