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 296D8A00C3; Fri, 13 May 2022 04:52:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BFF5B40E64; Fri, 13 May 2022 04:52:56 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 8B31940DDE for ; Fri, 13 May 2022 04:52:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652410375; x=1683946375; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=OS2cF7HiwgUg7/1SH1lBPukFy+YxrQGlBSetM2UJBCI=; b=A3aUXWzgQR1lrpDUVWJ7Dc/tiLsteI57tQlVnb2DpHol3dzy9dtdyDs0 hLENPNLj5a0In2iFBGdQPCKbM5T2pfKufqKovsZUaGzNx8V93etUw2MeW duw0TM3OidZE8K4Pi4CXsKOqHek+3vLMwurgSPXo9JwQmujMU0uBu94mH /wdOUxNwU3pLoAHXwWwLVgictNosAH9KOubYmM7uimVCymjdPGxCKZLso WNyXzAJTO9XNU45XbzUuTm2pr926FI3r5hw/WeR2FajNZxwkwsObRGmu3 j28mRFoOEMxXtav8wzsUE33BeTOR6TWcly56RK6MjHjq2zyF8DQA4apAN A==; X-IronPort-AV: E=McAfee;i="6400,9594,10345"; a="270330608" X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="270330608" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2022 19:52:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="554044116" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by orsmga002.jf.intel.com with ESMTP; 12 May 2022 19:52:53 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Thu, 12 May 2022 19:52:53 -0700 Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Thu, 12 May 2022 19:52:53 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Thu, 12 May 2022 19:52:53 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.42) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Thu, 12 May 2022 19:52:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YLRkSOOlwXr069Z1QDgnQ6YfFl+hl9CVz+oU2yeds+ijkQVWiaJboeG2NdIiCKGIce7ZLH6TSvlVVCkzq8iCuUSyrBTX9IHjPig+zIndvohhSxXrJx/krENDlRhZYXRzvj4dcr8C0zYTmTxprz/7igNxm6IpypGtsV1B8MFSolYGj0SLQ8YRIUzJf09q+K8kT4DEAh4ErAPXOsSuS33/XQ//lvoiXohhJEVTewWORvHQ8/6DFzIXCbCldlDUqc8tjaeO+tXg1OMqJ74q+WTntyIT99EoQfDczlyuq8/Niq1fUZO+RuIFuei+evDqI/QSLtV1N3QfoDRHu0BHAqZq7g== 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=4fyrzRK2ytKrOPWd2m2MHuOi3SRjquBS/vCZjKTEfEU=; b=ZAongHkF4kJD8gSECb7MQkvB1qGONWEq+g3jCkjUVNjF5ooqAEXkw0SXouscSKTco+wUHNIxTG7yoIAMUIFI7+NzZW2oLuncX+uj/hHwXsz1Q+W0CpzLWHOtDlvvTnjHQYWeShCTkaKrjVUiHE1H7e+PHJLpEC21kRROGa9egt4op4b78hm7CR58z2TIwx7gFr9WZMl0Ju93QaUUBqrXg4hOAhEJs8DLATJrYR7alhorQHRVDGXriL/Mmts0UVaYG3C+EDKp3sDawbQeb2rN6bLc948zbwwtwqDoIm7WeyessXxDz5Ox0+yQzImY6Wqu0qbJfhzXHVTj52hWdJuTHw== 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 BY5PR11MB4243.namprd11.prod.outlook.com (2603:10b6:a03:1c8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5227.23; Fri, 13 May 2022 02:52:46 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::2c8f:42df:ed85:99e5]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::2c8f:42df:ed85:99e5%4]) with mapi id 15.20.5227.023; Fri, 13 May 2022 02:52:46 +0000 From: "Xia, Chenbo" To: "Pei, Andy" , "dev@dpdk.org" CC: "maxime.coquelin@redhat.com" , "Cao, Gang" , "Liu, Changpeng" Subject: RE: [PATCH v7 14/18] vdpa/ifc: add interrupt and handle for virtio blk Thread-Topic: [PATCH v7 14/18] vdpa/ifc: add interrupt and handle for virtio blk Thread-Index: AQHYWheJNfItJEBMQUy4XKS8tVemhK0cLmEw Date: Fri, 13 May 2022 02:52:46 +0000 Message-ID: References: <1643093258-47258-2-git-send-email-andy.pei@intel.com> <1651048206-282372-1-git-send-email-andy.pei@intel.com> <1651048206-282372-15-git-send-email-andy.pei@intel.com> In-Reply-To: <1651048206-282372-15-git-send-email-andy.pei@intel.com> 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-office365-filtering-correlation-id: 71cc63d2-d470-4dbe-ab5e-08da348ba8a2 x-ms-traffictypediagnostic: BY5PR11MB4243:EE_ x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: SHh44qhoZ0W9HriJJpXqYLdACUHixATKG0WIyoMuk3bBCFTdT0DVERtG3zRXRvu4RLM+gvwHiXc0jav2zIM1IqkE/L78mhzZeiRy4AT0P6FsKXBTr1PwF/Z3PmsWtCV0MvYGVfIZHOwgEU8/kbdRHRnaJROTYf8tZKLt74k22nn9BwzrnbhtBRdjH7e17YWQSBEOMw+bNI+JtfMY1dflNjEAi1fwQ9d98MG5tbRHJ9nQMaEY6OXEe9+W5GPtPrDLJXj68D33r1nh7ZHg1T5RcJqZvo7Zo2pRYBfue0cS6One42mED8W9HeuXoKyyTEfzwcLD8gwOq1Q31VSTLwGPFjT8wpzxXc3dXS+3VeuwlyAL4xiA3ZvwFdzoA8damN7SOuIqo35Qkp2S891/HcBZ4FI+xY0TB+Rrz1rbSH7Mnl/GPqh1z2Y646GgCXlP/R7WdGRrY1XSDcWxzcbigqnXntW7PKuj+WW+Y6tFrYITykNLNIFQmE/ZfWJUTJf1/pY02iWWUfiTpDdIXoIZxqI9Y3QkJXwhoF34ssSWlObmjuQ3nSvQXNcdCnGCWitHT+7J1cVkM1yKf/kNX0iIe6zaqPKrHzGRo6SqKKpJVhpbUIIPYVYcW1QKajvnVKsaVAfNhycAGUHBg8VCrEQrqbmilRwIzLGAAMFkQHvUAzCFb1gPznjkBQy2ij1lXLWclvD9HWjTDh5pU+LNJYYD5b4kpA== 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:(13230001)(366004)(33656002)(6506007)(52536014)(186003)(2906002)(7696005)(9686003)(83380400001)(55016003)(53546011)(82960400001)(8936002)(5660300002)(508600001)(4326008)(122000001)(86362001)(316002)(8676002)(71200400001)(76116006)(107886003)(66446008)(66476007)(64756008)(66556008)(26005)(66946007)(38100700002)(38070700005)(54906003)(110136005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?oDJxgiIhWZmniSMg9IGMjN1Em8YVFu0zx4dhK1r2qNA0PqCtfdr68pNocT1B?= =?us-ascii?Q?u19R8JNJHge6dqOCb6xh1OELHR7aX7xdlTfSIegFSn65j8MLlOGQMWWVLQG0?= =?us-ascii?Q?w1uDSoQAowhlJuEQuCflsppUhldsCQ/qm3VFVMDkrBPxvB8SoBq1mjuT+SyS?= =?us-ascii?Q?GIg24BUghsvFKDFkZHkssO6ASNjIwEOmmVEjHPgkFg7Q6egNEXff4IPaXGKS?= =?us-ascii?Q?lEHGEKaDb2XiHmUG5KqnQRnvTPyXnFssyAVbVGVOAuWZM4X64WJJdT4JMnff?= =?us-ascii?Q?oOQq/ihdx7S6BQ/PCGop/1BFwvt4tnAxfPugecFMQS2GqjCoN3cQLPj2JbWQ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6D8YudnwVYASnon9z4L4mcGl?= =?us-ascii?Q?+H3HXq/r+l9chSvf8iTWfdZsb/HlZER/qBIFj9sQ5CxEq9A5t/rMAtLXC39r?= =?us-ascii?Q?P/DVDkVTSrx9WZGf5GNJ3RK+5fmQ641BufwJSCh/3CsMs1lpKPb7YA8F6QWx?= =?us-ascii?Q?5Z1maPSAKw9g/aWpzNtLErVRIgJXDD6EYRuTRZPkmhbS1sf8spPUipUfPHJd?= =?us-ascii?Q?JYwwlVqOIILOdx0v6Gcij9ypHyEjbtiuuqRKAroqbwkeq8GBOARTVT+MSnbQ?= =?us-ascii?Q?QEXlUiZC03z3S3UX1/fzqBys/zdFS6cah58Tn76jbUeFbRQn9dnvgqDnyKQ0?= =?us-ascii?Q?ZQuQWA+I2A0nELrfy/6M779jynQRWUKcq93q5KWhstAIeE64WMWmq6iyMMbg?= =?us-ascii?Q?UUuoBuutiM+G76LllOIiEAmeeDt8E5Xiw4k/476Nz33Mf6m4/nZoABJk6rgJ?= =?us-ascii?Q?mW5VxxWKxbomxIxuw5feJuPlNguHxIsoiPJUrtm5hrFSUJp+vmMjoycOpljq?= =?us-ascii?Q?c6s5qFzMbA=3D=3D?= 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: 71cc63d2-d470-4dbe-ab5e-08da348ba8a2 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 May 2022 02:52:46.0521 (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: kQTTF07FqA/GzbplUF/Po0/Iyn78MTy1Jc8sc4jfblerMf7seRWAKhEXdO/OZ4FYBS20bleIXjbNtnfCM6xcGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB4243 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: Pei, Andy > Sent: Wednesday, April 27, 2022 4:30 PM > To: dev@dpdk.org > Cc: Xia, Chenbo ; maxime.coquelin@redhat.com; Cao, > Gang ; Liu, Changpeng > Subject: [PATCH v7 14/18] vdpa/ifc: add interrupt and handle for virtio > blk Better be: vdpa/ifc: add interrupt handling for config space >=20 > Create a thread to poll and relay config space change interrupt. > Use VHOST_USER_SLAVE_CONFIG_CHANGE_MSG to info qemu. Inform QEMU. You don't need to save words in commit log. The commit log should be as detailed as possible to make readers understand quickly what the commit is doing :) >=20 > Signed-off-by: Andy Pei > --- > drivers/vdpa/ifc/ifcvf_vdpa.c | 112 > ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 112 insertions(+) >=20 > diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.= c > index 5a8cf1c..0e94e1f 100644 > --- a/drivers/vdpa/ifc/ifcvf_vdpa.c > +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c > @@ -53,7 +53,9 @@ struct ifcvf_internal { > int vfio_group_fd; > int vfio_dev_fd; > pthread_t tid; /* thread for notify relay */ > + pthread_t intr_tid; /* thread for intr relay */ Thread for virtio-blk config space change interrupt relay > int epfd; > + int csc_fd; csc_epfd > int vid; > struct rte_vdpa_device *vdev; > uint16_t max_queues; > @@ -558,6 +560,107 @@ struct rte_vdpa_dev_info { > return 0; > } >=20 > +static void > +virtio_interrupt_handler(struct ifcvf_internal *internal) > +{ > + int vid =3D internal->vid; > + int ret; > + > + ret =3D rte_vhost_slave_config_change(vid, 1); > + if (ret) > + DRV_LOG(ERR, "failed to notify the guest about configuration > space change."); > +} > + > +static void * > +intr_relay(void *arg) > +{ > + struct ifcvf_internal *internal =3D (struct ifcvf_internal *)arg; > + struct epoll_event csc_event; > + struct epoll_event ev; > + uint64_t buf; > + int nbytes; > + int csc_fd, csc_val =3D 0; > + > + csc_fd =3D epoll_create(1); > + if (csc_fd < 0) { > + DRV_LOG(ERR, "failed to create epoll for config space > change."); > + return NULL; > + } > + > + ev.events =3D EPOLLIN | EPOLLPRI | EPOLLRDHUP | EPOLLHUP; > + ev.data.fd =3D rte_intr_fd_get(internal->pdev->intr_handle); > + if (epoll_ctl(csc_fd, EPOLL_CTL_ADD, > + rte_intr_fd_get(internal->pdev->intr_handle), &ev) < 0) { > + DRV_LOG(ERR, "epoll add error: %s", strerror(errno)); > + return NULL; Close the epfd and set to -1 if err. > + } > + > + internal->csc_fd =3D csc_fd; > + > + for (;;) { > + csc_val =3D epoll_wait(csc_fd, &csc_event, 1, -1); > + if (csc_val < 0) { > + if (errno =3D=3D EINTR) > + continue; > + DRV_LOG(ERR, "epoll_wait return fail\n"); Save '\n', it's not needed for DRV_LOG. Please check other DRV_LOGs > + return NULL; > + } else if (csc_val =3D=3D 0) { > + continue; > + } else { > + /* csc_val > 0 */ > + nbytes =3D read(csc_event.data.fd, &buf, 8); > + if (nbytes < 0) { > + if (errno =3D=3D EINTR || errno =3D=3D EWOULDBLOCK) EAGAIN should also be this case? > + continue; > + DRV_LOG(ERR, "Error reading from file > descriptor %d: %s\n", > + csc_event.data.fd, > + strerror(errno)); > + return NULL; > + } else if (nbytes =3D=3D 0) { > + DRV_LOG(ERR, "Read nothing from file > descriptor %d\n", > + csc_event.data.fd); > + continue; > + } else { > + virtio_interrupt_handler(internal); > + } > + } > + } > + > + return NULL; > +} > + > +static int > +setup_intr_relay(struct ifcvf_internal *internal) > +{ > + int ret; > + > + ret =3D pthread_create(&internal->intr_tid, NULL, intr_relay, > + (void *)internal); EAL API: rte_ctrl_thread_create, will be preferred. > + if (ret) { > + DRV_LOG(ERR, "failed to create notify relay pthread."); > + return -1; > + } > + return 0; > +} > + > +static int > +unset_intr_relay(struct ifcvf_internal *internal) > +{ > + void *status; > + > + if (internal->intr_tid) { > + pthread_cancel(internal->intr_tid); > + pthread_join(internal->intr_tid, &status); > + } > + internal->intr_tid =3D 0; > + > + if (internal->csc_fd >=3D 0) > + close(internal->csc_fd); > + internal->csc_fd =3D -1; > + > + return 0; > +} > + > static int > update_datapath(struct ifcvf_internal *internal) > { > @@ -584,10 +687,16 @@ struct rte_vdpa_dev_info { > if (ret) > goto err; >=20 > + ret =3D setup_intr_relay(internal); > + if (ret) > + goto err; > + But this is not needed for net, right? As I said, we should include validation for net also.=20 Thanks, Chenbo > rte_atomic32_set(&internal->running, 1); > } else if (rte_atomic32_read(&internal->running) && > (!rte_atomic32_read(&internal->started) || > !rte_atomic32_read(&internal->dev_attached))) { > + ret =3D unset_intr_relay(internal); > + > ret =3D unset_notify_relay(internal); > if (ret) > goto err; > @@ -880,6 +989,9 @@ struct rte_vdpa_dev_info { > /* stop the direct IO data path */ > unset_notify_relay(internal); > vdpa_ifcvf_stop(internal); > + > + unset_intr_relay(internal); > + > vdpa_disable_vfio_intr(internal); >=20 > ret =3D rte_vhost_host_notifier_ctrl(vid, RTE_VHOST_QUEUE_ALL, false); > -- > 1.8.3.1