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 10A02A0524; Sun, 26 Jul 2020 15:27:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CECA81BFE8; Sun, 26 Jul 2020 15:27:32 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 3D641F04 for ; Sun, 26 Jul 2020 15:27:31 +0200 (CEST) IronPort-SDR: Th+XlB3pdmK7jHT8CHfjOqGmc0w5ZA97TcEuW9mopA7cIpFAnQPU56OaQIxdCVUU9m+wcKxsFO L1BYnQ98WBIw== X-IronPort-AV: E=McAfee;i="6000,8403,9693"; a="138408159" X-IronPort-AV: E=Sophos;i="5.75,398,1589266800"; d="scan'208";a="138408159" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2020 06:27:29 -0700 IronPort-SDR: 18gPh4kbc7MFyhB4vt/SGpt24cePomBIj2x9ggP/sRl8dCu4wnIBsmVLbiXT7qhUdIYWEKLd39 ayNufd2NktcA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,398,1589266800"; d="scan'208";a="489231836" Received: from orsmsx107.amr.corp.intel.com ([10.22.240.5]) by fmsmga006.fm.intel.com with ESMTP; 26 Jul 2020 06:27:29 -0700 Received: from orsmsx152.amr.corp.intel.com (10.22.226.39) by ORSMSX107.amr.corp.intel.com (10.22.240.5) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 26 Jul 2020 06:27:29 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by ORSMSX152.amr.corp.intel.com (10.22.226.39) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 26 Jul 2020 06:27:28 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.102) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 26 Jul 2020 06:27:28 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D2uzMZxKxFhMI9/wvs3InniI/8xNgPUCsKTGsR6nONP25sZvYZPXedYZXpunROo/nUfjOcq6Qm+xHt3MdCuul8zoICyCDE5V0jdM8vqouB7iOo8AGE4phOo4RR+2Ai0tJXj/MyLwq+KsLn0TC6B7/S7vqFDQQVSG+C+4+oTyKcb+DHUhAycZfLFwd9ZNml1XFlUF4UvhIqPLaEgA9MfzPma5Txxw/0DcdHDMmdXw9/BgQOcQ3BbuVaVIvAHdx4lxoPrIGtN9PPJs6IlDWhGVdLQNe3ESXem4NeUdADlDhqmNTsU+S+6ajuzVJxWGKMzvVRAPnwtcK1B2/P6YbC8XkA== 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=A+qJXf7Xy+7exT4vzkw0KVlIBBNm3ldEYYV2rYw9QKU=; b=ebeZaVW0QDzN7RNTkOYZIuaBaCmNtXUW6nRnE7OCgBEdgFeTzZ104kpNYmuD2YEn5KtdBN4KfhNJOkUyeM4NwwUox5umqBfHZdsOtrLmjOkmM/q0WjkEsB3GXiGimTbb/o/+AZ44EApRo0ayU9CblK72p5UxYYQ0k8TA3xwEeifSzy0pIMhCT9LkT930Et4het9kVylk3lhrltX8Z9eZIfGFj4CUaS+z7iZ6SeTm+8aVKXvGdiVz0t7B1Z+hT/IXwDCASYir2Fnq5RF8v7PNSSNNu7US5sYN9RE40A5DwzpeedV/OOFxBTnHn6ugLoOnLQ/Vu2RuRZlidVDi3Al16Q== 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=A+qJXf7Xy+7exT4vzkw0KVlIBBNm3ldEYYV2rYw9QKU=; b=T/L76LRjQmT29Z6jaD8mtDoCOzU51kW/wd4SK+0qsUWJrcn08yyPWS7Vart7NRiQRaM2McYvyKSEbJuNiSzsZfVPfSUiJMptKNuNak3fFQVn9SQ0rMQujN0+0fZ7HIGUMhhuhmF2Jt4365cVl0nvRLOa00caUG7OVBrbsSv5aYM= Received: from BYAPR11MB2901.namprd11.prod.outlook.com (2603:10b6:a03:91::23) by BY5PR11MB3973.namprd11.prod.outlook.com (2603:10b6:a03:185::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.21; Sun, 26 Jul 2020 13:27:23 +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.030; Sun, 26 Jul 2020 13:27:23 +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: AQHWYZMeLrAm43t1i0KOB1Cq8okfPakZ3MCA Date: Sun, 26 Jul 2020 13:27:23 +0000 Message-ID: References: <20200724170906.13843-1-chenbo.xia@intel.com> In-Reply-To: <20200724170906.13843-1-chenbo.xia@intel.com> 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: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMTFmYjczNGItMDcwNC00NjQ3LThkNjEtNTNkYzQxN2RhMGVkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiKzNJMTBVNjlpQ0VEcmZIZU1RanhweWw5dllwR05DTmljeHdEcms4T2dNVVU5QTZjVElJaG41SVRKT1ZvaUNBZiJ9 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.205] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a82899b8-caf4-44ad-0766-08d83167a1bd x-ms-traffictypediagnostic: BY5PR11MB3973: 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:7691; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: sK0yuqmQIEQ7kMxOELCoMnwKuVXf67Qijkjd1Ca8+h1H+xB7B4cvL5pEOy//VPWHIeQbBz0KIgewp/M1SAoy7uah2XFsdLDL07QevExxKaN43BU0EG8I/+nizlyt2vtrlOqH+7LtRm86D8OlNeyQVMn3SINFcxZu99q8y61xvoTismwMO3O3dDYiGVZIzgOBn6V7xdQQnPxgXJLqKCvXNgnCTp4BMT9loQfwkNrUPM3lpMCRZdru5TRfbfgdkJ7OezxUa4dQZeHWsmmdJFZCXTJndSbk5J593mjWoddLGccg0eByswauE5B6qbHLTQjQ6AudS7Q8qwcI5WRIRHZ897+lsoliFWqmzut+RGpabevdj8dA/ulQK5QLKDPGOv1Z 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)(396003)(376002)(346002)(366004)(478600001)(76116006)(9686003)(66476007)(66556008)(64756008)(66446008)(66946007)(86362001)(54906003)(71200400001)(8936002)(52536014)(8676002)(7696005)(83380400001)(5660300002)(33656002)(2906002)(15650500001)(316002)(4326008)(110136005)(186003)(26005)(55016002)(107886003)(6506007)(53546011)(309714004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: UytTtSdQVBukz12NCt3516UmXTPkMY6RavQfhaNGOJOt5PxW9ApT562S2Y0gcqEmjPB+X1xw0NKpUCJH8e9qTIIcBXPMGCGZgUoEXbLzEX9nPQ7/55o8gmIh7C8b9UmTEQCylvqwmYWA3DloROmZqUONb08MStuu+TdqyCf5TIsYNVqNFaKzy29XWH0yci+PWQUHljw77BUo5NHqfD/nqgXlRGszx8MH86xxQJkKfZahCYj4ZwKW7vTqLRHL66GizyqPTdhCYnApr22A5p/FNS/4rQ204LifdY0Ly0IUjvllEfTkbj05ZkT0dnaTBGYCRBHqBqAi4lKMgwxvflifR2UDkyWdf2F/zUIzWy1q3a8TfSkCYYLuTSyf9G8fCF07iTUq7tCwug+SgcjxR1ItzbnKZdf15t4wSUAZDMyUloFQM753ObbvJvYn1qw/tU1o4KtdtxtLC3tA8hFh2HQyk1Ii+ScR7jvKJPCEdFKQBKKgZOMbg0gbManxnFratvLX 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: a82899b8-caf4-44ad-0766-08d83167a1bd X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Jul 2020 13:27:23.3710 (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: etHOR0ullZPzQXnYp+UxxWHIzHpNk5zOmv779cS9n+nI9aD3NSpHvXttFqXfvCyChoeMMFKmQ7pzLbm9DlWE8A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB3973 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, > -----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 >=20 > The device ready state in vhost lib is now defined as the state that firs= t > queue pair is ready. And kick/callfd may be updated by QEMU when ifc > device is configured. >=20 > Although now ifc driver only supports one queue pair, it still has to upd= ate > callfd when working with QEMU. This patch fixes this vring update problem > by implementing the set_vring_state callback. >=20 > Fixes: a3f8150eac6d (net/ifcvf: add ifcvf vDPA driver) >=20 > 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(-) >=20 > 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; > }; >=20 > 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); >=20 > + internal->configured =3D 1; > return 0; > } >=20 > @@ -935,6 +937,7 @@ ifcvf_dev_close(int vid) > update_datapath(internal); > } >=20 > + internal->configured =3D 0; > return 0; > } >=20 > @@ -1084,13 +1087,61 @@ ifcvf_get_protocol_features(struct > rte_vdpa_device *vdev, uint64_t *features) > return 0; > } >=20 > +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". > + 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; > } >=20 > + 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