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 7D121A04FD; Mon, 23 May 2022 05:54:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2C52740156; Mon, 23 May 2022 05:54:41 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 3D1634014F for ; Mon, 23 May 2022 05:54: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=1653278079; x=1684814079; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=hBl0RAZN4zfhf/cdSDIBPeQSHFjvmHhQeMLg8SusuGs=; b=CywSXgvu7wh2P8yZH6WnFZoNsNizPqGzy7szwo74i2UwCn6pP3kKuaDr I+LS1D3zGVaMMFKpBRGt3IXwmv13UfIJwf/+JKZs2pDGmHHuAcQL8qrai ZAwijs26K+Q38DuQHH0Fq+nZmRNn70blOTWUb4rFwxb6TV6y37UpZ5kvJ B+mgBpnW6AojigcdNzAmn0i0f2L7fKfgbvxhJUvCy/LHwEwPIYJDB0+Iq SG01gkC4eFlQxh+gHq10/EkS3eDpD0mWFbaiDvqfKLYhKq4vmaVHt384H HcE+sPK7T7xvR5oblWXtPgMZEZNd+RgavuN7HYUOlTyVJVMxPkYr1I1a4 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10355"; a="359486648" X-IronPort-AV: E=Sophos;i="5.91,245,1647327600"; d="scan'208";a="359486648" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2022 20:54:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,245,1647327600"; d="scan'208";a="571874001" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga007.jf.intel.com with ESMTP; 22 May 2022 20:54:37 -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.2308.27; Sun, 22 May 2022 20:54:37 -0700 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) 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.2308.27; Sun, 22 May 2022 20:54:36 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Sun, 22 May 2022 20:54:36 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.103) 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.2308.27; Sun, 22 May 2022 20:54:36 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hj5AbnFlVKV3ANHFZQMMv9nXsaCBX0OH8fMx2pah09XL5wdi4yriXRssndH14XE1mmQ2iFLqvJ2KT93OKsRG7/3+8H/xE42iHbb4KNsl5+FFDtnETuCLmFeWPGavdRV2prIrh2Mig/8BCRxIVwqQgO3n4cx8UAffDnRVPm4u4+Sif9CYQj7th2iUE3qpyBfd9gczVRqs38CHZdFRwzUbeE3hcqpiR91mvaDAEAidp3yQwLQFeNWDYagsraOKMoiwicW66TPIr2AF/xYn86u8JqDwuwO7VOxtMNARUOGtuKKoUWgiN6fpU86ewgQZb6XURWvE2SNcHo+RMx+Usgd6uw== 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=wjVcyEmfNrZlyUdv8/NGiR7WeDEcDpm7DDOhdskJiBA=; b=BdW9l8rfRpya6Mi8Z58T/fvQouVmfZE/aWmj4WlnZdVkGrdf027HEXEPYxKIVPzWIdVSKffV3d/8f3uGBgmo/g7PgxvdvNb0mGATbRnQJmeU5M6QNb/O2D+lQBaW3+Hzv/vFMEsshjjj81te8wtr4Kk0dXOuvmCBhtHx+REtj5Db0bF4HBnS/WWiavHU4zN6ah4DrE61e5ZqkPu/z43psXCwyWNw10e1vS8fiuCdm6bhaCyXvzojOpuvAtO0diRNqzsehdYVWYLwCQxfH7jjKH+/u/rOLPbSX7bK0Qnk38nmh/5A/hhoAahXuGvUVavanrMkBqyuCemCbOH2XWQQxA== 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 BN9PR11MB5338.namprd11.prod.outlook.com (2603:10b6:408:137::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.15; Mon, 23 May 2022 03:54:30 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::54e1:e802:17c8:93f]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::54e1:e802:17c8:93f%7]) with mapi id 15.20.5273.022; Mon, 23 May 2022 03:54:30 +0000 From: "Xia, Chenbo" To: "Pei, Andy" , "dev@dpdk.org" CC: "maxime.coquelin@redhat.com" , "Cao, Gang" , "Liu, Changpeng" , "Xu, Rosen" , "Xiao, QimaiX" Subject: RE: [PATCH v8 03/13] vhost: add vhost msg support for get/set config Thread-Topic: [PATCH v8 03/13] vhost: add vhost msg support for get/set config Thread-Index: AQHYardUBrKmsC7cGUuDyqmdhP41eK0r26Mg Date: Mon, 23 May 2022 03:54:30 +0000 Message-ID: References: <1643093258-47258-2-git-send-email-andy.pei@intel.com> <1652876035-70513-1-git-send-email-andy.pei@intel.com> <1652876035-70513-4-git-send-email-andy.pei@intel.com> In-Reply-To: <1652876035-70513-4-git-send-email-andy.pei@intel.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-office365-filtering-correlation-id: 85e02adf-1d8b-43ba-884b-08da3c6ff08e x-ms-traffictypediagnostic: BN9PR11MB5338:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: uiAha3I8l54ScyFzYK0LP3pKlCKU8jmfAXtMRCzkOB90zoI2gpkd5465EtPyJxCWnbyYfY8mBIAkzvmfrlZGPg25vpuMRM0uB3wKOxHf9m7VMdPktXphB41da/jUrBghpq9I7Xu99z6fifqn74GBOQYUHUomzDbf3jq9f6OZ6qc5RyzQbCWE9/NbKY5nOZ+D2faAEJRrbs9fGkU+vgaMQpW/t0lqqIHiRU/y8NseDyaahkjdCafOCs/ruhAPnMpFFXQXEOnAjfhwhHXdD3Q84vNI0r7G4ejToOowp6Y3hzoAjvgpsRQJTpbm0OE88Yy5/hnZp1zHIJ8P/RPApuvcSIQ+4ak5aZBWtfB9EkTnuVx5kE0pU0spvalite3DbQGW+u6Op2MYoaPDagzwnag4ps7JW0M6CGW1suzqMHCOZUurAgVu/OB6YoJlllrOrJwqnxhKOghkSWQI8ahoVPCTOn1KHREhJL7n3kAlmg+tkU8VhlS08WY/QSy+K2PgBOQG4EH2EqYcz9UCkSAVNepbXUhkJVKcTuVjdtxk3GjOrNnAIICXNCpEhaxvqYGKABpf9+Uduah9+MWIMPKy5Mh+feqyrdRTRjW4o8+UnNgTBdeHCRQwqyjew9iTaThmNoKgwJPWDcbsuyyDtL3dIfV69jt00DctNkkYBECFB2t0Zsj4qcS0XogxhP+Tgi7ztPoiJsMtI02ZMtFsDdC2nS1Sjg== 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:(13230001)(366004)(8676002)(64756008)(9686003)(54906003)(66476007)(110136005)(66446008)(83380400001)(76116006)(66946007)(66556008)(186003)(26005)(86362001)(4326008)(6506007)(7696005)(38100700002)(53546011)(33656002)(2906002)(55016003)(52536014)(508600001)(82960400001)(122000001)(38070700005)(107886003)(8936002)(316002)(71200400001)(5660300002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?hgXoi/W5jISXEpcUrurWzZXkZ3fXh7sOFcghVTQokNfeByYvUySgsHG3fOo1?= =?us-ascii?Q?mtW1oacvrvOko094nWzB2rU28CvxFbQLNLltnYIIJP6RbWavaWi8hubv8oah?= =?us-ascii?Q?/doqC4KBKXYqajVxBrrXzUe7+cESI+YUaQ+3/u2VSAmd66vSVlkdaqaePIrh?= =?us-ascii?Q?JFT1BBpYCv/4GuxW5p+Ddhmj8UYga44SCSj1zmkw1ZKXNWr0gZZP29Eo62/w?= =?us-ascii?Q?bX2CjxxTK885hWbI6IIyDVGUarQlZEWkYV/IBz3tdA3z0pqiSQu+mXN4xgG+?= =?us-ascii?Q?qQcfFQsDwn5C16aRFoftafV9L5u0uVDenDPgIqZLhvssXySlvhv+ZyoKxP1o?= =?us-ascii?Q?chP8VzvWK79Dh2TkPE04cANxsdIKK3h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+B3ILwQsSbLt+w9AkzjlB4NYZsiNAgld7wLUo05//MDAoitev40/xG?= =?us-ascii?Q?SrN8EvfN/AMyIotgAiY7L0fKLK+Lrqm0V9LksAkMzwun+yey/M+hprGFzJoq?= =?us-ascii?Q?wZdJ9kRPS6kZchCfrILf0e/VfeltLp9PWwEP5baP2WSfEAXuRETtINuKRd4i?= =?us-ascii?Q?9UuOtZgiG+ryHQ1MSWSVgO4Jp/LOPE5rJpvbR1WhbWn6bY7MhawdABTIjy9O?= =?us-ascii?Q?AWJqhIlEKBsnK48pJY6aFnzb72VDFnikIIddHDhnRvaRPhdlPt7xgT/iPpFP?= =?us-ascii?Q?tTVSrPL8kcoiGts+uZ0CjIQFdPyGupV+kN5daYCN9CnUIBlrab60A/g7XFkL?= =?us-ascii?Q?mAOMbIjDApmllc/OnR715Rp8w2RgVcgzQEGXNlDgoDWUP40NI9jcnBuctcDA?= =?us-ascii?Q?FqSH2CW6zRjyVR2WkJJi4ArDvAS2sQkw3Qd/qqDJaDOIQ77PgZmpsv1Tbx3U?= =?us-ascii?Q?RbjJuiRosQ=3D=3D?= 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: 85e02adf-1d8b-43ba-884b-08da3c6ff08e X-MS-Exchange-CrossTenant-originalarrivaltime: 23 May 2022 03:54:30.0943 (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: 2s6Q1ekgYxuQm19yeJkppodXN+ycOdQMwPuZF2Kqe12gUBKSRtnpc57YSJjIOq+UDZRL3/GgMHfoTDEytvqJdw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR11MB5338 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: Pei, Andy > Sent: Wednesday, May 18, 2022 8:14 PM > To: dev@dpdk.org > Cc: Xia, Chenbo ; maxime.coquelin@redhat.com; Cao, > Gang ; Liu, Changpeng ; Xu, > Rosen ; Xiao, QimaiX > Subject: [PATCH v8 03/13] vhost: add vhost msg support for get/set config >=20 > Add support for VHOST_USER_GET_CONFIG and VHOST_USER_SET_CONFIG. > VHOST_USER_GET_CONFIG and VHOST_USER_SET_CONFIG message is only > supported by virtio blk VDPA device. >=20 > Signed-off-by: Andy Pei > --- > lib/vhost/vhost_user.c | 73 > ++++++++++++++++++++++++++++++++++++++++++++++++++ > lib/vhost/vhost_user.h | 13 +++++++++ > 2 files changed, 86 insertions(+) >=20 > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c > index 850848c..1dd1e25f 100644 > --- a/lib/vhost/vhost_user.c > +++ b/lib/vhost/vhost_user.c > @@ -2468,6 +2468,77 @@ static int is_vring_iotlb(struct virtio_net *dev, > } >=20 > static int > +vhost_user_get_config(struct virtio_net **pdev, > + struct vhu_msg_context *ctx, > + int main_fd __rte_unused) > +{ > + struct virtio_net *dev =3D *pdev; > + struct rte_vdpa_device *vdpa_dev =3D dev->vdpa_dev; > + int ret =3D 0; > + > + if (validate_msg_fds(dev, ctx, 0) !=3D 0) > + return RTE_VHOST_MSG_RESULT_ERR; > + > + if (vdpa_dev->ops->get_config) { > + ret =3D vdpa_dev->ops->get_config(dev->vid, > + ctx->msg.payload.cfg.region, > + ctx->msg.payload.cfg.size); > + if (ret !=3D 0) { > + ctx->msg.size =3D 0; > + VHOST_LOG_CONFIG(ERR, > + "(%s) get_config() return error!\n", > + dev->ifname); > + } > + } else { > + VHOST_LOG_CONFIG(ERR, "(%s) get_config() not supported!\n", > + dev->ifname); > + } > + > + return RTE_VHOST_MSG_RESULT_REPLY; > +} > + > +static int > +vhost_user_set_config(struct virtio_net **pdev, > + struct vhu_msg_context *ctx, > + int main_fd __rte_unused) > +{ > + struct virtio_net *dev =3D *pdev; > + struct rte_vdpa_device *vdpa_dev =3D dev->vdpa_dev; > + int ret =3D 0; > + > + if (validate_msg_fds(dev, ctx, 0) !=3D 0) > + return RTE_VHOST_MSG_RESULT_ERR; > + > + if (ctx->msg.payload.cfg.size > VHOST_USER_MAX_CONFIG_SIZE) { > + VHOST_LOG_CONFIG(ERR, > + "(%s) vhost_user_config size: %"PRIu32", should not be > larger than %d\n", > + dev->ifname, ctx->msg.payload.cfg.size, > + VHOST_USER_MAX_CONFIG_SIZE); > + goto out; > + } > + > + if (vdpa_dev->ops->set_config) { > + ret =3D vdpa_dev->ops->set_config(dev->vid, > + ctx->msg.payload.cfg.region, > + ctx->msg.payload.cfg.offset, > + ctx->msg.payload.cfg.size, > + ctx->msg.payload.cfg.flags); > + if (ret) > + VHOST_LOG_CONFIG(ERR, > + "(%s) set_config() return error!\n", > + dev->ifname); > + } else { > + VHOST_LOG_CONFIG(ERR, "(%s) set_config() not supported!\n", > + dev->ifname); > + } > + > + return RTE_VHOST_MSG_RESULT_OK; > + > +out: > + return RTE_VHOST_MSG_RESULT_ERR; > +} I missed one thing in previous reviews: vdpa_dev pointer needed to be check= ed (Not Null) in both set/get config. Thanks, Chenbo > + > +static int > vhost_user_iotlb_msg(struct virtio_net **pdev, > struct vhu_msg_context *ctx, > int main_fd __rte_unused) > @@ -2686,6 +2757,8 @@ static int is_vring_iotlb(struct virtio_net *dev, > VHOST_MESSAGE_HANDLER(VHOST_USER_NET_SET_MTU, vhost_user_net_set_mtu, > false) \ > VHOST_MESSAGE_HANDLER(VHOST_USER_SET_SLAVE_REQ_FD, vhost_user_set_req_fd= , > true) \ > VHOST_MESSAGE_HANDLER(VHOST_USER_IOTLB_MSG, vhost_user_iotlb_msg, false) > \ > +VHOST_MESSAGE_HANDLER(VHOST_USER_GET_CONFIG, vhost_user_get_config, fals= e) > \ > +VHOST_MESSAGE_HANDLER(VHOST_USER_SET_CONFIG, vhost_user_set_config, fals= e) > \ > VHOST_MESSAGE_HANDLER(VHOST_USER_POSTCOPY_ADVISE, > vhost_user_set_postcopy_advise, false) \ > VHOST_MESSAGE_HANDLER(VHOST_USER_POSTCOPY_LISTEN, > vhost_user_set_postcopy_listen, false) \ > VHOST_MESSAGE_HANDLER(VHOST_USER_POSTCOPY_END, vhost_user_postcopy_end, > false) \ > diff --git a/lib/vhost/vhost_user.h b/lib/vhost/vhost_user.h > index ba1c5c7..c4d091e 100644 > --- a/lib/vhost/vhost_user.h > +++ b/lib/vhost/vhost_user.h > @@ -50,6 +50,8 @@ > VHOST_USER_NET_SET_MTU =3D 20, > VHOST_USER_SET_SLAVE_REQ_FD =3D 21, > VHOST_USER_IOTLB_MSG =3D 22, > + VHOST_USER_GET_CONFIG =3D 24, > + VHOST_USER_SET_CONFIG =3D 25, > VHOST_USER_CRYPTO_CREATE_SESS =3D 26, > VHOST_USER_CRYPTO_CLOSE_SESS =3D 27, > VHOST_USER_POSTCOPY_ADVISE =3D 28, > @@ -123,6 +125,16 @@ > uint16_t queue_size; > } VhostUserInflight; >=20 > +#define VHOST_USER_MAX_CONFIG_SIZE 256 > + > +/** Get/set config msg payload */ > +struct vhost_user_config { > + uint32_t offset; > + uint32_t size; > + uint32_t flags; > + uint8_t region[VHOST_USER_MAX_CONFIG_SIZE]; > +}; > + > typedef struct VhostUserMsg { > union { > uint32_t master; /* a VhostUserRequest value */ > @@ -146,6 +158,7 @@ > VhostUserCryptoSessionParam crypto_session; > VhostUserVringArea area; > VhostUserInflight inflight; > + struct vhost_user_config cfg; > } payload; > /* Nothing should be added after the payload */ > } __rte_packed VhostUserMsg; > -- > 1.8.3.1