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 72CF6A0543; Thu, 22 Sep 2022 11:35:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0F90540156; Thu, 22 Sep 2022 11:35:42 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 8D796400D7 for ; Thu, 22 Sep 2022 11:35:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663839340; x=1695375340; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=ZbfVOqXSwfVU8Qhn01RDerX9TUaWt6JyFaLNcfO/jKM=; b=myswRqAZbb66jUwbdXyBzdWL19EBxgEJVdidZwl5yrPOow+A0549CHuW iFw7mAGEqrCnwwYM5cKezt16dTarcQEFtkDzBo4vjcmMSoZQDOVNlNr/p 0mixDY91tmi5QOG/B7wtdGPhqlfu8DphB3h53X7JirzBvOWoxGZD4+Veb 98AUEv9zL9v8Mcgj+BgoYeXLpbOncsvRQYOj2mKow3p8N552uOOnjUiZw dc/3Nd0p1vK1bCZ0ewyNSCIVNDZorDxqCYtg9gfDezhPzBtGr39bWunHL ixR6Vlel5izxGZ8aypVUZPBzniIBBWMdnAt9K/nh2sc6GEDwi/yre97a2 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10477"; a="280621148" X-IronPort-AV: E=Sophos;i="5.93,335,1654585200"; d="scan'208";a="280621148" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 02:35:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,335,1654585200"; d="scan'208";a="745317275" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga004.jf.intel.com with ESMTP; 22 Sep 2022 02:35:38 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 22 Sep 2022 02:35:37 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 22 Sep 2022 02:35:37 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Thu, 22 Sep 2022 02:35:37 -0700 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.40) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Thu, 22 Sep 2022 02:35:37 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Um9v4KX8WQ2OcwKxZCSaSq1Yre4xEX9EJHjq7LQE00M2PjNcHTqIjq08/dC3h6Xd2EdJJXk9kfUBZuZS2FHgI7hJOsq8V2po9FAzz25bg7wyVo/LMlhkWyaoAJcD8b+0SbFpepwnrsLb7K5kuNbcS9SZ1U9oSMwNp4z8K6CP/LvNMge81kLxLUAqHMdLpCxYrGLSWAZKgGJsDK2LyGPSMBOENg6wnNr4/8+zTW9YfDjxXEQifS4ub1T5H96NC/sKwhP/uhC95Eds0lCQIe1jmvIHWXeaYxRxcec1QV5qhB5ADEHpY4Lw+Zb6EApK4RzNfBK1XKIbRhvxSyO6HZf1ZQ== 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=Cbib+N9Nmwmb0T5xd7HYhgF10FdW+fzW/GoZwFG8RgI=; b=W2WSUb2uiIORivGme/uu+FBayDRLlS3qBWtB8CIBPLcZ/6kZfWK8PSgIA0kb3W5UzhRjnj7I6QtbSI2Ll3xOkfFW6qK1pEuSYuUrWKuvmSeKguBCAgvMtK/iCBHklD5WGfj7N/U+yI2icj68k6wROhpB4ymbwVNYbHFU55cY/daR/wGXerFVCwHH+pX/HtBDlBYwxueW2GaXqrveHdhpJj69PdUzsjxDY9BYy4K67tbYOWcKkU7WlXOnGhQTIbvD8wpIp0HGlqww2T9PyNkgNpLIaXOyRGf1OO5QmDWjoakLDNVIIJCCQJCwUdZicIK2m/3QJqsYYShoTcwpKsbM9A== 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 CH0PR11MB5508.namprd11.prod.outlook.com (2603:10b6:610:d7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.19; Thu, 22 Sep 2022 09:35:35 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::408e:79cb:b715:b8ac]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::408e:79cb:b715:b8ac%4]) with mapi id 15.20.5654.018; Thu, 22 Sep 2022 09:35:35 +0000 From: "Xia, Chenbo" To: Kangjie Xu , "maxime.coquelin@redhat.com" CC: "dev@dpdk.org" , "xuanzhuo@linux.alibaba.com" , "hengqi@linux.alibaba.com" , "jasonwang@redhat.com" , "mst@redhat.com" Subject: RE: [PATCH v2 2/2] vhost: introduce VHOST_USER_RESET_VRING Thread-Topic: [PATCH v2 2/2] vhost: introduce VHOST_USER_RESET_VRING Thread-Index: AQHYwNpXqyDLL9Gn8EWeD4O0LScN663rSgjQ Date: Thu, 22 Sep 2022 09:35:35 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.6.500.17 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_|CH0PR11MB5508:EE_ x-ms-office365-filtering-correlation-id: 37b18fa6-fe18-45b5-151f-08da9c7dcd44 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 7sediCZjdMFXb6PkNyFdU1PqAfArGVI/P39b6ngzF6R2cEpBFc8x8GwybbnxoMItZPX+BctGcnPi5mgUPkrEIJAj2tT0qFmb2JUNgLHVRaa+vRbXuwS2YpbcEA5XGjFtDjDj19hN4e1GItuBRoS7pIEM1UrndM6eXQf5kTvxI/x5t+t37L+vVj5sylTj7j1zsBUoF5ksRR07qz0omAGuzEO26JUudvc0nhRT1ePLYQQeaTji5oR15W6eCO8y0s4zY3TUADNQ4vkBXQDkIETU3lw4M6TW5bm20A00bOQu/rXK8gkkAydCwOSV2pV2tbO1NsjWA2f+Qd+MtLDk6jadpilI+hfPdgi7o6ylKDFRl0NAC5PujvgH/APbiG+m1jzz4aJexEVGeFC79IWAGYFZK+yw+RylpRBqKpxVOxNObtCNX5nfCjBszzSdSZVmkCjhDw/BHn3JMxFuzL6txrDcugtDdb8qckL4WphlnQ9TmngTzflXpAycNa/G65M97Ct1Kd48DrXHb79nCBLjFbhZbfRY05AZhNTOE9PWFZ1ncpxYIrcoixY0JUK8JdNYM388cHUW1/uj2nfZF3DNL8EHODloo7kqGsvwM2+gtxcKk4XngLxGwComoo5zWEPxpQuaJXmPQx6tlZeQzV/SpI4u2VFlQLKyMqm7qvs8cdZ+HBRF8vU9o6aqs5VSZWqy1bO3HChXZvFub0SzWkKoDhDv/MCBj+5Pp2wAx3PmIq0T4TAFglqMZwrwO5kxUYk9xTxPZq9AA0LUxg9Z1erDIKxKDQ== 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:(13230022)(39860400002)(366004)(396003)(376002)(136003)(346002)(451199015)(52536014)(2906002)(5660300002)(8676002)(4326008)(66446008)(64756008)(41300700001)(66476007)(66556008)(66946007)(122000001)(71200400001)(110136005)(38070700005)(38100700002)(54906003)(9686003)(8936002)(316002)(26005)(6506007)(7696005)(53546011)(478600001)(33656002)(76116006)(86362001)(82960400001)(55016003)(83380400001)(186003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?478g2QF56tuHe8ZujnkGhMo1Gf69Eg8arp+i/MvDkNUIGQ4akvfa3vUtRnAZ?= =?us-ascii?Q?NGKec1B7TsiI5/zTROC3wWxfK/r9qkhJ80R4j4JfDucGc5CxBJsjBXhPeRHu?= =?us-ascii?Q?oXBMNwVlRlzmoW2pTJcCypE8467MEuTUm05zPX8jAVNTt/qUcOaoe2uGEkgt?= =?us-ascii?Q?YhHYA+8E6/9gdxkvZ4e55fS+PhWspwsSrmL3NBhO1B4D6kHRN13iD8AJ+4sF?= =?us-ascii?Q?dFsmQDOgdSGM7vsdV8c+ioMAyVbXhx4pCKxz7UD/HLNLkORNKl0byMxQsaVZ?= =?us-ascii?Q?4m6nwaeRU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r?= =?us-ascii?Q?WuMM2f8naYDOpO53oIim7PQOqiL/OOIRtTrJW9iOD/Ok37yJ0swYGGXoOwf6?= =?us-ascii?Q?VE0doUin01jkTzLzSOSOc5+3cnhVoY/58muhc+g8FVcbjAn/RWqGD/XJhVrW?= =?us-ascii?Q?rQ9KdNHfBTS8IgGESNN2TMVruoCN4laEVklfbk24axjXjfjMegotr5h7qnJW?= =?us-ascii?Q?W0EfL5yoB3Bxv2wKHcR4lpMWaLldfQqJzKWfvZRsiRmqn3wTzHqptLETXa1O?= =?us-ascii?Q?TUMyxhj+EEIL192s0rryJt1TKuETInC6CUGwna9DWOI2VCP04RNgUuHSAqDw?= =?us-ascii?Q?F0p+Y8k82l/PxRQbtgWKGPosspB9PRtWnkovip6qZy9kvoPRwVqAZY3HUId0?= =?us-ascii?Q?O4AqVcQfWgEde9c1R1YjS3ojFz1K9s9sC5hygH2A?= 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: 37b18fa6-fe18-45b5-151f-08da9c7dcd44 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Sep 2022 09:35:35.4513 (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: Uvy3PJ2S4x1x94caW4vXfF7y2nSaSf8fKo6GkMz+NKCpCt5EiBqgfW1EAgW6o1sf+W2v78DnpCov/y8hTaP1kw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR11MB5508 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: Kangjie Xu > Sent: Monday, September 5, 2022 11:48 AM > To: maxime.coquelin@redhat.com; Xia, Chenbo > Cc: dev@dpdk.org; xuanzhuo@linux.alibaba.com; hengqi@linux.alibaba.com; > jasonwang@redhat.com; mst@redhat.com > Subject: [PATCH v2 2/2] vhost: introduce VHOST_USER_RESET_VRING >=20 > To support the reset operation for an individual virtqueue, we > introduce a new message VHOST_USER_RESET_VRING. When the feature > VIRTIO_F_RING_RESET feature has been successfully negotiated, This > message is submitted by the front-end to reset an individual > virtqueue to initial states in the back-end. The reply is needed > to ensure that the reset operation is complete. completed >=20 > Signed-off-by: Kangjie Xu > Signed-off-by: Xuan Zhuo > --- > lib/vhost/vhost.c | 2 +- > lib/vhost/vhost.h | 1 + > lib/vhost/vhost_user.c | 27 ++++++++++++++++++++++++++- > lib/vhost/vhost_user.h | 1 + > 4 files changed, 29 insertions(+), 2 deletions(-) >=20 > diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c > index 60cb05a0ff..215a1ca355 100644 > --- a/lib/vhost/vhost.c > +++ b/lib/vhost/vhost.c > @@ -610,7 +610,7 @@ init_vring_queue(struct virtio_net *dev, uint32_t > vring_idx) > vhost_user_iotlb_init(dev, vring_idx); > } >=20 > -static void > +void > reset_vring_queue(struct virtio_net *dev, uint32_t vring_idx) > { > struct vhost_virtqueue *vq; > diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h > index 76461a3406..eccb52842d 100644 > --- a/lib/vhost/vhost.h > +++ b/lib/vhost/vhost.h > @@ -791,6 +791,7 @@ get_device(int vid) >=20 > int vhost_new_device(void); > void cleanup_device(struct virtio_net *dev, int destroy); > +void reset_vring_queue(struct virtio_net *dev, uint32_t vring_idx); > void reset_device(struct virtio_net *dev); > void vhost_destroy_device(int); > void vhost_destroy_device_notify(struct virtio_net *dev); > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c > index 4ad28bac45..5f7743d9d9 100644 > --- a/lib/vhost/vhost_user.c > +++ b/lib/vhost/vhost_user.c > @@ -2771,6 +2771,30 @@ vhost_user_set_status(struct virtio_net **pdev, > return RTE_VHOST_MSG_RESULT_OK; > } >=20 > +static int > +vhost_user_reset_vring(struct virtio_net **pdev, > + struct vhu_msg_context *ctx __rte_unused, > + int main_fd __rte_unused) > +{ > + struct virtio_net *dev =3D *pdev; > + int index =3D (int)ctx->msg.payload.state.index; Why not just use unsigned int? > + > + VHOST_LOG_CONFIG(dev->ifname, INFO, "reset queue: queue idx: %d\n", > index); > + > + if (!(dev->features & (1ULL << VIRTIO_F_RING_RESET))) { > + return RTE_VHOST_MSG_RESULT_ERR; > + } braces {} are not necessary for single statement blocks > + > + dev->virtqueue[index]->enabled =3D false; > + reset_vring_queue(dev, index); > + > + ctx->msg.payload.state.num =3D 0; > + ctx->msg.size =3D sizeof(ctx->msg.payload.u64); > + ctx->fd_num =3D 0; > + > + return RTE_VHOST_MSG_RESULT_REPLY; > +} IIUC, before this handler, we need to lock the queue? Using vhost_user_lock= _all_queue_pairs BTW, is this support merged in QEMU now? I remember for similar cases, we wait for QEMU to merge first and then merge in DPDK. Maxime, do I remember this correctly? Thanks, Chenbo > + > #define VHOST_MESSAGE_HANDLERS \ > VHOST_MESSAGE_HANDLER(VHOST_USER_NONE, NULL, false) \ > VHOST_MESSAGE_HANDLER(VHOST_USER_GET_FEATURES, vhost_user_get_features, > false) \ > @@ -2803,7 +2827,8 @@ VHOST_MESSAGE_HANDLER(VHOST_USER_POSTCOPY_END, > vhost_user_postcopy_end, false) \ > VHOST_MESSAGE_HANDLER(VHOST_USER_GET_INFLIGHT_FD, > vhost_user_get_inflight_fd, false) \ > VHOST_MESSAGE_HANDLER(VHOST_USER_SET_INFLIGHT_FD, > vhost_user_set_inflight_fd, true) \ > VHOST_MESSAGE_HANDLER(VHOST_USER_SET_STATUS, vhost_user_set_status, fals= e) > \ > -VHOST_MESSAGE_HANDLER(VHOST_USER_GET_STATUS, vhost_user_get_status, fals= e) > +VHOST_MESSAGE_HANDLER(VHOST_USER_GET_STATUS, vhost_user_get_status, fals= e) > \ > +VHOST_MESSAGE_HANDLER(VHOST_USER_RESET_VRING, vhost_user_reset_vring, > false) >=20 > #define VHOST_MESSAGE_HANDLER(id, handler, accepts_fd) \ > [id] =3D { #id, handler, accepts_fd }, > diff --git a/lib/vhost/vhost_user.h b/lib/vhost/vhost_user.h > index 8ecca68597..51cb2fc74a 100644 > --- a/lib/vhost/vhost_user.h > +++ b/lib/vhost/vhost_user.h > @@ -60,6 +60,7 @@ typedef enum VhostUserRequest { > VHOST_USER_SET_INFLIGHT_FD =3D 32, > VHOST_USER_SET_STATUS =3D 39, > VHOST_USER_GET_STATUS =3D 40, > + VHOST_USER_RESET_VRING =3D 41 > } VhostUserRequest; >=20 > typedef enum VhostUserSlaveRequest { > -- > 2.32.0