[2/3] vdpa/mlx5: separate virtq stop
Checks
Commit Message
In live migration, before loging the virtq, the driver queries the virtq
indexes after moving it to suspend mode.
Separate this method to new function mlx5_vdpa_virtq_stop as a
preparation for reusing.
Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
drivers/vdpa/mlx5/mlx5_vdpa.h | 13 +++++++++++++
drivers/vdpa/mlx5/mlx5_vdpa_lm.c | 17 ++---------------
drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 26 ++++++++++++++++++++++++++
3 files changed, 41 insertions(+), 15 deletions(-)
Comments
On 3/31/20 1:12 PM, Matan Azrad wrote:
> In live migration, before loging the virtq, the driver queries the virtq
s/loging/logging/
> indexes after moving it to suspend mode.
>
> Separate this method to new function mlx5_vdpa_virtq_stop as a
> preparation for reusing.
>
> Signed-off-by: Matan Azrad <matan@mellanox.com>
> Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
> ---
> drivers/vdpa/mlx5/mlx5_vdpa.h | 13 +++++++++++++
> drivers/vdpa/mlx5/mlx5_vdpa_lm.c | 17 ++---------------
> drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 26 ++++++++++++++++++++++++++
> 3 files changed, 41 insertions(+), 15 deletions(-)
>
Other than that:
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Thanks,
Maxime
Hi Maxime
From: Maxime Coquelin
> On 3/31/20 1:12 PM, Matan Azrad wrote:
> > In live migration, before loging the virtq, the driver queries the
> > virtq
> s/loging/logging/
Ok, can this small change be done in integration?
> > indexes after moving it to suspend mode.
> >
> > Separate this method to new function mlx5_vdpa_virtq_stop as a
> > preparation for reusing.
> >
> > Signed-off-by: Matan Azrad <matan@mellanox.com>
> > Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
> > ---
> > drivers/vdpa/mlx5/mlx5_vdpa.h | 13 +++++++++++++
> > drivers/vdpa/mlx5/mlx5_vdpa_lm.c | 17 ++---------------
> > drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 26
> ++++++++++++++++++++++++++
> > 3 files changed, 41 insertions(+), 15 deletions(-)
> >
>
> Other than that:
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>
> Thanks,
> Maxime
On 4/10/20 3:59 PM, Matan Azrad wrote:
>
> Hi Maxime
>
> From: Maxime Coquelin
>> On 3/31/20 1:12 PM, Matan Azrad wrote:
>>> In live migration, before loging the virtq, the driver queries the
>>> virtq
>> s/loging/logging/
> Ok, can this small change be done in integration?
Of course!
>
>>> indexes after moving it to suspend mode.
>>>
>>> Separate this method to new function mlx5_vdpa_virtq_stop as a
>>> preparation for reusing.
>>>
>>> Signed-off-by: Matan Azrad <matan@mellanox.com>
>>> Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
>>> ---
>>> drivers/vdpa/mlx5/mlx5_vdpa.h | 13 +++++++++++++
>>> drivers/vdpa/mlx5/mlx5_vdpa_lm.c | 17 ++---------------
>>> drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 26
>> ++++++++++++++++++++++++++
>>> 3 files changed, 41 insertions(+), 15 deletions(-)
>>>
>>
>> Other than that:
>> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>>
>> Thanks,
>> Maxime
>
@@ -308,4 +308,17 @@ int mlx5_vdpa_dirty_bitmap_set(struct mlx5_vdpa_priv *priv, uint64_t log_base,
*/
int mlx5_vdpa_virtq_modify(struct mlx5_vdpa_virtq *virtq, int state);
+/**
+ * Stop virtq before destroying it.
+ *
+ * @param[in] priv
+ * The vdpa driver private structure.
+ * @param[in] index
+ * The virtq index.
+ *
+ * @return
+ * 0 on success, a negative value otherwise.
+ */
+int mlx5_vdpa_virtq_stop(struct mlx5_vdpa_priv *priv, int index);
+
#endif /* RTE_PMD_MLX5_VDPA_H_ */
@@ -91,7 +91,6 @@
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,21 +102,9 @@
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);
+ ret = mlx5_vdpa_virtq_stop(priv, i);
if (ret) {
- DRV_LOG(ERR, "Failed to set virtq %d base.", i);
+ DRV_LOG(ERR, "Failed to stop virtq %d.", i);
return -1;
}
rte_vhost_log_used_vring(priv->vid, i, 0,
@@ -112,6 +112,32 @@
return mlx5_devx_cmd_modify_virtq(virtq->virtq, &attr);
}
+int
+mlx5_vdpa_virtq_stop(struct mlx5_vdpa_priv *priv, int index)
+{
+ struct mlx5_devx_virtq_attr attr = {0};
+ struct mlx5_vdpa_virtq *virtq = &priv->virtqs[index];
+ int ret = mlx5_vdpa_virtq_modify(virtq, 0);
+
+ if (ret)
+ return -1;
+ if (mlx5_devx_cmd_query_virtq(virtq->virtq, &attr)) {
+ DRV_LOG(ERR, "Failed to query virtq %d.", index);
+ return -1;
+ }
+ DRV_LOG(INFO, "Query vid %d vring %d: hw_available_idx=%d, "
+ "hw_used_index=%d", priv->vid, index,
+ attr.hw_available_index, attr.hw_used_index);
+ ret = rte_vhost_set_vring_base(priv->vid, index,
+ attr.hw_available_index,
+ attr.hw_used_index);
+ if (ret) {
+ DRV_LOG(ERR, "Failed to set virtq %d base.", index);
+ return -1;
+ }
+ return 0;
+}
+
static uint64_t
mlx5_vdpa_hva_to_gpa(struct rte_vhost_memory *mem, uint64_t hva)
{