MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rte_fbarray_init

Function rte_fbarray_init

dpdk/lib/eal/common/eal_common_fbarray.c:718–842  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

716}
717
718int
719rte_fbarray_init(struct rte_fbarray *arr, const char *name, unsigned int len,
720 unsigned int elt_sz)
721{
722 size_t page_sz, mmap_len;
723 char path[PATH_MAX];
724 struct used_mask *msk;
725 struct mem_area *ma = NULL;
726 void *data = NULL;
727 int fd = -1;
728 const struct internal_config *internal_conf =
729 eal_get_internal_configuration();
730
731 if (arr == NULL) {
732 rte_errno = EINVAL;
733 return -1;
734 }
735
736 if (fully_validate(name, elt_sz, len))
737 return -1;
738
739 /* allocate mem area before doing anything */
740 ma = malloc(sizeof(*ma));
741 if (ma == NULL) {
742 rte_errno = ENOMEM;
743 return -1;
744 }
745
746 page_sz = rte_mem_page_size();
747 if (page_sz == (size_t)-1) {
748 free(ma);
749 return -1;
750 }
751
752 /* calculate our memory limits */
753 mmap_len = calc_data_size(page_sz, elt_sz, len);
754
755 data = eal_get_virtual_area(NULL, &mmap_len, page_sz, 0, 0);
756 if (data == NULL) {
757 free(ma);
758 return -1;
759 }
760
761 rte_spinlock_lock(&mem_area_lock);
762
763 fd = -1;
764
765 if (internal_conf->no_shconf) {
766 /* remap virtual area as writable */
767 static const int flags = RTE_MAP_FORCE_ADDRESS |
768 RTE_MAP_PRIVATE | RTE_MAP_ANONYMOUS;
769 void *new_data = rte_mem_map(data, mmap_len,
770 RTE_PROT_READ | RTE_PROT_WRITE, flags, fd, 0);
771 if (new_data == NULL) {
772 RTE_LOG(DEBUG, EAL, "%s(): couldn't remap anonymous memory: %s\n",
773 __func__, rte_strerror(rte_errno));
774 goto fail;
775 }

Callers 6

rte_eal_memzone_initFunction · 0.85
autotest_setupFunction · 0.85
test_invalidFunction · 0.85

Calls 15

fully_validateFunction · 0.85
mallocFunction · 0.85
calc_data_sizeFunction · 0.85
eal_get_virtual_areaFunction · 0.85
rte_strerrorFunction · 0.85
eal_get_fbarray_pathFunction · 0.85
resize_and_mapFunction · 0.85
memsetFunction · 0.85
get_used_maskFunction · 0.85
rte_rwlock_initFunction · 0.85
rte_mem_page_sizeFunction · 0.50

Tested by 2

autotest_setupFunction · 0.68
test_invalidFunction · 0.68