@@ -44,7 +44,120 @@ static int mlx5_cmd_hws_set_peer(struct mlx5_flow_root_namespace *ns,
44
44
return 0 ;
45
45
}
46
46
47
+ static int mlx5_fs_set_ft_default_miss (struct mlx5_flow_root_namespace * ns ,
48
+ struct mlx5_flow_table * ft ,
49
+ struct mlx5_flow_table * next_ft )
50
+ {
51
+ struct mlx5hws_table * next_tbl ;
52
+ int err ;
53
+
54
+ if (!ns -> fs_hws_context .hws_ctx )
55
+ return - EINVAL ;
56
+
57
+ /* if no change required, return */
58
+ if (!next_ft && !ft -> fs_hws_table .miss_ft_set )
59
+ return 0 ;
60
+
61
+ next_tbl = next_ft ? next_ft -> fs_hws_table .hws_table : NULL ;
62
+ err = mlx5hws_table_set_default_miss (ft -> fs_hws_table .hws_table , next_tbl );
63
+ if (err ) {
64
+ mlx5_core_err (ns -> dev , "Failed setting FT default miss (%d)\n" , err );
65
+ return err ;
66
+ }
67
+ ft -> fs_hws_table .miss_ft_set = !!next_tbl ;
68
+ return 0 ;
69
+ }
70
+
71
+ static int mlx5_cmd_hws_create_flow_table (struct mlx5_flow_root_namespace * ns ,
72
+ struct mlx5_flow_table * ft ,
73
+ struct mlx5_flow_table_attr * ft_attr ,
74
+ struct mlx5_flow_table * next_ft )
75
+ {
76
+ struct mlx5hws_context * ctx = ns -> fs_hws_context .hws_ctx ;
77
+ struct mlx5hws_table_attr tbl_attr = {};
78
+ struct mlx5hws_table * tbl ;
79
+ int err ;
80
+
81
+ if (mlx5_fs_cmd_is_fw_term_table (ft ))
82
+ return mlx5_fs_cmd_get_fw_cmds ()-> create_flow_table (ns , ft , ft_attr ,
83
+ next_ft );
84
+
85
+ if (ns -> table_type != FS_FT_FDB ) {
86
+ mlx5_core_err (ns -> dev , "Table type %d not supported for HWS\n" ,
87
+ ns -> table_type );
88
+ return - EOPNOTSUPP ;
89
+ }
90
+
91
+ tbl_attr .type = MLX5HWS_TABLE_TYPE_FDB ;
92
+ tbl_attr .level = ft_attr -> level ;
93
+ tbl = mlx5hws_table_create (ctx , & tbl_attr );
94
+ if (!tbl ) {
95
+ mlx5_core_err (ns -> dev , "Failed creating hws flow_table\n" );
96
+ return - EINVAL ;
97
+ }
98
+
99
+ ft -> fs_hws_table .hws_table = tbl ;
100
+ ft -> id = mlx5hws_table_get_id (tbl );
101
+
102
+ if (next_ft ) {
103
+ err = mlx5_fs_set_ft_default_miss (ns , ft , next_ft );
104
+ if (err )
105
+ goto destroy_table ;
106
+ }
107
+
108
+ ft -> max_fte = INT_MAX ;
109
+
110
+ return 0 ;
111
+
112
+ destroy_table :
113
+ mlx5hws_table_destroy (tbl );
114
+ ft -> fs_hws_table .hws_table = NULL ;
115
+ return err ;
116
+ }
117
+
118
+ static int mlx5_cmd_hws_destroy_flow_table (struct mlx5_flow_root_namespace * ns ,
119
+ struct mlx5_flow_table * ft )
120
+ {
121
+ int err ;
122
+
123
+ if (mlx5_fs_cmd_is_fw_term_table (ft ))
124
+ return mlx5_fs_cmd_get_fw_cmds ()-> destroy_flow_table (ns , ft );
125
+
126
+ err = mlx5_fs_set_ft_default_miss (ns , ft , NULL );
127
+ if (err )
128
+ mlx5_core_err (ns -> dev , "Failed to disconnect next table (%d)\n" , err );
129
+
130
+ err = mlx5hws_table_destroy (ft -> fs_hws_table .hws_table );
131
+ if (err )
132
+ mlx5_core_err (ns -> dev , "Failed to destroy flow_table (%d)\n" , err );
133
+
134
+ return err ;
135
+ }
136
+
137
+ static int mlx5_cmd_hws_modify_flow_table (struct mlx5_flow_root_namespace * ns ,
138
+ struct mlx5_flow_table * ft ,
139
+ struct mlx5_flow_table * next_ft )
140
+ {
141
+ if (mlx5_fs_cmd_is_fw_term_table (ft ))
142
+ return mlx5_fs_cmd_get_fw_cmds ()-> modify_flow_table (ns , ft , next_ft );
143
+
144
+ return mlx5_fs_set_ft_default_miss (ns , ft , next_ft );
145
+ }
146
+
147
+ static int mlx5_cmd_hws_update_root_ft (struct mlx5_flow_root_namespace * ns ,
148
+ struct mlx5_flow_table * ft ,
149
+ u32 underlay_qpn ,
150
+ bool disconnect )
151
+ {
152
+ return mlx5_fs_cmd_get_fw_cmds ()-> update_root_ft (ns , ft , underlay_qpn ,
153
+ disconnect );
154
+ }
155
+
47
156
static const struct mlx5_flow_cmds mlx5_flow_cmds_hws = {
157
+ .create_flow_table = mlx5_cmd_hws_create_flow_table ,
158
+ .destroy_flow_table = mlx5_cmd_hws_destroy_flow_table ,
159
+ .modify_flow_table = mlx5_cmd_hws_modify_flow_table ,
160
+ .update_root_ft = mlx5_cmd_hws_update_root_ft ,
48
161
.create_ns = mlx5_cmd_hws_create_ns ,
49
162
.destroy_ns = mlx5_cmd_hws_destroy_ns ,
50
163
.set_peer = mlx5_cmd_hws_set_peer ,
0 commit comments