Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright (c) 2022 NVIDIA Corporation & Affiliates 3 : : */ 4 : : 5 : : #ifndef MLX5DR_CONTEXT_H_ 6 : : #define MLX5DR_CONTEXT_H_ 7 : : 8 : : enum mlx5dr_context_flags { 9 : : MLX5DR_CONTEXT_FLAG_HWS_SUPPORT = 1 << 0, 10 : : MLX5DR_CONTEXT_FLAG_PRIVATE_PD = 1 << 1, 11 : : }; 12 : : 13 : : enum mlx5dr_context_shared_stc_type { 14 : : MLX5DR_CONTEXT_SHARED_STC_DECAP_L3 = 0, 15 : : MLX5DR_CONTEXT_SHARED_STC_DOUBLE_POP = 1, 16 : : MLX5DR_CONTEXT_SHARED_STC_MAX = 2, 17 : : }; 18 : : 19 : : struct mlx5dr_context_common_res { 20 : : struct mlx5dr_action_default_stc *default_stc; 21 : : struct mlx5dr_action_shared_stc *shared_stc[MLX5DR_CONTEXT_SHARED_STC_MAX]; 22 : : struct mlx5dr_cmd_forward_tbl *default_miss; 23 : : }; 24 : : 25 : : struct mlx5dr_context_shared_gvmi_res { 26 : : struct mlx5dr_devx_obj *end_ft; 27 : : struct mlx5dr_devx_obj *aliased_end_ft; 28 : : uint32_t refcount; 29 : : }; 30 : : 31 : : struct mlx5dr_context { 32 : : struct ibv_context *ibv_ctx; 33 : : /* When local_ibv_ctx is not NULL means we are using shared_ibv for resources */ 34 : : struct ibv_context *local_ibv_ctx; 35 : : struct mlx5dr_cmd_query_caps *caps; 36 : : struct ibv_pd *pd; 37 : : uint32_t pd_num; 38 : : struct mlx5dr_pool *stc_pool[MLX5DR_TABLE_TYPE_MAX]; 39 : : struct mlx5dr_context_common_res common_res[MLX5DR_TABLE_TYPE_MAX]; 40 : : struct mlx5dr_context_shared_gvmi_res gvmi_res[MLX5DR_TABLE_TYPE_MAX]; 41 : : struct mlx5dr_pattern_cache *pattern_cache; 42 : : struct mlx5dr_definer_cache *definer_cache; 43 : : pthread_spinlock_t ctrl_lock; 44 : : enum mlx5dr_context_flags flags; 45 : : struct mlx5dr_send_engine *send_queue; 46 : : size_t queues; 47 : : LIST_HEAD(table_head, mlx5dr_table) head; 48 : : }; 49 : : 50 : : static inline bool mlx5dr_context_shared_gvmi_used(struct mlx5dr_context *ctx) 51 : : { 52 [ # # # # : 0 : return ctx->local_ibv_ctx ? true : false; # # # # # # # # # # # # ] 53 : : } 54 : : 55 : : static inline struct ibv_context * 56 : : mlx5dr_context_get_local_ibv(struct mlx5dr_context *ctx) 57 : : { 58 [ # # # # ]: 0 : if (mlx5dr_context_shared_gvmi_used(ctx)) 59 : : return ctx->local_ibv_ctx; 60 : : 61 : 0 : return ctx->ibv_ctx; 62 : : } 63 : : 64 : : bool mlx5dr_context_cap_dynamic_reparse(struct mlx5dr_context *ctx); 65 : : 66 : : uint8_t mlx5dr_context_get_reparse_mode(struct mlx5dr_context *ctx); 67 : : 68 : : #endif /* MLX5DR_CONTEXT_H_ */