Skip to content

Commit 79a6fd2

Browse files
committed
Merge branch 'mlx4-misc-next'
Tariq Toukan says: ==================== mlx4_core misc for 4.18 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: 53a7bdf dt-bindings: dsa: Remove unnecessary #address/#size-cells ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents a37fb85 + e573283 commit 79a6fd2

File tree

4 files changed

+69
-2
lines changed

4 files changed

+69
-2
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ static void dump_dev_cap_flags2(struct mlx4_dev *dev, u64 flags)
165165
[36] = "QinQ VST mode support",
166166
[37] = "sl to vl mapping table change event support",
167167
[38] = "user MAC support",
168+
[39] = "Report driver version to FW support",
168169
};
169170
int i;
170171

@@ -1038,6 +1039,8 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
10381039
dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_ETH_BACKPL_AN_REP;
10391040
if (field32 & (1 << 7))
10401041
dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_RECOVERABLE_ERROR_EVENT;
1042+
if (field32 & (1 << 8))
1043+
dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_DRIVER_VERSION_TO_FW;
10411044
MLX4_GET(field32, outbox, QUERY_DEV_CAP_DIAG_RPRT_PER_PORT);
10421045
if (field32 & (1 << 17))
10431046
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)
18601863
#define INIT_HCA_UC_STEERING_OFFSET (INIT_HCA_MCAST_OFFSET + 0x18)
18611864
#define INIT_HCA_LOG_MC_TABLE_SZ_OFFSET (INIT_HCA_MCAST_OFFSET + 0x1b)
18621865
#define INIT_HCA_DEVICE_MANAGED_FLOW_STEERING_EN 0x6
1866+
#define INIT_HCA_DRIVER_VERSION_OFFSET 0x140
1867+
#define INIT_HCA_DRIVER_VERSION_SZ 0x40
18631868
#define INIT_HCA_FS_PARAM_OFFSET 0x1d0
18641869
#define INIT_HCA_FS_BASE_OFFSET (INIT_HCA_FS_PARAM_OFFSET + 0x00)
18651870
#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)
19501955
if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RECOVERABLE_ERROR_EVENT)
19511956
*(inbox + INIT_HCA_RECOVERABLE_ERROR_EVENT_OFFSET / 4) |= cpu_to_be32(1 << 31);
19521957

1958+
if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_DRIVER_VERSION_TO_FW) {
1959+
u8 *dst = (u8 *)(inbox + INIT_HCA_DRIVER_VERSION_OFFSET / 4);
1960+
1961+
strncpy(dst, DRV_NAME_FOR_FW, INIT_HCA_DRIVER_VERSION_SZ - 1);
1962+
mlx4_dbg(dev, "Reporting Driver Version to FW: %s\n", dst);
1963+
}
1964+
19531965
/* QPC/EEC/CQC/EQC/RDMARC attributes */
19541966

19551967
MLX4_PUT(inbox, param->qpc_base, INIT_HCA_QPC_BASE_OFFSET);

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

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ MODULE_PARM_DESC(debug_level, "Enable debug tracing if > 0");
7373

7474
static int msi_x = 1;
7575
module_param(msi_x, int, 0444);
76-
MODULE_PARM_DESC(msi_x, "attempt to use MSI-X if nonzero");
76+
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");
7777

7878
#else /* CONFIG_PCI_MSI */
7979

@@ -2815,6 +2815,9 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
28152815
dev->caps.num_eqs - dev->caps.reserved_eqs,
28162816
MAX_MSIX);
28172817

2818+
if (msi_x > 1)
2819+
nreq = min_t(int, nreq, msi_x);
2820+
28182821
entries = kcalloc(nreq, sizeof(*entries), GFP_KERNEL);
28192822
if (!entries)
28202823
goto no_msi;
@@ -4125,17 +4128,68 @@ static const struct pci_error_handlers mlx4_err_handler = {
41254128
.resume = mlx4_pci_resume,
41264129
};
41274130

