| 770 | } |
| 771 | |
| 772 | static int |
| 773 | check_memzone_bounded(const char *name, uint32_t len, uint32_t align, |
| 774 | uint32_t bound) |
| 775 | { |
| 776 | const struct rte_memzone *mz; |
| 777 | rte_iova_t bmask; |
| 778 | |
| 779 | bmask = ~((rte_iova_t)bound - 1); |
| 780 | |
| 781 | if ((mz = rte_memzone_reserve_bounded(name, len, SOCKET_ID_ANY, 0, |
| 782 | align, bound)) == NULL) { |
| 783 | printf("%s(%s): memzone creation failed\n", |
| 784 | __func__, name); |
| 785 | return -1; |
| 786 | } |
| 787 | |
| 788 | if ((mz->iova & ((rte_iova_t)align - 1)) != 0) { |
| 789 | printf("%s(%s): invalid phys addr alignment\n", |
| 790 | __func__, mz->name); |
| 791 | return -1; |
| 792 | } |
| 793 | |
| 794 | if (((uintptr_t) mz->addr & ((uintptr_t)align - 1)) != 0) { |
| 795 | printf("%s(%s): invalid virtual addr alignment\n", |
| 796 | __func__, mz->name); |
| 797 | return -1; |
| 798 | } |
| 799 | |
| 800 | if ((mz->len & RTE_CACHE_LINE_MASK) != 0 || mz->len < len || |
| 801 | mz->len < RTE_CACHE_LINE_SIZE) { |
| 802 | printf("%s(%s): invalid length\n", |
| 803 | __func__, mz->name); |
| 804 | return -1; |
| 805 | } |
| 806 | |
| 807 | if ((mz->iova & bmask) != |
| 808 | ((mz->iova + mz->len - 1) & bmask)) { |
| 809 | printf("%s(%s): invalid memzone boundary %u crossed\n", |
| 810 | __func__, mz->name, bound); |
| 811 | return -1; |
| 812 | } |
| 813 | |
| 814 | if (rte_memzone_free(mz)) { |
| 815 | printf("Fail memzone free\n"); |
| 816 | return -1; |
| 817 | } |
| 818 | |
| 819 | return 0; |
| 820 | } |
| 821 | |
| 822 | static int |
| 823 | test_memzone_bounded(void) |
no test coverage detected