Skip to content

Commit 07007db

Browse files
committed
Merge tag 'mlx5-fixes-2020-06-11' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux
Saeed Mahameed says: ==================== mlx5 fixes 2020-06-11 This series introduces some fixes to mlx5 driver. For more information please see tag log below. Please pull and let me know if there is any problem. For -stable v5.2 ('net/mlx5: drain health workqueue in case of driver load error') For -stable v5.3 ('net/mlx5e: Fix repeated XSK usage on one channel') ('net/mlx5: Fix fatal error handling during device load') For -stable v5.5 ('net/mlx5: Disable reload while removing the device') For -stable v5.7 ('net/mlx5e: CT: Fix ipv6 nat header rewrite actions') ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 2ad6691 + 09a9297 commit 07007db

File tree

8 files changed

+70
-55
lines changed

8 files changed

+70
-55
lines changed

drivers/net/ethernet/mellanox/mlx5/core/devlink.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ int mlx5_devlink_register(struct devlink *devlink, struct device *dev)
283283
goto params_reg_err;
284284
mlx5_devlink_set_params_init_values(devlink);
285285
devlink_params_publish(devlink);
286-
devlink_reload_enable(devlink);
287286
return 0;
288287

289288
params_reg_err:
@@ -293,7 +292,6 @@ int mlx5_devlink_register(struct devlink *devlink, struct device *dev)
293292

