From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 86A03A059F; Fri, 10 Apr 2020 15:58:07 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0110C1D164; Fri, 10 Apr 2020 15:58:07 +0200 (CEST) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150070.outbound.protection.outlook.com [40.107.15.70]) by dpdk.org (Postfix) with ESMTP id 987A51D158 for ; Fri, 10 Apr 2020 15:58:05 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IeTp40ijiKAOVIgCWUivqae7HY/ivVkx8pm9ATjyOtM/QfZlw4R0GwlNaX3jvJMEgnC1WbJe7Xge95yBB7wLdYNmv4tdJ4AuJxulhzjoK1C7YfFk7D5VNc6ToTpGAApheroluX2BbsWN3FBKReWxXnfYQYGShNFi/e0v4ELPIBwOMUsfHw3Kg5dizk2jYtOgXhT2e+HwAA6fBoQUvBRFqbTnS/PPIeTt7NmcgX4eg1RxxTK7K7S8gpLwa3LJ3PZIF+oQRjQiHfULmR4RtrLGoJuE86sjtJzWwdoNzdfar3cNLZthbcym63OW8uHOzqA8iXWsxvHiFV4eeW829r2wGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hJs0Oujjzq9J1g/Gym2DcFZ/KryV1HJVUZ2GmH8S2Ms=; b=HECXqZbwfAXMu0KTytc61x69TssaLnfW8YFmdjFlpuRopMLUI53d19qJAsN7ryqtvkf5ahNEHfhwu+MD4sSo+rNAY9L0fu09VduEFfzPox0g8AoiPAxgsiyPuzOWWWYlJG8Ggu8l/LoxWvnUCVr126NkNFb9v/10geV3/rLBiHQbZEnKfVbp7rQOfU0/wp/NXw8I3oco93X4jcLnTQxgWiy1yuJHq7nUI6xLMfFvI1XEzfWXLnk+kP6LvWiSg3CItKW6UTunkKwhfogwiHtKaW2zyFAyVEqobXLON2XOfKYMxw+Hk+cNC9nQ6nJWoPJVnxT8BNhy8XxBR+OOqwYbIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hJs0Oujjzq9J1g/Gym2DcFZ/KryV1HJVUZ2GmH8S2Ms=; b=hWqtvq4eL9E+rdxoM7eznx6hwyTdLjz/BuWZuVDbYw4Ja5ncKynIatKSpRtyzYgosWJDgk5F0ylQ2RpOtfmMwlfAti0ciU+6wg/JRp9yeKx1QqXb+p46XSErRvtK1+G+IxL37CWOcLbbRk42+zwtwTpNJe1GRDYZ10JIQeBTXjg= Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com (2603:10a6:208:f::11) by AM0PR0502MB3698.eurprd05.prod.outlook.com (2603:10a6:208:1d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.15; Fri, 10 Apr 2020 13:58:04 +0000 Received: from AM0PR0502MB4019.eurprd05.prod.outlook.com ([fe80::a564:a117:9022:1fee]) by AM0PR0502MB4019.eurprd05.prod.outlook.com ([fe80::a564:a117:9022:1fee%7]) with mapi id 15.20.2878.022; Fri, 10 Apr 2020 13:58:04 +0000 From: Matan Azrad To: Maxime Coquelin , "dev@dpdk.org" CC: Slava Ovsiienko , Shahaf Shuler Thread-Topic: [PATCH 1/3] vdpa/mlx5: manage virtqs by array Thread-Index: AQHWDoIaS7QI7C7lFUeUztktZYul66hyYjlg Date: Fri, 10 Apr 2020 13:58:04 +0000 Message-ID: References: <1585653143-21987-1-git-send-email-matan@mellanox.com> <1585653143-21987-2-git-send-email-matan@mellanox.com> <87dd22ef-1de3-6da3-c16d-906ba17e640a@redhat.com> In-Reply-To: <87dd22ef-1de3-6da3-c16d-906ba17e640a@redhat.com> Accept-Language: en-US, he-IL Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; x-originating-ip: [77.126.88.104] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 25f3fa33-6a1c-40dc-900a-08d7dd5730d8 x-ms-traffictypediagnostic: AM0PR0502MB3698:|AM0PR0502MB3698: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3513; x-forefront-prvs: 0369E8196C x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR0502MB4019.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(136003)(376002)(39860400002)(346002)(366004)(396003)(66476007)(66556008)(64756008)(66446008)(7696005)(110136005)(76116006)(66946007)(2906002)(81156014)(53546011)(5660300002)(316002)(8936002)(6506007)(86362001)(54906003)(52536014)(8676002)(71200400001)(478600001)(55016002)(30864003)(33656002)(4326008)(186003)(9686003)(107886003)(26005); DIR:OUT; SFP:1101; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: aqD1wpEOrBDD5CXukCdKgfZltSW4Mfnsq7V53TjA+jE/XNuwFj/ZTVSzFnj8swkhINuf/36wC3sl2MYJCZTGHjnl7SfqhGasrA4RcYakuaf1tSB6U8bwuequclWNzOGKIv4waVojXcVcADVIaUvOttN9JcpfiGrPeTWbm55g+vw/dDeQ9pxAuT2FfS3fYe1vLg/WFI5ZGpi1+Si5wZQ7v5LKmpYCcS1mD1/VbvQi/HLAJnFBWkwvtVxb/r/lywoh/xQTJnxmSJofmpRWCOv6slr2MsdrH3tv79YVvXJ/UJvCvXIjdKPpGIjmrwYpqLKRGTCsi8MMPiFPK68txsidLGryThwriHHjZPZNuq6HMrBpEY6jHrSLUg6H87kykvuleGFT9zyrWQLv/vRHeu3WStTe1tnQbdhcZDoZ05hYlYcARE/F3iq49hQk1qqvtMcE x-ms-exchange-antispam-messagedata: 2DgNwVA1PWHY4ZfvufbvRZgHjlpm7M2gUbjFSHQhApBoAU7Rb52CirdOJJKeqQrmSFRhaapwqm0RhDPk3FVHWzuH41r6/smmiRo9j46Q2sPa+Mstlz4Xt4LfDpvjf8hVPJN0PmVatF6epqiKPypkSg== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 25f3fa33-6a1c-40dc-900a-08d7dd5730d8 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Apr 2020 13:58:04.6027 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: BZLk6r9fAXIxXaK/2ghjL22s3q7EDULa2klAbb/u0+65yj8pyb3g4wjuEez+rBHCXR5WRV7TTO5j5UB/T5141A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB3698 Subject: Re: [dpdk-dev] [PATCH 1/3] vdpa/mlx5: manage virtqs by array X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Maxime From: Maxime Coquelin > On 3/31/20 1:12 PM, Matan Azrad wrote: > > As a preparation to listen the virtqs status before the device is > > configured, manage the virtqs structures in array instead of list. > > > > Signed-off-by: Matan Azrad > > Acked-by: Viacheslav Ovsiienko > > --- > > drivers/vdpa/mlx5/mlx5_vdpa.c | 43 ++++++++++++++++-------------= --- > -- > > drivers/vdpa/mlx5/mlx5_vdpa.h | 2 +- > > drivers/vdpa/mlx5/mlx5_vdpa_lm.c | 43 ++++++++++++++++-------------= - > ---- > > drivers/vdpa/mlx5/mlx5_vdpa_steer.c | 18 +++++++-------- > > drivers/vdpa/mlx5/mlx5_vdpa_virtq.c | 46 > > +++++++++++++++---------------------- > > 5 files changed, 68 insertions(+), 84 deletions(-) > > > > diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.c > > b/drivers/vdpa/mlx5/mlx5_vdpa.c index f10647b..b22f074 100644 > > --- a/drivers/vdpa/mlx5/mlx5_vdpa.c > > +++ b/drivers/vdpa/mlx5/mlx5_vdpa.c > > @@ -116,20 +116,18 @@ > > { > > int did =3D rte_vhost_get_vdpa_device_id(vid); > > struct mlx5_vdpa_priv *priv =3D > mlx5_vdpa_find_priv_resource_by_did(did); > > - struct mlx5_vdpa_virtq *virtq =3D NULL; > > > > if (priv =3D=3D NULL) { > > DRV_LOG(ERR, "Invalid device id: %d.", did); > > return -EINVAL; > > } > > - SLIST_FOREACH(virtq, &priv->virtq_list, next) > > - if (virtq->index =3D=3D vring) > > - break; > > - if (!virtq) { > > + if (!priv->configured || vring >=3D RTE_MIN((int)priv->nr_virtqs, > > + (int)priv->caps.max_num_virtio_queues * 2) || > > + !priv->virtqs[vring].virtq) { > > DRV_LOG(ERR, "Invalid or unconfigured vring id: %d.", vring); > > return -EINVAL; > > } > > - return mlx5_vdpa_virtq_enable(virtq, state); > > + return mlx5_vdpa_virtq_enable(&priv->virtqs[vring], state); > > } > > > > static int > > @@ -482,28 +480,28 @@ > > rte_errno =3D ENODEV; > > return -rte_errno; > > } > > - priv =3D rte_zmalloc("mlx5 vDPA device private", sizeof(*priv), > > - RTE_CACHE_LINE_SIZE); > > - if (!priv) { > > - DRV_LOG(ERR, "Failed to allocate private memory."); > > - rte_errno =3D ENOMEM; > > - goto error; > > - } > > ret =3D mlx5_devx_cmd_query_hca_attr(ctx, &attr); > > if (ret) { > > DRV_LOG(ERR, "Unable to read HCA capabilities."); > > rte_errno =3D ENOTSUP; > > goto error; > > - } else { > > - if (!attr.vdpa.valid || !attr.vdpa.max_num_virtio_queues) { > > - DRV_LOG(ERR, "Not enough capabilities to support > vdpa," > > - " maybe old FW/OFED version?"); > > - rte_errno =3D ENOTSUP; > > - goto error; > > - } > > - priv->caps =3D attr.vdpa; > > - priv->log_max_rqt_size =3D attr.log_max_rqt_size; > > + } else if (!attr.vdpa.valid || !attr.vdpa.max_num_virtio_queues) { > > + DRV_LOG(ERR, "Not enough capabilities to support vdpa, > maybe " > > + "old FW/OFED version?"); > > + rte_errno =3D ENOTSUP; > > + goto error; > > + } > > + priv =3D rte_zmalloc("mlx5 vDPA device private", sizeof(*priv) + > > + sizeof(struct mlx5_vdpa_virtq) * > > + attr.vdpa.max_num_virtio_queues * 2, > > + RTE_CACHE_LINE_SIZE); > > + if (!priv) { > > + DRV_LOG(ERR, "Failed to allocate private memory."); > > + rte_errno =3D ENOMEM; > > + goto error; > > } > > + priv->caps =3D attr.vdpa; > > + priv->log_max_rqt_size =3D attr.log_max_rqt_size; > > priv->ctx =3D ctx; > > priv->dev_addr.pci_addr =3D pci_dev->addr; > > priv->dev_addr.type =3D PCI_ADDR; > > @@ -519,7 +517,6 @@ > > goto error; > > } > > SLIST_INIT(&priv->mr_list); > > - SLIST_INIT(&priv->virtq_list); > > pthread_mutex_lock(&priv_list_lock); > > TAILQ_INSERT_TAIL(&priv_list, priv, next); > > pthread_mutex_unlock(&priv_list_lock); > > diff --git a/drivers/vdpa/mlx5/mlx5_vdpa.h > > b/drivers/vdpa/mlx5/mlx5_vdpa.h index 75af410..baec106 100644 > > --- a/drivers/vdpa/mlx5/mlx5_vdpa.h > > +++ b/drivers/vdpa/mlx5/mlx5_vdpa.h > > @@ -120,11 +120,11 @@ struct mlx5_vdpa_priv { > > uint16_t nr_virtqs; > > uint64_t features; /* Negotiated features. */ > > uint16_t log_max_rqt_size; > > - SLIST_HEAD(virtq_list, mlx5_vdpa_virtq) virtq_list; > > struct mlx5_vdpa_steer steer; > > struct mlx5dv_var *var; > > void *virtq_db_addr; > > SLIST_HEAD(mr_list, mlx5_vdpa_query_mr) mr_list; > > + struct mlx5_vdpa_virtq virtqs[]; > > }; > > > > /** > > diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_lm.c > > b/drivers/vdpa/mlx5/mlx5_vdpa_lm.c > > index 4457760..77f2eda 100644 > > --- a/drivers/vdpa/mlx5/mlx5_vdpa_lm.c > > +++ b/drivers/vdpa/mlx5/mlx5_vdpa_lm.c > > @@ -15,13 +15,12 @@ > > .type =3D > MLX5_VIRTQ_MODIFY_TYPE_DIRTY_BITMAP_DUMP_ENABLE, > > .dirty_bitmap_dump_enable =3D enable, > > }; > > - struct mlx5_vdpa_virtq *virtq; > > + int i; > > > > - SLIST_FOREACH(virtq, &priv->virtq_list, next) { > > - attr.queue_index =3D virtq->index; > > - if (mlx5_devx_cmd_modify_virtq(virtq->virtq, &attr)) { > > - DRV_LOG(ERR, "Failed to modify virtq %d logging.", > > - virtq->index); > > + for (i =3D 0; i < priv->nr_virtqs; ++i) { > > + attr.queue_index =3D i; > > + if (mlx5_devx_cmd_modify_virtq(priv->virtqs[i].virtq, &attr)) > { > > + DRV_LOG(ERR, "Failed to modify virtq %d logging.", > i); > > return -1; > > } > > } > > @@ -47,7 +46,7 @@ > > .dirty_bitmap_size =3D log_size, > > }; > > struct mlx5_vdpa_query_mr *mr =3D rte_malloc(__func__, > sizeof(*mr), 0); > > - struct mlx5_vdpa_virtq *virtq; > > + int i; > > > > if (!mr) { > > DRV_LOG(ERR, "Failed to allocate mem for lm mr."); @@ - > 67,11 +66,10 > > @@ > > goto err; > > } > > attr.dirty_bitmap_mkey =3D mr->mkey->id; > > - SLIST_FOREACH(virtq, &priv->virtq_list, next) { > > - attr.queue_index =3D virtq->index; > > - if (mlx5_devx_cmd_modify_virtq(virtq->virtq, &attr)) { > > - DRV_LOG(ERR, "Failed to modify virtq %d for lm.", > > - virtq->index); > > + for (i =3D 0; i < priv->nr_virtqs; ++i) { > > + attr.queue_index =3D i; > > + if (mlx5_devx_cmd_modify_virtq(priv->virtqs[i].virtq, &attr)) > { > > + DRV_LOG(ERR, "Failed to modify virtq %d for lm.", i); > > goto err; > > } > > } > > @@ -94,9 +92,9 @@ > > mlx5_vdpa_lm_log(struct mlx5_vdpa_priv *priv) { > > struct mlx5_devx_virtq_attr attr =3D {0}; > > - struct mlx5_vdpa_virtq *virtq; > > uint64_t features; > > int ret =3D rte_vhost_get_negotiated_features(priv->vid, &features); > > + int i; > > > > if (ret) { > > DRV_LOG(ERR, "Failed to get negotiated features."); @@ - > 104,27 > > +102,26 @@ > > } > > if (!RTE_VHOST_NEED_LOG(features)) > > return 0; > > - SLIST_FOREACH(virtq, &priv->virtq_list, next) { > > - ret =3D mlx5_vdpa_virtq_modify(virtq, 0); > > + for (i =3D 0; i < priv->nr_virtqs; ++i) { > > + ret =3D mlx5_vdpa_virtq_modify(&priv->virtqs[i], 0); > > if (ret) > > return -1; > > - if (mlx5_devx_cmd_query_virtq(virtq->virtq, &attr)) { > > - DRV_LOG(ERR, "Failed to query virtq %d.", virtq- > >index); > > + 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=3D%d, " > > - "hw_used_index=3D%d", priv->vid, virtq->index, > > + "hw_used_index=3D%d", priv->vid, i, > > attr.hw_available_index, attr.hw_used_index); > > - ret =3D rte_vhost_set_vring_base(priv->vid, virtq->index, > > + ret =3D 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.", > > - virtq->index); > > + DRV_LOG(ERR, "Failed to set virtq %d base.", i); > > return -1; > > } > > - rte_vhost_log_used_vring(priv->vid, virtq->index, 0, > > - MLX5_VDPA_USED_RING_LEN(virtq- > >vq_size)); > > + rte_vhost_log_used_vring(priv->vid, i, 0, > > + MLX5_VDPA_USED_RING_LEN(priv- > >virtqs[i].vq_size)); > > } > > return 0; > > } > > diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_steer.c > > b/drivers/vdpa/mlx5/mlx5_vdpa_steer.c > > index 9c11452..96ffc21 100644 > > --- a/drivers/vdpa/mlx5/mlx5_vdpa_steer.c > > +++ b/drivers/vdpa/mlx5/mlx5_vdpa_steer.c > > @@ -76,13 +76,13 @@ > > static int > > mlx5_vdpa_rqt_prepare(struct mlx5_vdpa_priv *priv) { > > - struct mlx5_vdpa_virtq *virtq; > > + int i; > > uint32_t rqt_n =3D RTE_MIN(MLX5_VDPA_DEFAULT_RQT_SIZE, > > 1 << priv->log_max_rqt_size); > > struct mlx5_devx_rqt_attr *attr =3D rte_zmalloc(__func__, > sizeof(*attr) > > + rqt_n * > > sizeof(uint32_t), 0); > > - uint32_t i =3D 0, j; > > + uint32_t k =3D 0, j; > > int ret =3D 0; > > > > if (!attr) { > > @@ -90,15 +90,15 @@ > > rte_errno =3D ENOMEM; > > return -ENOMEM; > > } > > - SLIST_FOREACH(virtq, &priv->virtq_list, next) { > > - if (is_virtq_recvq(virtq->index, priv->nr_virtqs) && > > - virtq->enable) { > > - attr->rq_list[i] =3D virtq->virtq->id; > > - i++; > > + for (i =3D 0; i < priv->nr_virtqs; i++) { > > + if (is_virtq_recvq(i, priv->nr_virtqs) && > > + priv->virtqs[i].enable) { > > + attr->rq_list[k] =3D priv->virtqs[i].virtq->id; > > + k++; > > } > > } > > - for (j =3D 0; i !=3D rqt_n; ++i, ++j) > > - attr->rq_list[i] =3D attr->rq_list[j]; > > + for (j =3D 0; k !=3D rqt_n; ++k, ++j) > > + attr->rq_list[k] =3D attr->rq_list[j]; > > attr->rq_type =3D MLX5_INLINE_Q_TYPE_VIRTQ; > > attr->rqt_max_size =3D rqt_n; > > attr->rqt_actual_size =3D rqt_n; > > diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c > > b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c > > index 8bebb92..3575272 100644 > > --- a/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c > > +++ b/drivers/vdpa/mlx5/mlx5_vdpa_virtq.c > > @@ -59,12 +59,9 @@ > > usleep(MLX5_VDPA_INTR_RETRIES_USEC); > > } > > } > > - virtq->intr_handle.fd =3D -1; > > } > > - if (virtq->virtq) { > > + if (virtq->virtq) > > claim_zero(mlx5_devx_cmd_destroy(virtq->virtq)); > > - virtq->virtq =3D NULL; > > - } > > for (i =3D 0; i < RTE_DIM(virtq->umems); ++i) { > > if (virtq->umems[i].obj) > > claim_zero(mlx5_glue->devx_umem_dereg > > @@ -72,27 +69,20 @@ > > if (virtq->umems[i].buf) > > rte_free(virtq->umems[i].buf); > > } > > - memset(&virtq->umems, 0, sizeof(virtq->umems)); > > if (virtq->eqp.fw_qp) > > mlx5_vdpa_event_qp_destroy(&virtq->eqp); > > + memset(virtq, 0, sizeof(*virtq)); > > + virtq->intr_handle.fd =3D -1; > > return 0; > > } > > > > void > > mlx5_vdpa_virtqs_release(struct mlx5_vdpa_priv *priv) { > > - struct mlx5_vdpa_virtq *entry; > > - struct mlx5_vdpa_virtq *next; > > + int i; > > > > - entry =3D SLIST_FIRST(&priv->virtq_list); > > - while (entry) { > > - next =3D SLIST_NEXT(entry, next); > > - mlx5_vdpa_virtq_unset(entry); > > - SLIST_REMOVE(&priv->virtq_list, entry, mlx5_vdpa_virtq, > next); > > - rte_free(entry); > > - entry =3D next; > > - } > > - SLIST_INIT(&priv->virtq_list); > > + for (i =3D 0; i < priv->nr_virtqs; i++) > > + mlx5_vdpa_virtq_unset(&priv->virtqs[i]); > > if (priv->tis) { > > claim_zero(mlx5_devx_cmd_destroy(priv->tis)); > > priv->tis =3D NULL; > > @@ -106,6 +96,7 @@ > > priv->virtq_db_addr =3D NULL; > > } > > priv->features =3D 0; > > + priv->nr_virtqs =3D 0; > > } > > > > int > > @@ -140,9 +131,9 @@ > > } > > > > static int > > -mlx5_vdpa_virtq_setup(struct mlx5_vdpa_priv *priv, > > - struct mlx5_vdpa_virtq *virtq, int index) > > +mlx5_vdpa_virtq_setup(struct mlx5_vdpa_priv *priv, int index) > > { > > + struct mlx5_vdpa_virtq *virtq =3D &priv->virtqs[index]; > > struct rte_vhost_vring vq; > > struct mlx5_devx_virtq_attr attr =3D {0}; > > uint64_t gpa; > > @@ -340,7 +331,6 @@ > > mlx5_vdpa_virtqs_prepare(struct mlx5_vdpa_priv *priv) { > > struct mlx5_devx_tis_attr tis_attr =3D {0}; > > - struct mlx5_vdpa_virtq *virtq; > > uint32_t i; > > uint16_t nr_vring =3D rte_vhost_get_vring_num(priv->vid); > > int ret =3D rte_vhost_get_negotiated_features(priv->vid, > > &priv->features); @@ -349,6 +339,12 @@ > > DRV_LOG(ERR, "Failed to configure negotiated features."); > > return -1; > > } > > + 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, > > + (int)nr_vring); > > + return -E2BIG; >=20 > All returns in thid function are either -1 or 0 except this one, so it lo= oks > inconsistent. You can find the consistent in negative values for error. If you insist and this is your only concern here, I agree to change to -1. Can it be done in integration?=20 >=20 > > + } > > /* Always map the entire page. */ > > priv->virtq_db_addr =3D mmap(NULL, priv->var->length, PROT_READ | > > PROT_WRITE, MAP_SHARED, priv->ctx- > >cmd_fd, @@ -372,16 +368,10 > > @@ > > DRV_LOG(ERR, "Failed to create TIS."); > > goto error; > > } > > - for (i =3D 0; i < nr_vring; i++) { > > - virtq =3D rte_zmalloc(__func__, sizeof(*virtq), 0); > > - if (!virtq || mlx5_vdpa_virtq_setup(priv, virtq, i)) { > > - if (virtq) > > - rte_free(virtq); > > - goto error; > > - } > > - SLIST_INSERT_HEAD(&priv->virtq_list, virtq, next); > > - } > > priv->nr_virtqs =3D nr_vring; > > + for (i =3D 0; i < nr_vring; i++) > > + if (mlx5_vdpa_virtq_setup(priv, i)) > > + goto error; > > return 0; > > error: > > mlx5_vdpa_virtqs_release(priv); > >