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 0846DA00C2; Mon, 30 May 2022 07:44:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AA20840A89; Mon, 30 May 2022 07:44:46 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 3040B40A82 for ; Mon, 30 May 2022 07:44:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653889485; x=1685425485; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=vEPMdXwqWXNmtWdAde+Xg7PF1hjWlNgWKb6HDtbrqnw=; b=mWMhlrBmmF07TZdsMsumAUs7qhkC6oyCWySrjovY82Q38/WuAVBXbmAe gmJueXg1KfsDwhqROGQx06nWpBwn4CraShCG8XtaMvP3acCzBJ9+zE40h 6/dDY6NAu3XOTQfYGV4SHvIOaYLlXPloLE7iA/bvRVtRMM6c+jsBFDvL5 GUnFmmH7FUginW34a4hsdW9n6eqdJG9C3FwCjGvPkQTK4HU/02Nmvp74j pXrXHGZH3ZSoOz21tn4dpTNhK3NYrwPgC3zWPTU8MLXDLtLyg1ToDsAte lTM249pqHBq+pJf51GIj3tLVUyzNbtj2WsVBAHwmOru2onev4xNkeScry w==; X-IronPort-AV: E=McAfee;i="6400,9594,10362"; a="274901851" X-IronPort-AV: E=Sophos;i="5.91,262,1647327600"; d="scan'208";a="274901851" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 May 2022 22:44:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,262,1647327600"; d="scan'208";a="666368041" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by FMSMGA003.fm.intel.com with ESMTP; 29 May 2022 22:44:31 -0700 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Sun, 29 May 2022 22:44:30 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx608.amr.corp.intel.com (10.22.229.21) 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, 29 May 2022 22:44:30 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.175) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Sun, 29 May 2022 22:44:30 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EI4psnGlAu+dCUMO4RST39Td6VPBrdNeMs4Fy90A2pF8o587QYHnOxZXzSK6tqVh7jqNeT2ieANuHxVM3xj9x0PNr/Fr0eJsN066tswisb8gPCMj+8ql7YeaQWLILNIKPk/Lr4EDDhjhdkeNhDUrxl3FYT1Y+6mUUb/NYzfh2ESn7gHkZdmQIrd67CjJKC2Z2QacWF8VQZ7Uaf3QqVE1pqe/NVvC1pu/f9PIGF32GB7svRdrQbFgsMQ7MiS9T2axcEe0H6oF0sWv+o9PHUByvfVaVJ37b1pdxa2FSKEMWQyJAOAeozJ327mbvZZQY5LGta4M9FQvj7vUOnex/wz5zg== 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=17dGi+pdCQYFE10JIFSRA+4zF3P3UV9RQTrnn6tqr+U=; b=bYULkL5nRyycdKqWjq4DBlHYtYGbjIBGb6jvc1ShcyM029CZbV/FvATzB+B7FGpc7bYTbHV4urI5FYZ8tCNiC2BJqbChv31TTcJYCJ0PHnz3vtjbXNsNcFEBpHUvUCguwdoNxuol5nNDZYNTKVLJs9xjIGFEYj+d6oIx4/y7l4mqS3Ju3UQoNYfahzwKb11DZb2mzlouX/pRukzWisqhq6E06deFt+fz0psmoLYTBlPp55SreJdI87GtKpVkbEx4KKwNB6zSPS9/wI0o1A06X3dNqFk1zFAbNpFHaybZIRxxYP6g+Nok7A5mGQFe4zlNJViKhe7vpKuG39YAGj9wQg== 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 DM6PR11MB2585.namprd11.prod.outlook.com (2603:10b6:5:ce::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13; Mon, 30 May 2022 05:44:27 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::d4ff:ac50:621a:60e7]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::d4ff:ac50:621a:60e7%7]) with mapi id 15.20.5293.013; Mon, 30 May 2022 05:44:27 +0000 From: "Xia, Chenbo" To: "Richardson, Bruce" , "dev@dpdk.org" CC: Maxime Coquelin Subject: RE: [PATCH v2 2/2] doc/howto: add code example to virtio-user exception path doc Thread-Topic: [PATCH v2 2/2] doc/howto: add code example to virtio-user exception path doc Thread-Index: AQHYcef8hwQRK/UVuEiorlcE0+2BqK027DQA Date: Mon, 30 May 2022 05:44:27 +0000 Message-ID: References: <20220527162659.129022-1-bruce.richardson@intel.com> <20220527163643.130679-1-bruce.richardson@intel.com> <20220527163643.130679-2-bruce.richardson@intel.com> In-Reply-To: <20220527163643.130679-2-bruce.richardson@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: 547f4e47-96ea-4845-e6ed-08da41ff75ee x-ms-traffictypediagnostic: DM6PR11MB2585:EE_ x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr 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: VC4BzpI5RuDokJrzFoygtoY1EB9OekqtkOR/rUHbUVUATthaeIBoW7jLHZjgws1rGIWE9ScEEESZdWT7FnbkqHctSFntZzL5K3x/BTCs6jd5dZyI3kSMyQ6761Sl/boTdSukfwSbZ8pR7kdeRNXISF3u9lKHOIDEWaFJrcVLNqHuz/P2cJXqj/Vitjlg0/N5YuFC92Y+5RMM62Zw4TtdLX+MxZrfM5rLnc8Nxxh1OksSlaUm6JAZF+GmL1kSRu765XV1Kx5F2I7dE3/+11oXs/DGWc5xhogS07gKJitSoLddUICNJZJ7y4DpkSlYrggIC89DNUsKDF3spOLcOILz/gib4MsOzZQd025ZfdERbALHsE0CrLS3Ljfe+ShiBo5NWtB7+Dn3YobxEziBKgCH4mviaAxWqLi+BrKbrtTt9ABZaKHiuHvq+0Oh0hKr0TAXHHfQZcD3cAdjsCvr4ep2LTfdNZTlU8LTK67Ck2Uaicc2VfCAK0hjov/OyrjMAHNDE1O5I6vDA3JN/L0J3LP6xq1aA3VQjqO+SDYnL6UdmH31tU/7KQaCSzXx7D7cuKc6o8KulCr6PThcCMFGrot8hP8rfJspj8noqYx74a2Ots+KlJRSCDKRS28UO+/A/6ez5rhlvfhlFmYMbu1rmCaB5VgN2eU6U1PMky002sYMPjtkMquNUEV5kxe0PAIddwnbCiQiJB4O90Y9io42LrnPsi1sV+LuQgKU7Wkabo/5Is44xm4x7FL5fpQcGmXj80YRv+Nw0oJCBs6Cb4dNBi2kvmn/7mRhWsjwRgBILPT3N04= 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)(186003)(26005)(55016003)(508600001)(52536014)(71200400001)(8936002)(5660300002)(7696005)(6506007)(53546011)(9686003)(2906002)(33656002)(86362001)(38100700002)(38070700005)(66446008)(4326008)(8676002)(64756008)(66476007)(66946007)(122000001)(76116006)(66556008)(82960400001)(316002)(110136005)(83380400001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?XFhr6fwYGYWx3YU44KnUwCS0jj4ibZ/6x/SaQI/Zh9Ax0Uwpp4PCb3HaVix3?= =?us-ascii?Q?L8LOfMZQOhAZBpq3hRoUkJOj0nftnimREGqwzuz11wrMIQDRVN/9EU1+kJjo?= =?us-ascii?Q?qngpSIMa3Q/sWcUsfv/AAmOaAT6egQBcu8Me+2oahq8xw6e8a+LD7QoSq3o3?= =?us-ascii?Q?O4bU+9Sdl3OQMMoiw24AopMB7fRow5dFK63V2crT3++EZHRGBezJlDlU+s3P?= =?us-ascii?Q?iNDOPs7+bNL5x/Vf3mN97uxpuK43UtgwT61N8UVQXbKdu/qs6Xt/6gG4CqxP?= =?us-ascii?Q?GhwA5hodBA/MKEztiN2rvoAe4k7qyc7fuK43OMcoUqOWajwMTrNdKwiWFzoi?= =?us-ascii?Q?yhMdoCbo///4147H+PGrUenc+2DbQ137x/YY6rSDnUUq7p9skUpexC6Tr6A9?= =?us-ascii?Q?2lfeDMTybEU7j8GYhadOODm+pQDy4tW8hPfcewX1EO0pADBDjFbCN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nL5ukyZXFeGGz2dg2jV6YTkS4tOL3W3BRmFCO7TjCzz?= =?us-ascii?Q?qmoLIPe6kxiFuhr+TmC/XGiGaSgy3KGSH+MJirBNnZH7WOXgEuScjiOC/WDS?= =?us-ascii?Q?LVHsuVJsVmzmZoHiPj/tLfFt9/GFGn2dKNx0cyV1pzxkLik8yo9FMj6OpNCj?= =?us-ascii?Q?vA1wWgylUQgiuhVl1PI3mwuqWwCBWqJUN3okR4KE4/BFODNUA9IEP8jhD7s+?= =?us-ascii?Q?yGHnQUbqGO66UX+3gU9ggpwYSUs/+yel0LfLd8eckymrSxqgAl9sjq4eVbnV?= =?us-ascii?Q?/xU9fZO/yysHc6G+X8m1TpVJre9Z9kCiuqg7SFOG6gcGP6sFRIE4kOPRqLaX?= =?us-ascii?Q?8FoIsWf63a95xwdP5YS+gV6VTWWVkBjdAVzPPZ2sIWHYvH40rjViLE/G/uz6?= =?us-ascii?Q?iSuw8feJZQ=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: 547f4e47-96ea-4845-e6ed-08da41ff75ee X-MS-Exchange-CrossTenant-originalarrivaltime: 30 May 2022 05:44:27.7090 (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: xN5i2lQZEch0bThd6QZ/rcFvFKFYl74SNv8YYhnCXl1A+urCccfUqcrHs4WZNOT0TsOrPsIm2afcaL4ycQIOGA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2585 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: Richardson, Bruce > Sent: Saturday, May 28, 2022 12:37 AM > To: dev@dpdk.org > Cc: Maxime Coquelin ; Xia, Chenbo > ; Richardson, Bruce > Subject: [PATCH v2 2/2] doc/howto: add code example to virtio-user > exception path doc >=20 > The HOWTO guide for using virtio-user as an exception path to the kernel > only provided an example of how testpmd may be used for that purpose. > However, a real application wanting to use virtio-user as exception path > would likely want to create such devices from code within the app > itself. Therefore, we update the doc with instructions and a code > snippet showing how this may be done. >=20 > Signed-off-by: Bruce Richardson >=20 > --- >=20 > v2: fix http link to https > --- > .../howto/virtio_user_as_exceptional_path.rst | 55 +++++++++++++++++++ > 1 file changed, 55 insertions(+) >=20 > diff --git a/doc/guides/howto/virtio_user_as_exceptional_path.rst > b/doc/guides/howto/virtio_user_as_exceptional_path.rst > index 100376c32d..45d4ebd284 100644 > --- a/doc/guides/howto/virtio_user_as_exceptional_path.rst > +++ b/doc/guides/howto/virtio_user_as_exceptional_path.rst > @@ -157,3 +157,58 @@ For example: > /path/to/dpdk-testpmd --vdev=3Dvirtio_user0,path=3D/dev/vhost- > net,queues=3D2,queue_size=3D1024 -- \ > -i --tx-offloads=3D0x002c --enable-lro --txq=3D2 --rxq=3D2 -= - > txd=3D1024 --rxd=3D1024 >=20 > + > +Creating Virtio-User Ports within an Application > +------------------------------------------------ > + > +To use virtio-user ports within an application, > +it is not necessary to explicitly initialize those ports using EAL > arguments at startup. > +Instead, one can use the generic EAL API > +`rte_eal_hotplug_add > bb>`_ > +function to create a new instance at startup. > +For example, to create a basic virtio-user port, the following code coul= d > be used: > + > +.. code-block:: C > + > + rte_eal_hotplug_add("vdev", "virtio_user0", "path=3D/dev/vhost-net"); > + > +A fuller code example is shown below, where a virtio-user port, and henc= e > kernel netdev, > +is created for each NIC port discovered by DPDK. > +Each virtio-user port is given the MAC address of its matching physical > port > +(assuming app was run without vdev args on commandline, so all ports > auto-discovered are HW ones). > +These new virtio-user netdevs will appear in the kernel port listings as > ``virtio_user0``, You mean vhost_tap netdev here? Or? Thanks, Chenbo > +``virtio_user1``, etc., > +based on the names passed in as ``iface=3D`` via the ``portargs`` parame= ter. > + > +.. code-block:: C > + > + nb_ports =3D rte_eth_dev_count_avail(); > + > + /* Create a vhost_user port for each physical port */ > + unsigned port_count =3D 0; > + RTE_ETH_FOREACH_DEV(portid) { > + char portname[32]; > + char portargs[256]; > + struct rte_ether_addr addr =3D {0}; > + > + /* don't create virtio_user ports for other virtio_user ports */ > + if (++port_count > nb_ports) > + break; > + > + /* get mac address of physical port to use as mac of virtio_user > port */ > + rte_eth_macaddr_get(portid, &addr); > + > + /* set the name and arguments */ > + snprintf(portname, sizeof(portname), "virtio_user%u", portid); > + snprintf(portargs, sizeof(portargs), > + "path=3D/dev/vhost- > net,queues=3D1,queue_size=3D%u,iface=3D%s,mac=3D" RTE_ETHER_ADDR_PRT_FMT, > + RX_RING_SIZE, portname, RTE_ETHER_ADDR_BYTES(&addr)); > + > + /* add the vdev for virtio_user */ > + if (rte_eal_hotplug_add("vdev", portname, portargs) < 0) > + rte_exit(EXIT_FAILURE, "Cannot create paired port for > port %u\n", portid); > + > + } > + > +Once these virtio-user ports have been created in the loop, all ports, > both physical and virtual, > +may be initialized and used as normal in the application. > -- > 2.34.1