static int fslmc_unmap_dma(uint64_t vaddr, rte_iova_t iovaddr, size_t len);
static void
-fslmc_memevent_cb(enum rte_mem_event type, const void *addr, size_t len)
+fslmc_memevent_cb(enum rte_mem_event type, const void *addr, size_t len,
+ void *arg __rte_unused)
{
struct rte_memseg_list *msl;
struct rte_memseg *ms;
}
ret = rte_mem_event_callback_register("fslmc_memevent_clb",
- fslmc_memevent_cb);
+ fslmc_memevent_cb, NULL);
if (ret && rte_errno == ENOTSUP)
DPAA2_BUS_DEBUG("Memory event callbacks not supported");
else if (ret)
TAILQ_ENTRY(mem_event_callback_entry) next;
char name[RTE_MEM_EVENT_CALLBACK_NAME_LEN];
rte_mem_event_callback_t clb;
+ void *arg;
};
struct mem_alloc_validator_entry {
static rte_rwlock_t mem_alloc_validator_rwlock = RTE_RWLOCK_INITIALIZER;
static struct mem_event_callback_entry *
-find_mem_event_callback(const char *name)
+find_mem_event_callback(const char *name, void *arg)
{
struct mem_event_callback_entry *r;
TAILQ_FOREACH(r, &mem_event_callback_list, next) {
- if (!strcmp(r->name, name))
+ if (!strcmp(r->name, name) && r->arg == arg)
break;
}
return r;
int
eal_memalloc_mem_event_callback_register(const char *name,
- rte_mem_event_callback_t clb)
+ rte_mem_event_callback_t clb, void *arg)
{
struct mem_event_callback_entry *entry;
int ret, len;
}
rte_rwlock_write_lock(&mem_event_rwlock);
- entry = find_mem_event_callback(name);
+ entry = find_mem_event_callback(name, arg);
if (entry != NULL) {
rte_errno = EEXIST;
ret = -1;
/* callback successfully created and is valid, add it to the list */
entry->clb = clb;
+ entry->arg = arg;
strlcpy(entry->name, name, RTE_MEM_EVENT_CALLBACK_NAME_LEN);
TAILQ_INSERT_TAIL(&mem_event_callback_list, entry, next);
ret = 0;
- RTE_LOG(DEBUG, EAL, "Mem event callback '%s' registered\n", name);
+ RTE_LOG(DEBUG, EAL, "Mem event callback '%s:%p' registered\n",
+ name, arg);
unlock:
rte_rwlock_write_unlock(&mem_event_rwlock);
}
int
-eal_memalloc_mem_event_callback_unregister(const char *name)
+eal_memalloc_mem_event_callback_unregister(const char *name, void *arg)
{
struct mem_event_callback_entry *entry;
int ret, len;
}
rte_rwlock_write_lock(&mem_event_rwlock);
- entry = find_mem_event_callback(name);
+ entry = find_mem_event_callback(name, arg);
if (entry == NULL) {
rte_errno = ENOENT;
ret = -1;
ret = 0;
- RTE_LOG(DEBUG, EAL, "Mem event callback '%s' unregistered\n", name);
+ RTE_LOG(DEBUG, EAL, "Mem event callback '%s:%p' unregistered\n",
+ name, arg);
unlock:
rte_rwlock_write_unlock(&mem_event_rwlock);
rte_rwlock_read_lock(&mem_event_rwlock);
TAILQ_FOREACH(entry, &mem_event_callback_list, next) {
- RTE_LOG(DEBUG, EAL, "Calling mem event callback %s",
- entry->name);
- entry->clb(event, start, len);
+ RTE_LOG(DEBUG, EAL, "Calling mem event callback '%s:%p'",
+ entry->name, entry->arg);
+ entry->clb(event, start, len, entry->arg);
}
rte_rwlock_read_unlock(&mem_event_rwlock);
* is in eal_common_memalloc.c, like all other memalloc internals.
*/
int __rte_experimental
-rte_mem_event_callback_register(const char *name, rte_mem_event_callback_t clb)
+rte_mem_event_callback_register(const char *name, rte_mem_event_callback_t clb,
+ void *arg)
{
/* FreeBSD boots with legacy mem enabled by default */
if (internal_config.legacy_mem) {
rte_errno = ENOTSUP;
return -1;
}
- return eal_memalloc_mem_event_callback_register(name, clb);
+ return eal_memalloc_mem_event_callback_register(name, clb, arg);
}
int __rte_experimental
-rte_mem_event_callback_unregister(const char *name)
+rte_mem_event_callback_unregister(const char *name, void *arg)
{
/* FreeBSD boots with legacy mem enabled by default */
if (internal_config.legacy_mem) {
rte_errno = ENOTSUP;
return -1;
}
- return eal_memalloc_mem_event_callback_unregister(name);
+ return eal_memalloc_mem_event_callback_unregister(name, arg);
}
int __rte_experimental
int
eal_memalloc_mem_event_callback_register(const char *name,
- rte_mem_event_callback_t clb);
+ rte_mem_event_callback_t clb, void *arg);
int
-eal_memalloc_mem_event_callback_unregister(const char *name);
+eal_memalloc_mem_event_callback_unregister(const char *name, void *arg);
void
eal_memalloc_mem_event_notify(enum rte_mem_event event, const void *start,
* Function typedef used to register callbacks for memory events.
*/
typedef void (*rte_mem_event_callback_t)(enum rte_mem_event event_type,
- const void *addr, size_t len);
+ const void *addr, size_t len, void *arg);
/**
* Function used to register callbacks for memory events.
* @param clb
* Callback function pointer.
*
+ * @param arg
+ * Argument to pass to the callback.
+ *
* @return
* 0 on successful callback register
* -1 on unsuccessful callback register, with rte_errno value indicating
* reason for failure.
*/
int __rte_experimental
-rte_mem_event_callback_register(const char *name, rte_mem_event_callback_t clb);
+rte_mem_event_callback_register(const char *name, rte_mem_event_callback_t clb,
+ void *arg);
/**
* Function used to unregister callbacks for memory events.
* @param name
* Name associated with specified callback to be removed from the list.
*
+ * @param arg
+ * Argument to look for among callbacks with specified callback name.
+ *
* @return
* 0 on successful callback unregister
* -1 on unsuccessful callback unregister, with rte_errno value indicating
* reason for failure.
*/
int __rte_experimental
-rte_mem_event_callback_unregister(const char *name);
+rte_mem_event_callback_unregister(const char *name, void *arg);
#define RTE_MEM_ALLOC_VALIDATOR_NAME_LEN 64
}
static void
-vfio_mem_event_callback(enum rte_mem_event type, const void *addr, size_t len)
+vfio_mem_event_callback(enum rte_mem_event type, const void *addr, size_t len,
+ void *arg __rte_unused)
{
struct rte_memseg_list *msl;
struct rte_memseg *ms;
if (vfio_cfg == default_vfio_cfg)
ret = rte_mem_event_callback_register(
VFIO_MEM_EVENT_CLB_NAME,
- vfio_mem_event_callback);
+ vfio_mem_event_callback, NULL);
else
ret = 0;
/* unlock memory hotplug */
* avoid spurious attempts to map/unmap memory from VFIO.
*/
if (vfio_cfg == default_vfio_cfg && vfio_cfg->vfio_active_groups == 0)
- rte_mem_event_callback_unregister(VFIO_MEM_EVENT_CLB_NAME);
+ rte_mem_event_callback_unregister(VFIO_MEM_EVENT_CLB_NAME,
+ NULL);
/* success */
ret = 0;