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 BDE5AA0C41; Wed, 23 Jun 2021 09:53:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4018D4003F; Wed, 23 Jun 2021 09:53:37 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 1D6F94003E for ; Wed, 23 Jun 2021 09:53:34 +0200 (CEST) IronPort-SDR: XHwtOPBIVsj+DusfyaKz/uRSTcznuOtodPUiDmdoIwT4moM1gFkBxxMCRQyH4C4CbMRODvBWRA EZRwxGat3Q0w== X-IronPort-AV: E=McAfee;i="6200,9189,10023"; a="207031499" X-IronPort-AV: E=Sophos;i="5.83,293,1616482800"; d="scan'208";a="207031499" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2021 00:53:31 -0700 IronPort-SDR: RSCJHpyIammnkGZkFpbLsrx+o/VfpAkvvQ2Jt0Ts4Xtv2txUgODOYEABmcm+CbRAxlEGioIG3P kqN+Dxambb4w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,293,1616482800"; d="scan'208";a="423613238" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga002.jf.intel.com with ESMTP; 23 Jun 2021 00:53:31 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Wed, 23 Jun 2021 00:53:31 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Wed, 23 Jun 2021 00:53:31 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4 via Frontend Transport; Wed, 23 Jun 2021 00:53:31 -0700 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (104.47.56.49) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.4; Wed, 23 Jun 2021 00:53:30 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SFeiLgENkn+1hI+4ES3Cpv/NguAZwjAp2j73nQNpqNwSR0FHe8zwbvxggZtquknonJiVWbRVBP0c5SF3dEELhoYSon3CSsKT7RfUObAj8uz5N5oKD8UE2lmZh6lg5uoDHBzPIJfmVxmi7BJdz7wvs56MSjw1JH20SOVCqof6eGXAppYvEqgLaIKPMiHXuxwgAc3+JsVYTwNXeNATr7VeewMTVq//VC3js1RPb97Vhmj9Z3YGf6vc2VXMEZGv1JDTlh+d+GW7pKGXWj1/2Z3GinOSSNgkctXxKjQjUBr85t4MD2ZZfQMGwdQlsCLameWEAwLNZJl3l7L6YpleYkBLsA== 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=LQPshBXIkYk52caUKusqF27x/7z89rBm7GSJ+V0Xk3M=; b=Kqx8TQ9Bfr5mu51unDKdPQZcpzBQBqqlHhkM9RIxvXBbp/qkV2SlCwvl2vX/IYneyNDRoHNEK2TQb1QW1FpEzg+pRpBrtEmHGaBUjTxldE/qLyKM0pL1Vw/2JIQmnLhXAbNg5APZhJr0bV+zGEB6Wu5C36Yp9dVg/J+s+oqj2u8D7QNzJewwm1bzMVkWRSjuahcVTEmljLlXuHJ5dLeFL49yJFjmhQynLfqjs1oU6Mw+dC0QiBSu8QPDtL5LxggTWWABP1PsZJTHnMGAas5JFbJNZ6kRyPI1I+R1PvcG31QnOvi0ngMUU7pEqY3yW8sUPGNwYoqATXWWHGVKpfVWOg== 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=LQPshBXIkYk52caUKusqF27x/7z89rBm7GSJ+V0Xk3M=; b=C0Xc0wJPXXW0TA0SsR1/MYz6DP/c/5YSYK7Xc43yh8+ixVGngYQETTYjlCdry2dzcokhLV4DrML9DN/zcMi6V915DE7j09p/6GnQawAxNh9wKP/6FcuwOKPFgdjiP78apjj9ZD1jyx1g/eAi9c84GwUM0E2t8hBXEYGeHSPZKdQ= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) by MN2PR11MB4094.namprd11.prod.outlook.com (2603:10b6:208:152::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.21; Wed, 23 Jun 2021 07:53:29 +0000 Received: from MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::d447:3a7a:aad7:4d32]) by MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::d447:3a7a:aad7:4d32%7]) with mapi id 15.20.4242.023; Wed, 23 Jun 2021 07:53:29 +0000 From: "Xia, Chenbo" To: Maxime Coquelin , "dev@dpdk.org" , "amorenoz@redhat.com" , "david.marchand@redhat.com" Thread-Topic: [PATCH v2 2/3] net/virtio: add device config support to vDPA Thread-Index: AQHXY4OLgi7QXefMrkScESlUcfEWIashQmAA Date: Wed, 23 Jun 2021 07:53:28 +0000 Message-ID: References: <20210617141718.173396-1-maxime.coquelin@redhat.com> <20210617141718.173396-3-maxime.coquelin@redhat.com> In-Reply-To: <20210617141718.173396-3-maxime.coquelin@redhat.com> 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.5.1.3 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.55.46.52] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 119ae534-2dce-4bd6-270a-08d9361bfd71 x-ms-traffictypediagnostic: MN2PR11MB4094: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1824; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 2d3rcyv2f+PjmmawBHqdKRvlPUIFatSxujRd6GTFQKJZDOU/EQjqs2Ko9hK3byPmlBtfqf5XgVMG61lma6uw57pwvsIKafkfZLb1d6v7cldf9EZuvFbDM7EMsXkeQaqThyjBo597NV8jbr3DJFA3loe9+7ZCqpZKxAcaqSN7122S59c4cruwZYksuF/WwoGiY/stJaAX0GL+Fd8LLLWzvFzbq2A36DEXLj9XuzSy69sItg5PO4/D5PBxNbTNE0MG3qIj15n1wfMdMKytD1iiKosHJO8x/frXxjdSdaVVhCc9PL9jnMh0TVUwa1ez5Cz1NoGtIUmvlIY2O08fy7FPROhlKSPIdA942DOWeWAwzKQVwtoMa6UCgD0lSek5SmSV3Sc1oC78eqg9hR62L1RjWCPMC2B63ibRDQBu3GNXf7O7cVAdNKzqQoXDQ6w5IbEXNSlXfgAqDL21w0lJCYnqDPbggP4ZeuJIr3wyrTkkohz2aBp3RTosAE8uTBCsyELfTgfynmdeaa2NOgnfhnUySv3dRLlg/Cr3gI6OfDk3vqA0GkKQF6sqDzVimgNXkqRw7qbFRBNgyuynxDNQjp/fnfOh08k+649ZIHlLxv/gJmSlLnrtqqqi1a3hMSy7YLRRq9S1BBGqVbpiciKz48meew== 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; SFS:(376002)(136003)(39860400002)(346002)(396003)(366004)(71200400001)(66446008)(26005)(64756008)(66946007)(186003)(76116006)(316002)(110136005)(122000001)(38100700002)(5660300002)(33656002)(66556008)(66476007)(8676002)(53546011)(52536014)(83380400001)(86362001)(9686003)(55016002)(2906002)(7696005)(6506007)(478600001)(8936002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?3RJ9JSh4fzTfF0Oi6dNQuWiy90qBKpLM8jfTlv2fJSYOKThGMJY4lfbGMBIZ?= =?us-ascii?Q?HaCEQz/0bjIsadxiklAp0M2znZL4HAZswo0UrmOw6zZ/qdyxanAulKgu/WjD?= =?us-ascii?Q?osubkDO7wsRtkNozdGB/snQIYu7bj7olLo+k4FIf5r/VKwMznwna5IHSIfVF?= =?us-ascii?Q?6ChQN+6X0EMHTp9kwhqOzs+i1N4Kz1OPfO6vdUmJTyX+zGfs51ihZ19kEErF?= =?us-ascii?Q?eBZeIttCfU5Py1xHjLNUY72yNpYYp18XFgstXD2QoHvPsul2dih/VFh7wVk0?= =?us-ascii?Q?jDKjXyc1iLy41VxR5p6WexBRy6KL0wP69bno/1C2DbBhzdolSTA1yjoNgBIe?= =?us-ascii?Q?lw+YAyJNNOv/M2of/FRYgxDZcEOZe5GXEVX1/rjQRR6Vbyugxz1CH5c4a7Bu?= =?us-ascii?Q?WCmmi49M5EkCp4Tb2bh0l57vzmaU2sA4Ytn2tJJgsXSKCrPKHWx4RPnvJVCI?= =?us-ascii?Q?2eplHZeUn+jGy3wFzh1gSbuQ1G66OZ3XAjFMSYVlpyftLEy1VOXgwkicbwVG?= =?us-ascii?Q?099k6BbeWTaFiCFmeA/kXz+kLpCgqHI3fmblvRzJHRd28EgIg5KT7wPb/mH8?= =?us-ascii?Q?gdXr6JGoDeBwGFPoQZQkPRC4uVu4gw+0KWBpZi7DhR0eqkQ82W1bD0mzvNA7?= =?us-ascii?Q?mYGiD3MxgvjmQGbvmByA1ZMTb6ethKtG3Ujj50yngjEKw7Ej01H2dOl+UsDe?= =?us-ascii?Q?HJbEG7EYMAAFql68ZAKCdZk8fbqu3kYY27hgNX0OHvm/WoRY2MyIEI+ZLPKW?= =?us-ascii?Q?8kHdnmtYWzqjIers5cjciUk1vaUgrJxY5669wIONu0MeKEOcGt/Ib7qf9CVs?= =?us-ascii?Q?RvWtx7BDx5J1dYb81NF2u7mSv7n2tQIRvWwIU4fd7HjGe6hM0jQ0N3EYUuXx?= =?us-ascii?Q?RPnl4n2hJaNMHA8aoUSOU8QxOlzbnj0BYrXKCy5SBEYC/oO5SWFDdY10w4Wf?= =?us-ascii?Q?gFBPBjCZZdknwL94pBEM999ZoFJJV8/Q4AxmyBd9LnXNAhkqhR5b4j9oCHvW?= =?us-ascii?Q?o0G60xIeO565bISuxUNxvy8QBRjrB+IPM5n+evVKVv3Y6lLVJrLwIwsvpyYz?= =?us-ascii?Q?6pSt/7/iNDkMORyyq68EWmk104wgCHnnDFYz6gurAZdzrzIRkh4z65iCY45l?= =?us-ascii?Q?d9F86UvMbcq05jsEdU4vx/Udk4LVfutv9ctK3/7pPCKm9PBhdAw658Jz95rf?= =?us-ascii?Q?PUkc4xO3AZLeu6KzQ4PQPpEYSoTU0lVctUR6SKivXwRxBf0G606KLgBgoXlJ?= =?us-ascii?Q?EEgu9Gb48QTpoAtUMossS/tC6SlbyPv63/1EW/rzexTygfUldBmBT98MUSTt?= =?us-ascii?Q?mWU=3D?= x-ms-exchange-transport-forked: True 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: 119ae534-2dce-4bd6-270a-08d9361bfd71 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jun 2021 07:53:29.2294 (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: FwK5i52DViYz2XEdOUE1k04KnaaHUd3W8fBO4R39nAXwIONhbez9ej9V+mrreg4sWWaD5zMyw6TZk7ni5SV6nw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4094 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v2 2/3] net/virtio: add device config support to vDPA 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 Sender: "dev" > -----Original Message----- > From: Maxime Coquelin > Sent: Thursday, June 17, 2021 10:17 PM > To: dev@dpdk.org; Xia, Chenbo ; amorenoz@redhat.com= ; > david.marchand@redhat.com > Cc: Maxime Coquelin > Subject: [PATCH v2 2/3] net/virtio: add device config support to vDPA >=20 > This patch introduces two virtio-user callbacks to get > and set device's config, and implements it for vDPA > backends. >=20 > Signed-off-by: Maxime Coquelin > --- > drivers/net/virtio/virtio_user/vhost.h | 3 + > drivers/net/virtio/virtio_user/vhost_vdpa.c | 69 +++++++++++++++++++++ > 2 files changed, 72 insertions(+) >=20 > diff --git a/drivers/net/virtio/virtio_user/vhost.h > b/drivers/net/virtio/virtio_user/vhost.h > index c49e88036d..dfbf6be033 100644 > --- a/drivers/net/virtio/virtio_user/vhost.h > +++ b/drivers/net/virtio/virtio_user/vhost.h > @@ -79,6 +79,9 @@ struct virtio_user_backend_ops { > int (*set_vring_addr)(struct virtio_user_dev *dev, struct > vhost_vring_addr *addr); > int (*get_status)(struct virtio_user_dev *dev, uint8_t *status); > int (*set_status)(struct virtio_user_dev *dev, uint8_t status); > + int (*get_config)(struct virtio_user_dev *dev, uint8_t *data, > uint32_t off, uint32_t len); > + int (*set_config)(struct virtio_user_dev *dev, const uint8_t *data, > uint32_t off, > + uint32_t len); > int (*enable_qp)(struct virtio_user_dev *dev, uint16_t pair_idx, int > enable); > int (*dma_map)(struct virtio_user_dev *dev, void *addr, uint64_t > iova, size_t len); > int (*dma_unmap)(struct virtio_user_dev *dev, void *addr, uint64_t > iova, size_t len); > diff --git a/drivers/net/virtio/virtio_user/vhost_vdpa.c > b/drivers/net/virtio/virtio_user/vhost_vdpa.c > index e2d6d3504d..3d65f0079a 100644 > --- a/drivers/net/virtio/virtio_user/vhost_vdpa.c > +++ b/drivers/net/virtio/virtio_user/vhost_vdpa.c > @@ -41,6 +41,8 @@ struct vhost_vdpa_data { > #define VHOST_VDPA_GET_DEVICE_ID _IOR(VHOST_VIRTIO, 0x70, __u32) > #define VHOST_VDPA_GET_STATUS _IOR(VHOST_VIRTIO, 0x71, __u8) > #define VHOST_VDPA_SET_STATUS _IOW(VHOST_VIRTIO, 0x72, __u8) > +#define VHOST_VDPA_GET_CONFIG _IOR(VHOST_VIRTIO, 0x73, struct > vhost_vdpa_config) > +#define VHOST_VDPA_SET_CONFIG _IOW(VHOST_VIRTIO, 0x74, struct > vhost_vdpa_config) > #define VHOST_VDPA_SET_VRING_ENABLE _IOW(VHOST_VIRTIO, 0x75, struct > vhost_vring_state) > #define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64) > #define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64) > @@ -65,6 +67,12 @@ struct vhost_iotlb_msg { >=20 > #define VHOST_IOTLB_MSG_V2 0x2 >=20 > +struct vhost_vdpa_config { > + uint32_t off; > + uint32_t len; > + uint8_t buf[0]; > +}; > + > struct vhost_msg { > uint32_t type; > uint32_t reserved; > @@ -440,6 +448,65 @@ vhost_vdpa_set_status(struct virtio_user_dev *dev, > uint8_t status) > return vhost_vdpa_ioctl(data->vhostfd, VHOST_VDPA_SET_STATUS, > &status); > } >=20 > +static int > +vhost_vdpa_get_config(struct virtio_user_dev *dev, uint8_t *data, > uint32_t off, uint32_t len) > +{ > + struct vhost_vdpa_data *vdpa_data =3D dev->backend_data; > + struct vhost_vdpa_config *config; > + int ret =3D 0; > + > + config =3D malloc(sizeof(*config) + len); > + if (!config) { > + PMD_DRV_LOG(ERR, "Failed to allocate vDPA config data"); > + return -1; > + } > + > + config->off =3D off; > + config->len =3D len; > + > + ret =3D vhost_vdpa_ioctl(vdpa_data->vhostfd, VHOST_VDPA_GET_CONFIG, > config); > + if (ret) { > + PMD_DRV_LOG(ERR, "Failed to get vDPA config (offset 0x%x, len > 0x%x)", off, len); > + ret =3D -1; > + goto out; > + } > + > + memcpy(data, config->buf, len); > +out: > + free(config); > + > + return ret; > +} > + > +static int > +vhost_vdpa_set_config(struct virtio_user_dev *dev, const uint8_t *data, > uint32_t off, uint32_t len) > +{ > + struct vhost_vdpa_data *vdpa_data =3D dev->backend_data; > + struct vhost_vdpa_config *config; > + int ret =3D 0; > + > + config =3D malloc(sizeof(*config) + len); > + if (!config) { > + PMD_DRV_LOG(ERR, "Failed to allocate vDPA config data"); > + return -1; > + } > + > + config->off =3D off; > + config->len =3D len; > + > + memcpy(config->buf, data, len); > + > + ret =3D vhost_vdpa_ioctl(vdpa_data->vhostfd, VHOST_VDPA_SET_CONFIG, > config); > + if (ret) { > + PMD_DRV_LOG(ERR, "Failed to set vDPA config (offset 0x%x, len > 0x%x)", off, len); > + ret =3D -1; > + } > + > + free(config); > + > + return ret; > +} > + > /** > * Set up environment to talk with a vhost vdpa backend. > * > @@ -559,6 +626,8 @@ struct virtio_user_backend_ops virtio_ops_vdpa =3D { > .set_vring_addr =3D vhost_vdpa_set_vring_addr, > .get_status =3D vhost_vdpa_get_status, > .set_status =3D vhost_vdpa_set_status, > + .get_config =3D vhost_vdpa_get_config, > + .set_config =3D vhost_vdpa_set_config, > .enable_qp =3D vhost_vdpa_enable_queue_pair, > .dma_map =3D vhost_vdpa_dma_map_batch, > .dma_unmap =3D vhost_vdpa_dma_unmap_batch, > -- > 2.31.1 Reviewed-by: Chenbo Xia