[4/6] mem: add function for setting internal dma mask

Message ID 1530034653-28299-5-git-send-email-alejandro.lucero@netronome.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series [1/6] eal: add internal dma mask |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation fail Compilation issues

Commit Message

Alejandro Lucero June 26, 2018, 5:37 p.m. UTC
  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.lucero@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(+)
  

Patch

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