aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetri Savolainen <petri.savolainen@nokia.com>2022-10-21 12:42:11 +0300
committerMatias Elo <matias.elo@nokia.com>2022-11-30 12:43:46 +0200
commitb1c312eced6e45d542d98bba43cfb4f44a19140e (patch)
tree94bf37a51dda5e37456ad01499bc96861fefcdbb
parent47a8ec02bfbe25827c2d8a5e3fc67e331467da10 (diff)
api: shm: add segment info
Added odp_shm_segment_info() which can be used to retrieve information of each memory segment of an SHM block. Signed-off-by: Petri Savolainen <petri.savolainen@nokia.com> Reviewed-by: Harman Kalra <hkalra@marvell.com> Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
-rw-r--r--include/odp/api/abi-default/shared_memory.h3
-rw-r--r--include/odp/api/spec/shared_memory.h65
-rw-r--r--platform/linux-generic/include-abi/odp/api/abi/shared_memory.h3
3 files changed, 71 insertions, 0 deletions
diff --git a/include/odp/api/abi-default/shared_memory.h b/include/odp/api/abi-default/shared_memory.h
index fdc93ea1d..4668927cd 100644
--- a/include/odp/api/abi-default/shared_memory.h
+++ b/include/odp/api/abi-default/shared_memory.h
@@ -23,6 +23,9 @@ typedef _odp_abi_shm_t *odp_shm_t;
#define ODP_SHM_INVALID ((odp_shm_t)0)
#define ODP_SHM_NAME_LEN 32
+#define ODP_SHM_IOVA_INVALID ((uint64_t)-1)
+#define ODP_SHM_PA_INVALID ODP_SHM_IOVA_INVALID
+
/**
* @}
*/
diff --git a/include/odp/api/spec/shared_memory.h b/include/odp/api/spec/shared_memory.h
index d1955db26..c1ca724c9 100644
--- a/include/odp/api/spec/shared_memory.h
+++ b/include/odp/api/spec/shared_memory.h
@@ -43,6 +43,16 @@ extern "C" {
/* Shared memory flags */
/**
+ * @def ODP_SHM_IOVA_INVALID
+ * Invalid IOVA address
+ */
+
+/**
+ * @def ODP_SHM_PA_INVALID
+ * Invalid physical address
+ */
+
+/**
* Application SW only, no HW access
*
* @deprecated When set, application will not share the reserved memory with HW
@@ -123,9 +133,43 @@ typedef struct odp_shm_info_t {
/** ODP_SHM_* flags */
uint32_t flags;
+
+ /**
+ * Number of memory segments
+ *
+ * Number of segments in physical (or IOVA) address space that map memory to
+ * the SHM block. More information about each segment can be retrieved with
+ * odp_shm_segment_info(). Number of segments is always at least one, also when
+ * physical (or IOVA) segmentation information is not available. */
+ uint32_t num_seg;
+
} odp_shm_info_t;
/**
+ * SHM memory segment info
+ */
+typedef struct odp_shm_segment_info_t {
+ /** Segment start address (virtual) */
+ uintptr_t addr;
+
+ /** Segment start address in IO virtual address (IOVA) space
+ *
+ * Value is ODP_SHM_IOVA_INVALID when IOVA address is not available.
+ */
+ uint64_t iova;
+
+ /** Segment start address in physical address space
+ *
+ * Value is ODP_SHM_PA_INVALID when physical address is not available.
+ */
+ uint64_t pa;
+
+ /** Segment length in bytes */
+ uint64_t len;
+
+} odp_shm_segment_info_t;
+
+/**
* Shared memory capabilities
*/
typedef struct odp_shm_capability_t {
@@ -262,6 +306,27 @@ void *odp_shm_addr(odp_shm_t shm);
int odp_shm_info(odp_shm_t shm, odp_shm_info_t *info);
/**
+ * SHM block segmentation information
+ *
+ * Retrieve information about each memory segment of an SHM block. SHM info call outputs the number
+ * of memory segments (@see odp_shm_info_t.num_seg). A single segment info call may be used
+ * to request information for all the segments, or for a subset of those. Use 'index' and 'num'
+ * parameters to specify the segments. Segment indexing starts from zero and continues to
+ * odp_shm_info_t.num_seg - 1. Segment infos are written in virtual memory address order and
+ * without address overlaps. Segment info array must have at least 'num' elements.
+ *
+ * @param shm SHM block handle
+ * @param index Index of the first segment to retrieve information
+ * @param num Number of segments to retrieve information
+ * @param[out] info Segment info array for output
+ *
+ * @retval 0 on success
+ * @retval <0 on failure
+ */
+int odp_shm_segment_info(odp_shm_t shm, uint32_t index, uint32_t num,
+ odp_shm_segment_info_t info[]);
+
+/**
* Print all shared memory blocks
*/
void odp_shm_print_all(void);
diff --git a/platform/linux-generic/include-abi/odp/api/abi/shared_memory.h b/platform/linux-generic/include-abi/odp/api/abi/shared_memory.h
index 648bd1ee3..551d49e30 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/shared_memory.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/shared_memory.h
@@ -31,6 +31,9 @@ typedef ODP_HANDLE_T(odp_shm_t);
#define ODP_SHM_NAME_LEN 32
+#define ODP_SHM_IOVA_INVALID ((uint64_t)-1)
+#define ODP_SHM_PA_INVALID ODP_SHM_IOVA_INVALID
+
/**
* @}
*/