294293
void mlx5_devlink_unregister(struct devlink *devlink)
295294
{
296-
devlink_reload_disable(devlink);
297295
devlink_params_unregister(devlink, mlx5_devlink_params,
298296
ARRAY_SIZE(mlx5_devlink_params));
299297
devlink_unregister(devlink);

drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -328,21 +328,21 @@ mlx5_tc_ct_parse_mangle_to_mod_act(struct flow_action_entry *act,
328328

329329
case FLOW_ACT_MANGLE_HDR_TYPE_IP6:
330330
MLX5_SET(set_action_in, modact, length, 0);
331-
if (offset == offsetof(struct ipv6hdr, saddr))
331+
if (offset == offsetof(struct ipv6hdr, saddr) + 12)
332332
field = MLX5_ACTION_IN_FIELD_OUT_SIPV6_31_0;
333-
else if (offset == offsetof(struct ipv6hdr, saddr) + 4)
334-
field = MLX5_ACTION_IN_FIELD_OUT_SIPV6_63_32;
335333
else if (offset == offsetof(struct ipv6hdr, saddr) + 8)
334+
field = MLX5_ACTION_IN_FIELD_OUT_SIPV6_63_32;
335+
else if (offset == offsetof(struct ipv6hdr, saddr) + 4)
336336
field = MLX5_ACTION_IN_FIELD_OUT_SIPV6_95_64;
337-
else if (offset == offsetof(struct ipv6hdr, saddr) + 12)
337+
else if (offset == offsetof(struct ipv6hdr, saddr))
338338
field = MLX5_ACTION_IN_FIELD_OUT_SIPV6_127_96;
339-
else if (offset == offsetof(struct ipv6hdr, daddr))
339+
else if (offset == offsetof(struct ipv6hdr, daddr) + 12)
340340
field = MLX5_ACTION_IN_FIELD_OUT_DIPV6_31_0;
341-
else if (offset == offsetof(struct ipv6hdr, daddr) + 4)
342-
field = MLX5_ACTION_IN_FIELD_OUT_DIPV6_63_32;
343341
else if (offset == offsetof(struct ipv6hdr, daddr) + 8)
342+
field = MLX5_ACTION_IN_FIELD_OUT_DIPV6_63_32;
343+
else if (offset == offsetof(struct ipv6hdr, daddr) + 4)
344344
field = MLX5_ACTION_IN_FIELD_OUT_DIPV6_95_64;
345-
else if (offset == offsetof(struct ipv6hdr, daddr) + 12)
345+
else if (offset == offsetof(struct ipv6hdr, daddr))
346346
field = MLX5_ACTION_IN_FIELD_OUT_DIPV6_127_96;
347347
else
348348
return -EOPNOTSUPP;

drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ void mlx5e_close_xsk(struct mlx5e_channel *c)
152152
mlx5e_close_cq(&c->xskicosq.cq);
153153
mlx5e_close_xdpsq(&c->xsksq);
154154
mlx5e_close_cq(&c->xsksq.cq);
155+
156+
memset(&c->xskrq, 0, sizeof(c->xskrq));
157+
memset(&c->xsksq, 0, sizeof(c->xsksq));
158+
memset(&c->xskicosq, 0, sizeof(c->xskicosq));
155159
}
156160

157161
void mlx5e_activate_xsk(struct mlx5e_channel *c)

drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,8 @@ int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir,
11731173
struct mlx5e_priv *priv = netdev_priv(dev);
11741174
struct mlx5e_rss_params *rss = &priv->rss_params;
11751175
int inlen = MLX5_ST_SZ_BYTES(modify_tir_in);
1176-
bool hash_changed = false;
1176+
bool refresh_tirs = false;
1177+
bool refresh_rqt = false;
11771178
void *in;
11781179

11791180
if ((hfunc != ETH_RSS_HASH_NO_CHANGE) &&
@@ -1189,36 +1190,38 @@ int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir,
11891190

11901191
if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != rss->hfunc) {
11911192
rss->hfunc = hfunc;
1192-
hash_changed = true;
1193+
refresh_rqt = true;
1194+
refresh_tirs = true;
11931195
}
11941196

11951197
if (indir) {
11961198
memcpy(rss->indirection_rqt, indir,
11971199
sizeof(rss->indirection_rqt));
1198-
1199-
if (test_bit(MLX5E_STATE_OPENED, &priv->state)) {
1200-
u32 rqtn = priv->indir_rqt.rqtn;
1201-
struct mlx5e_redirect_rqt_param rrp = {
1202-
.is_rss = true,
1203-
{
1204-
.rss = {
1205-
.hfunc = rss->hfunc,
1206-
.channels = &priv->channels,
1207-
},
1208-
},
1209-
};
1210-
1211-
mlx5e_redirect_rqt(priv, rqtn, MLX5E_INDIR_RQT_SIZE, rrp);
1212-
}
1200+
refresh_rqt = true;
12131201
}
12141202

12151203
if (key) {
12161204
memcpy(rss->toeplitz_hash_key, key,
12171205
sizeof(rss->toeplitz_hash_key));
1218-
hash_changed = hash_changed || rss->hfunc == ETH_RSS_HASH_TOP;
1206+
refresh_tirs = refresh_tirs || rss->hfunc == ETH_RSS_HASH_TOP;
1207+
}
1208+
1209+
if (refresh_rqt && test_bit(MLX5E_STATE_OPENED, &priv->state)) {
1210+
struct mlx5e_redirect_rqt_param rrp = {
1211+
.is_rss = true,
1212+
{
1213+
.rss = {
1214+
.hfunc = rss->hfunc,
1215+
.channels = &priv->channels,
1216+
},
1217+
},
1218+
};
1219+
u32 rqtn = priv->indir_rqt.rqtn;
1220+
1221+
mlx5e_redirect_rqt(priv, rqtn, MLX5E_INDIR_RQT_SIZE, rrp);
12191222
}
12201223

1221-
if (hash_changed)
1224+
if (refresh_tirs)
12221225
mlx5e_modify_tirs_hash(priv, in);
12231226

12241227
mutex_unlock(&priv->state_lock);

drivers/net/ethernet/mellanox/mlx5/core/esw/acl/ingress_lgcy.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,12 @@ int esw_acl_ingress_lgcy_setup(struct mlx5_eswitch *esw,
162162

163163
if (MLX5_CAP_ESW_INGRESS_ACL(esw->dev, flow_counter)) {
164164
counter = mlx5_fc_create(esw->dev, false);
165-
if (IS_ERR(counter))
165+
if (IS_ERR(counter)) {
166166
esw_warn(esw->dev,
167167
"vport[%d] configure ingress drop rule counter failed\n",
168168
vport->vport);
169+
counter = NULL;
170+
}
169171
vport->ingress.legacy.drop_counter = counter;
170172
}
171173

@@ -272,7 +274,7 @@ void esw_acl_ingress_lgcy_cleanup(struct mlx5_eswitch *esw,
272274
esw_acl_ingress_table_destroy(vport);
273275

274276
clean_drop_counter:
275-
if (!IS_ERR_OR_NULL(vport->ingress.legacy.drop_counter)) {
277+
if (vport->ingress.legacy.drop_counter) {
276278
mlx5_fc_destroy(esw->dev, vport->ingress.legacy.drop_counter);
277279
vport->ingress.legacy.drop_counter = NULL;
278280
}

drivers/net/ethernet/mellanox/mlx5/core/health.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,23 @@ static bool reset_fw_if_needed(struct mlx5_core_dev *dev)
192192

193193
void mlx5_enter_error_state(struct mlx5_core_dev *dev, bool force)
194194
{
195+
bool err_detected = false;
196+
197+
/* Mark the device as fatal in order to abort FW commands */
198+
if ((check_fatal_sensors(dev) || force) &&
199+
dev->state == MLX5_DEVICE_STATE_UP) {
200+
dev->state = MLX5_DEVICE_STATE_INTERNAL_ERROR;
201+
err_detected = true;
202+
}
195203
mutex_lock(&dev->intf_state_mutex);
196-
if (dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR)
197-
goto unlock;
204+
if (!err_detected && dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR)
205+
goto unlock;/* a previous error is still being handled */
198206
if (dev->state == MLX5_DEVICE_STATE_UNINITIALIZED) {
199207
dev->state = MLX5_DEVICE_STATE_INTERNAL_ERROR;
200208
goto unlock;
201209
}
202210

203-
if (check_fatal_sensors(dev) || force) {
211+
if (check_fatal_sensors(dev) || force) { /* protected state setting */
204212
dev->state = MLX5_DEVICE_STATE_INTERNAL_ERROR;
205213
mlx5_cmd_flush(dev);
206214
}

drivers/net/ethernet/mellanox/mlx5/core/main.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,11 @@ static int mlx5_pci_init(struct mlx5_core_dev *dev, struct pci_dev *pdev,
785785

786786
static void mlx5_pci_close(struct mlx5_core_dev *dev)
787787
{
788+
/* health work might still be active, and it needs pci bar in
789+
* order to know the NIC state. Therefore, drain the health WQ
790+
* before removing the pci bars
791+
*/
792+
mlx5_drain_health_wq(dev);
788793
iounmap(dev->iseg);
789794
pci_clear_master(dev->pdev);
790795
release_bar(dev->pdev);
@@ -1194,23 +1199,22 @@ int mlx5_load_one(struct mlx5_core_dev *dev, bool boot)
11941199
if (err)
11951200
goto err_load;
11961201

1202+
set_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state);
1203+
11971204
if (boot) {
11981205
err = mlx5_devlink_register(priv_to_devlink(dev), dev->device);
11991206
if (err)
12001207
goto err_devlink_reg;
1201-
}
1202-
1203-
if (mlx5_device_registered(dev))
1204-
mlx5_attach_device(dev);
1205-
else
12061208
mlx5_register_device(dev);
1207-
1208-
set_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state);
1209+
} else {
1210+
mlx5_attach_device(dev);
1211+
}
12091212

12101213
mutex_unlock(&dev->intf_state_mutex);
12111214
return 0;
12121215

12131216
err_devlink_reg:
1217+
clear_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state);
12141218
mlx5_unload(dev);
12151219
err_load:
12161220
if (boot)
@@ -1226,10 +1230,15 @@ int mlx5_load_one(struct mlx5_core_dev *dev, bool boot)
12261230

12271231
void mlx5_unload_one(struct mlx5_core_dev *dev, bool cleanup)
12281232
{
1229-
if (cleanup)
1233+
mutex_lock(&dev->intf_state_mutex);
1234+
1235+
if (cleanup) {
12301236
mlx5_unregister_device(dev);
1237+
mlx5_devlink_unregister(priv_to_devlink(dev));
1238+
} else {
1239+
mlx5_detach_device(dev);
1240+
}
12311241

1232-
mutex_lock(&dev->intf_state_mutex);
12331242
if (!test_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state)) {
12341243
mlx5_core_warn(dev, "%s: interface is down, NOP\n",
12351244
__func__);
@@ -1240,9 +1249,6 @@ void mlx5_unload_one(struct mlx5_core_dev *dev, bool cleanup)
12401249

12411250
clear_bit(MLX5_INTERFACE_STATE_UP, &dev->intf_state);
12421251

1243-
if (mlx5_device_registered(dev))
1244-
mlx5_detach_device(dev);
1245-
12461252
mlx5_unload(dev);
12471253

12481254
if (cleanup)
@@ -1275,11 +1281,6 @@ static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)
12751281

12761282
priv->dbg_root = debugfs_create_dir(dev_name(dev->device),
12771283
mlx5_debugfs_root);
1278-
if (!priv->dbg_root) {
1279-
dev_err(dev->device, "mlx5_core: error, Cannot create debugfs dir, aborting\n");
1280-
goto err_dbg_root;
1281-
}
1282-
12831284
err = mlx5_health_init(dev);
12841285
if (err)
12851286
goto err_health_init;
@@ -1294,7 +1295,6 @@ static int mlx5_mdev_init(struct mlx5_core_dev *dev, int profile_idx)
12941295
mlx5_health_cleanup(dev);
12951296
err_health_init:
12961297
debugfs_remove(dev->priv.dbg_root);
1297-
err_dbg_root:
12981298
mutex_destroy(&priv->pgdir_mutex);
12991299
mutex_destroy(&priv->alloc_mutex);
13001300
mutex_destroy(&priv->bfregs.wc_head.lock);
@@ -1362,6 +1362,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *id)
13621362
dev_err(&pdev->dev, "mlx5_crdump_enable failed with error code %d\n", err);
13631363

13641364
pci_save_state(pdev);
1365+
devlink_reload_enable(devlink);
13651366
return 0;
13661367

13671368
err_load_one:
@@ -1379,9 +1380,8 @@ static void remove_one(struct pci_dev *pdev)
13791380
struct mlx5_core_dev *dev = pci_get_drvdata(pdev);
13801381
struct devlink *devlink = priv_to_devlink(dev);
13811382

1383+
devlink_reload_disable(devlink);
13821384
mlx5_crdump_disable(dev);
1383-
mlx5_devlink_unregister(devlink);
1384-
13851385
mlx5_drain_health_wq(dev);
13861386
mlx5_unload_one(dev, true);
13871387
mlx5_pci_close(dev);

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_send.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ static struct mlx5dr_qp *dr_create_rc_qp(struct mlx5_core_dev *mdev,
179179
MLX5_SET(create_qp_in, in, opcode, MLX5_CMD_OP_CREATE_QP);
180180
err = mlx5_cmd_exec(mdev, in, inlen, out, sizeof(out));
181181
dr_qp->qpn = MLX5_GET(create_qp_out, out, qpn);
182-
kfree(in);
182+
kvfree(in);
183183
if (err)
184184
goto err_in;
185185
dr_qp->uar = attr->uar;

0 commit comments

Comments
 (0)