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 C4AF1A052B; Tue, 28 Jul 2020 04:35:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1B5001BE8A; Tue, 28 Jul 2020 04:35:42 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id AEDAA2B8D for ; Tue, 28 Jul 2020 04:35:40 +0200 (CEST) IronPort-SDR: B4TOn/g8mThvjCscPEoGrHCfQJMIUde4EdgJaOgQfuGQd0PotuhIpNHUGZKbOa/D+ZBtvYwcv4 dlMTYL01gQIw== X-IronPort-AV: E=McAfee;i="6000,8403,9695"; a="212665152" X-IronPort-AV: E=Sophos;i="5.75,404,1589266800"; d="scan'208";a="212665152" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2020 19:35:38 -0700 IronPort-SDR: l+pG2UvxLxhXFXrEXZoQLUHIt8NWmYq514+EL6GJN+cqBAB+gvDFalF9YYHJQsU0KRFUOa5Oe3 lW8ng8oxphrg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,404,1589266800"; d="scan'208";a="364336270" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga001.jf.intel.com with ESMTP; 27 Jul 2020 19:35:38 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 27 Jul 2020 19:35:37 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 27 Jul 2020 19:35:35 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Mon, 27 Jul 2020 19:35:35 -0700 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (104.47.37.54) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 27 Jul 2020 19:35:34 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UrXr/7XO7nMGji2jUlr06T/MU5/7bInJcFIZdApvQQQX8gTwgLHGFa233RJ9nB8CI9S7FdVFkhTwUvK4+VB7mwyhEzpE/kLXAJMtdMokxxh1YFBXi4vnIPOykrYIKYZKqCsrXu06vIJ43QBuuqu2QfyovqSR8rIW4m5RuL88Q9RHYrdp8ZPzYYvPSuA+gIEKwbTblvXc4eK2bWMnnllwkvYHrZrruRMMMr8gBErZBRc4zfn1VnGPlyJ/3MW3WAnmJgzVWHme8Y3fU2mrAHcVDhYNUwVe5fTGeo1qQDJAR7PpMajKldgyc8pXUYsfHPOTKG1W7W9F3ZnlaSdJFN6pIQ== 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=cnsZB9Xfmzd1E/fef7mOvT5vfBaC4r1bEX+aTDylXjM=; b=gG9/VycIPnxI+Yfy9iUnXj7zhh2JcZX42OpFgKKXrhh8fICskfJtVV5Uhwp+xzwzU/j5dY+jJnKB5JJGytzSZscT8/N/xjcGcaVZ4bxcT9J4/6Le6sMQ8zn02WtfGAQWIQj/Ey7UFA5pNR7+LRMnqHFyj6W9yzkfd5D4jBGQczN3tsg8YlaQWTBaFziqr8310ZRtLD43bWQj8M9/PYvwteSHpVEHGrRWARkKHoi9jXTUqFWK940wFtpx88FvzbDvMikxs1vLn79ZMZSuI1eZaUP9JVIkExyH/HPJtxU8DuFzvTXpOYhAkPIrTxMQwkucYUi/Aj/p1IbrRDU4yr5hbg== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cnsZB9Xfmzd1E/fef7mOvT5vfBaC4r1bEX+aTDylXjM=; b=PN/sZHhiQv1PB61GMGkQiJEvFunOEgZhHs2znTdi1W18H3XWjEnXhcFcJtfDtbxxPYde3TkCiN36kMt+T9jL85aokb7k1lVVylP5NSgqFq4cr6OVVSsUqdtcNTFMFEtQQZ2mvPnpL3tvJmxuR3yikzcmQrbtNj0lB+qy9WHBjek= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) by MN2PR11MB3886.namprd11.prod.outlook.com (2603:10b6:208:137::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.23; Tue, 28 Jul 2020 02:35:28 +0000 Received: from MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::b898:36f5:61cb:42ca]) by MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::b898:36f5:61cb:42ca%7]) with mapi id 15.20.3216.033; Tue, 28 Jul 2020 02:35:28 +0000 From: "Xia, Chenbo" To: "Xu, Rosen" , "dev@dpdk.org" CC: "maxime.coquelin@redhat.com" , "Yigit, Ferruh" , "Wang, Xiao W" Thread-Topic: [PATCH v1] vdpa/ifc: fix vring update after device config Thread-Index: AQHWY1CCsf5oATi1p0CwTH/rJVknzakcR6VA Date: Tue, 28 Jul 2020 02:35:28 +0000 Message-ID: References: <20200724170906.13843-1-chenbo.xia@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: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.102.204.45] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 55bb92fc-08fd-4678-b37b-08d8329ee40d x-ms-traffictypediagnostic: MN2PR11MB3886: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: h1aXTFydzT/holuGSPE1SNGwgHA1kM8406Sh++mZ0NmyO89FYevORcYz2XESsGOYMN6voWd41UxVbHDmL7Vi5EEAn48XjF0VOavKk2SJjCg6cAKsbKubmy4q4g9NKGFmF0SN3DbHF+Zlntnp77gbPjYvaxmt2ey6cQqDjY1GGhBXXRIraTQBUSuzLN13M7IgbIN/cRVsIhbSSDSypMM30+KKJ2uzbwHqXqpyS4YB3B+bsBDZeewfvmXq//9hvigf7hD2Kqe+gCTtTJaYkpQbRTn/KVfw0bSb7MlloIEEqic9z7JSdrrRZMHQnO4VIVnHj4AfCVE8U5Rl5XnmY1QT2FWlpk+weg7UIa1tfOljIVhLBrDKaAX9wWaiKcYczBIb x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR11MB4063.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(396003)(136003)(376002)(346002)(366004)(478600001)(8676002)(52536014)(5660300002)(33656002)(15650500001)(6506007)(53546011)(7696005)(8936002)(71200400001)(186003)(66446008)(9686003)(110136005)(86362001)(4326008)(83380400001)(54906003)(2906002)(55016002)(107886003)(26005)(66946007)(76116006)(66476007)(316002)(66556008)(64756008)(309714004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: pHJ6oR2cSe+YHqBytxTTsAbVcXawLUcYQGatzG6Z7BCh73MIb0cdKX+TWo1EJHMItd43xPwY4YVYnGZnqpbpyj9mN/9vcf4ggRLV7BIghSm0w2gWBjhatkfb9OQYDV2+nnLkTQZwTgCbzHRDUfx4++MPv9GhRG98C+I3wtQE464XupP0gwmH0RAPONLakOo+fBFC4xl4s0e1NLLMkWf38HhmyaXbb4dDzeDe6J1SEg6AoHgMwicPAdVw/xzJVk8AIOaViKUSVDyz+PAQwF+kthoATiuS7g+7RpPo1ReHBnKGW/aIuvA2hk24S2dXG/djvPXy7+Ejh1/4dJynmKAXEtBQ3XnSw8CypTcPC7qgX9xumEj+4X9zg636+JbyI8ZO50WZQQbbfdohRh0RKjrJi+aFX+kw6grs5b4GsHkpPSk1ezUTDYuqhUJweuINI/D/mvphu06L+9YauI7qJZoNjcT9NarLu1Gd/guNn+Qdw0DzIDZyHqIXVk2g/Psb3ymv 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: MN2PR11MB4063.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55bb92fc-08fd-4678-b37b-08d8329ee40d X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jul 2020 02:35:28.3780 (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: DAno1QqtwblmsFCIX1Tvtrxx0IX6fQOweePbwOv31CyT7PAnp8k+xT7U7Z9JLRvtY6Iwz9+Xdj60Er1okUDSbw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3886 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v1] vdpa/ifc: fix vring update after device config 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 Rosen, > -----Original Message----- > From: Xu, Rosen > Sent: Sunday, July 26, 2020 9:27 PM > To: Xia, Chenbo ; dev@dpdk.org > Cc: maxime.coquelin@redhat.com; Yigit, Ferruh ; > Wang, Xiao W > Subject: RE: [PATCH v1] vdpa/ifc: fix vring update after device config >=20 > Hi, >=20 > > -----Original Message----- > > From: Xia, Chenbo > > Sent: Saturday, July 25, 2020 1:09 > > To: dev@dpdk.org > > Cc: maxime.coquelin@redhat.com; Yigit, Ferruh > > ; Wang, Xiao W ; Xu, > > Rosen > > Subject: [PATCH v1] vdpa/ifc: fix vring update after device config > > > > The device ready state in vhost lib is now defined as the state that > > first queue pair is ready. And kick/callfd may be updated by QEMU when > > ifc device is configured. > > > > Although now ifc driver only supports one queue pair, it still has to > > update callfd when working with QEMU. This patch fixes this vring > > update problem by implementing the set_vring_state callback. > > > > Fixes: a3f8150eac6d (net/ifcvf: add ifcvf vDPA driver) > > > > Suggested-by: Maxime Coquelin > > Signed-off-by: Chenbo Xia > > Acked-by: Wang Xiao W > > --- > > drivers/vdpa/ifc/base/ifcvf.h | 1 + > > drivers/vdpa/ifc/ifcvf_vdpa.c | 54 > > ++++++++++++++++++++++++++++++++++- > > 2 files changed, 54 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/vdpa/ifc/base/ifcvf.h > > b/drivers/vdpa/ifc/base/ifcvf.h index eb04a9406..a288ce57d 100644 > > --- a/drivers/vdpa/ifc/base/ifcvf.h > > +++ b/drivers/vdpa/ifc/base/ifcvf.h > > @@ -115,6 +115,7 @@ struct vring_info { > > u16 size; > > u16 last_avail_idx; > > u16 last_used_idx; > > + bool enable; > > }; > > > > struct ifcvf_hw { > > diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c > > b/drivers/vdpa/ifc/ifcvf_vdpa.c index a757d45ec..9da25f0c7 100644 > > --- a/drivers/vdpa/ifc/ifcvf_vdpa.c > > +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c > > @@ -49,6 +49,7 @@ static const char * const ifcvf_valid_arguments[] =3D > > { struct ifcvf_internal { > > struct rte_pci_device *pdev; > > struct ifcvf_hw hw; > > + int configured; > > int vfio_container_fd; > > int vfio_group_fd; > > int vfio_dev_fd; > > @@ -897,6 +898,7 @@ ifcvf_dev_config(int vid) > > DRV_LOG(NOTICE, "vDPA (%s): software relay is used.", > > vdev->device->name); > > > > + internal->configured =3D 1; > > return 0; > > } > > > > @@ -935,6 +937,7 @@ ifcvf_dev_close(int vid) > > update_datapath(internal); > > } > > > > + internal->configured =3D 0; > > return 0; > > } > > > > @@ -1084,13 +1087,61 @@ ifcvf_get_protocol_features(struct > > rte_vdpa_device *vdev, uint64_t *features) > > 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; > > + int ret =3D 0; > > + > > + vdev =3D rte_vhost_get_vdpa_device(vid); > > + list =3D find_internal_resource_by_vdev(vdev); > > + if (list =3D=3D NULL) { > > + DRV_LOG(ERR, "Invalid vDPA device: %p", vdev); > > + return -1; > > + } > > + > > + internal =3D list->internal; > > + if (vring < 0 || vring >=3D internal->max_queues * 2) { > > + DRV_LOG(ERR, "Vring index %d not correct", vring); > > + return -1; > > + } > > + > > + hw =3D &internal->hw; > > + if (!internal->configured) > > + goto exit; > > + > > + cfg =3D hw->common_cfg; > > + IFCVF_WRITE_REG16(vring, &cfg->queue_select); > > + IFCVF_WRITE_REG16(state, &cfg->queue_enable); > > + > > + if (!state && hw->vring[vring].enable) { > > + ret =3D vdpa_disable_vfio_intr(internal); > > + if (ret) > > + return ret; > > + } > > + > > + if (state && !hw->vring[vring].enable) { > > + ret =3D vdpa_enable_vfio_intr(internal, 0); > > + if (ret) > > + return ret; > > + } > > + > > +exit: > > + hw->vring[vring].enable =3D !!state; >=20 > Redundant operation on variable "state". The state should be 0/1 by default, but as the callback definition uses 'int', for other lib passing non-0/1 to the callback, we'd better to make sure it's 0/1 internally. What do you think? And thanks to your comments, I find that the register writing does not make sure it's a 0/1. Thanks! Chenbo >=20 > > + return 0; > > +} > > + > > static struct rte_vdpa_dev_ops ifcvf_ops =3D { > > .get_queue_num =3D ifcvf_get_queue_num, > > .get_features =3D ifcvf_get_vdpa_features, > > .get_protocol_features =3D ifcvf_get_protocol_features, > > .dev_conf =3D ifcvf_dev_config, > > .dev_close =3D ifcvf_dev_close, > > - .set_vring_state =3D NULL, > > + .set_vring_state =3D ifcvf_set_vring_state, > > .set_features =3D ifcvf_set_features, > > .migration_done =3D NULL, > > .get_vfio_group_fd =3D ifcvf_get_vfio_group_fd, @@ -1170,6 +1221,7 > @@ > > ifcvf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, > > goto error; > > } > > > > + internal->configured =3D 0; > > internal->max_queues =3D IFCVF_MAX_QUEUES; > > features =3D ifcvf_get_features(&internal->hw); > > internal->features =3D (features & > > -- > > 2.17.1