X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Fcommon%2Finclude%2Frte_fbarray.h;h=6dccdbec98947f668db62a024c5bf227861f99f4;hb=df3ff6be2b33faea3edf3c112b9bdc5b74d6f684;hp=97df945ea32e19ae37d81f5e35e1afb39571b295;hpb=c44d09811b40815d0b6d4b297f7709c741197774;p=dpdk.git diff --git a/lib/librte_eal/common/include/rte_fbarray.h b/lib/librte_eal/common/include/rte_fbarray.h index 97df945ea3..6dccdbec98 100644 --- a/lib/librte_eal/common/include/rte_fbarray.h +++ b/lib/librte_eal/common/include/rte_fbarray.h @@ -34,7 +34,6 @@ extern "C" { #endif -#include #include #include @@ -44,9 +43,9 @@ extern "C" { struct rte_fbarray { char name[RTE_FBARRAY_NAME_LEN]; /**< name associated with an array */ - int count; /**< number of entries stored */ - int len; /**< current length of the array */ - int elt_sz; /**< size of each element */ + unsigned int count; /**< number of entries stored */ + unsigned int len; /**< current length of the array */ + unsigned int elt_sz; /**< size of each element */ void *data; /**< data pointer */ rte_rwlock_t rwlock; /**< multiprocess lock */ }; @@ -75,9 +74,10 @@ struct rte_fbarray { * - 0 on success. * - -1 on failure, with ``rte_errno`` indicating reason for failure. */ -int __rte_experimental -rte_fbarray_init(struct rte_fbarray *arr, const char *name, int len, - int elt_sz); +__rte_experimental +int +rte_fbarray_init(struct rte_fbarray *arr, const char *name, unsigned int len, + unsigned int elt_sz); /** @@ -97,7 +97,8 @@ rte_fbarray_init(struct rte_fbarray *arr, const char *name, int len, * - 0 on success. * - -1 on failure, with ``rte_errno`` indicating reason for failure. */ -int __rte_experimental +__rte_experimental +int rte_fbarray_attach(struct rte_fbarray *arr); @@ -118,7 +119,8 @@ rte_fbarray_attach(struct rte_fbarray *arr); * - 0 on success. * - -1 on failure, with ``rte_errno`` indicating reason for failure. */ -int __rte_experimental +__rte_experimental +int rte_fbarray_destroy(struct rte_fbarray *arr); @@ -136,7 +138,8 @@ rte_fbarray_destroy(struct rte_fbarray *arr); * - 0 on success. * - -1 on failure, with ``rte_errno`` indicating reason for failure. */ -int __rte_experimental +__rte_experimental +int rte_fbarray_detach(struct rte_fbarray *arr); @@ -153,8 +156,9 @@ rte_fbarray_detach(struct rte_fbarray *arr); * - non-NULL pointer on success. * - NULL on failure, with ``rte_errno`` indicating reason for failure. */ -void * __rte_experimental -rte_fbarray_get(const struct rte_fbarray *arr, int idx); +__rte_experimental +void * +rte_fbarray_get(const struct rte_fbarray *arr, unsigned int idx); /** @@ -170,7 +174,8 @@ rte_fbarray_get(const struct rte_fbarray *arr, int idx); * - non-negative integer on success. * - -1 on failure, with ``rte_errno`` indicating reason for failure. */ -int __rte_experimental +__rte_experimental +int rte_fbarray_find_idx(const struct rte_fbarray *arr, const void *elt); @@ -187,8 +192,9 @@ rte_fbarray_find_idx(const struct rte_fbarray *arr, const void *elt); * - 0 on success. * - -1 on failure, with ``rte_errno`` indicating reason for failure. */ -int __rte_experimental -rte_fbarray_set_used(struct rte_fbarray *arr, int idx); +__rte_experimental +int +rte_fbarray_set_used(struct rte_fbarray *arr, unsigned int idx); /** @@ -204,8 +210,9 @@ rte_fbarray_set_used(struct rte_fbarray *arr, int idx); * - 0 on success. * - -1 on failure, with ``rte_errno`` indicating reason for failure. */ -int __rte_experimental -rte_fbarray_set_free(struct rte_fbarray *arr, int idx); +__rte_experimental +int +rte_fbarray_set_free(struct rte_fbarray *arr, unsigned int idx); /** @@ -222,8 +229,9 @@ rte_fbarray_set_free(struct rte_fbarray *arr, int idx); * - 0 if element is unused. * - -1 on failure, with ``rte_errno`` indicating reason for failure. */ -int __rte_experimental -rte_fbarray_is_used(struct rte_fbarray *arr, int idx); +__rte_experimental +int +rte_fbarray_is_used(struct rte_fbarray *arr, unsigned int idx); /** @@ -239,8 +247,9 @@ rte_fbarray_is_used(struct rte_fbarray *arr, int idx); * - non-negative integer on success. * - -1 on failure, with ``rte_errno`` indicating reason for failure. */ -int __rte_experimental -rte_fbarray_find_next_free(struct rte_fbarray *arr, int start); +__rte_experimental +int +rte_fbarray_find_next_free(struct rte_fbarray *arr, unsigned int start); /** @@ -256,8 +265,9 @@ rte_fbarray_find_next_free(struct rte_fbarray *arr, int start); * - non-negative integer on success. * - -1 on failure, with ``rte_errno`` indicating reason for failure. */ -int __rte_experimental -rte_fbarray_find_next_used(struct rte_fbarray *arr, int start); +__rte_experimental +int +rte_fbarray_find_next_used(struct rte_fbarray *arr, unsigned int start); /** @@ -276,8 +286,10 @@ rte_fbarray_find_next_used(struct rte_fbarray *arr, int start); * - non-negative integer on success. * - -1 on failure, with ``rte_errno`` indicating reason for failure. */ -int __rte_experimental -rte_fbarray_find_next_n_free(struct rte_fbarray *arr, int start, int n); +__rte_experimental +int +rte_fbarray_find_next_n_free(struct rte_fbarray *arr, unsigned int start, + unsigned int n); /** @@ -296,8 +308,10 @@ rte_fbarray_find_next_n_free(struct rte_fbarray *arr, int start, int n); * - non-negative integer on success. * - -1 on failure, with ``rte_errno`` indicating reason for failure. */ -int __rte_experimental -rte_fbarray_find_next_n_used(struct rte_fbarray *arr, int start, int n); +__rte_experimental +int +rte_fbarray_find_next_n_used(struct rte_fbarray *arr, unsigned int start, + unsigned int n); /** @@ -313,8 +327,10 @@ rte_fbarray_find_next_n_used(struct rte_fbarray *arr, int start, int n); * - non-negative integer on success. * - -1 on failure, with ``rte_errno`` indicating reason for failure. */ -int __rte_experimental -rte_fbarray_find_contig_free(struct rte_fbarray *arr, int start); +__rte_experimental +int +rte_fbarray_find_contig_free(struct rte_fbarray *arr, + unsigned int start); /** @@ -330,8 +346,203 @@ rte_fbarray_find_contig_free(struct rte_fbarray *arr, int start); * - non-negative integer on success. * - -1 on failure, with ``rte_errno`` indicating reason for failure. */ -int __rte_experimental -rte_fbarray_find_contig_used(struct rte_fbarray *arr, int start); +__rte_experimental +int +rte_fbarray_find_contig_used(struct rte_fbarray *arr, unsigned int start); + +/** + * Find index of previous free element, starting at specified index. + * + * @param arr + * Valid pointer to allocated and correctly set up ``rte_fbarray`` structure. + * + * @param start + * Element index to start search from. + * + * @return + * - non-negative integer on success. + * - -1 on failure, with ``rte_errno`` indicating reason for failure. + */ +__rte_experimental +int +rte_fbarray_find_prev_free(struct rte_fbarray *arr, unsigned int start); + + +/** + * Find index of previous used element, starting at specified index. + * + * @param arr + * Valid pointer to allocated and correctly set up ``rte_fbarray`` structure. + * + * @param start + * Element index to start search from. + * + * @return + * - non-negative integer on success. + * - -1 on failure, with ``rte_errno`` indicating reason for failure. + */ +__rte_experimental +int +rte_fbarray_find_prev_used(struct rte_fbarray *arr, unsigned int start); + + +/** + * Find lowest start index of chunk of ``n`` free elements, down from specified + * index. + * + * @param arr + * Valid pointer to allocated and correctly set up ``rte_fbarray`` structure. + * + * @param start + * Element index to start search from. + * + * @param n + * Number of free elements to look for. + * + * @return + * - non-negative integer on success. + * - -1 on failure, with ``rte_errno`` indicating reason for failure. + */ +__rte_experimental +int +rte_fbarray_find_prev_n_free(struct rte_fbarray *arr, unsigned int start, + unsigned int n); + + +/** + * Find lowest start index of chunk of ``n`` used elements, down from specified + * index. + * + * @param arr + * Valid pointer to allocated and correctly set up ``rte_fbarray`` structure. + * + * @param start + * Element index to start search from. + * + * @param n + * Number of used elements to look for. + * + * @return + * - non-negative integer on success. + * - -1 on failure, with ``rte_errno`` indicating reason for failure. + */ +__rte_experimental +int +rte_fbarray_find_prev_n_used(struct rte_fbarray *arr, unsigned int start, + unsigned int n); + + +/** + * Find how many more free entries there are before specified index (like + * ``rte_fbarray_find_contig_free`` but going in reverse). + * + * @param arr + * Valid pointer to allocated and correctly set up ``rte_fbarray`` structure. + * + * @param start + * Element index to start search from. + * + * @return + * - non-negative integer on success. + * - -1 on failure, with ``rte_errno`` indicating reason for failure. + */ +__rte_experimental +int +rte_fbarray_find_rev_contig_free(struct rte_fbarray *arr, + unsigned int start); + + +/** + * Find how many more used entries there are before specified index (like + * ``rte_fbarray_find_contig_used`` but going in reverse). + * + * @param arr + * Valid pointer to allocated and correctly set up ``rte_fbarray`` structure. + * + * @param start + * Element index to start search from. + * + * @return + * - non-negative integer on success. + * - -1 on failure, with ``rte_errno`` indicating reason for failure. + */ +__rte_experimental +int +rte_fbarray_find_rev_contig_used(struct rte_fbarray *arr, unsigned int start); + + +/** + * Find index of biggest chunk of free elements, starting at specified index. + * + * @param arr + * Valid pointer to allocated and correctly set up ``rte_fbarray`` structure. + * + * @param start + * Element index to start search from. + * + * @return + * - non-negative integer on success. + * - -1 on failure, with ``rte_errno`` indicating reason for failure. + */ +__rte_experimental +int +rte_fbarray_find_biggest_free(struct rte_fbarray *arr, unsigned int start); + + +/** + * Find index of biggest chunk of used elements, starting at specified index. + * + * @param arr + * Valid pointer to allocated and correctly set up ``rte_fbarray`` structure. + * + * @param start + * Element index to start search from. + * + * @return + * - non-negative integer on success. + * - -1 on failure, with ``rte_errno`` indicating reason for failure. + */ +__rte_experimental +int +rte_fbarray_find_biggest_used(struct rte_fbarray *arr, unsigned int start); + + +/** + * Find index of biggest chunk of free elements before a specified index (like + * ``rte_fbarray_find_biggest_free``, but going in reverse). + * + * @param arr + * Valid pointer to allocated and correctly set up ``rte_fbarray`` structure. + * + * @param start + * Element index to start search from. + * + * @return + * - non-negative integer on success. + * - -1 on failure, with ``rte_errno`` indicating reason for failure. + */ +__rte_experimental +int +rte_fbarray_find_rev_biggest_free(struct rte_fbarray *arr, unsigned int start); + + +/** + * Find index of biggest chunk of used elements before a specified index (like + * ``rte_fbarray_find_biggest_used``, but going in reverse). + * + * @param arr + * Valid pointer to allocated and correctly set up ``rte_fbarray`` structure. + * + * @param start + * Element index to start search from. + * + * @return + * - non-negative integer on success. + * - -1 on failure, with ``rte_errno`` indicating reason for failure. + */ +__rte_experimental +int +rte_fbarray_find_rev_biggest_used(struct rte_fbarray *arr, unsigned int start); /** @@ -343,7 +554,8 @@ rte_fbarray_find_contig_used(struct rte_fbarray *arr, int start); * @param f * File object to dump information into. */ -void __rte_experimental +__rte_experimental +void rte_fbarray_dump_metadata(struct rte_fbarray *arr, FILE *f); #ifdef __cplusplus