From: Or Gerlitz <ogerlitz@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Matan Barak <matanb@mellanox.com>,
Amir Vadai <amirv@mellanox.com>, Tal Alon <talal@mellanox.com>,
Roland Dreier <roland@kernel.org>,
Yishai Hadas <yishaih@mellanox.com>,
Or Gerlitz <ogerlitz@mellanox.com>
Subject: [PATCH net-next 2/9] net/mlx4_core: Set device configuration data to be persistent across reset
Date: Wed, 21 Jan 2015 16:45:50 +0200 [thread overview]
Message-ID: <1421851557-12084-3-git-send-email-ogerlitz@mellanox.com> (raw)
In-Reply-To: <1421851557-12084-1-git-send-email-ogerlitz@mellanox.com>
From: Yishai Hadas <yishaih@mellanox.com>
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>
---
drivers/net/ethernet/mellanox/mlx4/main.c | 45 +++++++++++++++++++++++++++-
include/linux/mlx4/device.h | 2 +
2 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index abcee61..2c5a555 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -3109,18 +3109,34 @@ static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
return ret;
}
+static void mlx4_clean_dev(struct mlx4_dev *dev)
+{
+ struct mlx4_dev_persistent *persist = dev->persist;
+ struct mlx4_priv *priv = mlx4_priv(dev);
+
+ memset(priv, 0, sizeof(*priv));
+ priv->dev.persist = persist;
+}
+
static void mlx4_unload_one(struct pci_dev *pdev)
{
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
struct mlx4_dev *dev = persist->dev;
struct mlx4_priv *priv = mlx4_priv(dev);
int pci_dev_data;
- int p;
+ int p, i;
int active_vfs = 0;
if (priv->removed)
return;
+ /* saving current ports type for further use */
+ for (i = 0; i < dev->caps.num_ports; i++) {
+ dev->persist->curr_port_type[i] = dev->caps.port_type[i + 1];
+ dev->persist->curr_port_poss_type[i] = dev->caps.
+ possible_type[i + 1];
+ }
+
pci_dev_data = priv->pci_dev_data;
/* 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)
kfree(dev->caps.qp1_proxy);
kfree(dev->dev_vfs);
- memset(priv, 0, sizeof(*priv));
+ mlx4_clean_dev(dev);
priv->pci_dev_data = pci_dev_data;
priv->removed = 1;
}
@@ -3210,6 +3226,25 @@ static void mlx4_remove_one(struct pci_dev *pdev)
pci_set_drvdata(pdev, NULL);
}
+static int restore_current_port_types(struct mlx4_dev *dev,
+ enum mlx4_port_type *types,
+ enum mlx4_port_type *poss_types)
+{
+ struct mlx4_priv *priv = mlx4_priv(dev);
+ int err, i;
+
+ mlx4_stop_sense(dev);
+
+ mutex_lock(&priv->port_mutex);
+ for (i = 0; i < dev->caps.num_ports; i++)
+ dev->caps.possible_type[i + 1] = poss_types[i];
+ err = mlx4_change_port_types(dev, types);
+ mlx4_start_sense(dev);
+ mutex_unlock(&priv->port_mutex);
+
+ return err;
+}
+
int mlx4_restart_one(struct pci_dev *pdev)
{
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
@@ -3230,6 +3265,12 @@ int mlx4_restart_one(struct pci_dev *pdev)
return err;
}
+ err = restore_current_port_types(dev, dev->persist->curr_port_type,
+ dev->persist->curr_port_poss_type);
+ if (err)
+ mlx4_err(dev, "could not restore original port types (%d)\n",
+ err);
+
return err;
}
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index 1069ce6..8c3837a 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -749,6 +749,8 @@ struct mlx4_dev_persistent {
struct mlx4_dev *dev;
int nvfs[MLX4_MAX_PORTS + 1];
int num_vfs;
+ enum mlx4_port_type curr_port_type[MLX4_MAX_PORTS + 1];
+ enum mlx4_port_type curr_port_poss_type[MLX4_MAX_PORTS + 1];
};
struct mlx4_dev {
--
1.7.1
next prev parent reply other threads:[~2015-01-21 14:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-21 14:45 [PATCH net-next 0/9] mlx4: Fix and enhance the device reset flow Or Gerlitz
2015-01-21 14:45 ` [PATCH net-next 1/9] net/mlx4_core: Maintain a persistent memory for mlx4 devices Or Gerlitz
2015-01-21 14:45 ` Or Gerlitz [this message]
2015-01-21 14:45 ` [PATCH net-next 3/9] net/mlx4_core: Refactor the catas flow to work per device Or Gerlitz
2015-01-21 14:45 ` [PATCH net-next 4/9] net/mlx4_core: Enhance the catas flow to support device reset Or Gerlitz
2015-01-21 14:45 ` [PATCH net-next 5/9] net/mlx4_core: Activate reset flow upon fatal command cases Or Gerlitz
2015-01-21 14:45 ` [PATCH net-next 6/9] net/mlx4_core: Manage interface state for Reset flow cases Or Gerlitz
2015-01-21 14:45 ` [PATCH net-next 7/9] net/mlx4_core: Handle AER flow properly Or Gerlitz
2015-01-21 14:45 ` [PATCH net-next 8/9] net/mlx4_core: Enable device recovery flow with SRIOV Or Gerlitz
2015-01-21 14:45 ` [PATCH net-next 9/9] net/mlx4_core: Reset flow activation upon SRIOV fatal command cases Or Gerlitz
2015-01-22 14:05 ` [PATCH net-next 0/9] mlx4: Fix and enhance the device reset flow Or Gerlitz
2015-01-25 7:31 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1421851557-12084-3-git-send-email-ogerlitz@mellanox.com \
--to=ogerlitz@mellanox.com \
--cc=amirv@mellanox.com \
--cc=davem@davemloft.net \
--cc=matanb@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=roland@kernel.org \
--cc=talal@mellanox.com \
--cc=yishaih@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox