1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 2 /* Copyright (c) 2025 NVIDIA Corporation & Affiliates */ 3 4 #ifndef _MLX5_FS_HWS_ 5 #define _MLX5_FS_HWS_ 6 7 #include "mlx5hws.h" 8 #include "fs_hws_pools.h" 9 10 struct mlx5_fs_hws_actions_pool { 11 struct mlx5hws_action *tag_action; 12 struct mlx5hws_action *pop_vlan_action; 13 struct mlx5hws_action *push_vlan_action; 14 struct mlx5hws_action *drop_action; 15 struct mlx5hws_action *decapl2_action; 16 struct mlx5hws_action *remove_hdr_vlan_action; 17 struct mlx5_fs_pool insert_hdr_pool; 18 struct mlx5_fs_pool dl3tnltol2_pool; 19 struct xarray el2tol3tnl_pools; 20 struct xarray el2tol2tnl_pools; 21 struct xarray mh_pools; 22 struct xarray table_dests; 23 struct xarray vport_vhca_dests; 24 struct xarray vport_dests; 25 struct xarray aso_meters; 26 struct xarray sample_dests; 27 }; 28 29 struct mlx5_fs_hws_context { 30 struct mlx5hws_context *hws_ctx; 31 struct mlx5_fs_hws_actions_pool hws_pool; 32 }; 33 34 struct mlx5_fs_hws_table { 35 struct mlx5hws_table *hws_table; 36 bool miss_ft_set; 37 }; 38 39 struct mlx5_fs_hws_action { 40 struct mlx5hws_action *hws_action; 41 struct mlx5_fs_pool *fs_pool; 42 struct mlx5_fs_hws_pr *pr_data; 43 struct mlx5_fs_hws_mh *mh_data; 44 }; 45 46 struct mlx5_fs_hws_matcher { 47 struct mlx5hws_bwc_matcher *matcher; 48 }; 49 50 struct mlx5_fs_hws_rule_action { 51 struct mlx5hws_action *action; 52 union { 53 struct mlx5_fc *counter; 54 struct mlx5_exe_aso *exe_aso; 55 u32 sampler_id; 56 }; 57 }; 58 59 struct mlx5_fs_hws_rule { 60 struct mlx5hws_bwc_rule *bwc_rule; 61 struct mlx5_fs_hws_rule_action *hws_fs_actions; 62 int num_fs_actions; 63 }; 64 65 struct mlx5_fs_hws_data { 66 struct mlx5hws_action *hws_action; 67 struct mutex lock; /* protects hws_action */ 68 refcount_t hws_action_refcount; 69 }; 70 71 struct mlx5_fs_hws_create_action_ctx { 72 enum mlx5hws_action_type actions_type; 73 struct mlx5hws_context *hws_ctx; 74 u32 id; 75 union { 76 u8 return_reg_id; 77 }; 78 }; 79 80 struct mlx5hws_action * 81 mlx5_fs_get_hws_action(struct mlx5_fs_hws_data *fs_hws_data, 82 struct mlx5_fs_hws_create_action_ctx *create_ctx); 83 void mlx5_fs_put_hws_action(struct mlx5_fs_hws_data *fs_hws_data); 84 85 #ifdef CONFIG_MLX5_HW_STEERING 86 87 bool mlx5_fs_hws_is_supported(struct mlx5_core_dev *dev); 88 89 const struct mlx5_flow_cmds *mlx5_fs_cmd_get_hws_cmds(void); 90 91 #else 92 mlx5_fs_hws_is_supported(struct mlx5_core_dev * dev)93static inline bool mlx5_fs_hws_is_supported(struct mlx5_core_dev *dev) 94 { 95 return false; 96 } 97 mlx5_fs_cmd_get_hws_cmds(void)98static inline const struct mlx5_flow_cmds *mlx5_fs_cmd_get_hws_cmds(void) 99 { 100 return NULL; 101 } 102 103 #endif /* CONFIG_MLX5_HWS_STEERING */ 104 #endif 105