netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] mlx4_core misc for 4.18
@ 2018-05-09 15:29 Tariq Toukan
  2018-05-09 15:29 ` [PATCH net-next 1/3] net/mlx4_core: Report driver version to FW Tariq Toukan
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Tariq Toukan @ 2018-05-09 15:29 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Eran Ben Elisha, Tariq Toukan

Hi Dave,

This patchset contains misc enhancements from the team
to the mlx4 Core driver.

Patch 1 by Eran adds driver version report in FW.
Patch 2 by Yishai implements suspend/resume PCI callbacks.
Patch 3 extends the range of an existing module param from boolean to numerical.

Series generated against net-next commit:
53a7bdfb2a27 dt-bindings: dsa: Remove unnecessary #address/#size-cells

Thanks,
Tariq.


Eran Ben Elisha (1):
  net/mlx4_core: Report driver version to FW

Tariq Toukan (1):
  net/mlx4_core: Use msi_x module param to limit num of MSI-X irqs

Yishai Hadas (1):
  net/mlx4_core: Add PCI calls for suspend/resume

 drivers/net/ethernet/mellanox/mlx4/fw.c   | 12 +++++++
 drivers/net/ethernet/mellanox/mlx4/main.c | 56 ++++++++++++++++++++++++++++++-
 drivers/net/ethernet/mellanox/mlx4/mlx4.h |  2 +-
 include/linux/mlx4/device.h               |  1 +
 4 files changed, 69 insertions(+), 2 deletions(-)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next 1/3] net/mlx4_core: Report driver version to FW
  2018-05-09 15:29 [PATCH net-next 0/3] mlx4_core misc for 4.18 Tariq Toukan
@ 2018-05-09 15:29 ` Tariq Toukan
  2018-05-09 15:29 ` [PATCH net-next 2/3] net/mlx4_core: Add PCI calls for suspend/resume Tariq Toukan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Tariq Toukan @ 2018-05-09 15:29 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Eran Ben Elisha, Tariq Toukan

From: Eran Ben Elisha <eranbe@mellanox.com>

If supported, write a driver version string to FW as part of the
INIT_HCA command.

Example of driver version: "Linux,mlx4_core,4.0-0"

Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/fw.c   | 12 ++++++++++++
 drivers/net/ethernet/mellanox/mlx4/mlx4.h |  2 +-
 include/linux/mlx4/device.h               |  1 +
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c
index de6b3d416148..46dcbfbe4c5e 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -165,6 +165,7 @@ static void dump_dev_cap_flags2(struct mlx4_dev *dev, u64 flags)
 		[36] = "QinQ VST mode support",
 		[37] = "sl to vl mapping table change event support",
 		[38] = "user MAC support",
+		[39] = "Report driver version to FW support",
 	};
 	int i;
 
@@ -1038,6 +1039,8 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
 		dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_ETH_BACKPL_AN_REP;
 	if (field32 & (1 << 7))
 		dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_RECOVERABLE_ERROR_EVENT;
+	if (field32 & (1 << 8))
+		dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_DRIVER_VERSION_TO_FW;
 	MLX4_GET(field32, outbox, QUERY_DEV_CAP_DIAG_RPRT_PER_PORT);
 	if (field32 & (1 << 17))
 		dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_DIAG_PER_PORT;
@@ -1860,6 +1863,8 @@ int mlx4_INIT_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param *param)
 #define  INIT_HCA_UC_STEERING_OFFSET	 (INIT_HCA_MCAST_OFFSET + 0x18)
 #define	 INIT_HCA_LOG_MC_TABLE_SZ_OFFSET (INIT_HCA_MCAST_OFFSET + 0x1b)
 #define  INIT_HCA_DEVICE_MANAGED_FLOW_STEERING_EN	0x6
+#define  INIT_HCA_DRIVER_VERSION_OFFSET   0x140
+#define  INIT_HCA_DRIVER_VERSION_SZ       0x40
 #define  INIT_HCA_FS_PARAM_OFFSET         0x1d0
 #define  INIT_HCA_FS_BASE_OFFSET          (INIT_HCA_FS_PARAM_OFFSET + 0x00)
 #define  INIT_HCA_FS_LOG_ENTRY_SZ_OFFSET  (INIT_HCA_FS_PARAM_OFFSET + 0x12)
@@ -1950,6 +1955,13 @@ int mlx4_INIT_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param *param)
 	if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RECOVERABLE_ERROR_EVENT)
 		*(inbox + INIT_HCA_RECOVERABLE_ERROR_EVENT_OFFSET / 4) |= cpu_to_be32(1 << 31);
 
+	if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_DRIVER_VERSION_TO_FW) {
+		u8 *dst = (u8 *)(inbox + INIT_HCA_DRIVER_VERSION_OFFSET / 4);
+
+		strncpy(dst, DRV_NAME_FOR_FW, INIT_HCA_DRIVER_VERSION_SZ - 1);
+		mlx4_dbg(dev, "Reporting Driver Version to FW: %s\n", dst);
+	}
+
 	/* QPC/EEC/CQC/EQC/RDMARC attributes */
 
 	MLX4_PUT(inbox, param->qpc_base,      INIT_HCA_QPC_BASE_OFFSET);
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
index c68da1986e51..cb9e923e8399 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
@@ -55,8 +55,8 @@
 #include "fw_qos.h"
 
 #define DRV_NAME	"mlx4_core"
-#define PFX		DRV_NAME ": "
 #define DRV_VERSION	"4.0-0"
+#define DRV_NAME_FOR_FW		"Linux," DRV_NAME "," DRV_VERSION
 
 #define MLX4_FS_UDP_UC_EN		(1 << 1)
 #define MLX4_FS_TCP_UC_EN		(1 << 2)
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index 81d0799b6091..122e7e9d3091 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -225,6 +225,7 @@ enum {
 	MLX4_DEV_CAP_FLAG2_SVLAN_BY_QP          = 1ULL <<  36,
 	MLX4_DEV_CAP_FLAG2_SL_TO_VL_CHANGE_EVENT = 1ULL << 37,
 	MLX4_DEV_CAP_FLAG2_USER_MAC_EN		= 1ULL << 38,
+	MLX4_DEV_CAP_FLAG2_DRIVER_VERSION_TO_FW = 1ULL << 39,
 };
 
 enum {
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 2/3] net/mlx4_core: Add PCI calls for suspend/resume
  2018-05-09 15:29 [PATCH net-next 0/3] mlx4_core misc for 4.18 Tariq Toukan
  2018-05-09 15:29 ` [PATCH net-next 1/3] net/mlx4_core: Report driver version to FW Tariq Toukan
