Skip to content

Commit dd0eefe

Browse files
yishaihdavem330
authored andcommitted
net/mlx4_core: Set device configuration data to be persistent across reset
When an HCA enters an internal error state, this is detected by the driver. The driver then should reset the HCA and restart the software stack. Keep ports information and some SRIOV configuration in a persistent area to have it valid across reset. Signed-off-by: Yishai Hadas <yishaih@mellanox.com> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 872bf2f commit dd0eefe

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

drivers/net/ethernet/mellanox/mlx4/main.c

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3109,18 +3109,34 @@ static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
31093109
return ret;
31103110
}
31113111

3112+
static void mlx4_clean_dev(struct mlx4_dev *dev)
3113+
{
3114+
struct mlx4_dev_persistent *persist = dev->persist;
3115+
struct mlx4_priv *priv = mlx4_priv(dev);
3116+
3117+
memset(priv, 0, sizeof(*priv));
3118+
priv->dev.persist = persist;
3119+
}
3120+
31123121
static void mlx4_unload_one(struct pci_dev *pdev)
31133122
{
31143123
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
31153124
struct mlx4_dev *dev = persist->dev;
31163125
struct mlx4_priv *priv = mlx4_priv(dev);
31173126
int pci_dev_data;
3118-
int p;
3127+
int p, i;
31193128
int active_vfs = 0;
31203129

31213130
if (priv->removed)
31223131
return;
31233132

3133+
/* saving current ports type for further use */
3134+
for (i = 0; i < dev->caps.num_ports; i++) {
3135+
dev->persist->curr_port_type[i] = dev->caps.port_type[i + 1];
3136+
dev->persist->curr_port_poss_type[i] = dev->caps.
3137+
possible_type[i + 1];
3138+
}
3139+
31243140
pci_dev_data = priv->pci_dev_data;
31253141

31263142
/* Disabling SR-IOV is not allowed while there are active vf's */
@@ -3191,7 +3207,7 @@ static void mlx4_unload_one(struct pci_dev *pdev)
31913207
kfree(dev->caps.qp1_proxy);
31923208
kfree(dev->dev_vfs);
31933209

3194-
memset(priv, 0, sizeof(*priv));
3210+
mlx4_clean_dev(dev);
31953211
priv->pci_dev_data = pci_dev_data;
31963212
priv->removed = 1;
31973213
}
@@ -3210,6 +3226,25 @@ static void mlx4_remove_one(struct pci_dev *pdev)
32103226
pci_set_drvdata(pdev, NULL);
32113227
}
32123228

3229+
static int restore_current_port_types(struct mlx4_dev *dev,
3230+
enum mlx4_port_type *types,
3231+
enum mlx4_port_type *poss_types)
3232+
{
3233+
struct mlx4_priv *priv = mlx4_priv(dev);
3234+
int err, i;
3235+
3236+
mlx4_stop_sense(dev);
3237+
3238+
mutex_lock(&priv->port_mutex);
3239+
for (i = 0; i < dev->caps.num_ports; i++)
3240+
dev->caps.possible_type[i + 1] = poss_types[i];
3241+
err = mlx4_change_port_types(dev, types);
3242+
mlx4_start_sense(dev);
3243+
mutex_unlock(&priv->port_mutex);
3244+
3245+
return err;
3246+
}
3247+
32133248
int mlx4_restart_one(struct pci_dev *pdev)
32143249
{
32153250
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
@@ -3230,6 +3265,12 @@ int mlx4_restart_one(struct pci_dev *pdev)
32303265
return err;
32313266
}
32323267

3268+
err = restore_current_port_types(dev, dev->persist->curr_port_type,
3269+
dev->persist->curr_port_poss_type);
3270+
if (err)
3271+
mlx4_err(dev, "could not restore original port types (%d)\n",
3272+
err);
3273+
32333274
return err;
32343275
}
32353276

include/linux/mlx4/device.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,8 @@ struct mlx4_dev_persistent {
749749
struct mlx4_dev *dev;
750750
int nvfs[MLX4_MAX_PORTS + 1];
751751
int num_vfs;
752+
enum mlx4_port_type curr_port_type[MLX4_MAX_PORTS + 1];
753+
enum mlx4_port_type curr_port_poss_type[MLX4_MAX_PORTS + 1];
752754
};
753755

754756
struct mlx4_dev {

0 commit comments

Comments
 (0)