| 35 | #define EXTERNAL_MEM_SZ (RTE_PGSIZE_4K << 10) /* 4M of data */ |
| 36 | |
| 37 | static int |
| 38 | check_mem(void *addr, rte_iova_t *iova, size_t pgsz, int n_pages) |
| 39 | { |
| 40 | int i; |
| 41 | |
| 42 | /* check that we can get this memory from EAL now */ |
| 43 | for (i = 0; i < n_pages; i++) { |
| 44 | const struct rte_memseg_list *msl; |
| 45 | const struct rte_memseg *ms; |
| 46 | void *cur = RTE_PTR_ADD(addr, pgsz * i); |
| 47 | rte_iova_t expected_iova; |
| 48 | |
| 49 | msl = rte_mem_virt2memseg_list(cur); |
| 50 | if (!msl->external) { |
| 51 | printf("%s():%i: Memseg list is not marked as external\n", |
| 52 | __func__, __LINE__); |
| 53 | return -1; |
| 54 | } |
| 55 | |
| 56 | ms = rte_mem_virt2memseg(cur, msl); |
| 57 | if (ms == NULL) { |
| 58 | printf("%s():%i: Failed to retrieve memseg for external mem\n", |
| 59 | __func__, __LINE__); |
| 60 | return -1; |
| 61 | } |
| 62 | if (ms->addr != cur) { |
| 63 | printf("%s():%i: VA mismatch\n", __func__, __LINE__); |
| 64 | return -1; |
| 65 | } |
| 66 | expected_iova = (iova == NULL) ? RTE_BAD_IOVA : iova[i]; |
| 67 | if (ms->iova != expected_iova) { |
| 68 | printf("%s():%i: IOVA mismatch\n", __func__, __LINE__); |
| 69 | return -1; |
| 70 | } |
| 71 | } |
| 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | static int |
| 76 | test_malloc_invalid_param(void *addr, size_t len, size_t pgsz, rte_iova_t *iova, |
no test coverage detected