@ 2018-05-09 15:29 ` Tariq Toukan
  2018-05-09 15:29 ` [PATCH net-next 3/3] net/mlx4_core: Use msi_x module param to limit num of MSI-X irqs Tariq Toukan
  2018-05-10 20:09 ` [PATCH net-next 0/3] mlx4_core misc for 4.18 David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: Tariq Toukan @ 2018-05-09 15:29 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Eran Ben Elisha, Yishai Hadas, Tariq Toukan

From: Yishai Hadas <yishaih@mellanox.com>

Implement suspend/resume callbacks in struct pci_driver.

Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/main.c | 46 +++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 211578ffc70d..b6aaf34d6648 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -4125,12 +4125,58 @@ static void mlx4_shutdown(struct pci_dev *pdev)
 	.resume		= mlx4_pci_resume,
 };
 
+static int mlx4_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+	struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
+	struct mlx4_dev	*dev = persist->dev;
+
+	mlx4_err(dev, "suspend was called\n");
+	mutex_lock(&persist->interface_state_mutex);
+	if (persist->interface_state & MLX4_INTERFACE_STATE_UP)
+		mlx4_unload_one(pdev);
+	mutex_unlock(&persist->interface_state_mutex);
+
+	return 0;
+}
+
+static int mlx4_resume(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 nvfs[MLX4_MAX_PORTS + 1] = {0, 0, 0};
+	int total_vfs;
+	int ret = 0;
+
+	mlx4_err(dev, "resume was called\n");
+	total_vfs = dev->persist->num_vfs;
+	memcpy(nvfs, dev->persist->nvfs, sizeof(dev->persist->nvfs));
+
+	mutex_lock(&persist->interface_state_mutex);
+	if (!(persist->interface_state & MLX4_INTERFACE_STATE_UP)) {
+		ret = mlx4_load_one(pdev, priv->pci_dev_data, total_vfs,
+				    nvfs, priv, 1);
+		if (!ret) {
+			ret = restore_current_port_types(dev,
+					dev->persist->curr_port_type,
+					dev->persist->curr_port_poss_type);
+			if (ret)
+				mlx4_err(dev, "resume: could not restore original port types (%d)\n", ret);
+		}
+	}
+	mutex_unlock(&persist->interface_state_mutex);
+
+	return ret;
+}
+
 static struct pci_driver mlx4_driver = {
 	.name		= DRV_NAME,
 	.id_table	= mlx4_pci_table,
 	.probe		= mlx4_init_one,
 	.shutdown	= mlx4_shutdown,
 	.remove		= mlx4_remove_one,
+	.suspend	= mlx4_suspend,
+	.resume		= mlx4_resume,
 	.err_handler    = &mlx4_err_handler,
 };
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 3/3] net/mlx4_core: Use msi_x module param to limit num of MSI-X irqs
  2018-05-09 15:29 [PATCH net-next 0/3] mlx4_core misc for 4.18 Tariq Toukan
  2018-05-09 15:29 ` [PATCH net-next 1/3] net/mlx4_core: Report driver version to FW Tariq Toukan
  2018-05-09 15:29 ` [PATCH net-next 2/3] net/mlx4_core: Add PCI calls for suspend/resume Tariq Toukan
@ 2018-05-09 15:29 ` Tariq Toukan
  2018-05-09 19:29   ` Ajaykumar Hotchandani
  2018-05-10 20:09 ` [PATCH net-next 0/3] mlx4_core misc for 4.18 David Miller
  3 siblings, 1 reply; 6+ messages in thread
