common/cnxk: support bandwidth profile configure
[dpdk.git] / drivers / vdpa / mlx5 / mlx5_vdpa_virtq.c
index d5ac040..f530646 100644 (file)
@@ -103,17 +103,14 @@ mlx5_vdpa_virtqs_release(struct mlx5_vdpa_priv *priv)
        for (i = 0; i < priv->nr_virtqs; i++) {
                virtq = &priv->virtqs[i];
                mlx5_vdpa_virtq_unset(virtq);
-               if (virtq->counters) {
+               if (virtq->counters)
                        claim_zero(mlx5_devx_cmd_destroy(virtq->counters));
-                       virtq->counters = NULL;
-                       memset(&virtq->reset, 0, sizeof(virtq->reset));
-               }
-               memset(virtq->err_time, 0, sizeof(virtq->err_time));
-               virtq->n_retry = 0;
        }
-       if (priv->tis) {
-               claim_zero(mlx5_devx_cmd_destroy(priv->tis));
-               priv->tis = NULL;
+       for (i = 0; i < priv->num_lag_ports; i++) {
+               if (priv->tiss[i]) {
+                       claim_zero(mlx5_devx_cmd_destroy(priv->tiss[i]));
+                       priv->tiss[i] = NULL;
+               }
        }
        if (priv->td) {
                claim_zero(mlx5_devx_cmd_destroy(priv->td));
@@ -124,6 +121,7 @@ mlx5_vdpa_virtqs_release(struct mlx5_vdpa_priv *priv)
                priv->virtq_db_addr = NULL;
        }
        priv->features = 0;
+       memset(priv->virtqs, 0, sizeof(*virtq) * priv->nr_virtqs);
        priv->nr_virtqs = 0;
 }
 
@@ -322,9 +320,12 @@ mlx5_vdpa_virtq_setup(struct mlx5_vdpa_priv *priv, int index)
        attr.hw_used_index = last_used_idx;
        attr.q_size = vq.size;
        attr.mkey = priv->gpa_mkey_index;
-       attr.tis_id = priv->tis->id;
+       attr.tis_id = priv->tiss[(index / 2) % priv->num_lag_ports]->id;
        attr.queue_index = index;
        attr.pd = priv->pdn;
+       attr.hw_latency_mode = priv->hw_latency_mode;
+       attr.hw_max_latency_us = priv->hw_max_latency_us;
+       attr.hw_max_pending_comp = priv->hw_max_pending_comp;
        virtq->virtq = mlx5_devx_cmd_create_virtq(priv->ctx, &attr);
        virtq->priv = priv;
        if (!virtq->virtq)
@@ -441,6 +442,13 @@ mlx5_vdpa_virtqs_prepare(struct mlx5_vdpa_priv *priv)
                DRV_LOG(ERR, "Failed to configure negotiated features.");
                return -1;
        }
+       if ((priv->features & (1ULL << VIRTIO_NET_F_CSUM)) == 0 &&
+           ((priv->features & (1ULL << VIRTIO_NET_F_HOST_TSO4)) > 0 ||
+            (priv->features & (1ULL << VIRTIO_NET_F_HOST_TSO6)) > 0)) {
+               /* Packet may be corrupted if TSO is enabled without CSUM. */
+               DRV_LOG(INFO, "TSO is enabled without CSUM, force CSUM.");
+               priv->features |= (1ULL << VIRTIO_NET_F_CSUM);
+       }
        if (nr_vring > priv->caps.max_num_virtio_queues * 2) {
                DRV_LOG(ERR, "Do not support more than %d virtqs(%d).",
                        (int)priv->caps.max_num_virtio_queues * 2,
@@ -465,10 +473,14 @@ mlx5_vdpa_virtqs_prepare(struct mlx5_vdpa_priv *priv)
                return -rte_errno;
        }
        tis_attr.transport_domain = priv->td->id;
-       priv->tis = mlx5_devx_cmd_create_tis(priv->ctx, &tis_attr);
-       if (!priv->tis) {
-               DRV_LOG(ERR, "Failed to create TIS.");
-               goto error;
+       for (i = 0; i < priv->num_lag_ports; i++) {
+               /* 0 is auto affinity, non-zero value to propose port. */
+               tis_attr.lag_tx_port_affinity = i + 1;
+               priv->tiss[i] = mlx5_devx_cmd_create_tis(priv->ctx, &tis_attr);
+               if (!priv->tiss[i]) {
+                       DRV_LOG(ERR, "Failed to create TIS %u.", i);
+                       goto error;
+               }
        }
        priv->nr_virtqs = nr_vring;
        for (i = 0; i < nr_vring; i++)
@@ -491,7 +503,7 @@ mlx5_vdpa_virtq_is_modified(struct mlx5_vdpa_priv *priv,
                return -1;
        if (vq.size != virtq->vq_size || vq.kickfd != virtq->intr_handle.fd)
                return 1;
-       if (virtq->eqp.cq.cq) {
+       if (virtq->eqp.cq.cq_obj.cq) {
                if (vq.callfd != virtq->eqp.cq.callfd)
                        return 1;
        } else if (vq.callfd != -1) {