4131+
static int mlx4_suspend(struct pci_dev *pdev, pm_message_t state)
4132+
{
4133+
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
4134+
struct mlx4_dev *dev = persist->dev;
4135+
4136+
mlx4_err(dev, "suspend was called\n");
4137+
mutex_lock(&persist->interface_state_mutex);
4138+
if (persist->interface_state & MLX4_INTERFACE_STATE_UP)
4139+
mlx4_unload_one(pdev);
4140+
mutex_unlock(&persist->interface_state_mutex);
4141+
4142+
return 0;
4143+
}
4144+
4145+
static int mlx4_resume(struct pci_dev *pdev)
4146+
{
4147+
struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
4148+
struct mlx4_dev *dev = persist->dev;
4149+
struct mlx4_priv *priv = mlx4_priv(dev);
4150+
int nvfs[MLX4_MAX_PORTS + 1] = {0, 0, 0};
4151+
int total_vfs;
4152+
int ret = 0;
4153+
4154+
mlx4_err(dev, "resume was called\n");
4155+
total_vfs = dev->persist->num_vfs;
4156+
memcpy(nvfs, dev->persist->nvfs, sizeof(dev->persist->nvfs));
4157+
4158+
mutex_lock(&persist->interface_state_mutex);
4159+
if (!(persist->interface_state & MLX4_INTERFACE_STATE_UP)) {
4160+
ret = mlx4_load_one(pdev, priv->pci_dev_data, total_vfs,
4161+
nvfs, priv, 1);
4162+
if (!ret) {
4163+
ret = restore_current_port_types(dev,
4164+
dev->persist->curr_port_type,
4165+
dev->persist->curr_port_poss_type);
4166+
if (ret)
4167+
mlx4_err(dev, "resume: could not restore original port types (%d)\n", ret);
4168+
}
4169+
}
4170+
mutex_unlock(&persist->interface_state_mutex);
4171+
4172+
return ret;
4173+
}
4174+
41284175
static struct pci_driver mlx4_driver = {
41294176
.name = DRV_NAME,
41304177
.id_table = mlx4_pci_table,
41314178
.probe = mlx4_init_one,
41324179
.shutdown = mlx4_shutdown,
41334180
.remove = mlx4_remove_one,
4181+
.suspend = mlx4_suspend,
4182+
.resume = mlx4_resume,
41344183
.err_handler = &mlx4_err_handler,
41354184
};
41364185

41374186
static int __init mlx4_verify_params(void)
41384187
{
4188+
if (msi_x < 0) {
4189+
pr_warn("mlx4_core: bad msi_x: %d\n", msi_x);
4190+
return -1;
4191+
}
4192+
41394193
if ((log_num_mac < 0) || (log_num_mac > 7)) {
41404194
pr_warn("mlx4_core: bad num_mac: %d\n", log_num_mac);
41414195
return -1;

drivers/net/ethernet/mellanox/mlx4/mlx4.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
#include "fw_qos.h"
5656

5757
#define DRV_NAME "mlx4_core"
58-
#define PFX DRV_NAME ": "
5958
#define DRV_VERSION "4.0-0"
59+
#define DRV_NAME_FOR_FW "Linux," DRV_NAME "," DRV_VERSION
6060

6161
#define MLX4_FS_UDP_UC_EN (1 << 1)
6262
#define MLX4_FS_TCP_UC_EN (1 << 2)

include/linux/mlx4/device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ enum {
225225
MLX4_DEV_CAP_FLAG2_SVLAN_BY_QP = 1ULL << 36,
226226
MLX4_DEV_CAP_FLAG2_SL_TO_VL_CHANGE_EVENT = 1ULL << 37,
227227
MLX4_DEV_CAP_FLAG2_USER_MAC_EN = 1ULL << 38,
228+
MLX4_DEV_CAP_FLAG2_DRIVER_VERSION_TO_FW = 1ULL << 39,
228229
};
229230

230231
enum {

0 commit comments

Comments
 (0)