From: Tariq Toukan @ 2018-05-09 15:29 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Eran Ben Elisha, Tariq Toukan, Ajaykumar Hotchandani

Extend the boolean interpretation of msi_x module parameter
to numerical, as follows:

0   - Don't use MSI-X.
1   - Use MSI-X, driver decides the num of MSI-X irqs.
>=2 - Use MSI-X, limit number of MSI-X irqs to msi_x.
      In SRIOV, this limits the number of MSI-X irqs per VF.

Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Cc: Ajaykumar Hotchandani <ajaykumar.hotchandani@oracle.com>
---
 drivers/net/ethernet/mellanox/mlx4/main.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index b6aaf34d6648..80a75c80a463 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -73,7 +73,7 @@
 
 static int msi_x = 1;
 module_param(msi_x, int, 0444);
-MODULE_PARM_DESC(msi_x, "attempt to use MSI-X if nonzero");
+MODULE_PARM_DESC(msi_x, "0 - don't use MSI-X, 1 - use MSI-X, >1 - limit number of MSI-X irqs to msi_x");
 
 #else /* CONFIG_PCI_MSI */
 
@@ -2815,6 +2815,9 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
 				dev->caps.num_eqs - dev->caps.reserved_eqs,
 				MAX_MSIX);
 
+		if (msi_x > 1)
+			nreq = min_t(int, nreq, msi_x);
+
 		entries = kcalloc(nreq, sizeof(*entries), GFP_KERNEL);
 		if (!entries)
 			goto no_msi;
