#include <rte_spinlock.h>
#include <rte_tailq.h>
#include <rte_eal_paging.h>
+#include <rte_telemetry.h>
#include "rte_mempool.h"
#include "rte_mempool_trace.h"
STAILQ_INSERT_TAIL(&mp->mem_list, memhdr, next);
mp->nb_mem_chunks++;
- /* At least some objects in the pool can now be used for IO. */
- if (iova != RTE_BAD_IOVA)
+ /* Check if at least some objects in the pool are now usable for IO. */
+ if (!(mp->flags & RTE_MEMPOOL_F_NO_IOVA_CONTIG) && iova != RTE_BAD_IOVA)
mp->flags &= ~RTE_MEMPOOL_F_NON_IO;
/* Report the mempool as ready only when fully populated. */
rte_free(cache);
}
-#define MEMPOOL_KNOWN_FLAGS (RTE_MEMPOOL_F_NO_SPREAD \
- | RTE_MEMPOOL_F_NO_CACHE_ALIGN \
- | RTE_MEMPOOL_F_SP_PUT \
- | RTE_MEMPOOL_F_SC_GET \
- | RTE_MEMPOOL_F_POOL_CREATED \
- | RTE_MEMPOOL_F_NO_IOVA_CONTIG \
- )
/* create an empty mempool */
struct rte_mempool *
rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
return NULL;
}
- /* enforce no unknown flag is passed by the application */
- if ((flags & ~MEMPOOL_KNOWN_FLAGS) != 0) {
+ /* enforce only user flags are passed by the application */
+ if ((flags & ~RTE_MEMPOOL_VALID_USER_FLAGS) != 0) {
rte_errno = EINVAL;
return NULL;
}
rte_errno = -ret;
return ret;
}
+
+static void
+mempool_list_cb(struct rte_mempool *mp, void *arg)
+{
+ struct rte_tel_data *d = (struct rte_tel_data *)arg;
+
+ rte_tel_data_add_array_string(d, mp->name);
+}
+
+static int
+mempool_handle_list(const char *cmd __rte_unused,
+ const char *params __rte_unused, struct rte_tel_data *d)
+{
+ rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+ rte_mempool_walk(mempool_list_cb, d);
+ return 0;
+}
+
+struct mempool_info_cb_arg {
+ char *pool_name;
+ struct rte_tel_data *d;
+};
+
+static void
+mempool_info_cb(struct rte_mempool *mp, void *arg)
+{
+ struct mempool_info_cb_arg *info = (struct mempool_info_cb_arg *)arg;
+ const struct rte_memzone *mz;
+
+ if (strncmp(mp->name, info->pool_name, RTE_MEMZONE_NAMESIZE))
+ return;
+
+ rte_tel_data_add_dict_string(info->d, "name", mp->name);
+ rte_tel_data_add_dict_int(info->d, "pool_id", mp->pool_id);
+ rte_tel_data_add_dict_int(info->d, "flags", mp->flags);
+ rte_tel_data_add_dict_int(info->d, "socket_id", mp->socket_id);
+ rte_tel_data_add_dict_int(info->d, "size", mp->size);
+ rte_tel_data_add_dict_int(info->d, "cache_size", mp->cache_size);
+ rte_tel_data_add_dict_int(info->d, "elt_size", mp->elt_size);
+ rte_tel_data_add_dict_int(info->d, "header_size", mp->header_size);
+ rte_tel_data_add_dict_int(info->d, "trailer_size", mp->trailer_size);
+ rte_tel_data_add_dict_int(info->d, "private_data_size",
+ mp->private_data_size);
+ rte_tel_data_add_dict_int(info->d, "ops_index", mp->ops_index);
+ rte_tel_data_add_dict_int(info->d, "populated_size",
+ mp->populated_size);
+
+ mz = mp->mz;
+ rte_tel_data_add_dict_string(info->d, "mz_name", mz->name);
+ rte_tel_data_add_dict_int(info->d, "mz_len", mz->len);
+ rte_tel_data_add_dict_int(info->d, "mz_hugepage_sz",
+ mz->hugepage_sz);
+ rte_tel_data_add_dict_int(info->d, "mz_socket_id", mz->socket_id);
+ rte_tel_data_add_dict_int(info->d, "mz_flags", mz->flags);
+}
+
+static int
+mempool_handle_info(const char *cmd __rte_unused, const char *params,
+ struct rte_tel_data *d)
+{
+ struct mempool_info_cb_arg mp_arg;
+ char name[RTE_MEMZONE_NAMESIZE];
+
+ if (!params || strlen(params) == 0)
+ return -EINVAL;
+
+ rte_strlcpy(name, params, RTE_MEMZONE_NAMESIZE);
+
+ rte_tel_data_start_dict(d);
+ mp_arg.pool_name = name;
+ mp_arg.d = d;
+ rte_mempool_walk(mempool_info_cb, &mp_arg);
+
+ return 0;
+}
+
+RTE_INIT(mempool_init_telemetry)
+{
+ rte_telemetry_register_cmd("/mempool/list", mempool_handle_list,
+ "Returns list of available mempool. Takes no parameters");
+ rte_telemetry_register_cmd("/mempool/info", mempool_handle_info,
+ "Returns mempool info. Parameters: pool_name");
+}