vdpa/mlx5: fix live migration termination
[dpdk.git] / drivers / vdpa / mlx5 / mlx5_vdpa_lm.c
index 77f2eda..273c46f 100644 (file)
@@ -19,8 +19,13 @@ mlx5_vdpa_logging_enable(struct mlx5_vdpa_priv *priv, int enable)
 
        for (i = 0; i < priv->nr_virtqs; ++i) {
                attr.queue_index = i;
-               if (mlx5_devx_cmd_modify_virtq(priv->virtqs[i].virtq, &attr)) {
-                       DRV_LOG(ERR, "Failed to modify virtq %d logging.", i);
+               if (!priv->virtqs[i].virtq) {
+                       DRV_LOG(DEBUG, "virtq %d is invalid for dirty bitmap "
+                               "enabling.", i);
+               } else if (mlx5_devx_cmd_modify_virtq(priv->virtqs[i].virtq,
+                          &attr)) {
+                       DRV_LOG(ERR, "Failed to modify virtq %d for dirty "
+                               "bitmap enabling.", i);
                        return -1;
                }
        }
@@ -68,8 +73,11 @@ mlx5_vdpa_dirty_bitmap_set(struct mlx5_vdpa_priv *priv, uint64_t log_base,
        attr.dirty_bitmap_mkey = mr->mkey->id;
        for (i = 0; i < priv->nr_virtqs; ++i) {
                attr.queue_index = i;
-               if (mlx5_devx_cmd_modify_virtq(priv->virtqs[i].virtq, &attr)) {
-                       DRV_LOG(ERR, "Failed to modify virtq %d for lm.", i);
+               if (!priv->virtqs[i].virtq) {
+                       DRV_LOG(DEBUG, "virtq %d is invalid for LM.", i);
+               } else if (mlx5_devx_cmd_modify_virtq(priv->virtqs[i].virtq,
+                                                     &attr)) {
+                       DRV_LOG(ERR, "Failed to modify virtq %d for LM.", i);
                        goto err;
                }
        }
@@ -91,7 +99,6 @@ err:
 int
 mlx5_vdpa_lm_log(struct mlx5_vdpa_priv *priv)
 {
-       struct mlx5_devx_virtq_attr attr = {0};
        uint64_t features;
        int ret = rte_vhost_get_negotiated_features(priv->vid, &features);
        int i;
@@ -103,22 +110,15 @@ mlx5_vdpa_lm_log(struct mlx5_vdpa_priv *priv)
        if (!RTE_VHOST_NEED_LOG(features))
                return 0;
        for (i = 0; i < priv->nr_virtqs; ++i) {
-               ret = mlx5_vdpa_virtq_modify(&priv->virtqs[i], 0);
-               if (ret)
-                       return -1;
-               if (mlx5_devx_cmd_query_virtq(priv->virtqs[i].virtq, &attr)) {
-                       DRV_LOG(ERR, "Failed to query virtq %d.", i);
-                       return -1;
-               }
-               DRV_LOG(INFO, "Query vid %d vring %d: hw_available_idx=%d, "
-                       "hw_used_index=%d", priv->vid, i,
-                       attr.hw_available_index, attr.hw_used_index);
-               ret = rte_vhost_set_vring_base(priv->vid, i,
-                                              attr.hw_available_index,
-                                              attr.hw_used_index);
-               if (ret) {
-                       DRV_LOG(ERR, "Failed to set virtq %d base.", i);
-                       return -1;
+               if (!priv->virtqs[i].virtq) {
+                       DRV_LOG(DEBUG, "virtq %d is invalid for LM log.", i);
+               } else {
+                       ret = mlx5_vdpa_virtq_stop(priv, i);
+                       if (ret) {
+                               DRV_LOG(ERR, "Failed to stop virtq %d for LM "
+                                       "log.", i);
+                               return -1;
+                       }
                }
                rte_vhost_log_used_vring(priv->vid, i, 0,
                              MLX5_VDPA_USED_RING_LEN(priv->virtqs[i].vq_size));