X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fmlx5%2Fmlx5_utils.h;h=e2dcbafc0a8bfb5379c791f85f765ca77419fb4c;hb=8e83ba285abe4341b7666927d3fc265b35446c06;hp=737dd7052d9d4baa75a9e0365c3f595e747d3536;hpb=64a80f1c4818ff662f2c54cd0477baca0a7a018f;p=dpdk.git diff --git a/drivers/net/mlx5/mlx5_utils.h b/drivers/net/mlx5/mlx5_utils.h index 737dd7052d..e2dcbafc0a 100644 --- a/drivers/net/mlx5/mlx5_utils.h +++ b/drivers/net/mlx5/mlx5_utils.h @@ -55,7 +55,7 @@ extern int mlx5_logtype; /* * For the case which data is linked with sequence increased index, the - * array table will be more efficiect than hash table once need to serarch + * array table will be more efficient than hash table once need to search * one data entry in large numbers of entries. Since the traditional hash * tables has fixed table size, when huge numbers of data saved to the hash * table, it also comes lots of hash conflict. @@ -248,6 +248,7 @@ struct mlx5_ipool_per_lcore { struct mlx5_indexed_pool { struct mlx5_indexed_pool_config cfg; /* Indexed pool configuration. */ rte_spinlock_t rsz_lock; /* Pool lock for multiple thread usage. */ + rte_spinlock_t lcore_lock; /* Dim of trunk pointer array. */ union { struct { @@ -259,7 +260,7 @@ struct mlx5_indexed_pool { struct { struct mlx5_indexed_cache *gc; /* Global cache. */ - struct mlx5_ipool_per_lcore *cache[RTE_MAX_LCORE]; + struct mlx5_ipool_per_lcore *cache[RTE_MAX_LCORE + 1]; /* Local cache. */ struct rte_bitmap *ibmp; void *bmp_mem; @@ -296,187 +297,6 @@ log2above(unsigned int v) return l + r; } -/************************ cache list *****************************/ - -/** Maximum size of string for naming. */ -#define MLX5_NAME_SIZE 32 - -struct mlx5_cache_list; - -/** - * Structure of the entry in the cache list, user should define its own struct - * that contains this in order to store the data. - */ -struct mlx5_cache_entry { - LIST_ENTRY(mlx5_cache_entry) next; /* Entry pointers in the list. */ - uint32_t ref_cnt; /* Reference count. */ -}; - -/** - * Type of callback function for entry removal. - * - * @param list - * The cache list. - * @param entry - * The entry in the list. - */ -typedef void (*mlx5_cache_remove_cb)(struct mlx5_cache_list *list, - struct mlx5_cache_entry *entry); - -/** - * Type of function for user defined matching. - * - * @param list - * The cache list. - * @param entry - * The entry in the list. - * @param ctx - * The pointer to new entry context. - * - * @return - * 0 if matching, non-zero number otherwise. - */ -typedef int (*mlx5_cache_match_cb)(struct mlx5_cache_list *list, - struct mlx5_cache_entry *entry, void *ctx); - -/** - * Type of function for user defined cache list entry creation. - * - * @param list - * The cache list. - * @param entry - * The new allocated entry, NULL if list entry size unspecified, - * New entry has to be allocated in callback and return. - * @param ctx - * The pointer to new entry context. - * - * @return - * Pointer of entry on success, NULL otherwise. - */ -typedef struct mlx5_cache_entry *(*mlx5_cache_create_cb) - (struct mlx5_cache_list *list, - struct mlx5_cache_entry *entry, - void *ctx); - -/** - * Linked cache list structure. - * - * Entry in cache list could be reused if entry already exists, - * reference count will increase and the existing entry returns. - * - * When destroy an entry from list, decrease reference count and only - * destroy when no further reference. - * - * Linked list cache is designed for limited number of entries cache, - * read mostly, less modification. - * - * For huge amount of entries cache, please consider hash list cache. - * - */ -struct mlx5_cache_list { - char name[MLX5_NAME_SIZE]; /**< Name of the cache list. */ - uint32_t entry_sz; /**< Entry size, 0: use create callback. */ - rte_rwlock_t lock; /* read/write lock. */ - uint32_t gen_cnt; /* List modification will update generation count. */ - uint32_t count; /* number of entries in list. */ - void *ctx; /* user objects target to callback. */ - mlx5_cache_create_cb cb_create; /**< entry create callback. */ - mlx5_cache_match_cb cb_match; /**< entry match callback. */ - mlx5_cache_remove_cb cb_remove; /**< entry remove callback. */ - LIST_HEAD(mlx5_cache_head, mlx5_cache_entry) head; -}; - -/** - * Initialize a cache list. - * - * @param list - * Pointer to the hast list table. - * @param name - * Name of the cache list. - * @param entry_size - * Entry size to allocate, 0 to allocate by creation callback. - * @param ctx - * Pointer to the list context data. - * @param cb_create - * Callback function for entry create. - * @param cb_match - * Callback function for entry match. - * @param cb_remove - * Callback function for entry remove. - * @return - * 0 on success, otherwise failure. - */ -int mlx5_cache_list_init(struct mlx5_cache_list *list, - const char *name, uint32_t entry_size, void *ctx, - mlx5_cache_create_cb cb_create, - mlx5_cache_match_cb cb_match, - mlx5_cache_remove_cb cb_remove); - -/** - * Search an entry matching the key. - * - * Result returned might be destroyed by other thread, must use - * this function only in main thread. - * - * @param list - * Pointer to the cache list. - * @param ctx - * Common context parameter used by entry callback function. - * - * @return - * Pointer of the cache entry if found, NULL otherwise. - */ -struct mlx5_cache_entry *mlx5_cache_lookup(struct mlx5_cache_list *list, - void *ctx); - -/** - * Reuse or create an entry to the cache list. - * - * @param list - * Pointer to the hast list table. - * @param ctx - * Common context parameter used by callback function. - * - * @return - * registered entry on success, NULL otherwise - */ -struct mlx5_cache_entry *mlx5_cache_register(struct mlx5_cache_list *list, - void *ctx); - -/** - * Remove an entry from the cache list. - * - * User should guarantee the validity of the entry. - * - * @param list - * Pointer to the hast list. - * @param entry - * Entry to be removed from the cache list table. - * @return - * 0 on entry removed, 1 on entry still referenced. - */ -int mlx5_cache_unregister(struct mlx5_cache_list *list, - struct mlx5_cache_entry *entry); - -/** - * Destroy the cache list. - * - * @param list - * Pointer to the cache list. - */ -void mlx5_cache_list_destroy(struct mlx5_cache_list *list); - -/** - * Get entry number from the cache list. - * - * @param list - * Pointer to the hast list. - * @return - * Cache list entry number. - */ -uint32_t -mlx5_cache_list_get_entry_num(struct mlx5_cache_list *list); - /********************************* indexed pool *************************/ /**