1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 2 /* Copyright (c) 2019, Mellanox Technologies */ 3 4 #ifndef _MLX5DR_H_ 5 #define _MLX5DR_H_ 6 7 struct mlx5dr_domain; 8 struct mlx5dr_table; 9 struct mlx5dr_matcher; 10 struct mlx5dr_rule; 11 struct mlx5dr_action; 12 13 enum mlx5dr_domain_type { 14 MLX5DR_DOMAIN_TYPE_NIC_RX, 15 MLX5DR_DOMAIN_TYPE_NIC_TX, 16 MLX5DR_DOMAIN_TYPE_FDB, 17 }; 18 19 enum mlx5dr_domain_sync_flags { 20 MLX5DR_DOMAIN_SYNC_FLAGS_SW = 1 << 0, 21 MLX5DR_DOMAIN_SYNC_FLAGS_HW = 1 << 1, 22 }; 23 24 enum mlx5dr_action_reformat_type { 25 DR_ACTION_REFORMAT_TYP_TNL_L2_TO_L2, 26 DR_ACTION_REFORMAT_TYP_L2_TO_TNL_L2, 27 DR_ACTION_REFORMAT_TYP_TNL_L3_TO_L2, 28 DR_ACTION_REFORMAT_TYP_L2_TO_TNL_L3, 29 }; 30 31 struct mlx5dr_match_parameters { 32 size_t match_sz; 33 u64 *match_buf; /* Device spec format */ 34 }; 35 36 struct mlx5dr_action_dest { 37 struct mlx5dr_action *dest; 38 struct mlx5dr_action *reformat; 39 }; 40 41 struct mlx5dr_domain * 42 mlx5dr_domain_create(struct mlx5_core_dev *mdev, enum mlx5dr_domain_type type); 43 44 int mlx5dr_domain_destroy(struct mlx5dr_domain *domain); 45 46 int mlx5dr_domain_sync(struct mlx5dr_domain *domain, u32 flags); 47 48 void mlx5dr_domain_set_peer(struct mlx5dr_domain *dmn, 49 struct mlx5dr_domain *peer_dmn); 50 51 struct mlx5dr_table * 52 mlx5dr_table_create(struct mlx5dr_domain *domain, u32 level, u32 flags); 53 54 int mlx5dr_table_destroy(struct mlx5dr_table *table); 55 56 u32 mlx5dr_table_get_id(struct mlx5dr_table *table); 57 58 struct mlx5dr_matcher * 59 mlx5dr_matcher_create(struct mlx5dr_table *table, 60 u32 priority, 61 u8 match_criteria_enable, 62 struct mlx5dr_match_parameters *mask); 63 64 int mlx5dr_matcher_destroy(struct mlx5dr_matcher *matcher); 65 66 struct mlx5dr_rule * 67 mlx5dr_rule_create(struct mlx5dr_matcher *matcher, 68 struct mlx5dr_match_parameters *value, 69 size_t num_actions, 70 struct mlx5dr_action *actions[]); 71 72 int mlx5dr_rule_destroy(struct mlx5dr_rule *rule); 73 74 int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl, 75 struct mlx5dr_action *action); 76 77 struct mlx5dr_action * 78 mlx5dr_action_create_dest_table_num(struct mlx5dr_domain *dmn, u32 table_num); 79 80 struct mlx5dr_action * 81 mlx5dr_action_create_dest_table(struct mlx5dr_table *table); 82 83 struct mlx5dr_action * 84 mlx5dr_action_create_dest_flow_fw_table(struct mlx5dr_domain *domain, 85 struct mlx5_flow_table *ft); 86 87 struct mlx5dr_action * 88 mlx5dr_action_create_dest_vport(struct mlx5dr_domain *domain, 89 u32 vport, u8 vhca_id_valid, 90 u16 vhca_id); 91 92 struct mlx5dr_action * 93 mlx5dr_action_create_mult_dest_tbl(struct mlx5dr_domain *dmn, 94 struct mlx5dr_action_dest *dests, 95 u32 num_of_dests); 96 97 struct mlx5dr_action *mlx5dr_action_create_drop(void); 98 99 struct mlx5dr_action *mlx5dr_action_create_tag(u32 tag_value); 100 101 struct mlx5dr_action * 102 mlx5dr_action_create_flow_counter(u32 counter_id); 103 104 struct mlx5dr_action * 105 mlx5dr_action_create_packet_reformat(struct mlx5dr_domain *dmn, 106 enum mlx5dr_action_reformat_type reformat_type, 107 size_t data_sz, 108 void *data); 109 110 struct mlx5dr_action * 111 mlx5dr_action_create_modify_header(struct mlx5dr_domain *domain, 112 u32 flags, 113 size_t actions_sz, 114 __be64 actions[]); 115 116 struct mlx5dr_action *mlx5dr_action_create_pop_vlan(void); 117 118 struct mlx5dr_action * 119 mlx5dr_action_create_push_vlan(struct mlx5dr_domain *domain, __be32 vlan_hdr); 120 121 int mlx5dr_action_destroy(struct mlx5dr_action *action); 122 123 static inline bool 124 mlx5dr_is_supported(struct mlx5_core_dev *dev) 125 { 126 return MLX5_CAP_ESW_FLOWTABLE_FDB(dev, sw_owner); 127 } 128 129 #endif /* _MLX5DR_H_ */ 130