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 095CDA00C5; Sun, 5 Jul 2020 15:53:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 71BB81DC25; Sun, 5 Jul 2020 15:53:21 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 4286A1DB8B for ; Sun, 5 Jul 2020 15:53:19 +0200 (CEST) IronPort-SDR: gwTC00KgMfUqbA4zfJase2BCONGboasXmy9vkLXR3HrxhO5gghHL3EgZYs8aZWJY+mGTSlQjSX hhfm4fdTTDCQ== X-IronPort-AV: E=McAfee;i="6000,8403,9672"; a="146396105" X-IronPort-AV: E=Sophos;i="5.75,316,1589266800"; d="scan'208";a="146396105" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jul 2020 06:53:18 -0700 IronPort-SDR: d9S6USgQTN0GEyKqDCEOlnM0BfX+5aAta9CYQQIhTzBSepCasInHr81FAMCQDs/Yp5us7jRebu UFspPSVGayzg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,316,1589266800"; d="scan'208";a="267719905" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by fmsmga008.fm.intel.com with ESMTP; 05 Jul 2020 06:53:17 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sun, 5 Jul 2020 06:53:16 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Sun, 5 Jul 2020 06:53:16 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.40) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 5 Jul 2020 06:53:15 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HtNeDsKsgS6J/TtFUFi195y07JX4ft3IoH/eCmwncKs6flQnnxu0YhZjoGNlrWDNDc2yUytuQRLyEBHD9mDvEj0iYc04/Fc++31tiilfOVtLjQ5wLYQASVALnm3jntFXyghJu5DJQRgQ3VM0ntyRtzyFYQewuUuupKYqaz3YXaTd3pKNSr1Crn5zYcy0zIY0PCG4sW3KMImtykJyDn9x+vkS2Eu1e2F2r+iR6dxCpp+yf1+AU5AZvphpXVSFfg+eP8LEteViaeThZDn1g6fBE5AzaN39kUUyTnGNhYrCiCLfOjlmSPohgyoAfExslJqVJxdVOvMm5dQR7ZGKnKKTmQ== 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=QVSmckVUGt7KDP7MG38DSRa8fwyLESkjJUIzBlVmX5g=; b=M7bned+Ts1No2R/yy/+hPrra6Daf2zrX5xBBLGp+X4miDota94YdE2epCcbsyFM08UtTWKdQqzYZx3m7RqZrTOVwoM3Z3XfjsaQ4aj+pLO2gXz/whGgZT1qJEH9LDiKsnhTO/+/KpZLwvAG/WeJBowpwely5aBZLyLmqCzXDnfN3AY2NASUwtFNQqgPJjMR5Ba2DBH29SOy+WsqqxAy1EFzxe0+g66o0heq2DkARVfevo9IFaI7nqKLNYkN8NH3V6O/2KAaXxDlE7Yt9HSfTVZ8DNRoJi9cCjlW/vdVwj9w7f11DcJV7wel9/CshM4M+6BfnqCg6jKuT9WxBJA/usg== 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=QVSmckVUGt7KDP7MG38DSRa8fwyLESkjJUIzBlVmX5g=; b=lQWAFMBW5nvePX9xjEOhMw2o9sGS6fXxOQHgsJN/DlW0Nn31S3rTxUroFn/ImxyEWwDFzMof9OFaiKQY3rPZPLnIu8mgZcZieSlQBhyTP8FwM07PhybBOsw51vBLE2yeOtnj2kN7YEVhXxBt3AnVn290Mj/mQ1tGcfrLhhnUTV8= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) by MN2PR11MB3614.namprd11.prod.outlook.com (2603:10b6:208:ea::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.22; Sun, 5 Jul 2020 13:52:51 +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; Sun, 5 Jul 2020 13:52:50 +0000 From: "Xia, Chenbo" To: Adrian Moreno , "dev@dpdk.org" CC: "Wang, Zhihong" , "Wang, Xiao W" , "Yigit, Ferruh" , "maxime.coquelin@redhat.com" Thread-Topic: [PATCH v4 1/2] net/virtio: add vhost-user protocol features support Thread-Index: AQHWUVK1OGof63AymkShI/3RUp+Crqj5BAEQ Date: Sun, 5 Jul 2020 13:52:50 +0000 Message-ID: References: <20200703155727.1320821-1-amorenoz@redhat.com> <20200703155727.1320821-2-amorenoz@redhat.com> In-Reply-To: <20200703155727.1320821-2-amorenoz@redhat.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.2.0.6 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.195] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ae88317b-710a-4c43-9fd3-08d820eab545 x-ms-traffictypediagnostic: MN2PR11MB3614: 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:6790; x-forefront-prvs: 045584D28C x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: o1ojFCilbZ2DA5ze90g5Y3nkaQ2i4A0bgaczPngqBSGCpDN5kF8CICpMnZvbcS9a9pvicxDO0vGKlS9roxkZwl/OnJZ7RCsBs1UzyZvYNlOP8VLQ+gi3rUER/IqZA3L0ID56+flYdciJDwUeKDiQPhICjJWLVwusQVEyUvduR3M8ldCI+Q/OD8jKL2s48waLXKtEgpW3ZbDfry7Xr3D2CYqMxNPWf2FMkhd0SfVb5Dsfksv28mgp72ETjvGnjsIXj43zqrv0MFYvSs657azGPBQzWI8rkL2mk1lgTh7T5vjPUB3kxgCr4lbsDYC543WrTaydcCcq78gi7iuANyhRHA== 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)(346002)(366004)(396003)(39860400002)(136003)(52536014)(66946007)(66476007)(64756008)(66446008)(55016002)(66556008)(86362001)(478600001)(4326008)(110136005)(2906002)(186003)(5660300002)(8676002)(26005)(6506007)(33656002)(316002)(54906003)(8936002)(9686003)(83380400001)(53546011)(76116006)(71200400001)(7696005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: hMfbu6LVTVCV9urrEMNF4q+S+7LxaV6WdcbAk7VEqCAVAg7YquWvfiLR1Jm9JNdcarwnRvY7DOket469/jrkZBUr5NqdlbVejLFSqSr3VzNO+41ftS540ert6gt2HkgYDIkX+GhN6pWvhhTcglcHOGYxa04+iqLSXk356T+lveREvQRuwthjS2z2TbwI0pen4eIjDnAP/e+/qRuvuntG+D3zr4silzcA3b7LHkxcNn0VtXCSsHtqZQM7NXP2Ks107L6eQHSINJ7JQYEgCb0r8oAGDMUSjWoYmSbSlWILu7WGy2R5m7fKSk0khc/8BiSYnjd/CLAMssNbSTxhAlX+2oVTGD9M3Xba1AgVFD8wWkrjhB5Px3I9sGT48+PyX/DXEEzAY8Y1Ty4S9YlTEgcBGdnq/Tpt9m6CQkmASVF26enpBocpBv7lOyzggU2s61t/FtLv3svYo4UB08QwM8IOhIukp2AvAbuubCZG4/vFXoXSW5PWNaJHFED9IjdL0U4q 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: ae88317b-710a-4c43-9fd3-08d820eab545 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Jul 2020 13:52:50.7251 (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: VEdxYVh8jaBj8O87013IP+KgbHPy6mbNulFNR4tCLqQoKGl+7HLe/rQi1eBxS25fOZh60QXyAq3UX5mX1aFZAA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3614 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v4 1/2] 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" > -----Original Message----- > From: Adrian Moreno > Sent: Friday, July 3, 2020 11:57 PM > To: dev@dpdk.org > Cc: Xia, Chenbo ; Wang, Zhihong > ; Wang, Xiao W ; Yigit, > Ferruh ; maxime.coquelin@redhat.com > Subject: [PATCH v4 1/2] net/virtio: add vhost-user protocol features supp= ort >=20 > From: Maxime Coquelin >=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 | 5 +++ > .../net/virtio/virtio_user/virtio_user_dev.c | 40 ++++++++++++++++++- > .../net/virtio/virtio_user/virtio_user_dev.h | 3 ++ > drivers/net/virtio/virtio_user_ethdev.c | 20 ++++++++++ > 5 files changed, 75 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/net/virtio/virtio_user/vhost.h > b/drivers/net/virtio/virtio_user/vhost.h > index 1e784e58e..9ace1a90c 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 74b82e56e..e33067561 100644 > --- a/drivers/net/virtio/virtio_user/vhost_user.c > +++ b/drivers/net/virtio/virtio_user/vhost_user.c > @@ -241,6 +241,8 @@ const char * const vhost_msg_strings[] =3D { > [VHOST_USER_SET_VRING_KICK] =3D "VHOST_SET_VRING_KICK", > [VHOST_USER_SET_MEM_TABLE] =3D "VHOST_SET_MEM_TABLE", > [VHOST_USER_SET_VRING_ENABLE] =3D "VHOST_SET_VRING_ENABLE", > + [VHOST_USER_GET_PROTOCOL_FEATURES] =3D > "VHOST_USER_GET_PROTOCOL_FEATURES", > + [VHOST_USER_SET_PROTOCOL_FEATURES] =3D > +"VHOST_USER_SET_PROTOCOL_FEATURES", > }; >=20 > static int > @@ -269,10 +271,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 +355,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 7fb135f49..105536d35 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,27 @@ 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; > + > + 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 +503,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 3b6b6065a..56e638f8a 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 798f191c3..e51425c4f 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,25 @@ 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); > + } > + > dev->device_features |=3D dev->frontend_features; >=20 > /* umask vhost-user unsupported features */ > -- > 2.26.2 Reviewed-by: Chenbo Xia