@@ -180,12 +180,90 @@ static int mlx5e_rep_get_sset_count(struct net_device *dev, int sset)
180
180
}
181
181
}
182
182
183
+ static int mlx5e_replace_rep_vport_rx_rule (struct mlx5e_priv * priv ,
184
+ struct mlx5_flow_destination * dest )
185
+ {
186
+ struct mlx5_eswitch * esw = priv -> mdev -> priv .eswitch ;
187
+ struct mlx5e_rep_priv * rpriv = priv -> ppriv ;
188
+ struct mlx5_eswitch_rep * rep = rpriv -> rep ;
189
+ struct mlx5_flow_handle * flow_rule ;
190
+
191
+ flow_rule = mlx5_eswitch_create_vport_rx_rule (esw ,
192
+ rep -> vport ,
193
+ dest );
194
+ if (IS_ERR (flow_rule ))
195
+ return PTR_ERR (flow_rule );
196
+
197
+ mlx5_del_flow_rules (rpriv -> vport_rx_rule );
198
+ rpriv -> vport_rx_rule = flow_rule ;
199
+ return 0 ;
200
+ }
201
+
202
+ static void mlx5e_rep_get_channels (struct net_device * dev ,
203
+ struct ethtool_channels * ch )
204
+ {
205
+ struct mlx5e_priv * priv = netdev_priv (dev );
206
+
207
+ mlx5e_ethtool_get_channels (priv , ch );
208
+ }
209
+
210
+ static int mlx5e_rep_set_channels (struct net_device * dev ,
211
+ struct ethtool_channels * ch )
212
+ {
213
+ struct mlx5e_priv * priv = netdev_priv (dev );
214
+ u16 curr_channels_amount = priv -> channels .params .num_channels ;
215
+ u32 new_channels_amount = ch -> combined_count ;
216
+ struct mlx5_flow_destination new_dest ;
217
+ int err = 0 ;
218
+
219
+ err = mlx5e_ethtool_set_channels (priv , ch );
220
+ if (err )
221
+ return err ;
222
+
223
+ if (curr_channels_amount == 1 && new_channels_amount > 1 ) {
224
+ new_dest .type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE ;
225
+ new_dest .ft = priv -> fs .ttc .ft .t ;
226
+ } else if (new_channels_amount == 1 && curr_channels_amount > 1 ) {
227
+ new_dest .type = MLX5_FLOW_DESTINATION_TYPE_TIR ;
228
+ new_dest .tir_num = priv -> direct_tir [0 ].tirn ;
229
+ } else {
230
+ return 0 ;
231
+ }
232
+
233
+ err = mlx5e_replace_rep_vport_rx_rule (priv , & new_dest );
234
+ if (err ) {
235
+ netdev_warn (priv -> netdev , "Failed to update vport rx rule, when going from (%d) channels to (%d) channels\n" ,
236
+ curr_channels_amount , new_channels_amount );
237
+ return err ;
238
+ }
239
+
240
+ return 0 ;
241
+ }
242
+
243
+ static u32 mlx5e_rep_get_rxfh_key_size (struct net_device * netdev )
244
+ {
245
+ struct mlx5e_priv * priv = netdev_priv (netdev );
246
+
247
+ return mlx5e_ethtool_get_rxfh_key_size (priv );
248
+ }
249
+
250
+ static u32 mlx5e_rep_get_rxfh_indir_size (struct net_device * netdev )
251
+ {
252
+ struct mlx5e_priv * priv = netdev_priv (netdev );
253
+
254
+ return mlx5e_ethtool_get_rxfh_indir_size (priv );
255
+ }
256
+
183
257
static const struct ethtool_ops mlx5e_rep_ethtool_ops = {
184
258
.get_drvinfo = mlx5e_rep_get_drvinfo ,
185
259
.get_link = ethtool_op_get_link ,
186
260
.get_strings = mlx5e_rep_get_strings ,
187
261
.get_sset_count = mlx5e_rep_get_sset_count ,
188
262
.get_ethtool_stats = mlx5e_rep_get_ethtool_stats ,
263
+ .get_channels = mlx5e_rep_get_channels ,
264
+ .set_channels = mlx5e_rep_set_channels ,
265
+ .get_rxfh_key_size = mlx5e_rep_get_rxfh_key_size ,
266
+ .get_rxfh_indir_size = mlx5e_rep_get_rxfh_indir_size ,
189
267
};
190
268
191
269
int mlx5e_attr_get (struct net_device * dev , struct switchdev_attr * attr )
@@ -943,6 +1021,9 @@ static void mlx5e_build_rep_params(struct mlx5_core_dev *mdev,
943
1021
params -> num_tc = 1 ;
944
1022
945
1023
mlx5_query_min_inline (mdev , & params -> tx_min_inline_mode );
1024
+
1025
+ /* RSS */
1026
+ mlx5e_build_rss_params (params );
946
1027
}
947
1028
948
1029
static void mlx5e_build_rep_netdev (struct net_device * netdev )
@@ -995,14 +1076,36 @@ static void mlx5e_init_rep(struct mlx5_core_dev *mdev,
995
1076
996
1077
INIT_DELAYED_WORK (& priv -> update_stats_work , mlx5e_update_stats_work );
997
1078
998
- priv -> channels .params .num_channels = profile -> max_nch ( mdev ) ;
1079
+ priv -> channels .params .num_channels = 1 ;
999
1080
1000
1081
mlx5e_build_rep_params (mdev , & priv -> channels .params , netdev -> mtu );
1001
1082
mlx5e_build_rep_netdev (netdev );
1002
1083
1003
1084
mlx5e_timestamp_init (priv );
1004
1085
}
1005
1086
1087
+ static int mlx5e_create_rep_ttc_table (struct mlx5e_priv * priv )
1088
+ {
1089
+ struct ttc_params ttc_params = {};
1090
+ int tt , err ;
1091
+
1092
+ priv -> fs .ns = mlx5_get_flow_namespace (priv -> mdev ,
1093
+ MLX5_FLOW_NAMESPACE_KERNEL );
1094
+
1095
+ /* The inner_ttc in the ttc params is intentionally not set */
1096
+ ttc_params .any_tt_tirn = priv -> direct_tir [0 ].tirn ;
1097
+ mlx5e_set_ttc_ft_params (& ttc_params );
1098
+ for (tt = 0 ; tt < MLX5E_NUM_INDIR_TIRS ; tt ++ )
1099
+ ttc_params .indir_tirn [tt ] = priv -> indir_tir [tt ].tirn ;
1100
+
1101
+ err = mlx5e_create_ttc_table (priv , & ttc_params , & priv -> fs .ttc );
1102
+ if (err ) {
1103
+ netdev_err (priv -> netdev , "Failed to create rep ttc table, err=%d\n" , err );
1104
+ return err ;
1105
+ }
1106
+ return 0 ;
1107
+ }
1108
+
1006
1109
static int mlx5e_create_rep_vport_rx_rule (struct mlx5e_priv * priv )
1007
1110
{
1008
1111
struct mlx5_eswitch * esw = priv -> mdev -> priv .eswitch ;
@@ -1035,24 +1138,42 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv)
1035
1138
return err ;
1036
1139
}
1037
1140
1038
- err = mlx5e_create_direct_rqts (priv );
1141
+ err = mlx5e_create_indirect_rqt (priv );
1039
1142
if (err )
1040
1143
goto err_close_drop_rq ;
1041
1144
1042
- err = mlx5e_create_direct_tirs (priv );
1145
+ err = mlx5e_create_direct_rqts (priv );
1146
+ if (err )
1147
+ goto err_destroy_indirect_rqts ;
1148
+
1149
+ err = mlx5e_create_indirect_tirs (priv , false);
1043
1150
if (err )
1044
1151
goto err_destroy_direct_rqts ;
1045
1152
1046
- err = mlx5e_create_rep_vport_rx_rule (priv );
1153
+ err = mlx5e_create_direct_tirs (priv );
1154
+ if (err )
1155
+ goto err_destroy_indirect_tirs ;
1156
+
1157
+ err = mlx5e_create_rep_ttc_table (priv );
1047
1158
if (err )
1048
1159
goto err_destroy_direct_tirs ;
1049
1160
1161
+ err = mlx5e_create_rep_vport_rx_rule (priv );
1162
+ if (err )
1163
+ goto err_destroy_ttc_table ;
1164
+
1050
1165
return 0 ;
1051
1166
1167
+ err_destroy_ttc_table :
1168
+ mlx5e_destroy_ttc_table (priv , & priv -> fs .ttc );
1052
1169
err_destroy_direct_tirs :
1053
1170
mlx5e_destroy_direct_tirs (priv );
1171
+ err_destroy_indirect_tirs :
1172
+ mlx5e_destroy_indirect_tirs (priv , false);
1054
1173
err_destroy_direct_rqts :
1055
1174
mlx5e_destroy_direct_rqts (priv );
1175
+ err_destroy_indirect_rqts :
1176
+ mlx5e_destroy_rqt (priv , & priv -> indir_rqt );
1056
1177
err_close_drop_rq :
1057
1178
mlx5e_close_drop_rq (& priv -> drop_rq );
1058
1179
return err ;
@@ -1063,8 +1184,11 @@ static void mlx5e_cleanup_rep_rx(struct mlx5e_priv *priv)
1063
1184
struct mlx5e_rep_priv * rpriv = priv -> ppriv ;
1064
1185
1065
1186
mlx5_del_flow_rules (rpriv -> vport_rx_rule );
1187
+ mlx5e_destroy_ttc_table (priv , & priv -> fs .ttc );
1066
1188
mlx5e_destroy_direct_tirs (priv );
1189
+ mlx5e_destroy_indirect_tirs (priv , false);
1067
1190
mlx5e_destroy_direct_rqts (priv );
1191
+ mlx5e_destroy_rqt (priv , & priv -> indir_rqt );
1068
1192
mlx5e_close_drop_rq (& priv -> drop_rq );
1069
1193
}
1070
1194
@@ -1080,20 +1204,14 @@ static int mlx5e_init_rep_tx(struct mlx5e_priv *priv)
1080
1204
return 0 ;
1081
1205
}
1082
1206
1083
- static int mlx5e_get_rep_max_num_channels (struct mlx5_core_dev * mdev )
1084
- {
1085
- #define MLX5E_PORT_REPRESENTOR_NCH 1
1086
- return MLX5E_PORT_REPRESENTOR_NCH ;
1087
- }
1088
-
1089
1207
static const struct mlx5e_profile mlx5e_rep_profile = {
1090
1208
.init = mlx5e_init_rep ,
1091
1209
.init_rx = mlx5e_init_rep_rx ,
1092
1210
.cleanup_rx = mlx5e_cleanup_rep_rx ,
1093
1211
.init_tx = mlx5e_init_rep_tx ,
1094
1212
.cleanup_tx = mlx5e_cleanup_nic_tx ,
1095
1213
.update_stats = mlx5e_rep_update_hw_counters ,
1096
- .max_nch = mlx5e_get_rep_max_num_channels ,
1214
+ .max_nch = mlx5e_get_max_num_channels ,
1097
1215
.update_carrier = NULL ,
1098
1216
.rx_handlers .handle_rx_cqe = mlx5e_handle_rx_cqe_rep ,
1099
1217
.rx_handlers .handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq ,
0 commit comments