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 74D0242A69; Fri, 5 May 2023 07:07:50 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 62D57427E9; Fri, 5 May 2023 07:07:50 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 384E6427E9 for ; Fri, 5 May 2023 07:07:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683263269; x=1714799269; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=iPIynO6PCfQqDeVcd1bKm8Bu45FutwfZgKZcBoVGwkk=; b=f1i5hQKJnujoQKvfv3GgU+MkwVQo10rYY9Fut7+xgV5JklJuCce+zvRw dtTmadYe71Exd/GDz/ij8JsqnuXzq4yZrAC5Eyyh3zBMqg0/+Qi3WnKTm F/GmQOaFGAcXuH8tH5xTj9vQGBTC5VO93AUpNnmA3qgwj72ADMnuY5QWd F1YQtln/AEF2dr3sV0X+/YjnrLJd+7+GXDV5w/2xz2O4ivX0AZg5qtkoA silmmw1K19Ulbr2Ijzkx8EjQRdUWpe6q/IV0xUgzgQ0x0aTyfSLtf0HrK sYj9yRxkCGihnr0tfKQjlWnRhCkNddoKoxVLkK5uURo4FX/VToMSYxWYN g==; X-IronPort-AV: E=McAfee;i="6600,9927,10700"; a="352164609" X-IronPort-AV: E=Sophos;i="5.99,250,1677571200"; d="scan'208";a="352164609" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 May 2023 22:07:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10700"; a="1027276341" X-IronPort-AV: E=Sophos;i="5.99,250,1677571200"; d="scan'208";a="1027276341" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmsmga005.fm.intel.com with ESMTP; 04 May 2023 22:07:38 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Thu, 4 May 2023 22:07:37 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) 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.2507.23; Thu, 4 May 2023 22:07:37 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Thu, 4 May 2023 22:07:37 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.168) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Thu, 4 May 2023 22:07:37 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bOTR0KZuCTdG6AuvIEoLXOiTAVEw7/rcFUOJ76bEE42igAEIbwx/swX4+oQP8LEBP6yXk+8TAFtgIw6341k39YuRBBrVc8OWwR4wWjElCyI4qLH54GaLz604LzlcewJFInzqEK2zE60KA5AYTgQAnjzsnkdSDI9+zZJYdjyBZCoDp5cJ0DnRo/TSNW2bdfQA+rqc4r0THzKXmvY1Y4p+lwJUZgqFnE4483h7b0Es98jjekQwT/GUuurr2PoOWYV5A32w8Y+gRb1SKVL35w3XbW+iP/i+xAjctaPrX1UvEYaaSNaAbodYA9GLNzSFC0URD4vC3KUsjN0Uryfs5A0d2A== 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=v0T/RenvuILRhBHalN/sjLfzuWxp7/RC9dygs+Qw2Qg=; b=JMKQKmCNYr6diNvVNr3bD8IH4y7Mzudk/btBoadekyTbteOtBy1i+VKwF4doTFv16y1RKMWtTymDdCWJphjRtxLbmIgiyQdMHA6+xf6Wa/2pbtGE6eRv7/PGPwghkpwI8+UBQYGWP6xh+1ndCgf74dnekW7CgyD3NDAbL8XavE39WNpDJuZCk+fhPvM2an5FYt9IWj8yNHou6KQSmoDp+bCX0aMQF1cBlQxeBVUSQjUycKGiPsUZIKJOs6pNOWzzQDfBDiRXdP9E9ys00lXPkraXYGAn2tSKibxCSjZ6nmzrFn+4B7vyaAwKm2TdkuOJBWUzdy5bbOK1YTBvllDH3w== 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 IA1PR11MB6444.namprd11.prod.outlook.com (2603:10b6:208:3a7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.22; Fri, 5 May 2023 05:07:31 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::5797:849:7a10:560d]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::5797:849:7a10:560d%6]) with mapi id 15.20.6363.022; Fri, 5 May 2023 05:07:31 +0000 From: "Xia, Chenbo" To: Maxime Coquelin , "dev@dpdk.org" , "david.marchand@redhat.com" , "mkp@redhat.com" , "fbl@redhat.com" , "jasowang@redhat.com" , "Liang, Cunming" , "Xie, Yongji" , "echaudro@redhat.com" , "eperezma@redhat.com" , "amorenoz@redhat.com" Subject: RE: [RFC 11/27] vhost: introduce backend ops Thread-Topic: [RFC 11/27] vhost: introduce backend ops Thread-Index: AQHZY+eWX9YioFGi9UODBOMOiWAZ0K9LK2lQ Date: Fri, 5 May 2023 05:07:31 +0000 Message-ID: References: <20230331154259.1447831-1-maxime.coquelin@redhat.com> <20230331154259.1447831-12-maxime.coquelin@redhat.com> In-Reply-To: <20230331154259.1447831-12-maxime.coquelin@redhat.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-traffictypediagnostic: SN6PR11MB3504:EE_|IA1PR11MB6444:EE_ x-ms-office365-filtering-correlation-id: f065a709-bc93-481a-6fe2-08db4d26a189 x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: yzWnqpwkAkayYxuxvi3tb/KpHXvNJjDCR+wRtJUQetA0wyNjt1iZhqLJFrFkM0HVgzzfgiVERno2/F+hJ6YbKmZxm3CfeiRJcCLQszPLyzYVvsl087VV+feke3yOuTBy1ziriRChMP1qnPoAlnpxW/Vo8Y5wz9bnpzR8IufgkY91vDmN5JR+mQkc43osa8N5cWGhBCwhHgECjZnosd8gSfWL1ry2xsoCKTTqt7XLblfj330W6UBBJiJmcW13DBngN40mdqOIvH1dx+TNQSRckhtCee3XO+Q5W2jvq6cInQwEhmyBzm9Ub2wwJEByhQ3rHciUwmxO582GA2cIK1DrPidtYZX0qiKoLpgjye4vaB4lEMajrCE07Re3FWx0ZLeB0T7gfB1lA4KVHY603zq68k/djfru6QHsXyLZ/qbEpW/rRsVPR27krdKZ43F8LiPCTv1vmqKJ0u8u5A8LgKi4Hgx2PpSKihYOCOkrpRSANFImP5m1LmYD8wWVVv/0pkZJeUHR7J2yeVizsZJ1LRpLOcgvrKFMxY6EUoHOpMYv35BopVvlMBjva8x4tzKLHtcxgJGYU96jazCzEA7lMBGGrRmIaOY2fMEN3Pv0iO1QAwpe5g1J5ZaA7oC3oRjuGyVbo03HzWwHomvSbxzL5Whw4Q== 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:(13230028)(136003)(39860400002)(396003)(376002)(366004)(346002)(451199021)(921005)(55016003)(8676002)(26005)(6506007)(9686003)(8936002)(7416002)(53546011)(52536014)(76116006)(316002)(66556008)(110136005)(66476007)(66946007)(64756008)(66446008)(71200400001)(41300700001)(478600001)(5660300002)(7696005)(122000001)(33656002)(38100700002)(82960400001)(86362001)(38070700005)(186003)(2906002)(83380400001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?4FnLsqJwHjopfb1a+JkarnE0Fcx3ivhBbQinmuFQ+uxIMe9L8r3nTAIbm10j?= =?us-ascii?Q?Cqk/rTW00+I8Ho3bxD0SqnH7AvSFQg93fSfDsyQejP+LRaPvRHQgZ4HB0uPu?= =?us-ascii?Q?o68jtN8vxFDSNVGyW9KtVfL9k6hgdozyzcrCg47bJ60Adt32hL+YlNrcz3nh?= =?us-ascii?Q?RAVHTLDAuyq6Jc314QayOGBIf1c1K+YPFC/QfS1v5OIGpAd/7WufID6jHpvU?= =?us-ascii?Q?L2V/gSClsnGey+BKsunJwoxKR/VxpnzgkjHlyhFFyNbtZip645fHGbgz7fGQ?= =?us-ascii?Q?Dptxr0JRbUbMR6OAmwo9LCCks97vyGsk2Uxpevb6ptMIpd6PqhBv72V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ecfhiuDx3DuLR0XY7bdXNl5cU9TZzJ7?= =?us-ascii?Q?rjAobwaPZ67xdOnD3jqJIZS2Qmd1Arc1lu2TSecz8ZmTU8LbiB1Md0IgmQFU?= =?us-ascii?Q?ZVN8/W5YWsC4J/A7YtH1uH1ty7oFU4CRnwSY4wkQ5qXH6V4eROI8uPYjsHLW?= =?us-ascii?Q?z2OZxDKbtIEtXaC36GqFO8ZEPFvyB+BUoOIKa0PT5N/GGoNIgHBtaVMl4TZh?= =?us-ascii?Q?00QK51XRB0BUZxbTPrcYbGkpwEHWqovAcFDo3ZzQ/E4e27vAYJ2J6E0QRN38?= =?us-ascii?Q?JAoR7CmVONhTjqm635KY8bfIUGX/TrtICcvLWARXH9ujOtNXcDEWPQh9sPzC?= =?us-ascii?Q?ii42EiZn6e2y2WTQY0+3o/+m8oB7eVRDi4YOEkS6?= 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: f065a709-bc93-481a-6fe2-08db4d26a189 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 May 2023 05:07:31.6812 (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: 4cNyVQzzkmg+b+5ULp8AhM1iEbMNFV7KfiUGo09rR0O11q6UuPKaF98xutmv59psrLCeoQ4Cook8AI5VUjcpRA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR11MB6444 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: Maxime Coquelin > Sent: Friday, March 31, 2023 11:43 PM > To: dev@dpdk.org; david.marchand@redhat.com; Xia, Chenbo > ; mkp@redhat.com; fbl@redhat.com; > jasowang@redhat.com; Liang, Cunming ; Xie, Yongj= i > ; echaudro@redhat.com; eperezma@redhat.com; > amorenoz@redhat.com > Cc: Maxime Coquelin > Subject: [RFC 11/27] vhost: introduce backend ops >=20 > This patch introduces backend ops struct, that will enable > calling backend specifics callbacks (Vhost-user, VDUSE), in > shared code. >=20 > This is an empty shell for now, it will be filled in later > patches. >=20 > Signed-off-by: Maxime Coquelin > --- > lib/vhost/socket.c | 2 +- > lib/vhost/vhost.c | 8 +++++++- > lib/vhost/vhost.h | 10 +++++++++- > lib/vhost/vhost_user.c | 8 ++++++++ > lib/vhost/vhost_user.h | 1 + > 5 files changed, 26 insertions(+), 3 deletions(-) >=20 > diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c > index 669c322e12..ba54263824 100644 > --- a/lib/vhost/socket.c > +++ b/lib/vhost/socket.c > @@ -221,7 +221,7 @@ vhost_user_add_connection(int fd, struct > vhost_user_socket *vsocket) > return; > } >=20 > - vid =3D vhost_new_device(); > + vid =3D vhost_user_new_device(); > if (vid =3D=3D -1) { > goto err; > } > diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c > index 4f16307e4d..41f212315e 100644 > --- a/lib/vhost/vhost.c > +++ b/lib/vhost/vhost.c > @@ -676,11 +676,16 @@ reset_device(struct virtio_net *dev) > * there is a new virtio device being attached). > */ > int > -vhost_new_device(void) > +vhost_new_device(struct vhost_backend_ops *ops) > { > struct virtio_net *dev; > int i; >=20 > + if (ops =3D=3D NULL) { > + VHOST_LOG_CONFIG("device", ERR, "missing backend ops.\n"); > + return -1; > + } > + > pthread_mutex_lock(&vhost_dev_lock); > for (i =3D 0; i < RTE_MAX_VHOST_DEVICE; i++) { > if (vhost_devices[i] =3D=3D NULL) > @@ -708,6 +713,7 @@ vhost_new_device(void) > dev->backend_req_fd =3D -1; > dev->postcopy_ufd =3D -1; > rte_spinlock_init(&dev->backend_req_lock); > + dev->backend_ops =3D ops; >=20 > return i; > } > diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h > index 4ace5ab081..cc5c707205 100644 > --- a/lib/vhost/vhost.h > +++ b/lib/vhost/vhost.h > @@ -89,6 +89,12 @@ > for (iter =3D val; iter < num; iter++) > #endif >=20 > +/** > + * Structure that contains backend-specific ops. > + */ > +struct vhost_backend_ops { > +}; > + > /** > * Structure contains buffer address, length and descriptor index > * from vring to do scatter RX. > @@ -513,6 +519,8 @@ struct virtio_net { > void *extern_data; > /* pre and post vhost user message handlers for the device */ > struct rte_vhost_user_extern_ops extern_ops; > + > + struct vhost_backend_ops *backend_ops; > } __rte_cache_aligned; >=20 > static inline void > @@ -812,7 +820,7 @@ get_device(int vid) > return dev; > } >=20 > -int vhost_new_device(void); > +int vhost_new_device(struct vhost_backend_ops *ops); > void cleanup_device(struct virtio_net *dev, int destroy); > void reset_device(struct virtio_net *dev); > void vhost_destroy_device(int); > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c > index a989f2c46d..2d5dec5bc1 100644 > --- a/lib/vhost/vhost_user.c > +++ b/lib/vhost/vhost_user.c > @@ -3464,3 +3464,11 @@ int rte_vhost_host_notifier_ctrl(int vid, uint16_t > qid, bool enable) >=20 > return ret; > } > + > +static struct vhost_backend_ops vhost_user_backend_ops; > + > +int > +vhost_user_new_device(void) > +{ > + return vhost_new_device(&vhost_user_backend_ops); > +} > diff --git a/lib/vhost/vhost_user.h b/lib/vhost/vhost_user.h > index a0987a58f9..61456049c8 100644 > --- a/lib/vhost/vhost_user.h > +++ b/lib/vhost/vhost_user.h > @@ -185,5 +185,6 @@ int vhost_user_iotlb_miss(struct virtio_net *dev, > uint64_t iova, uint8_t perm); > int read_fd_message(char *ifname, int sockfd, char *buf, int buflen, int > *fds, int max_fds, > int *fd_num); > int send_fd_message(char *ifname, int sockfd, char *buf, int buflen, int > *fds, int fd_num); > +int vhost_user_new_device(void); >=20 > #endif > -- > 2.39.2 Reviewed-by: Chenbo Xia =20