1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 2 /* Copyright (c) 2024 NVIDIA Corporation & Affiliates */ 3 4 #ifndef HWS_CONTEXT_H_ 5 #define HWS_CONTEXT_H_ 6 7 enum mlx5hws_context_flags { 8 MLX5HWS_CONTEXT_FLAG_HWS_SUPPORT = 1 << 0, 9 MLX5HWS_CONTEXT_FLAG_PRIVATE_PD = 1 << 1, 10 MLX5HWS_CONTEXT_FLAG_BWC_SUPPORT = 1 << 2, 11 MLX5HWS_CONTEXT_FLAG_NATIVE_SUPPORT = 1 << 3, 12 }; 13 14 enum mlx5hws_context_shared_stc_type { 15 MLX5HWS_CONTEXT_SHARED_STC_DECAP_L3 = 0, 16 MLX5HWS_CONTEXT_SHARED_STC_DOUBLE_POP = 1, 17 MLX5HWS_CONTEXT_SHARED_STC_MAX = 2, 18 }; 19 20 struct mlx5hws_context_common_res { 21 struct mlx5hws_action_default_stc *default_stc; 22 struct mlx5hws_action_shared_stc *shared_stc[MLX5HWS_CONTEXT_SHARED_STC_MAX]; 23 struct mlx5hws_cmd_forward_tbl *default_miss; 24 }; 25 26 struct mlx5hws_context_debug_info { 27 struct dentry *steering_debugfs; 28 struct dentry *fdb_debugfs; 29 }; 30 31 struct mlx5hws_context_vports { 32 u16 esw_manager_gvmi; 33 u16 uplink_gvmi; 34 struct xarray vport_gvmi_xa; 35 }; 36 37 struct mlx5hws_context { 38 struct mlx5_core_dev *mdev; 39 struct mlx5hws_cmd_query_caps *caps; 40 u32 pd_num; 41 struct mlx5hws_pool *stc_pool; 42 struct mlx5hws_action_ste_pool *action_ste_pool; /* One per queue */ 43 struct delayed_work action_ste_cleanup; 44 struct mlx5hws_context_common_res common_res; 45 struct mlx5hws_pattern_cache *pattern_cache; 46 struct mlx5hws_definer_cache *definer_cache; 47 struct mutex ctrl_lock; /* control lock to protect the whole context */ 48 enum mlx5hws_context_flags flags; 49 struct mlx5hws_send_engine *send_queue; 50 size_t queues; 51 struct mutex *bwc_send_queue_locks; /* protect BWC queues */ 52 struct lock_class_key *bwc_lock_class_keys; 53 struct list_head tbl_list; 54 struct mlx5hws_context_debug_info debug_info; 55 struct xarray peer_ctx_xa; 56 struct mlx5hws_context_vports vports; 57 }; 58 mlx5hws_context_bwc_supported(struct mlx5hws_context * ctx)59static inline bool mlx5hws_context_bwc_supported(struct mlx5hws_context *ctx) 60 { 61 return ctx->flags & MLX5HWS_CONTEXT_FLAG_BWC_SUPPORT; 62 } 63 mlx5hws_context_native_supported(struct mlx5hws_context * ctx)64static inline bool mlx5hws_context_native_supported(struct mlx5hws_context *ctx) 65 { 66 return ctx->flags & MLX5HWS_CONTEXT_FLAG_NATIVE_SUPPORT; 67 } 68 69 bool mlx5hws_context_cap_dynamic_reparse(struct mlx5hws_context *ctx); 70 71 u8 mlx5hws_context_get_reparse_mode(struct mlx5hws_context *ctx); 72 73 #endif /* HWS_CONTEXT_H_ */ 74