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 3FD70A0521; Tue, 28 Jul 2020 05:08:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 892841BFF2; Tue, 28 Jul 2020 05:08:03 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 6E43D2B8D for ; Tue, 28 Jul 2020 05:08:02 +0200 (CEST) IronPort-SDR: m3oP1luKQMF3Rx55RjFe1EeDfAtTA+hj6aQJAs9Qg3UlsFTnPS1KaT78Aow/TJG56kFIoAJ8oc jQAKvKrHiGFw== X-IronPort-AV: E=McAfee;i="6000,8403,9695"; a="139177228" X-IronPort-AV: E=Sophos;i="5.75,404,1589266800"; d="scan'208";a="139177228" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2020 20:08:00 -0700 IronPort-SDR: Z4yQmQrFAswO0KEnbW7rdIqSAuHz6iCkY9l1JkYndw6I+0la+KlwLJcS2Zc0r+74mIVfFNVfAe X51qeBBS+T5Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,404,1589266800"; d="scan'208";a="312448968" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga004.fm.intel.com with ESMTP; 27 Jul 2020 20:08:00 -0700 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 27 Jul 2020 20:08:00 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 27 Jul 2020 20:08:00 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.174) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 27 Jul 2020 20:07:59 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DonHm38Dxp4UWFt8/6BlXTmtrjt4bURsikeztnRCqjteVFD5QsApihLbz/qkGwDtdpDRWw+j12vfXY0pEjRPnL+oplBqhG8rEzsN0IVwA9gIOH6VSLflASTKG1t5Rgy0NTwBgvBGuQgPMxIiAkdGYuhQ6U6jcGk/3FKjY43ihuW1DcjsjUxqRPoslWiBhgLAZ5DVh4MMCJxTix1A9b5ai965BoDuYIPIl/nJzWe8idMuNEE3cAy+ScrQa93NbcfZ5X8HiVGjKaeiAT342GdTr/e4JeAGYBr9rdOzN+o+DxCHeUhLhb93Wj78khE7tMF4rTkxAy9G+G+krGls23qs4g== 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=CyMQvvXich08YxjNiQ+uxJch3HOurR2wvAhSXEro19I=; b=CKD5O3PC/fgWwIqDdyjQZByOlGVeKIMTv39PppMLlhslgjo/FNYu2VA4keidUxF5BiaUKq23+WIUv2deECND2JHKWiXmhW3BU2t+sR6bt1iBQr6jhx4aNNjdQAkugUQfop37JSKTDAvtpkRNPBQGcW7vzifg1sh31ftsUeIRCrUt/eMtRGsCxCwQSAnMPVPohE/+Y39BK9k037t2BlxvvFUQWM+1Be11WcCdDZhNo1wOyICf0BjVRAnFo3klskmR0maZBYwFKCOqayoUABE0ruQNUaMulU/huFQD8QmATnjCX46ifVCLMgbRUFYrRGFjXa8yXg7ccGMvL3QZrGw5Yw== 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=CyMQvvXich08YxjNiQ+uxJch3HOurR2wvAhSXEro19I=; b=sztlx6ApTO9ZspIY1OEjkG/cMYrMwAk1x5Jodb/t255f2PWMN4hLqU3Sk3AqOmqOipVxbAARO534n8KmYWkEf7FqF0duUwKg/Yf2vT4+/Gw+Q03KKG9FBNPvw28m7fUqufPOh2djJELVI5Ns3v2LrdidTF67EQrrpnKM5w1xEQU= Received: from BYAPR11MB2901.namprd11.prod.outlook.com (2603:10b6:a03:91::23) by BY5PR11MB4226.namprd11.prod.outlook.com (2603:10b6:a03:1bf::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.21; Tue, 28 Jul 2020 03:07:57 +0000 Received: from BYAPR11MB2901.namprd11.prod.outlook.com ([fe80::6552:92f9:74a5:412]) by BYAPR11MB2901.namprd11.prod.outlook.com ([fe80::6552:92f9:74a5:412%4]) with mapi id 15.20.3216.033; Tue, 28 Jul 2020 03:07:57 +0000 From: "Xu, Rosen" To: "Xia, Chenbo" , "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: AQHWYZMeLrAm43t1i0KOB1Cq8okfPakZ3MCAgAJvnACAAAjbQA== Date: Tue, 28 Jul 2020 03:07:56 +0000 Message-ID: References: <20200724170906.13843-1-chenbo.xia@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMDQ3Mzk0ZWMtOGFkYi00Mjc2LThlMTYtMGI1MDc3ODI3OWFjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiOGRZZnEzU2tRQ2MxSDgxQzlJRTFlM0RVeGpnUzIxU3RIZHVaRHFrdzRQVXAxdnVhS0hxR2lTQ3pUcEJ3OFE3YSJ9 x-ctpclassification: CTP_NT 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.198.147.218] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0b63d193-61ca-420e-5f79-08d832a36dbe x-ms-traffictypediagnostic: BY5PR11MB4226: 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: G0g/B15cbsn70z6e4veYfoRlftnp0K5rWX4sG0NgKpDwmVoZyEzP0UMJSPTyc5cQe0ks1lDoSdfct33GqDPXE2SbJYj1LDN6c7XGDOJvf4tkf2MpFf72jtgDjqz8IRYGYOWAjLdV8/Qz9vFvEMR0ZRyio+M6SQWoOZb0DsC7lEBPbeivWJgYzSmy6RSpsku8ORfO2ZV/e52QTD2e8b9tvpIgZfGecYcYndH2Hs49dmPb91bgbHMlMHGazZMOywBVzxO3stSAYWH4aFkjtQf1cE4lxJAf9+wdlsDVUv4bfD/rARLGXBs6S6fnYj/iivy2qMZ8l+iFE9UtSq7mWdDllWWViqBlZ6kmooLxc9Fl315+9wPF2EH+oGLyuJOnlrAe x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB2901.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(136003)(376002)(396003)(346002)(366004)(478600001)(76116006)(66476007)(66556008)(64756008)(66446008)(9686003)(66946007)(86362001)(54906003)(7696005)(71200400001)(8936002)(52536014)(8676002)(83380400001)(5660300002)(33656002)(6506007)(15650500001)(2906002)(4326008)(110136005)(55016002)(26005)(53546011)(107886003)(316002)(186003)(309714004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: +iX2mykHt4R93W408uOZm+GNZma1ZavzSM0WczzFfJ78yeM3K37FcgeqnXPYBu5DY7ASO8GTaRYlcHebgCISZ0nypiSW5sVFWTTXMWD4uNZSQxmH1iWox4/9DL9FAQFS45XgffCpqWGQjYEeCeqYYwuhjZOAjc+HzaziwTEe+waMH1O0xn12v+S6+IdsthTFvQq4Cb+hUhsIDXpEGGijHL+jRk/B/AwjGHhb8FuKGw8LyJ4PDMD7B1ByYHi6I68KNJDWTixnH2k83CRIAlhkz9RxdCWEt4jSH1qu1VOY+40fm4Fa4/gwxOscMqV6WoLCqPKj8noIC2zp+oX/nWbeCFmNOGQwhQOG/vdINIQofq/tapI/2CKmt+/KcH/x/ULNaPUEOOfSZ7wfedqjJOeYC1yjj6Q2pOSu0RpNApUvThLa0ir3hSrmMWgpV2rfDeKq3j/UWGkfpxDwRsqRZbP49yJDM+2uc5CzGD3zLLIpVl0bjUF5Atfpk5jXVzrk1KKu 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: BYAPR11MB2901.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b63d193-61ca-420e-5f79-08d832a36dbe X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jul 2020 03:07:57.4056 (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: +ZU1aZ423x9C73WbVlE3lgVBnEjhk2gAp0ztFgU8P+e/9sivpc4AY+vuZsagfFwOPtr4EKD4xEPmQDz3obQr7Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB4226 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 Chenbo, > -----Original Message----- > From: Xia, Chenbo > Sent: Tuesday, July 28, 2020 10:35 > To: Xu, Rosen ; 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 Rosen, >=20 > > -----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 > > > > Hi, > > > > > -----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; > > > > Redundant operation on variable "state". >=20 > 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 i= t's 0/1 > internally. What do you think? Got, it make sense. > And thanks to your comments, I find that the register writing does not ma= ke > sure it's a 0/1. >=20 > 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