Loading include/spdk/env.h +30 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ extern "C" { #endif #include <stdbool.h> #include <stddef.h> #include <stdint.h> Loading @@ -61,6 +62,35 @@ spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr); void spdk_free(void *buf); /** * Reserve a named, process shared memory zone with the given size, * socket_id and flags. * Return a pointer to the allocated memory address. If the allocation * cannot be done, return NULL. */ void * spdk_memzone_reserve(const char *name, size_t len, int socket_id, unsigned flags); /** * Lookup the memory zone identified by the given name. * Return a pointer to the reserved memory address. If the reservation * cannot be found, return NULL. */ void * spdk_memzone_lookup(const char *name); /** * Free the memory zone identified by the given name. */ int spdk_memzone_free(const char *name); /** * Return true if the calling process is primary process */ bool spdk_process_is_primary(void); /** * Get a monotonic timestamp counter. */ Loading lib/env/env.c +44 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,8 @@ #include <rte_config.h> #include <rte_cycles.h> #include <rte_malloc.h> #include <rte_mempool.h> #include <rte_memzone.h> void * spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr) Loading @@ -56,6 +58,48 @@ spdk_free(void *buf) return rte_free(buf); } void * spdk_memzone_reserve(const char *name, size_t len, int socket_id, unsigned flags) { const struct rte_memzone *mz = rte_memzone_reserve(name, len, socket_id, flags); if (mz != NULL) { return mz->addr; } else { return NULL; } } void * spdk_memzone_lookup(const char *name) { const struct rte_memzone *mz = rte_memzone_lookup(name); if (mz != NULL) { return mz->addr; } else { return NULL; } } int spdk_memzone_free(const char *name) { const struct rte_memzone *mz = rte_memzone_lookup(name); if (mz != NULL) { return rte_memzone_free(mz); } return -1; } bool spdk_process_is_primary(void) { return (rte_eal_process_type() == RTE_PROC_PRIMARY); } uint64_t spdk_get_ticks(void) { return rte_get_timer_cycles(); Loading lib/nvme/nvme_impl.h +4 −39 Original line number Diff line number Diff line Loading @@ -56,7 +56,6 @@ #include <rte_config.h> #include <rte_mempool.h> #include <rte_version.h> #include <rte_memzone.h> #include <rte_eal.h> #include "spdk/pci_ids.h" Loading Loading @@ -91,58 +90,24 @@ * Return a pointer to the allocated memory address. If the allocation * cannot be done, return NULL. */ static inline void * nvme_memzone_reserve(const char *name, size_t len, int socket_id, unsigned flags) { const struct rte_memzone *mz = rte_memzone_reserve(name, len, socket_id, flags); if (mz != NULL) { return mz->addr; } else { return NULL; } } #define nvme_memzone_reserve spdk_memzone_reserve /** * Lookup the memory zone identified by the given name. * Return a pointer to the reserved memory address. If the reservation * cannot be found, return NULL. */ static inline void * nvme_memzone_lookup(const char *name) { const struct rte_memzone *mz = rte_memzone_lookup(name); if (mz != NULL) { return mz->addr; } else { return NULL; } } #define nvme_memzone_lookup spdk_memzone_lookup /** * Free the memory zone identified by the given name. */ static inline int nvme_memzone_free(const char *name) { const struct rte_memzone *mz = rte_memzone_lookup(name); if (mz != NULL) { return rte_memzone_free(mz); } return -1; } #define nvme_memzone_free spdk_memzone_free /** * Return true if the calling process is primary process */ static inline bool nvme_process_is_primary(void) { return (rte_eal_process_type() == RTE_PROC_PRIMARY); } #define nvme_process_is_primary spdk_process_is_primary /** * Return the physical address for the specified virtual address. Loading Loading
include/spdk/env.h +30 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ extern "C" { #endif #include <stdbool.h> #include <stddef.h> #include <stdint.h> Loading @@ -61,6 +62,35 @@ spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr); void spdk_free(void *buf); /** * Reserve a named, process shared memory zone with the given size, * socket_id and flags. * Return a pointer to the allocated memory address. If the allocation * cannot be done, return NULL. */ void * spdk_memzone_reserve(const char *name, size_t len, int socket_id, unsigned flags); /** * Lookup the memory zone identified by the given name. * Return a pointer to the reserved memory address. If the reservation * cannot be found, return NULL. */ void * spdk_memzone_lookup(const char *name); /** * Free the memory zone identified by the given name. */ int spdk_memzone_free(const char *name); /** * Return true if the calling process is primary process */ bool spdk_process_is_primary(void); /** * Get a monotonic timestamp counter. */ Loading
lib/env/env.c +44 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,8 @@ #include <rte_config.h> #include <rte_cycles.h> #include <rte_malloc.h> #include <rte_mempool.h> #include <rte_memzone.h> void * spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr) Loading @@ -56,6 +58,48 @@ spdk_free(void *buf) return rte_free(buf); } void * spdk_memzone_reserve(const char *name, size_t len, int socket_id, unsigned flags) { const struct rte_memzone *mz = rte_memzone_reserve(name, len, socket_id, flags); if (mz != NULL) { return mz->addr; } else { return NULL; } } void * spdk_memzone_lookup(const char *name) { const struct rte_memzone *mz = rte_memzone_lookup(name); if (mz != NULL) { return mz->addr; } else { return NULL; } } int spdk_memzone_free(const char *name) { const struct rte_memzone *mz = rte_memzone_lookup(name); if (mz != NULL) { return rte_memzone_free(mz); } return -1; } bool spdk_process_is_primary(void) { return (rte_eal_process_type() == RTE_PROC_PRIMARY); } uint64_t spdk_get_ticks(void) { return rte_get_timer_cycles(); Loading
lib/nvme/nvme_impl.h +4 −39 Original line number Diff line number Diff line Loading @@ -56,7 +56,6 @@ #include <rte_config.h> #include <rte_mempool.h> #include <rte_version.h> #include <rte_memzone.h> #include <rte_eal.h> #include "spdk/pci_ids.h" Loading Loading @@ -91,58 +90,24 @@ * Return a pointer to the allocated memory address. If the allocation * cannot be done, return NULL. */ static inline void * nvme_memzone_reserve(const char *name, size_t len, int socket_id, unsigned flags) { const struct rte_memzone *mz = rte_memzone_reserve(name, len, socket_id, flags); if (mz != NULL) { return mz->addr; } else { return NULL; } } #define nvme_memzone_reserve spdk_memzone_reserve /** * Lookup the memory zone identified by the given name. * Return a pointer to the reserved memory address. If the reservation * cannot be found, return NULL. */ static inline void * nvme_memzone_lookup(const char *name) { const struct rte_memzone *mz = rte_memzone_lookup(name); if (mz != NULL) { return mz->addr; } else { return NULL; } } #define nvme_memzone_lookup spdk_memzone_lookup /** * Free the memory zone identified by the given name. */ static inline int nvme_memzone_free(const char *name) { const struct rte_memzone *mz = rte_memzone_lookup(name); if (mz != NULL) { return rte_memzone_free(mz); } return -1; } #define nvme_memzone_free spdk_memzone_free /** * Return true if the calling process is primary process */ static inline bool nvme_process_is_primary(void) { return (rte_eal_process_type() == RTE_PROC_PRIMARY); } #define nvme_process_is_primary spdk_process_is_primary /** * Return the physical address for the specified virtual address. Loading