hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ethtool.c
....@@ -130,14 +130,6 @@
130130 return mlx5e_ethtool_flash_device(priv, flash);
131131 }
132132
133
-enum mlx5_ptys_width {
134
- MLX5_PTYS_WIDTH_1X = 1 << 0,
135
- MLX5_PTYS_WIDTH_2X = 1 << 1,
136
- MLX5_PTYS_WIDTH_4X = 1 << 2,
137
- MLX5_PTYS_WIDTH_8X = 1 << 3,
138
- MLX5_PTYS_WIDTH_12X = 1 << 4,
139
-};
140
-
141133 static inline int mlx5_ptys_width_enum_to_int(enum mlx5_ptys_width width)
142134 {
143135 switch (width) {
....@@ -174,34 +166,16 @@
174166 }
175167 }
176168
177
-static int mlx5i_get_port_settings(struct net_device *netdev,
178
- u16 *ib_link_width_oper, u16 *ib_proto_oper)
179
-{
180
- struct mlx5e_priv *priv = mlx5i_epriv(netdev);
181
- struct mlx5_core_dev *mdev = priv->mdev;
182
- u32 out[MLX5_ST_SZ_DW(ptys_reg)] = {0};
183
- int ret;
184
-
185
- ret = mlx5_query_port_ptys(mdev, out, sizeof(out), MLX5_PTYS_IB, 1);
186
- if (ret)
187
- return ret;
188
-
189
- *ib_link_width_oper = MLX5_GET(ptys_reg, out, ib_link_width_oper);
190
- *ib_proto_oper = MLX5_GET(ptys_reg, out, ib_proto_oper);
191
-
192
- return 0;
193
-}
194
-
195
-static int mlx5i_get_speed_settings(u16 ib_link_width_oper, u16 ib_proto_oper)
169
+static u32 mlx5i_get_speed_settings(u16 ib_link_width_oper, u16 ib_proto_oper)
196170 {
197171 int rate, width;
198172
199173 rate = mlx5_ptys_rate_enum_to_int(ib_proto_oper);
200174 if (rate < 0)
201
- return -EINVAL;
175
+ return SPEED_UNKNOWN;
202176 width = mlx5_ptys_width_enum_to_int(ib_link_width_oper);
203177 if (width < 0)
204
- return -EINVAL;
178
+ return SPEED_UNKNOWN;
205179
206180 return rate * width;
207181 }
....@@ -209,11 +183,14 @@
209183 static int mlx5i_get_link_ksettings(struct net_device *netdev,
210184 struct ethtool_link_ksettings *link_ksettings)
211185 {
186
+ struct mlx5e_priv *priv = mlx5i_epriv(netdev);
187
+ struct mlx5_core_dev *mdev = priv->mdev;
212188 u16 ib_link_width_oper;
213189 u16 ib_proto_oper;
214190 int speed, ret;
215191
216
- ret = mlx5i_get_port_settings(netdev, &ib_link_width_oper, &ib_proto_oper);
192
+ ret = mlx5_query_ib_port_oper(mdev, &ib_link_width_oper, &ib_proto_oper,
193
+ 1);
217194 if (ret)
218195 return ret;
219196
....@@ -221,20 +198,20 @@
221198 ethtool_link_ksettings_zero_link_mode(link_ksettings, advertising);
222199
223200 speed = mlx5i_get_speed_settings(ib_link_width_oper, ib_proto_oper);
224
- if (speed < 0)
225
- return -EINVAL;
201
+ link_ksettings->base.speed = speed;
202
+ link_ksettings->base.duplex = speed == SPEED_UNKNOWN ? DUPLEX_UNKNOWN : DUPLEX_FULL;
226203
227
- link_ksettings->base.duplex = DUPLEX_FULL;
228204 link_ksettings->base.port = PORT_OTHER;
229205
230206 link_ksettings->base.autoneg = AUTONEG_DISABLE;
231
-
232
- link_ksettings->base.speed = speed;
233207
234208 return 0;
235209 }
236210
237211 const struct ethtool_ops mlx5i_ethtool_ops = {
212
+ .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
213
+ ETHTOOL_COALESCE_MAX_FRAMES |
214
+ ETHTOOL_COALESCE_USE_ADAPTIVE,
238215 .get_drvinfo = mlx5i_get_drvinfo,
239216 .get_strings = mlx5i_get_strings,
240217 .get_sset_count = mlx5i_get_sset_count,