-struct sync_mem_walk_arg {
- void *va_addr;
- size_t len;
- int result;
- bool attach;
-};
-
-static int
-sync_mem_walk(const struct rte_memseg_list *msl, void *arg)
-{
- struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
- struct sync_mem_walk_arg *wa = arg;
- size_t len = msl->page_sz * msl->memseg_arr.len;
-
- if (msl->base_va == wa->va_addr &&
- len == wa->len) {
- struct rte_memseg_list *found_msl;
- int msl_idx, ret;
-
- /* msl is const */
- msl_idx = msl - mcfg->memsegs;
- found_msl = &mcfg->memsegs[msl_idx];
-
- if (wa->attach) {
- ret = rte_fbarray_attach(&found_msl->memseg_arr);
- } else {
- /* notify all subscribers that a memory area is about to
- * be removed
- */
- eal_memalloc_mem_event_notify(RTE_MEM_EVENT_FREE,
- msl->base_va, msl->len);
- ret = rte_fbarray_detach(&found_msl->memseg_arr);
- }
-
- if (ret < 0) {
- wa->result = -rte_errno;
- } else {
- /* notify all subscribers that a new memory area was
- * added
- */
- if (wa->attach)
- eal_memalloc_mem_event_notify(
- RTE_MEM_EVENT_ALLOC,
- msl->base_va, msl->len);
- wa->result = 0;
- }
- return 1;
- }
- return 0;
-}
-