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 5C6FCA04A5; Wed, 17 Jun 2020 13:57:17 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3939E1252; Wed, 17 Jun 2020 13:57:16 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 634BD1150 for ; Wed, 17 Jun 2020 13:57:14 +0200 (CEST) IronPort-SDR: GDVHN35+RQsbWWQIva3VwRY7UNXkapXUXZf9h2NuH44qbslJuBtnV0kqZtYMVpXnjHtaOl6EHp C+E99o51/m6Q== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2020 04:57:13 -0700 IronPort-SDR: cLzzRmpfO/79jKG5f4GhCe3eDZb5BTMrJwMlVbs8u0/wxolP/c08AlK3o1CUANKm9vBGSO3Ald 4kw98wnLPr2w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,522,1583222400"; d="scan'208";a="317509140" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by FMSMGA003.fm.intel.com with ESMTP; 17 Jun 2020 04:57:13 -0700 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 17 Jun 2020 04:57:13 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 17 Jun 2020 04:57:12 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.102) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 17 Jun 2020 04:57:12 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D5YgYq/TwcH5IfC6WXvViZZoRsp1jeCXqUokE8BO2jpaRufyRbuY650dsITnQYsynijIPtmDsU8hOu+pR1NmpTskHU+m3G9l+24HNNtjkpzSsZyGikWjW3xjn3AWJ1xv8S1yJMI6kE6h2G5+YKQH30t7+GWt09APG6SWIquYY60HIaZ6sAOeStK9Kk7UgldmvwB7mJDxDqFq4P/kj/arDWe45mRxZNofb8dzVt3WG3HnB3J16ZvvLwcCg9VXRaFx5d4SYyyEjvTCGIwcBjSm1Y4Lu2F1KoKj9hF2LLl2gmCkYzjmuJ2OTjimqx6pn92GsN1vVQ1Tkf7NrgViRL2MMQ== 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=q/vJxdXDFu/tBHQoXAKA88tERMReN/PQYuMd7Gss7R8=; b=Qqdp+17x3yQw3eiU5/8ieci/tdNYkmdPx3HEipQb0s0VqCLBeHK8X2GTHfPAVBQOlGc9WO58v1ISt1On8zj/0ePV7+ZV4bz8DZtmvfg7i0bSGx2Himp7CVbCkqcL6OCPfCKoSLbnacAgAO0nOqMmKiB0dwhcKRb0uDEK107DU6rBfbKK8SB4XG5Jr2v0gfuwmCHxdJtsTQuzY6XvnXp5eBwww+mffU5pbv7hO0V5KMgU0MlkvCtEmP3YU2GxhD0PwEegBdgd2wtl7WMh2OQMjtX7sr1Yx/lwb2DVepA5QsC5mbZlL7g0rTh71dmENFpkUB1uZh6dCJA6ervraZLw0g== 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=q/vJxdXDFu/tBHQoXAKA88tERMReN/PQYuMd7Gss7R8=; b=Ooy+8T3P0TMMN256MAn0E9H3Lm4ab5jIxZWqZGDLRdRMDrs6DfPAS03YKAuxZ4aZaZHr1wd+mWfF0wug5cyrZmDBT1FCCuFigmcARHObFAIffkKnyOOy2fByoFQvaDW4jZnWuFJV9S17DXhwjYU2/KF5viLQzGHijWg0Z07O+Uc= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) by MN2PR11MB3695.namprd11.prod.outlook.com (2603:10b6:208:f2::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Wed, 17 Jun 2020 11:57:10 +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.3109.021; Wed, 17 Jun 2020 11:57:10 +0000 From: "Xia, Chenbo" To: Maxime Coquelin , "dev@dpdk.org" , "amorenoz@redhat.com" , "Ye, Xiaolong" , "shahafs@mellanox.com" , "matan@mellanox.com" Thread-Topic: [dpdk-dev] [PATCH 1/3] net/virtio: add vhost-user protocol features support Thread-Index: AQHWNMRIG5ThyfRaDEC7vpvGjGF34KjczYsw Date: Wed, 17 Jun 2020 11:57:10 +0000 Message-ID: References: <20200528074627.439192-1-maxime.coquelin@redhat.com> <20200528074627.439192-2-maxime.coquelin@redhat.com> In-Reply-To: <20200528074627.439192-2-maxime.coquelin@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.102.204.36] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: aa0159b9-2c70-4c15-b7b5-08d812b59133 x-ms-traffictypediagnostic: MN2PR11MB3695: 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-forefront-prvs: 04371797A5 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: qiQGDYP4qx3q38CcOl8IyONDV29uB7lRGygAFqamcuFPJpkuiXabcqxITxk3hhijxnmJdvVeF4pmZ4tCsRbm0UCbfdjAAGJE7bi46uOV61TW9qZm80VQ3FAFUwejzd3CmRBqFAjPE50mmhzqpCPVrcM4Tsja5l1wm8NehBETVrWSl9TL0JFpSD/lAhlhvS6Eq9FPERQjH1a39V/uQ31FHhTsFDckowoyMQghiELGsOHnFdqZ9Ue0qSpQ6hxKJhpYWzz6TyuTfZQ/vugHL/BXsnI/obzWrSHcEOOqnr2y9Qyz9tWJHElf1/P5bPSV03G3mIHKZL2ugycgTiaEfTX4mA== 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)(346002)(136003)(396003)(376002)(39860400002)(366004)(52536014)(53546011)(83380400001)(6506007)(478600001)(71200400001)(8936002)(86362001)(26005)(2906002)(5660300002)(110136005)(76116006)(66946007)(9686003)(66476007)(186003)(7696005)(55016002)(66556008)(64756008)(33656002)(316002)(66446008); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: el1kKwDMbXsx6NHZlLajNM1FYT5fAdeCg4wH+ZcIjYvvBE/UUDWO+Ls1/SRkar4D6UBhiB85+Y/R7vVGNkA848x27chUe9eZ3p9VxsO6iUnWJnf5SQM4sbbTVUdztmX0wdSWdgE8vixnx+fHbHZVIP27R+HK911ishtqxobu9M+ImJJq4zgDupfHqHCdQq3LHiRpP9fKH7nqPz8t7nCPZGw8RJUX/q7VYH0pBVM8VNqLaPVUfLl5vzqUHpwu/UafVNv5cLpg9Q0D8F4rw9ZbgX2STnNi4wpzxQNWCoYIv4zBMmuqj1PpWke750q3C1c7V9xqx4S/VklXM0V46RJALPT8obzuYInVqxgVeoUQpJeUyqBrzYbLZe29yk83DpfaPaMYulMz0eLMG+3WTtkA+Q1onU2Q6InH8GQTQoC3Eqb3HS//afNF9heCPTRHRupIT+wMZ4iJRv6UP/otF318NO6OtlL9Dl4fE0jaydRCm+x/sOhWSOSvw1pfjQ5qaOws Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: aa0159b9-2c70-4c15-b7b5-08d812b59133 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jun 2020 11:57:10.5612 (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: k8iHk7hUx/CKV/H/S4bCZKTgvq6r/iD9GyQW8vXw47xgHf+p0YnOExiAabmfo1HHFVSuH9g0bRg4JAK8zCempQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3695 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH 1/3] net/virtio: add vhost-user protocol features support 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 Maxime, > -----Original Message----- > From: dev On Behalf Of Maxime Coquelin > Sent: Thursday, May 28, 2020 3:46 PM > To: dev@dpdk.org; amorenoz@redhat.com; Ye, Xiaolong > ; shahafs@mellanox.com; matan@mellanox.com > Cc: Maxime Coquelin > Subject: [dpdk-dev] [PATCH 1/3] net/virtio: add vhost-user protocol featu= res > support >=20 > This patch adds support for Vhost-user protocol features. > It is required to support protocol features that were not in initial Vhos= t-user > specification, such as reply-ack, MTU... >=20 > Also, this patch prevents Virtio multiqueue feature negotiation if the sl= ave does > not support MQ protocol feature as stated in Vhost-user specification: > "The multiple queues feature is supported only when the protocol feature > ``VHOST_USER_PROTOCOL_F_MQ`` (bit 0) is set." >=20 > Signed-off-by: Maxime Coquelin > --- > drivers/net/virtio/virtio_user/vhost.h | 9 +++++ > drivers/net/virtio/virtio_user/vhost_user.c | 3 ++ > .../net/virtio/virtio_user/virtio_user_dev.c | 39 ++++++++++++++++++- > .../net/virtio/virtio_user/virtio_user_dev.h | 3 ++ > drivers/net/virtio/virtio_user_ethdev.c | 19 +++++++++ > 5 files changed, 71 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/net/virtio/virtio_user/vhost.h > b/drivers/net/virtio/virtio_user/vhost.h > index 1e784e58ef..9ace1a90c3 100644 > --- a/drivers/net/virtio/virtio_user/vhost.h > +++ b/drivers/net/virtio/virtio_user/vhost.h > @@ -44,6 +44,15 @@ struct vhost_vring_addr { > uint64_t log_guest_addr; > }; >=20 > +#ifndef VHOST_USER_F_PROTOCOL_FEATURES > +#define VHOST_USER_F_PROTOCOL_FEATURES 30 #endif > + > +/** Protocol features. */ > +#ifndef VHOST_USER_PROTOCOL_F_MQ > +#define VHOST_USER_PROTOCOL_F_MQ 0 > +#endif > + > enum vhost_user_request { > VHOST_USER_NONE =3D 0, > VHOST_USER_GET_FEATURES =3D 1, > diff --git a/drivers/net/virtio/virtio_user/vhost_user.c > b/drivers/net/virtio/virtio_user/vhost_user.c > index 74b82e56e4..b687665042 100644 > --- a/drivers/net/virtio/virtio_user/vhost_user.c > +++ b/drivers/net/virtio/virtio_user/vhost_user.c > @@ -269,10 +269,12 @@ vhost_user_sock(struct virtio_user_dev *dev, >=20 > switch (req) { > case VHOST_USER_GET_FEATURES: > + case VHOST_USER_GET_PROTOCOL_FEATURES: > need_reply =3D 1; > break; >=20 > case VHOST_USER_SET_FEATURES: > + case VHOST_USER_SET_PROTOCOL_FEATURES: > case VHOST_USER_SET_LOG_BASE: > msg.payload.u64 =3D *((__u64 *)arg); > msg.size =3D sizeof(m.payload.u64); > @@ -351,6 +353,7 @@ vhost_user_sock(struct virtio_user_dev *dev, >=20 > switch (req) { > case VHOST_USER_GET_FEATURES: > + case VHOST_USER_GET_PROTOCOL_FEATURES: > if (msg.size !=3D sizeof(m.payload.u64)) { > PMD_DRV_LOG(ERR, "Received bad msg size"); > return -1; > diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c > b/drivers/net/virtio/virtio_user/virtio_user_dev.c > index 7fb135f49a..3afb09df2d 100644 > --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c > +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c > @@ -151,8 +151,10 @@ virtio_user_start_device(struct virtio_user_dev *dev= ) > if (virtio_user_queue_setup(dev, virtio_user_create_queue) < 0) > goto error; >=20 > - /* Step 1: set features */ > + /* Step 1: negotiate protocol features & set features */ > features =3D dev->features; > + > + > /* Strip VIRTIO_NET_F_MAC, as MAC address is handled in vdev init */ > features &=3D ~(1ull << VIRTIO_NET_F_MAC); > /* Strip VIRTIO_NET_F_CTRL_VQ, as devices do not really need to know > */ @@ -417,13 +419,19 @@ virtio_user_dev_setup(struct virtio_user_dev *de= v) > 1ULL << VIRTIO_NET_F_GUEST_TSO6 | \ > 1ULL << VIRTIO_F_IN_ORDER | \ > 1ULL << VIRTIO_F_VERSION_1 | \ > - 1ULL << VIRTIO_F_RING_PACKED) > + 1ULL << VIRTIO_F_RING_PACKED | \ > + 1ULL << VHOST_USER_F_PROTOCOL_FEATURES) > + > +#define VIRTIO_USER_SUPPORTED_PROTOCOL_FEATURES \ > + (1ULL << VHOST_USER_PROTOCOL_F_MQ) >=20 > int > virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues= , > int cq, int queue_size, const char *mac, char **ifname, > int server, int mrg_rxbuf, int in_order, int packed_vq) { > + uint64_t protocol_features =3D 0; > + > pthread_mutex_init(&dev->mutex, NULL); > strlcpy(dev->path, path, PATH_MAX); > dev->started =3D 0; > @@ -434,6 +442,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, cha= r > *path, int queues, > dev->mac_specified =3D 0; > dev->frontend_features =3D 0; > dev->unsupported_features =3D ~VIRTIO_USER_SUPPORTED_FEATURES; > + dev->protocol_features =3D > VIRTIO_USER_SUPPORTED_PROTOCOL_FEATURES; > parse_mac(dev, mac); >=20 > if (*ifname) { > @@ -446,6 +455,10 @@ virtio_user_dev_init(struct virtio_user_dev *dev, ch= ar > *path, int queues, > return -1; > } >=20 > + if (!is_vhost_user_by_type(dev->path)) > + dev->unsupported_features |=3D > + (1ULL << VHOST_USER_F_PROTOCOL_FEATURES); > + > if (!dev->is_server) { > if (dev->ops->send_request(dev, VHOST_USER_SET_OWNER, > NULL) < 0) { > @@ -460,6 +473,26 @@ virtio_user_dev_init(struct virtio_user_dev *dev, ch= ar > *path, int queues, > strerror(errno)); > return -1; > } > + > + > + if (dev->device_features & > + (1ULL << VHOST_USER_F_PROTOCOL_FEATURES)) { > + if (dev->ops->send_request(dev, > + VHOST_USER_GET_PROTOCOL_FEATURES, > + &protocol_features)) > + return -1; > + } Should we put '}' after sending VHOST_USER_SET_PROTOCOL_FEATURES like in vi= rtio_user_server_reconnect? =20 > + > + dev->protocol_features &=3D protocol_features; > + > + if (dev->ops->send_request(dev, > + VHOST_USER_SET_PROTOCOL_FEATURES, > + &dev->protocol_features)) > + return -1; > + > + if (!(dev->protocol_features & > + (1ULL << > VHOST_USER_PROTOCOL_F_MQ))) > + dev->unsupported_features |=3D (1ull << > VIRTIO_NET_F_MQ); > } else { > /* We just pretend vhost-user can support all these features. > * Note that this could be problematic that if some feature is > @@ -469,6 +502,8 @@ virtio_user_dev_init(struct virtio_user_dev *dev, cha= r > *path, int queues, > dev->device_features =3D VIRTIO_USER_SUPPORTED_FEATURES; > } >=20 > + > + > if (!mrg_rxbuf) > dev->unsupported_features |=3D (1ull << > VIRTIO_NET_F_MRG_RXBUF); >=20 > diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h > b/drivers/net/virtio/virtio_user/virtio_user_dev.h > index 3b6b6065a5..56e638f8a6 100644 > --- a/drivers/net/virtio/virtio_user/virtio_user_dev.h > +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h > @@ -40,6 +40,9 @@ struct virtio_user_dev { > uint64_t device_features; /* supported features by device */ > uint64_t frontend_features; /* enabled frontend features */ > uint64_t unsupported_features; /* unsupported features mask > */ > + uint64_t protocol_features; /* negotiated protocol features > + * (Vhost-user only) > + */ > uint8_t status; > uint16_t port_id; > uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; > diff --git a/drivers/net/virtio/virtio_user_ethdev.c > b/drivers/net/virtio/virtio_user_ethdev.c > index 798f191c32..ccb5a18e25 100644 > --- a/drivers/net/virtio/virtio_user_ethdev.c > +++ b/drivers/net/virtio/virtio_user_ethdev.c > @@ -68,6 +68,7 @@ virtio_user_server_reconnect(struct virtio_user_dev *de= v) > int connectfd; > struct rte_eth_dev *eth_dev =3D &rte_eth_devices[dev->port_id]; > struct virtio_hw *hw =3D eth_dev->data->dev_private; > + uint64_t protocol_features; >=20 > connectfd =3D accept(dev->listenfd, NULL, NULL); > if (connectfd < 0) > @@ -81,6 +82,24 @@ virtio_user_server_reconnect(struct virtio_user_dev *d= ev) > return -1; > } >=20 > + if (dev->device_features & > + (1ULL << VHOST_USER_F_PROTOCOL_FEATURES)) { > + if (dev->ops->send_request(dev, > + > VHOST_USER_GET_PROTOCOL_FEATURES, > + &protocol_features)) > + return -1; > + > + dev->protocol_features &=3D protocol_features; > + > + if (dev->ops->send_request(dev, > + > VHOST_USER_SET_PROTOCOL_FEATURES, > + &dev->protocol_features)) > + return -1; > + } > + > + if (!(dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_MQ))) > + dev->unsupported_features |=3D (1ull << VIRTIO_NET_F_MQ); Should we consider the case that vhost-user does not support VHOST_USER_F_P= ROTOCOL_FEATURES but support VIRTIO_NET_F_MQ? Because if the device negotiated feature does not include = that, we should not use above logic to decide whether MQ is supported. If the case should be considered, the above two li= nes should be moved into last '{}' and same thing should be done in virtio_user_dev_init. Thanks! Chenbo > + > dev->device_features |=3D dev->frontend_features; >=20 > /* umask vhost-user unsupported features */ > -- > 2.26.2