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 93B62A00BE; Tue, 7 Jul 2020 05:21:49 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 784841DD2E; Tue, 7 Jul 2020 05:21:49 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 4B3791DD2E for ; Tue, 7 Jul 2020 05:21:47 +0200 (CEST) IronPort-SDR: LTQUZaY2r4uK4J2GF5ulEC7I51OKXUFvNKiBHXE2vT1d9KeqHKMNQ999kTPLW2nuGCb8gOoxfG U6cW87u9c1rA== X-IronPort-AV: E=McAfee;i="6000,8403,9674"; a="146607852" X-IronPort-AV: E=Sophos;i="5.75,321,1589266800"; d="scan'208";a="146607852" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 20:21:46 -0700 IronPort-SDR: CoErQNlqJPn9eLAx42ojNheNSm2ryGE3eC1PrccleMHm0m41wwvzlPa5vdjeVbz5PpI+S/zLPn bm0DQPnfoP6A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,321,1589266800"; d="scan'208";a="483353484" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga005.fm.intel.com with ESMTP; 06 Jul 2020 20:21:46 -0700 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 6 Jul 2020 20:21:45 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.172) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 6 Jul 2020 20:21:46 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P0zBTUW3cvCOsE0Eue7C7gAox3R2X8BH+yXgz2ZCHLsKiHklSG5AL3WLP6uDGag5DJK9chsSBPZDe7Ghot3gZ7IsGV19pkPJwPP+BnD3dEbLZnw43X7IctDY2Sr7fR7s0wPxh/mm/lsTuLEKTzvHi771goRugUDDAvDIqC6sD8fk7saKOZpnGsdEqyMLT1Czba7iXjt7s9UZxXuFyHRMCqvnBXE9ciAaXV9fSPjn37Vbrjt5tIRKOdXG+wbhh8BPzkEgi4cYxDL3pQlesOYCtc+mWaeqVFFBWF7gbak0LU6YLITxKduumh7EgpYlDi448GDEBbSSpXiSD7Vkzw+oZg== 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=zXM8UWkKtggpYmIlfw4IDWfTZddCJ50+Fv1CswFkx9o=; b=kif8ZGEtA0r4p/sGjwNb8gM+LNDXpZVfQfgQxNQNEMb4hjxgcfycAc57/aAJQ6TwIOdMu4cuUvdlpuN/lD+Z90Lf0kI1W3rai7Cs50bLRtlP2+LOCIIN53o6V2OacVbIDBKEEbqnBNVG3osmo+UGY9ZWv/MXyAhWvjblcV0CiWpiQba6knt+QEqjOOM507sj0yr9Pna/hqB3HpkP50k689u7SgT7U6CXmydeirGv4oR5jOFnEVhLXJOOJlSPnttI/q5qu5iguyACnQqR2R0lUjV5e3uBl7vQT/OiP9jAYeRLGpui8cUDsJsst3ylnnTcwvAk9DvPdgA3bEeGMv8AbQ== 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=zXM8UWkKtggpYmIlfw4IDWfTZddCJ50+Fv1CswFkx9o=; b=rPwS/ap91pA8/3bqxCXokxTMH/VGXaRGCkASRxu4ZIn6NvG2QuSFW52NdU2T4K/wbHGemXtHgqAcbnjp1H8iW9Ndk3lPH3NEBPvjNQicRlnDYvaVwZjGFm9SqrDJByBEWwY32z01Esesn4fR6/XkR1nju3HwUemOjSDya12jlWY= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) by MN2PR11MB3709.namprd11.prod.outlook.com (2603:10b6:208:f3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.21; Tue, 7 Jul 2020 03:21:44 +0000 Received: from MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::7cde:8326:5010:c47e]) by MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::7cde:8326:5010:c47e%7]) with mapi id 15.20.3153.029; Tue, 7 Jul 2020 03:21:44 +0000 From: "Xia, Chenbo" To: Adrian Moreno , "dev@dpdk.org" , "Ye, Xiaolong" , "shahafs@mellanox.com" , "matan@mellanox.com" , "maxime.coquelin@redhat.com" , "Wang, Xiao W" , "viacheslavo@mellanox.com" CC: "jasowang@redhat.com" , "lulu@redhat.com" Thread-Topic: [PATCH v3 3/8] vhost: make some vDPA callbacks mandatory Thread-Index: AQHWU4g0gJO6IbbbD0+kts0Sv8XARaj7dF0A Date: Tue, 7 Jul 2020 03:21:44 +0000 Message-ID: References: <20200706112452.1474533-1-amorenoz@redhat.com> <20200706112452.1474533-4-amorenoz@redhat.com> In-Reply-To: <20200706112452.1474533-4-amorenoz@redhat.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: redhat.com; dkim=none (message not signed) header.d=none;redhat.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: fb6e6968-f763-4558-878b-08d82224dffb x-ms-traffictypediagnostic: MN2PR11MB3709: 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:1417; x-forefront-prvs: 0457F11EAF x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: OHIAUCx66VrtedzAEMm6dh56I0U7XWcqEnz7OnE1ZLT/xbaPqQJbFBSiNdneaumi8QA+c5+wt0GGbEOBZ8QWX+a3vYGnvNEs91SwQc/sBY6NMfE63kzZEgw2Yb/bG56CWxTMj3HjuCi0aNCDneaKQ7Yg+GiftXBLouVbbCxjCuHyBdVaOo0CbnXok0hHKc5EerbqvEvMeCJhw98YiKW/aUezw3JnuOnlFKOOy2JYvpWoipalwhw3f3dDs2ZuGf5E2a5rkwCC+R2shivT/f/rI8BxecpFnK+GzA2Tmllc7ZyKpatn3PF8kezWgCZwmf7/eGuD4kH97j+GBeWY061Zjv35fX/vsY2VZHQ2rrspCb6H26bGrkKf/c7CBdZD7ii2 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)(376002)(366004)(346002)(39860400002)(136003)(396003)(83380400001)(8936002)(478600001)(4326008)(316002)(33656002)(110136005)(5660300002)(54906003)(52536014)(2906002)(9686003)(55016002)(8676002)(53546011)(7696005)(6506007)(76116006)(86362001)(66446008)(64756008)(66556008)(186003)(66476007)(71200400001)(26005)(66946007)(921003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: yDlHZjXG7D4I6L6LbjpAGQEZ9Y1F00dV/tWSJmXlCTlRH0W1QdNi8fvzYd9sQcQKJO3I53+/cEw0e4ya2RHjUZCs1H27ya4pf2BX1yqkBCXpGIGnCdQCeFT2WZtjKXXYwwJqbHk5Er4XrHmEfAi1iHOJXNqYMsvqp47QypTJ6y/H9ToIh0RyWVREumfK5GfcMAcAuYX38pOi0jr+3hn/AIyc212s2ZyToIm1jjKRP0JtmuYPsngY9IlTkpyz1yaQvurRZ79q4B6stZWq0J+dKagYw3fGP3fXzXvMVqEPLJb60+qfqyscBe0NBxkshEGNf5D0ZO2u0/8yfBHgnxaFNEKE+tNbMcQ49awvgHy1BPURSxXy0AcxRBgkYWiVKAnWYbBKS9TmRDoV46RjnhBZE/XPBgUMVR20kv9qM6F3Dtxo0a3p1/DKJ3DKfPuBvu9yPwQLHQyDfGBSGh2IeYxNOmNRghsREcQm/SSIjRdT5+XtiGksDqUTm0Kv6fL+aTE1 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: fb6e6968-f763-4558-878b-08d82224dffb X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jul 2020 03:21:44.3116 (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: 3trBqKkmZnVzmG3mfv9/5OKk+vHr9+t/pjJnYLuXc7CmiQhzYKPhVDAl3Pt3LT3qA26ERVLFpEOBTnxTADycvQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3709 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v3 3/8] vhost: make some vDPA callbacks mandatory 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" > -----Original Message----- > From: Adrian Moreno > Sent: Monday, July 6, 2020 7:25 PM > To: dev@dpdk.org; Xia, Chenbo ; Ye, Xiaolong > ; shahafs@mellanox.com; matan@mellanox.com; > maxime.coquelin@redhat.com; Wang, Xiao W ; > viacheslavo@mellanox.com > Cc: jasowang@redhat.com; lulu@redhat.com > Subject: [PATCH v3 3/8] vhost: make some vDPA callbacks mandatory >=20 > From: Maxime Coquelin >=20 > Some of the vDPA callbacks have to be implemented for vDPA to work proper= ly. >=20 > This patch marks them as mandatory in the API doc and simplify code calli= ng > these ops with removing unnecessary checks that are now done at registrat= ion > time. >=20 > Signed-off-by: Maxime Coquelin > --- > lib/librte_vhost/rte_vdpa_dev.h | 14 ++++++++------ > lib/librte_vhost/socket.c | 6 +++--- > lib/librte_vhost/vdpa.c | 10 ++++++++++ > lib/librte_vhost/vhost.c | 2 +- > lib/librte_vhost/vhost_user.c | 6 ++---- > 5 files changed, 24 insertions(+), 14 deletions(-) >=20 > diff --git a/lib/librte_vhost/rte_vdpa_dev.h b/lib/librte_vhost/rte_vdpa_= dev.h > index 65557cb05..89444c2ea 100644 > --- a/lib/librte_vhost/rte_vdpa_dev.h > +++ b/lib/librte_vhost/rte_vdpa_dev.h > @@ -15,24 +15,26 @@ > * vdpa device operations > */ > struct rte_vdpa_dev_ops { > - /** Get capabilities of this device */ > + /** Get capabilities of this device (Mandatory) */ > int (*get_queue_num)(struct rte_vdpa_device *dev, uint32_t > *queue_num); >=20 > - /** Get supported features of this device */ > + /** Get supported features of this device (Mandatory) */ > int (*get_features)(struct rte_vdpa_device *dev, uint64_t *features); >=20 > - /** Get supported protocol features of this device */ > + /** Get supported protocol features of this device (Mandatory) */ > int (*get_protocol_features)(struct rte_vdpa_device *dev, > uint64_t *protocol_features); >=20 > - /** Driver configure/close the device */ > + /** Driver configure the device (Mandatory) */ > int (*dev_conf)(int vid); > + > + /** Driver close the device (Mandatory) */ > int (*dev_close)(int vid); >=20 > - /** Enable/disable this vring */ > + /** Enable/disable this vring (Mandatory) */ > int (*set_vring_state)(int vid, int vring, int state); >=20 > - /** Set features when changed */ > + /** Set features when changed (Mandatory) */ > int (*set_features)(int vid); >=20 > /** Destination operations when migration done */ diff --git > a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c index > 49267cebf..047d9395d 100644 > --- a/lib/librte_vhost/socket.c > +++ b/lib/librte_vhost/socket.c > @@ -701,7 +701,7 @@ rte_vhost_driver_get_features(const char *path, > uint64_t *features) > } >=20 > vdpa_dev =3D vsocket->vdpa_dev; > - if (!vdpa_dev || !vdpa_dev->ops->get_features) { > + if (!vdpa_dev) { > *features =3D vsocket->features; > goto unlock_exit; > } > @@ -754,7 +754,7 @@ rte_vhost_driver_get_protocol_features(const char > *path, > } >=20 > vdpa_dev =3D vsocket->vdpa_dev; > - if (!vdpa_dev || !vdpa_dev->ops->get_protocol_features) { > + if (!vdpa_dev) { > *protocol_features =3D vsocket->protocol_features; > goto unlock_exit; > } > @@ -794,7 +794,7 @@ rte_vhost_driver_get_queue_num(const char *path, > uint32_t *queue_num) > } >=20 > vdpa_dev =3D vsocket->vdpa_dev; > - if (!vdpa_dev || !vdpa_dev->ops->get_queue_num) { > + if (!vdpa_dev) { > *queue_num =3D VHOST_MAX_QUEUE_PAIRS; > goto unlock_exit; > } > diff --git a/lib/librte_vhost/vdpa.c b/lib/librte_vhost/vdpa.c index > ef21ca2a1..ae6fdd24e 100644 > --- a/lib/librte_vhost/vdpa.c > +++ b/lib/librte_vhost/vdpa.c > @@ -77,6 +77,16 @@ rte_vdpa_register_device(struct rte_device *rte_dev, > if (ops =3D=3D NULL) > return NULL; >=20 > + /* Check mandatory ops are implemented */ > + if (!ops->get_queue_num || !ops->get_features || > + !ops->get_protocol_features || !ops->dev_conf || > + !ops->dev_close || !ops->set_vring_state || > + !ops->set_features) { > + VHOST_LOG_CONFIG(ERR, > + "Some mandatory vDPA ops aren't > implemented\n"); > + return NULL; > + } > + > rte_spinlock_lock(&vdpa_device_list_lock); > /* Check the device hasn't been register already */ > dev =3D __vdpa_find_device_by_name(rte_dev->name); > diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index > aa1424261..da461e843 100644 > --- a/lib/librte_vhost/vhost.c > +++ b/lib/librte_vhost/vhost.c > @@ -646,7 +646,7 @@ vhost_destroy_device_notify(struct virtio_net *dev) >=20 > if (dev->flags & VIRTIO_DEV_RUNNING) { > vdpa_dev =3D dev->vdpa_dev; > - if (vdpa_dev && vdpa_dev->ops->dev_close) > + if (vdpa_dev) > vdpa_dev->ops->dev_close(dev->vid); > dev->flags &=3D ~VIRTIO_DEV_RUNNING; > dev->notify_ops->destroy_device(dev->vid); > diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.= c index > ff8b1752b..6be5c771b 100644 > --- a/lib/librte_vhost/vhost_user.c > +++ b/lib/librte_vhost/vhost_user.c > @@ -398,7 +398,7 @@ vhost_user_set_features(struct virtio_net **pdev, str= uct > VhostUserMsg *msg, > } >=20 > vdpa_dev =3D dev->vdpa_dev; > - if (vdpa_dev && vdpa_dev->ops->set_features) > + if (vdpa_dev) > vdpa_dev->ops->set_features(dev->vid); >=20 > return RTE_VHOST_MSG_RESULT_OK; > @@ -2849,9 +2849,7 @@ vhost_user_msg_handler(int vid, int fd) > goto out; >=20 > if (!(dev->flags & VIRTIO_DEV_VDPA_CONFIGURED)) { > - if (vdpa_dev->ops->dev_conf) > - vdpa_dev->ops->dev_conf(dev->vid); > - > + vdpa_dev->ops->dev_conf(dev->vid); > dev->flags |=3D VIRTIO_DEV_VDPA_CONFIGURED; > } >=20 > -- > 2.26.2 Reviewed-by: Chenbo Xia