mlx4: Add support for devlink reload and load driverinit values
authorMoshe Shemesh <moshe@mellanox.com>
Wed, 4 Jul 2018 11:30:35 +0000 (14:30 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 5 Jul 2018 10:58:35 +0000 (19:58 +0900)
Add mlx4_devlink_reload() to support devlink reload operation.
Add mlx4_devlink_param_load_driverinit_values() to load values which
were set using driverinit configuration mode.

Signed-off-by: Moshe Shemesh <moshe@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx4/catas.c
drivers/net/ethernet/mellanox/mlx4/main.c
drivers/net/ethernet/mellanox/mlx4/mlx4.h

index e2b6b0cac1acf9dad8168587743ccc5e871a7c92..8afe4b5fb09b5caaa8995076341b57661ccd550a 100644 (file)
@@ -212,7 +212,7 @@ static void mlx4_handle_error_state(struct mlx4_dev_persistent *persist)
        mutex_lock(&persist->interface_state_mutex);
        if (persist->interface_state & MLX4_INTERFACE_STATE_UP &&
            !(persist->interface_state & MLX4_INTERFACE_STATE_DELETION)) {
-               err = mlx4_restart_one(persist->pdev);
+               err = mlx4_restart_one(persist->pdev, false, NULL);
                mlx4_info(persist->dev, "mlx4_restart_one was ended, ret=%d\n",
                          err);
        }
index 2445f799962907bf3dd6003b30062fce64c69322..c42eddfcd2b5e30423da1b1d1e3704a88ef79770 100644 (file)
@@ -3852,8 +3852,57 @@ static int mlx4_devlink_port_type_set(struct devlink_port *devlink_port,
        return __set_port_type(info, mlx4_port_type);
 }
 
+static void mlx4_devlink_param_load_driverinit_values(struct devlink *devlink)
+{
+       union devlink_param_value saved_value;
+       int err;
+
+       err = devlink_param_driverinit_value_get(devlink,
+                                                DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET,
+                                                &saved_value);
+       if (!err && mlx4_internal_err_reset != saved_value.vbool) {
+               mlx4_internal_err_reset = saved_value.vbool;
+               /* Notify on value changed on runtime configuration mode */
+               devlink_param_value_changed(devlink,
+                                           DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET);
+       }
+       err = devlink_param_driverinit_value_get(devlink,
+                                                DEVLINK_PARAM_GENERIC_ID_MAX_MACS,
+                                                &saved_value);
+       if (!err)
+               log_num_mac = order_base_2(saved_value.vu32);
+       err = devlink_param_driverinit_value_get(devlink,
+                                                MLX4_DEVLINK_PARAM_ID_ENABLE_64B_CQE_EQE,
+                                                &saved_value);
+       if (!err)
+               enable_64b_cqe_eqe = saved_value.vbool;
+       err = devlink_param_driverinit_value_get(devlink,
+                                                MLX4_DEVLINK_PARAM_ID_ENABLE_4K_UAR,
+                                                &saved_value);
+       if (!err)
+               enable_4k_uar = saved_value.vbool;
+}
+
+static int mlx4_devlink_reload(struct devlink *devlink,
+                              struct netlink_ext_ack *extack)
+{
+       struct mlx4_priv *priv = devlink_priv(devlink);
+       struct mlx4_dev *dev = &priv->dev;
+       struct mlx4_dev_persistent *persist = dev->persist;
+       int err;
+
+       if (persist->num_vfs)
+               mlx4_warn(persist->dev, "Reload performed on PF, will cause reset on operating Virtual Functions\n");
+       err = mlx4_restart_one(persist->pdev, true, devlink);
+       if (err)
+               mlx4_err(persist->dev, "mlx4_restart_one failed, ret=%d\n", err);
+
+       return err;
+}
+
 static const struct devlink_ops mlx4_devlink_ops = {
        .port_type_set  = mlx4_devlink_port_type_set,
+       .reload         = mlx4_devlink_reload,
 };
 
 static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
@@ -4064,7 +4113,7 @@ static int restore_current_port_types(struct mlx4_dev *dev,
        return err;
 }
 
-int mlx4_restart_one(struct pci_dev *pdev)
+int mlx4_restart_one(struct pci_dev *pdev, bool reload, struct devlink *devlink)
 {
        struct mlx4_dev_persistent *persist = pci_get_drvdata(pdev);
        struct mlx4_dev  *dev  = persist->dev;
@@ -4077,6 +4126,8 @@ int mlx4_restart_one(struct pci_dev *pdev)
        memcpy(nvfs, dev->persist->nvfs, sizeof(dev->persist->nvfs));
 
        mlx4_unload_one(pdev);
+       if (reload)
+               mlx4_devlink_param_load_driverinit_values(devlink);
        err = mlx4_load_one(pdev, pci_dev_data, total_vfs, nvfs, priv, 1);
        if (err) {
                mlx4_err(dev, "%s: ERROR: mlx4_load_one failed, pci_name=%s, err=%d\n",
index cb9e923e83996499c2d98c8023b5ebc069bb0731..2ebaa3bee42fbc6da7babfbf169bf3a9a2d118c3 100644 (file)
@@ -1042,7 +1042,8 @@ void mlx4_start_catas_poll(struct mlx4_dev *dev);
 void mlx4_stop_catas_poll(struct mlx4_dev *dev);
 int mlx4_catas_init(struct mlx4_dev *dev);
 void mlx4_catas_end(struct mlx4_dev *dev);
-int mlx4_restart_one(struct pci_dev *pdev);
+int mlx4_restart_one(struct pci_dev *pdev, bool reload,
+                    struct devlink *devlink);
 int mlx4_register_device(struct mlx4_dev *dev);
 void mlx4_unregister_device(struct mlx4_dev *dev);
 void mlx4_dispatch_event(struct mlx4_dev *dev, enum mlx4_dev_event type,