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 11E32A0548; Wed, 15 Jun 2022 03:48:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B87CE40222; Wed, 15 Jun 2022 03:48:54 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 6E14C40220 for ; Wed, 15 Jun 2022 03:48:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655257732; x=1686793732; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=f+QaP5HwHc5cqbHNh1lmkRb3XhmBHDwQDhylkcB00P4=; b=Ty95wjhftBraAyYbep4+vB+6rZTARrfg0LNQGb6554yvw/hrV0IxltSO BF81yasHa1KX4d3BUqNYxvI9wrBGly4YpvXcrs+1IjKNIlrPCXGmsipuF 3uzO7G3QfCyp1s+BJRDx2wDgvX3FjsgPChh1uc5hz+tb+DpM0cK4Er10i CA7gLKMifJKM9FuY3rICwmtWIfROJW9AsTBxH964j+x1Nr1bZu2ClCmNF z9VV5Pa6fYEja/IgSQ81elgOT/GOYW7N2W4hoMhq/mFav4AKRv9y+fic6 GPR/29qFcx0cwkBLln5Ez3DwSX1inUyekA7fdF4LdsRrwyyzO5PV096+M g==; X-IronPort-AV: E=McAfee;i="6400,9594,10378"; a="261827652" X-IronPort-AV: E=Sophos;i="5.91,300,1647327600"; d="scan'208";a="261827652" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2022 18:48:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,300,1647327600"; d="scan'208";a="762229443" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by orsmga005.jf.intel.com with ESMTP; 14 Jun 2022 18:48:51 -0700 Received: from orsmsx604.amr.corp.intel.com (10.22.229.17) 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; Tue, 14 Jun 2022 18:48:50 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Tue, 14 Jun 2022 18:48:50 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.174) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Tue, 14 Jun 2022 18:48:50 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fALfRqgrgYeQCjU2MBjLH3SuK474OMJgAY4/3aGTU+QcFcTGmd2MsVb1oKm/CPNbbr3DfvCvJXdKjiza89P/ruBSu3n/a1dfOk1TXKBGl3LCwgkkInQU4aLj8dwYzLXK0ZVB7JE0BEazMCVa+uH9WVchV/70qbdla5lncbIRoUkLQ5cA3LFtg3BFP5Wyf5oxlHdInYDxpnu+mNio+zn0tmLaLv9wrxDKgFWTHKmoKU1/AW9sSfzwDSeSayEm8d2GJ/FKmybqN5Yw/BbRVeWwYYeFfKJSgTJJpQXg1XRI/8M2iqaBKdao3hW/cWAg2gvbYg50056gMKZmk34WQkQUlA== 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=uly0i9C4oOANbDNkMIi/WI6nPpt2oSSkU62WBs57/tw=; b=VsmFzC+i6d6/cQhGM4tQCqLUTkR8QO5kEzsbUXI3hmf50zAdaqwdSdbgn10w+9PlPcj5PZYxOOVZj6I57lmalXvzU77jjP+Unptf+FV44Afv/yR3sui4Sf3bjKTZiZs7R80djDH5XW8CYatyUmbqNU9xFmYMtsAAwoQesRbf5lkFqHBAcCRvZLuT3mU2S2o6sX7dVg6FTC49SLExPE5FSUkhub958b2TqvKgdBNLq/5yJWhu2ARmMcChcOpfHO2Sqizs5MFDOvDfRlYJQFJhkKFZ4KNFW/qb2c0hRuiHDCpD1weDAQcpvbzTPt7i2h6TBKciDZiVkONuZryiZwvVMg== 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 BN6PR1101MB2274.namprd11.prod.outlook.com (2603:10b6:405:4d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.12; Wed, 15 Jun 2022 01:47:08 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::54a0:2dbc:18b7:2aa9]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::54a0:2dbc:18b7:2aa9%7]) with mapi id 15.20.5332.020; Wed, 15 Jun 2022 01:47:07 +0000 From: "Xia, Chenbo" To: "Richardson, Bruce" , "dev@dpdk.org" CC: Maxime Coquelin , Stephen Hemminger Subject: RE: [PATCH v3 3/4] doc/howto: add code example to virtio-user exception path doc Thread-Topic: [PATCH v3 3/4] doc/howto: add code example to virtio-user exception path doc Thread-Index: AQHYfN/PJ7zL3U9DKEOa34BS9glwPK1PudCA Date: Wed, 15 Jun 2022 01:47:07 +0000 Message-ID: References: <20220527162659.129022-1-bruce.richardson@intel.com> <20220610153535.659076-1-bruce.richardson@intel.com> <20220610153535.659076-4-bruce.richardson@intel.com> In-Reply-To: <20220610153535.659076-4-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: 11a93b4c-8ddc-4780-0030-08da4e70f4e2 x-ms-traffictypediagnostic: BN6PR1101MB2274: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: HOsVX1S5v6UoSoXBvX82uCmhslgvkR+m4C1EvLFsgIA82avgSdRLn0TuNWgKF3CL3SbN2/m96WyK9QRK9wZB6XQuQvnW4lyenNqdd0bFLj66gbtieDnb/cqVN2jBg4/pqy4UPA1JmzeHCbSgn5J1sPF1R7NH8IJiGru1BBNzzZBjUEqtCrPKLddMtcrvvNdT+2eGFvzs0fK3wCOiUoYkWnGOfe4oBdwBggYuQMKHRZLFgp9njLy3PSOGqW0rWh5CZyznFNKwCMajyk7SS67LWdoy9aaGiLMsDIK2VprdTJdngvYommjBqSa0vJGV2Ygd76WcgrscEQ5PytJ9NqT7g8bKNaF37pJu+7Td+3DgGoOqxqyVV/UKYuQs09ei2QVYLvknSdcOOdswNuQC2/bf5PKW3kgKvJbneXORKT94srKyG9aXYU9hY/ublujq+aj8WTXn3RtVz/9cnXhWoUOu/wik54UxMmKt/tB0o6WweWy2vtViCfrIxqNZ5McdACZtQmqDXGsWGYEP+ss8Aw/tbUcx8d3lsVosqJ6H1849jUqlijPiGmHn92TlwOfg4Ouw2Y2yZ1E4JSZZz/6GqnmjDboqKvsSwyFejO1itCbUjab0g5Oq9gKnIJld+WS5UnjaXGoGwIY9l55IYyYBNdaedoIGg47HDrWPllMzX75LmEuZ2UW+Ovvegk7i+EnYwIkc3ZpZGWd+mqW9M0yLfBwCWraZGUSsMhqagfv1cLPclsS5MzMzOZ9m33pFuAKBN4bKBAEt5x89awWmLJ4tXvBViWW2q6NFVHGeZZg11SsZqPM= 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:(13230016)(366004)(54906003)(82960400001)(316002)(33656002)(2906002)(186003)(122000001)(110136005)(9686003)(26005)(7696005)(5660300002)(55016003)(66446008)(66476007)(64756008)(86362001)(53546011)(76116006)(52536014)(4326008)(8676002)(66946007)(66556008)(8936002)(508600001)(6506007)(83380400001)(38100700002)(71200400001)(38070700005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?OjQI7Ok1xZqphOxEchDY2lFBLGHHHTuzno/X0nJjPUFb1plYMU9YLeknQBtu?= =?us-ascii?Q?qGdfgZi7qg2IeOzNLw2H3hZDnXJaZo3u8i4EqVzIrlJIpHVXpgjWW0AJkc8D?= =?us-ascii?Q?nEJvzrbfI6q1N8DwiTuKV/tWIkKxXHMEjK7la18JstFuHkVNFh9ofDaFIo1k?= =?us-ascii?Q?Ujj9FmklPeT7mDsVfBMYJ2GpfYcDjSncL/Ujl96nYM8BWmZJOlnzXfysHoxy?= =?us-ascii?Q?dy3orjlwucP0LtMM4W/JdxFO8ZcNCfcjbHPf9tyxRlBmR4wYLInus3t26grz?= =?us-ascii?Q?atEIzphRGLASOTjVsmgNRO7TKuxx+4H56LugsCmVYbLYrhtNzwhSrUtrKCsI?= =?us-ascii?Q?Tyn9T/H0Y4xVLxALDRUQJU2I0zHYcjLAfAz0XoKDBs/gaV0FxBovNNG/bvNu?= =?us-ascii?Q?LfES4EWIssK1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RHz4fXrx34?= =?us-ascii?Q?gixVY+cSZTwdUzsZ25nSJIQ9cDpWZXfNBb4vMsLqF3oL4XE5vJ++qdCceRJc?= =?us-ascii?Q?NEulq83sC7n/kWvEdLvN6jynFD8XitUqdhcfPx1KtS8AoPBWlhDh1Fe751fC?= =?us-ascii?Q?eOvQ0AAN04L2lKNgyABX0gI6rRPMRluLRB/ryQ7vZzskMSqq7dddJwz00oX0?= =?us-ascii?Q?J3cEO9WKMTwxdQqcdsZi1xrfJ/gslP6gX29WegLGUxtVmqk44UdtCe6UMapf?= =?us-ascii?Q?JHnPG9GJG+VaZjzPW7oycnS8buOV84Nxuo1pxsMoaRuJTSTQshsd5CbyBSYM?= =?us-ascii?Q?R1fCTPd08jM4AvFqp5mnntlyj71AD/sez0UdcJHKhSD3KrOoMjubDngST/wJ?= =?us-ascii?Q?EvIlJBEU4wxfjPmuZ9Ku4s+a//rdsuRl/G8/lllSDBIH3j4v0OHdhVdpCDP7?= =?us-ascii?Q?XW/ZurQmjQ=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: 11a93b4c-8ddc-4780-0030-08da4e70f4e2 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jun 2022 01:47:07.7477 (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: NMEJNnMrkanGagLK+zMkj5Iv2fnhDNEVJkRzC1arhATo8q0XUmcNxKGehUNIaDs+3aw05tTRG/yqM/GjmyVlgA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1101MB2274 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: Friday, June 10, 2022 11:36 PM > To: dev@dpdk.org > Cc: Maxime Coquelin ; Xia, Chenbo > ; Richardson, Bruce ; > Stephen Hemminger > Subject: [PATCH v3 3/4] 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 > Acked-by: Stephen Hemminger > --- > .../howto/virtio_user_as_exception_path.rst | 55 +++++++++++++++++++ > 1 file changed, 55 insertions(+) >=20 > diff --git a/doc/guides/howto/virtio_user_as_exception_path.rst > b/doc/guides/howto/virtio_user_as_exception_path.rst > index a7f0d366fe..2af1778578 100644 > --- a/doc/guides/howto/virtio_user_as_exception_path.rst > +++ b/doc/guides/howto/virtio_user_as_exception_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``, > +``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 Acked-by: Chenbo Xia