From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B61FDA0032; Wed, 14 Sep 2022 05:14:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4E88B4021D; Wed, 14 Sep 2022 05:14:59 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 9329240151 for ; Wed, 14 Sep 2022 05:14:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663125296; x=1694661296; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=xHFfbd6GbU9vDKh6TsrC1iKKpsd4et7vwUF+L9ivh68=; b=E2poUiq2mJXJTpS5akjjx4eKMYgIz/0h6fobe23Dg7LjENmS+HOztmAk VFEjNa3q5Xr9jTn+rAb8WeIMoZIDOKHLdb74oXsxKKLpv7MZCJ6Y6h8ew kIRCghMtsAS3qCQVskqfZnc31kpa1nL4fNNn+/l5Dny3CByQRbaNY+8pd BEE6MM92zPlIDeawff8Bv9s1oZsMU96SHTYgmtDrwLbSXxlvL0I7qS1Ks nGrxJxAsTC4TWh6p4IVVWQoGyLwhJlAtCS6oNhcDspxeA2UxabOrqLbDS vs7X5GfubE7oYx+0+eFZpxke5hCqJhaDUfth8MtKTDbJ8nE1+A2wN560y g==; X-IronPort-AV: E=McAfee;i="6500,9779,10469"; a="285361637" X-IronPort-AV: E=Sophos;i="5.93,313,1654585200"; d="scan'208";a="285361637" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2022 20:14:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,313,1654585200"; d="scan'208";a="945343485" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga005.fm.intel.com with ESMTP; 13 Sep 2022 20:14:54 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 13 Sep 2022 20:14:54 -0700 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 13 Sep 2022 20:14:54 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx608.amr.corp.intel.com (10.18.126.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Tue, 13 Sep 2022 20:14:54 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.102) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Tue, 13 Sep 2022 20:14:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AJC5qIEV7W9gmkXDB/w8v3LukLrI4EwxqzqVbKsGz+DOtfL+8FUmkhGwfARFitb5IcPyiNs+QpLK8otlAkdVVbIDvkq6l3dQS/G0WRA918IDj9ujZUHAkHbvIZttN2rzkM1el1HrEoAuQBQuKefdglSr0RGxTIqh46mB3bTGQffX3NZn8wHiuPJdXoy5ARnGpU7SIu8AdGpjy7B5LZFEHilPKXs2Oq0AaT8HhfCmnhnj+5XD9rwybCoMn0jXq33sh/nT7D8woGf5H8572XNt0qIlVhcE5srCF5uWwJ5wq1GwJFi7yax5urea1AvNrNWgyqGlrXf8J4HjKP/jSY6JLQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uSbjEL+lUPwW187scVAVau2vPvPphXOd8pO+2SDN9i4=; b=YTYz4Jq3Hsk9v4WOp9S3qoDFOMdWI3JNhAyRK9Qx60ZcmtDhkBqF0T+S/BY0v7XqJR8bzMAtAVyB/mXz43Dm6S8jwIafrIoQfy8DsQ2aID8QdCm7DrTUlVT6t+riJQAh0HhX3cq4zIaF1CIfSl7bV2Ahvdp7oHHfctteDpD1MBJlRAseaJoaY8XGhD4QzPlUZ332SDLyDYafq0hcW2ulsNdUcg3XoQoLE2ZbXZ/yDIS8UdwZFK+2TQBmK3nK2e06XUWdHertT7dGudwWNvH62VSgiIBY4I3N1u10SKONm150SZmk84WNrcJsFNWcovrGPzeidINkaQSqyZ1g0vp1/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SN6PR11MB3504.namprd11.prod.outlook.com (2603:10b6:805:d0::17) by PH0PR11MB4981.namprd11.prod.outlook.com (2603:10b6:510:39::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.12; Wed, 14 Sep 2022 03:14:52 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::408e:79cb:b715:b8ac]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::408e:79cb:b715:b8ac%4]) with mapi id 15.20.5612.022; Wed, 14 Sep 2022 03:14:52 +0000 From: "Xia, Chenbo" To: "Huang, Wei" , "Pei, Andy" , "dev@dpdk.org" CC: "Xu, Rosen" , "Cao, Gang" , "maxime.coquelin@redhat.com" , Huang Wei Subject: RE: [PATCH v2 6/8] vdpa/ifc: support dynamic enable/disable queue Thread-Topic: [PATCH v2 6/8] vdpa/ifc: support dynamic enable/disable queue Thread-Index: AQHYw0dbw4qU/UFbFkyG5BEmcal1vq3eNlZAgAAQfgCAAAF5cA== Date: Wed, 14 Sep 2022 03:14:52 +0000 Message-ID: References: <1661229305-240952-2-git-send-email-andy.pei@intel.com> <1662616458-164613-1-git-send-email-andy.pei@intel.com> <1662616458-164613-7-git-send-email-andy.pei@intel.com> In-Reply-To: Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SN6PR11MB3504:EE_|PH0PR11MB4981:EE_ x-ms-office365-filtering-correlation-id: 3e490538-ab62-48b5-a422-08da95ff4a3f x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: SwPbQtmewSZigqi/LAfVJBU5p7Ea78vevWVBkn+rxSjK6rd9UjE61mr1qhnM4GP/3O/Q65fZ3SUbim/d1Nf4OT9Q6s+PJamWpIzdnB6LHKZ+ar8KHIfmOcP0D+Po+J1N4Q/cefaLqyDgYDU/y0zD/W2w7AteKoqpXQUrtWtyyNZephGFvTYXiIZo7EpdvTm99XeMk6kE8NGPTH0qecYUNFDYYLnOt/+zCoIsHSGDl9nXLSKfNDnp4xgOduMuGn2ZmtN+We5kI8Ph+2MdM4YfE3wkit1fwX3aJC08BS9bzXIppgaowgTHAomXd8NmMZNislulqptgFuiYtSxvrjKJAXso3KXLBTnhPL1bNUMiPjm5oA9moKEzOPZVPfqhcoMjYIKHF9nkcJi23ciTzYT9jSQ3fAJkL7SkUSGulZIzFjucF9eKC/potZAmDK7b7fcQL8BWYz4Ow78tv762cCKVsoxqkHZXJY1kNahiTNhCchunG4DWxzFpK/TD+tFAkVdgSH7CiWXh5Rvwl3St70sMogOkhwlNCw4G/ik1QOKcg3qmXgVJ6USBcZx22bOb2rDXe6x9lzXBnw8xb+HPPl/AOOjdtkOwGL3TqBV3xfzB1+QVSzOxC0QwT3iailOL1narYeK3y+f3mM0jaOgjqJaUXhP3dQQx20CL1msYEcZ2mS01A5aPu1WlOl/F0vva6eubGDXj0pRK0KmOfyTdu5lvkLKcafbrQukoDAwVszNYCAkmGstyyW8AlTlpouaehNeyvPianRnM9mMgHcYE/tYcpMN0z9Z1wG6WtC0lSWEK5ow= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB3504.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(346002)(366004)(396003)(376002)(39860400002)(136003)(451199015)(54906003)(38100700002)(66446008)(316002)(7696005)(64756008)(8676002)(66476007)(66556008)(41300700001)(66946007)(9686003)(33656002)(2906002)(8936002)(5660300002)(83380400001)(186003)(122000001)(55016003)(86362001)(26005)(71200400001)(110136005)(4326008)(107886003)(30864003)(38070700005)(76116006)(82960400001)(52536014)(6506007)(478600001)(53546011)(309714004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?9JnnsBefGmRlfs09Uob76zFtOuZilAKzydwx8qNJXM57JCTVcykimiCcdLBh?= =?us-ascii?Q?rRJib8mCVFb7rGYnijKpRJKmlu83fZhS7DaS9MX7lNXT+qroIBq1oq9Qgzth?= =?us-ascii?Q?pArq9xt4TClSIkboka9xb2EkemvGFciKDUgF+WEVO5uwVk0Yit8Af76yBPtu?= =?us-ascii?Q?jypbgjo4dzZMff7bBa8idYhpszqY9SSl7kCB8b8HaQlBzRf7ABKexcoC6neM?= =?us-ascii?Q?J8s6fNq3+Hp/zPK6Ga9BtsXH48rHpnKvJypVZo2ZotmeYJDduCx1Ylm8S7rR?= =?us-ascii?Q?kERlpv0q7d4m6/TMUpfHRVal/LVoAYlvqO1dTIn2ujweDSKvI4rULmnbF+wk?= =?us-ascii?Q?ecyGVlU8Y1uq/UtCNr0h9vAjiKMVhXluqeAYeSVbi09x190XAYbibg4nO+1e?= =?us-ascii?Q?syBKEn00CE7tgprNUxLcdEOdVlQevIKiCQVK/xYaBlhddciEorqKcZGitjy+?= =?us-ascii?Q?x9MzzojA2yDmLlNFoRfpI4kHekshR44DB42fj2i9RRyMZ83bqCIE/bLNz08b?= =?us-ascii?Q?VKH9R+Zwm8kNoyyQU7Sd1TbBgSM26K/WjFs/lcLmGngpUEYf7bnYSU/StMpZ?= =?us-ascii?Q?9G6KCASO2O9iJyfJZ3mfAYxgkECty0LojZbZn2v71bOyNCKCzwE7N/PLgUbz?= =?us-ascii?Q?it3Pi5ap7lyQifn73WmMpCOsIWSv49cl3rlh8YWhjpziy5P4ScdAJxbcg+NC?= =?us-ascii?Q?rHz5VM9YhgbeAiEpN4WNVOdGRq9Ribd0ZVfDPShCl9lA0e9qeWUato/PQ8Q5?= =?us-ascii?Q?V14ovfHvyfCgkU9SuYT9V53MoTNRW/ttPeuv6KB4tsnNQlfWBbf9MUrCdBJ+?= =?us-ascii?Q?vgF57sen+J4kwCqsvp1WL7alzH3iTQAYXWBn7pP8rs3qkhZgrpxnZsOv/0kP?= =?us-ascii?Q?8sgnmuac52oJUYwUh6eox3OiqjYIekh2bHY7xIlwJP0hgsdcNq+GGkH9SZGp?= =?us-ascii?Q?Eav6r2eR3aTRADB+j6wZI22Ty3PUwEHNBhqDk+3Nr7BWivkAVJg9G8uvr1jL?= =?us-ascii?Q?6hzNpWjCgvvkJcQFZTNl+eQvfNMk4qKkFxKU7jfxrTjndX7O0Te8ogEd8XfJ?= =?us-ascii?Q?vIj+wetQpqNKMcvHQbLMvSEFd/7N/sS3ls1lxihTIG8rOdXan2TvS+G20O/l?= =?us-ascii?Q?Awh3BVd2hq0p9I6HZSXfix+UsbeT2COwaESknL7fuEe6WkiSd6Do8V3rln5T?= =?us-ascii?Q?IY2tIc51/BpO15WWMi3yzSlgHHY2pgTKMBlm5Dp91m0VayNSRWV9RALE/p5v?= =?us-ascii?Q?yK5+AQAfBxR870t0x0XTcDOm4YS1cEkuvqUQjX14/FKUq+ZeCmZ3+PuuaQ8r?= =?us-ascii?Q?ibLaH7DMHEuSDYi99dio9Tyyl+Hm2oymEAA8x9GEDAXc9IH61DuDu8/RLkxJ?= =?us-ascii?Q?M6dC0S+iG8ZHnOX/9XvoBIxQ14ORIPr4a51iil3p3Bb3K70MnWjwJNQn52zj?= =?us-ascii?Q?SsWTRU+0/9Afd0hurlSuYBfcIxmnwamm/sXmscB/+Q+0IGcE9GjdZxGFdFlA?= =?us-ascii?Q?c2CJYbQcnU611wuCm5n8fbk51OJ3dDF4Ix78G63XxF7ZrKOy5uBKsv2JDevl?= =?us-ascii?Q?K/hiOcvAYffAp2sTXv7yhcyWFwDnIq8bFmsOhxdD?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB3504.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e490538-ab62-48b5-a422-08da95ff4a3f X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Sep 2022 03:14:52.1074 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: w9TDECIwHGief3nXOB1vkv+wpmNhKmGgiMdhXKDj22NVHlHcTfaFWuJnmeL7C88UfvH9r6mpWyTCx/5TlDDQ4Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB4981 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > -----Original Message----- > From: Huang, Wei > Sent: Wednesday, September 14, 2022 11:04 AM > To: Xia, Chenbo ; Pei, Andy ; > dev@dpdk.org > Cc: Xu, Rosen ; Cao, Gang ; > maxime.coquelin@redhat.com; Huang Wei > Subject: RE: [PATCH v2 6/8] vdpa/ifc: support dynamic enable/disable queu= e >=20 >=20 >=20 > > -----Original Message----- > > From: Xia, Chenbo > > Sent: Wednesday, September 14, 2022 10:23 > > To: Pei, Andy ; dev@dpdk.org > > Cc: Xu, Rosen ; Huang, Wei ; > Cao, > > Gang ; maxime.coquelin@redhat.com; Huang Wei > > > > Subject: RE: [PATCH v2 6/8] vdpa/ifc: support dynamic enable/disable > queue > > > > > -----Original Message----- > > > From: Pei, Andy > > > Sent: Thursday, September 8, 2022 1:54 PM > > > To: dev@dpdk.org > > > Cc: Xia, Chenbo ; Xu, Rosen > > > ; Huang, Wei ; Cao, Gang > > > ; maxime.coquelin@redhat.com; Huang Wei > > > > > > Subject: [PATCH v2 6/8] vdpa/ifc: support dynamic enable/disable queu= e > > > > > > From: Huang Wei > > > > > > Support dynamic enable or disable queue. > > > For front end, like QEMU, user can use ethtool to configurate queue. > > > For example, "ethtool -L eth0 combined 3" to enable 3 queues pairs. > > > > > > Signed-off-by: Huang Wei > > > Signed-off-by: Andy Pei > > > --- > > > drivers/vdpa/ifc/base/ifcvf.c | 101 > > > ++++++++++++++++++++++++++++++++++++ > > > drivers/vdpa/ifc/base/ifcvf.h | 6 +++ > > > drivers/vdpa/ifc/base/ifcvf_osdep.h | 1 + > > > drivers/vdpa/ifc/ifcvf_vdpa.c | 93 > +++++++++++++++++++++++++++---- > > > -- > > > 4 files changed, 186 insertions(+), 15 deletions(-) > > > > > > diff --git a/drivers/vdpa/ifc/base/ifcvf.c > > > b/drivers/vdpa/ifc/base/ifcvf.c index 4875ea1..34f32f8 100644 > > > --- a/drivers/vdpa/ifc/base/ifcvf.c > > > +++ b/drivers/vdpa/ifc/base/ifcvf.c > > > @@ -230,6 +230,107 @@ > > > } > > > } > > > > > > +int > > > +ifcvf_enable_vring_hw(struct ifcvf_hw *hw, int i) { > > > + struct ifcvf_pci_common_cfg *cfg; > > > + u8 *lm_cfg; > > > + u16 notify_off; > > > + int msix_vector; > > > + > > > + if (!hw || (i >=3D (int)hw->nr_vring)) > > > + return -1; > > > > Seems HW will always be not NULL > As a external function, we should not assume the input argument is always > valid. It's actually internal: all logic is inside a your driver. It's not like a library API. > > > > > + > > > + cfg =3D hw->common_cfg; > > > + if (!cfg) { > > > + ERROUT("common_cfg in HW is NULL.\n"); > > > > I am thinking why you introduce this new log? Why not just use DRV_LOG > that is > > already defined? > Because below type of log macros are already defined and used in original > code, I just follow its tradition. > #define WARNINGOUT(S, args...) RTE_LOG(WARNING, PMD, S, ##args) > #define DEBUGOUT(S, args...) RTE_LOG(DEBUG, PMD, S, ##args) > #define ERROUT(S, args...) RTE_LOG(ERR, PMD, S, ##args) I think all above seems not needed. DRV_LOG could cover all. Thanks, Chenbo > > > > > + return -1; > > > + } > > > + > > > + ifcvf_enable_multiqueue(hw); > > > + > > > + IFCVF_WRITE_REG16(i, &cfg->queue_select); > > > + msix_vector =3D IFCVF_READ_REG16(&cfg->queue_msix_vector); > > > + if (msix_vector !=3D (i + 1)) { > > > + IFCVF_WRITE_REG16(i + 1, &cfg->queue_msix_vector); > > > + msix_vector =3D IFCVF_READ_REG16(&cfg->queue_msix_vector); > > > + if (msix_vector =3D=3D IFCVF_MSI_NO_VECTOR) { > > > + ERROUT("queue %u, msix vec alloc failed\n", i); > > > + return -1; > > > + } > > > + } > > > + > > > + io_write64_twopart(hw->vring[i].desc, &cfg->queue_desc_lo, > > > + &cfg->queue_desc_hi); > > > + io_write64_twopart(hw->vring[i].avail, &cfg->queue_avail_lo, > > > + &cfg->queue_avail_hi); > > > + io_write64_twopart(hw->vring[i].used, &cfg->queue_used_lo, > > > + &cfg->queue_used_hi); > > > + IFCVF_WRITE_REG16(hw->vring[i].size, &cfg->queue_size); > > > + > > > + lm_cfg =3D hw->lm_cfg; > > > + if (lm_cfg) { > > > + if (hw->device_type =3D=3D IFCVF_BLK) > > > + *(u32 *)(lm_cfg + IFCVF_LM_RING_STATE_OFFSET + > > > + i * IFCVF_LM_CFG_SIZE) =3D > > > + (u32)hw->vring[i].last_avail_idx | > > > + ((u32)hw->vring[i].last_used_idx << 16); > > > + else > > > + *(u32 *)(lm_cfg + IFCVF_LM_RING_STATE_OFFSET + > > > + (i / 2) * IFCVF_LM_CFG_SIZE + > > > + (i % 2) * 4) =3D > > > + (u32)hw->vring[i].last_avail_idx | > > > + ((u32)hw->vring[i].last_used_idx << 16); > > > + } > > > > So the register layout is different for blk and net? > That's sure. > > > > > + > > > + notify_off =3D IFCVF_READ_REG16(&cfg->queue_notify_off); > > > + hw->notify_addr[i] =3D (void *)((u8 *)hw->notify_base + > > > + notify_off * hw->notify_off_multiplier); > > > + IFCVF_WRITE_REG16(1, &cfg->queue_enable); > > > + > > > + return 0; > > > +} > > > + > > > +void > > > +ifcvf_disable_vring_hw(struct ifcvf_hw *hw, int i) { > > > + struct ifcvf_pci_common_cfg *cfg; > > > + u32 ring_state; > > > + u8 *lm_cfg; > > > + > > > + if (!hw || (i >=3D (int)hw->nr_vring)) > > > + return; > > > + > > > + cfg =3D hw->common_cfg; > > > + if (!cfg) { > > > + ERROUT("common_cfg in HW is NULL.\n"); > > > + return; > > > + } > > > + > > > + IFCVF_WRITE_REG16(i, &cfg->queue_select); > > > + IFCVF_WRITE_REG16(0, &cfg->queue_enable); > > > + > > > + lm_cfg =3D hw->lm_cfg; > > > + if (lm_cfg) { > > > + if (hw->device_type =3D=3D IFCVF_BLK) > > > + ring_state =3D *(u32 *)(lm_cfg + > > > + IFCVF_LM_RING_STATE_OFFSET + > > > + i * IFCVF_LM_CFG_SIZE); > > > + else > > > + ring_state =3D *(u32 *)(lm_cfg + > > > + IFCVF_LM_RING_STATE_OFFSET + > > > + (i / 2) * IFCVF_LM_CFG_SIZE + > > > + (i % 2) * 4); > > > + > > > + if (hw->device_type =3D=3D IFCVF_BLK) > > > + hw->vring[i].last_avail_idx =3D > > > + (u16)(ring_state & IFCVF_16_BIT_MASK); > > > + else > > > + hw->vring[i].last_avail_idx =3D (u16)(ring_state >> 16); > > > > Above two if-else should be combined. > It's a good suggestion. > > > > Thanks, > > Chenbo > > > > > + hw->vring[i].last_used_idx =3D (u16)(ring_state >> 16); > > > + } > > > +} > > > + > > > STATIC int > > > ifcvf_hw_enable(struct ifcvf_hw *hw) > > > { > > > diff --git a/drivers/vdpa/ifc/base/ifcvf.h > > > b/drivers/vdpa/ifc/base/ifcvf.h index c17bf2a..e67d4e8 100644 > > > --- a/drivers/vdpa/ifc/base/ifcvf.h > > > +++ b/drivers/vdpa/ifc/base/ifcvf.h > > > @@ -164,6 +164,12 @@ struct ifcvf_hw { ifcvf_get_features(struct > > > ifcvf_hw *hw); > > > > > > int > > > +ifcvf_enable_vring_hw(struct ifcvf_hw *hw, int i); > > > + > > > +void > > > +ifcvf_disable_vring_hw(struct ifcvf_hw *hw, int i); > > > + > > > +int > > > ifcvf_start_hw(struct ifcvf_hw *hw); > > > > > > void > > > diff --git a/drivers/vdpa/ifc/base/ifcvf_osdep.h > > > b/drivers/vdpa/ifc/base/ifcvf_osdep.h > > > index 3d56769..4a1bfec 100644 > > > --- a/drivers/vdpa/ifc/base/ifcvf_osdep.h > > > +++ b/drivers/vdpa/ifc/base/ifcvf_osdep.h > > > @@ -16,6 +16,7 @@ > > > > > > #define WARNINGOUT(S, args...) RTE_LOG(WARNING, PMD, S, ##args) > > > #define DEBUGOUT(S, args...) RTE_LOG(DEBUG, PMD, S, ##args) > > > +#define ERROUT(S, args...) RTE_LOG(ERR, PMD, S, ##args) > > > #define STATIC static > > > > > > #define msec_delay(x) rte_delay_us_sleep(1000 * (x)) > > > diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c > > > b/drivers/vdpa/ifc/ifcvf_vdpa.c index 48f1a89..16fd0fd 100644 > > > --- a/drivers/vdpa/ifc/ifcvf_vdpa.c > > > +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c > > > @@ -1288,13 +1288,59 @@ struct rte_vdpa_dev_info { } > > > > > > static int > > > +ifcvf_config_vring(struct ifcvf_internal *internal, int vring) { > > > + struct ifcvf_hw *hw =3D &internal->hw; > > > + int vid =3D internal->vid; > > > + struct rte_vhost_vring vq; > > > + uint64_t gpa; > > > + > > > + if (hw->vring[vring].enable) { > > > + rte_vhost_get_vhost_vring(vid, vring, &vq); > > > + gpa =3D hva_to_gpa(vid, (uint64_t)(uintptr_t)vq.desc); > > > + if (gpa =3D=3D 0) { > > > + DRV_LOG(ERR, "Fail to get GPA for descriptor ring."); > > > + return -1; > > > + } > > > + hw->vring[vring].desc =3D gpa; > > > + > > > + gpa =3D hva_to_gpa(vid, (uint64_t)(uintptr_t)vq.avail); > > > + if (gpa =3D=3D 0) { > > > + DRV_LOG(ERR, "Fail to get GPA for available ring."); > > > + return -1; > > > + } > > > + hw->vring[vring].avail =3D gpa; > > > + > > > + gpa =3D hva_to_gpa(vid, (uint64_t)(uintptr_t)vq.used); > > > + if (gpa =3D=3D 0) { > > > + DRV_LOG(ERR, "Fail to get GPA for used ring."); > > > + return -1; > > > + } > > > + hw->vring[vring].used =3D gpa; > > > + > > > + hw->vring[vring].size =3D vq.size; > > > + rte_vhost_get_vring_base(vid, vring, > > > + &hw->vring[vring].last_avail_idx, > > > + &hw->vring[vring].last_used_idx); > > > + ifcvf_enable_vring_hw(&internal->hw, vring); > > > + } else { > > > + ifcvf_disable_vring_hw(&internal->hw, vring); > > > + rte_vhost_set_vring_base(vid, vring, > > > + hw->vring[vring].last_avail_idx, > > > + hw->vring[vring].last_used_idx); > > > + } > > > + > > > + return 0; > > > +} > > > + > > > +static int > > > ifcvf_set_vring_state(int vid, int vring, int state) { > > > struct rte_vdpa_device *vdev; > > > struct internal_list *list; > > > struct ifcvf_internal *internal; > > > struct ifcvf_hw *hw; > > > - struct ifcvf_pci_common_cfg *cfg; > > > + bool enable =3D !!state; > > > int ret =3D 0; > > > > > > vdev =3D rte_vhost_get_vdpa_device(vid); @@ -1304,6 +1350,9 @@ > > struct > > > rte_vdpa_dev_info { > > > return -1; > > > } > > > > > > + DRV_LOG(INFO, "%s queue %d of vDPA device %s", > > > + enable ? "enable" : "disable", vring, vdev->device->name); > > > + > > > internal =3D list->internal; > > > if (vring < 0 || vring >=3D internal->max_queues * 2) { > > > DRV_LOG(ERR, "Vring index %d not correct", vring); @@ - > > 1311,27 > > > +1360,41 @@ struct rte_vdpa_dev_info { > > > } > > > > > > hw =3D &internal->hw; > > > + hw->vring[vring].enable =3D enable; > > > + > > > if (!internal->configured) > > > - goto exit; > > > + return 0; > > > > > > - cfg =3D hw->common_cfg; > > > - IFCVF_WRITE_REG16(vring, &cfg->queue_select); > > > - IFCVF_WRITE_REG16(!!state, &cfg->queue_enable); > > > + unset_notify_relay(internal); > > > > > > - if (!state && hw->vring[vring].enable) { > > > - ret =3D vdpa_disable_vfio_intr(internal); > > > - if (ret) > > > - return ret; > > > + ret =3D vdpa_enable_vfio_intr(internal, false); > > > + if (ret) { > > > + DRV_LOG(ERR, "failed to set vfio interrupt of vDPA device %s", > > > + vdev->device->name); > > > + return ret; > > > } > > > > > > - if (state && !hw->vring[vring].enable) { > > > - ret =3D vdpa_enable_vfio_intr(internal, false); > > > - if (ret) > > > - return ret; > > > + ret =3D ifcvf_config_vring(internal, vring); > > > + if (ret) { > > > + DRV_LOG(ERR, "failed to configure queue %d of vDPA > > device %s", > > > + vring, vdev->device->name); > > > + return ret; > > > + } > > > + > > > + ret =3D setup_notify_relay(internal); > > > + if (ret) { > > > + DRV_LOG(ERR, "failed to setup notify relay of vDPA device %s", > > > + vdev->device->name); > > > + return ret; > > > + } > > > + > > > + ret =3D rte_vhost_host_notifier_ctrl(vid, vring, enable); > > > + if (ret) { > > > + DRV_LOG(ERR, "vDPA device %s queue %d host notifier ctrl fail", > > > + vdev->device->name, vring); > > > + return ret; > > > } > > > > > > -exit: > > > - hw->vring[vring].enable =3D !!state; > > > return 0; > > > } > > > > > > -- > > > 1.8.3.1