X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fcommon%2Fmlx5%2Fmlx5_common_utils.h;h=98e487e7efa6ad9c5c6ca22194e8a6bb435ab056;hb=33a7493c8df8cd7dc72df31b503e439810f34042;hp=d49fb6445794097a93a64c06bf34833d94d90b7d;hpb=25481e5025a70513f4cd0404b6380ec70f1b2c7b;p=dpdk.git diff --git a/drivers/common/mlx5/mlx5_common_utils.h b/drivers/common/mlx5/mlx5_common_utils.h index d49fb64457..98e487e7ef 100644 --- a/drivers/common/mlx5/mlx5_common_utils.h +++ b/drivers/common/mlx5/mlx5_common_utils.h @@ -5,12 +5,20 @@ #ifndef RTE_PMD_MLX5_COMMON_UTILS_H_ #define RTE_PMD_MLX5_COMMON_UTILS_H_ +#include + #include "mlx5_common.h" /************************ mlx5 list *****************************/ /** Maximum size of string for naming. */ #define MLX5_NAME_SIZE 32 +/** Maximum size of list. */ +#define MLX5_LIST_MAX (RTE_MAX_LCORE + 2) +/** Global list index. */ +#define MLX5_LIST_GLOBAL ((MLX5_LIST_MAX) - 1) +/** None rte core list index. */ +#define MLX5_LIST_NLCORE ((MLX5_LIST_MAX) - 2) struct mlx5_list; @@ -80,6 +88,33 @@ typedef void (*mlx5_list_clone_free_cb)(void *tool_ctx, typedef struct mlx5_list_entry *(*mlx5_list_create_cb)(void *tool_ctx, void *ctx); +/** + * Linked mlx5 list constant object. + */ +struct mlx5_list_const { + char name[MLX5_NAME_SIZE]; /**< Name of the mlx5 list. */ + void *ctx; /* user objects target to callback. */ + bool lcores_share; /* Whether to share objects between the lcores. */ + rte_spinlock_t lcore_lock; /* Lock for non-lcore list. */ + mlx5_list_create_cb cb_create; /**< entry create callback. */ + mlx5_list_match_cb cb_match; /**< entry match callback. */ + mlx5_list_remove_cb cb_remove; /**< entry remove callback. */ + mlx5_list_clone_cb cb_clone; /**< entry clone callback. */ + mlx5_list_clone_free_cb cb_clone_free; + /**< entry clone free callback. */ +}; + +/** + * Linked mlx5 list inconstant data. + */ +struct mlx5_list_inconst { + rte_rwlock_t lock; /* read/write lock. */ + volatile uint32_t gen_cnt; /* List modification may update it. */ + volatile uint32_t count; /* number of entries in list. */ + struct mlx5_list_cache *cache[MLX5_LIST_MAX]; + /* Lcore cache, last index is the global cache. */ +}; + /** * Linked mlx5 list structure. * @@ -96,19 +131,8 @@ typedef struct mlx5_list_entry *(*mlx5_list_create_cb)(void *tool_ctx, * */ struct mlx5_list { - char name[MLX5_NAME_SIZE]; /**< Name of the mlx5 list. */ - void *ctx; /* user objects target to callback. */ - bool lcores_share; /* Whether to share objects between the lcores. */ - mlx5_list_create_cb cb_create; /**< entry create callback. */ - mlx5_list_match_cb cb_match; /**< entry match callback. */ - mlx5_list_remove_cb cb_remove; /**< entry remove callback. */ - mlx5_list_clone_cb cb_clone; /**< entry clone callback. */ - mlx5_list_clone_free_cb cb_clone_free; - struct mlx5_list_cache *cache[RTE_MAX_LCORE + 1]; - /* Lcore cache, last index is the global cache. */ - volatile uint32_t gen_cnt; /* List modification may update it. */ - volatile uint32_t count; /* number of entries in list. */ - rte_rwlock_t lock; /* read/write lock. */ + struct mlx5_list_const l_const; + struct mlx5_list_inconst l_inconst; }; /** @@ -219,7 +243,7 @@ mlx5_list_get_entry_num(struct mlx5_list *list); /* Hash list bucket. */ struct mlx5_hlist_bucket { - struct mlx5_list l; + struct mlx5_list_inconst l; } __rte_cache_aligned; /** @@ -231,7 +255,7 @@ struct mlx5_hlist { uint32_t mask; /* A mask for the bucket index range. */ uint8_t flags; bool direct_key; /* Whether to use the key directly as hash index. */ - bool lcores_share; /* Whether to share objects between the lcores. */ + struct mlx5_list_const l_const; /* List constant data. */ struct mlx5_hlist_bucket buckets[] __rte_cache_aligned; };