@@ -4182,6 +4185,11 @@ static int mlx4_resume(struct pci_dev *pdev)
 
 static int __init mlx4_verify_params(void)
 {
+	if (msi_x < 0) {
+		pr_warn("mlx4_core: bad msi_x: %d\n", msi_x);
+		return -1;
+	}
+
 	if ((log_num_mac < 0) || (log_num_mac > 7)) {
 		pr_warn("mlx4_core: bad num_mac: %d\n", log_num_mac);
 		return -1;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 3/3] net/mlx4_core: Use msi_x module param to limit num of MSI-X irqs
  2018-05-09 15:29 ` [PATCH net-next 3/3] net/mlx4_core: Use msi_x module param to limit num of MSI-X irqs Tariq Toukan
@ 2018-05-09 19:29   ` Ajaykumar Hotchandani
  0 siblings, 0 replies; 6+ messages in thread
From: Ajaykumar Hotchandani @ 2018-05-09 19:29 UTC (permalink / raw)
  To: Tariq Toukan, David S. Miller; +Cc: netdev, Eran Ben Elisha

Thanks Tariq.

Reviewed-by: Ajaykumar Hotchandani <ajaykumar.hotchandani@oracle.com>

On 05/09/2018 08:29 AM, Tariq Toukan wrote:
> Extend the boolean interpretation of msi_x module parameter
> to numerical, as follows:
>
> 0   - Don't use MSI-X.
> 1   - Use MSI-X, driver decides the num of MSI-X irqs.
>> =2 - Use MSI-X, limit number of MSI-X irqs to msi_x.
>        In SRIOV, this limits the number of MSI-X irqs per VF.
>
> Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
> Cc: Ajaykumar Hotchandani <ajaykumar.hotchandani@oracle.com>
> ---
>   drivers/net/ethernet/mellanox/mlx4/main.c | 10 +++++++++-
>   1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
> index b6aaf34d6648..80a75c80a463 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/main.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/main.c
> @@ -73,7 +73,7 @@
>   
>   static int msi_x = 1;
>   module_param(msi_x, int, 0444);
> -MODULE_PARM_DESC(msi_x, "attempt to use MSI-X if nonzero");
> +MODULE_PARM_DESC(msi_x, "0 - don't use MSI-X, 1 - use MSI-X, >1 - limit number of MSI-X irqs to msi_x");
>   
>   #else /* CONFIG_PCI_MSI */
>   
> @@ -2815,6 +2815,9 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
>   				dev->caps.num_eqs - dev->caps.reserved_eqs,
>   				MAX_MSIX);
>   
> +		if (msi_x > 1)
> +			nreq = min_t(int, nreq, msi_x);
> +
>   		entries = kcalloc(nreq, sizeof(*entries), GFP_KERNEL);
>   		if (!entries)
>   			goto no_msi;
> @@ -4182,6 +4185,11 @@ static int mlx4_resume(struct pci_dev *pdev)
>   
>   static int __init mlx4_verify_params(void)
>   {
> +	if (msi_x < 0) {
> +		pr_warn("mlx4_core: bad msi_x: %d\n", msi_x);
> +		return -1;
> +	}
> +
>   	if ((log_num_mac < 0) || (log_num_mac > 7)) {
>   		pr_warn("mlx4_core: bad num_mac: %d\n", log_num_mac);
>   		return -1;

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 0/3] mlx4_core misc for 4.18
  2018-05-09 15:29 [PATCH net-next 0/3] mlx4_core misc for 4.18 Tariq Toukan
                   ` (2 preceding siblings ...)
  2018-05-09 15:29 ` [PATCH net-next 3/3] net/mlx4_core: Use msi_x module param to limit num of MSI-X irqs Tariq Toukan
@ 2018-05-10 20:09 ` David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2018-05-10 20:09 UTC (permalink / raw)
  To: tariqt; +Cc: netdev, eranbe

From: Tariq Toukan <tariqt@mellanox.com>
Date: Wed,  9 May 2018 18:29:01 +0300

> This patchset contains misc enhancements from the team
> to the mlx4 Core driver.
> 
> Patch 1 by Eran adds driver version report in FW.
> Patch 2 by Yishai implements suspend/resume PCI callbacks.
> Patch 3 extends the range of an existing module param from boolean to numerical.
> 
> Series generated against net-next commit:
> 53a7bdfb2a27 dt-bindings: dsa: Remove unnecessary #address/#size-cells

Series applied.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-05-10 20:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-09 15:29 [PATCH net-next 0/3] mlx4_core misc for 4.18 Tariq Toukan
2018-05-09 15:29 ` [PATCH net-next 1/3] net/mlx4_core: Report driver version to FW Tariq Toukan
2018-05-09 15:29 ` [PATCH net-next 2/3] net/mlx4_core: Add PCI calls for suspend/resume Tariq Toukan
2018-05-09 15:29 ` [PATCH net-next 3/3] net/mlx4_core: Use msi_x module param to limit num of MSI-X irqs Tariq Toukan
2018-05-09 19:29   ` Ajaykumar Hotchandani
2018-05-10 20:09 ` [PATCH net-next 0/3] mlx4_core misc for 4.18 David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).