From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id AF47F5685 for ; Sat, 28 Nov 2015 12:02:10 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 28 Nov 2015 03:02:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,356,1444719600"; d="scan'208";a="608717305" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by FMSMGA003.fm.intel.com with ESMTP; 28 Nov 2015 03:02:05 -0800 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id tASB24wY003112; Sat, 28 Nov 2015 11:02:04 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id tASB24a0013777; Sat, 28 Nov 2015 11:02:04 GMT Received: (from bairemon@localhost) by sivswdev01.ir.intel.com with id tASB24rE013773; Sat, 28 Nov 2015 11:02:04 GMT From: Bernard Iremonger To: dev@dpdk.org Date: Sat, 28 Nov 2015 11:01:54 +0000 Message-Id: <1448708514-13724-3-git-send-email-bernard.iremonger@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1448708514-13724-1-git-send-email-bernard.iremonger@intel.com> References: <1448640460-25249-1-git-send-email-bernard.iremonger@intel.com> <1448708514-13724-1-git-send-email-bernard.iremonger@intel.com> Subject: [dpdk-dev] [PATCH v4 2/2] doc: correct Rings-based PMD section in the NIC Drivers guides X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Nov 2015 11:02:11 -0000 Correct the sample code in the pcap_ring.rst file to match the latest rte_eth_ring.c code. The parameters to the rte_eth_from_rings() function have changed since the documentation was written. The API change occurred before DPDK 1.8 when the rst files were added. The original documentation on which the pcap_ring.rst file was based was not correct. Fixes: fc1f2750a3ec("doc: programmers guide") Signed-off-by: Bernard Iremonger Acked-by: Bruce Richardson --- doc/guides/nics/pcap_ring.rst | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/doc/guides/nics/pcap_ring.rst b/doc/guides/nics/pcap_ring.rst index 5d65dc6..46aa3ac 100644 --- a/doc/guides/nics/pcap_ring.rst +++ b/doc/guides/nics/pcap_ring.rst @@ -1,5 +1,5 @@ .. BSD LICENSE - Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + Copyright(c) 2010-2015 Intel Corporation. All rights reserved. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -217,7 +217,7 @@ Using the Poll Mode Driver from an Application Both drivers can provide similar APIs to allow the user to create a PMD, that is, rte_ethdev structure, instances at run-time in the end-application, for example, using rte_eth_from_rings() or rte_eth_from_pcaps() APIs. -For the rings- based PMD, this functionality could be used, for example, +For the rings-based PMD, this functionality could be used, for example, to allow data exchange between cores using rings to be done in exactly the same way as sending or receiving packets from an Ethernet device. For the libpcap-based PMD, it allows an application to open one or more pcap files @@ -231,26 +231,30 @@ for reception on the same port (error handling omitted for clarity): .. code-block:: c - struct rte_ring *r1, *r2; - int port1, port2; + #define RING_SIZE 256 + #define NUM_RINGS 2 + #define SOCKET0 0 - r1 = rte_ring_create("R1", 256, SOCKET0,RING_F_SP_ENQ|RING_F_SC_DEQ); - r2 = rte_ring_create("R2", 256, SOCKET0, RING_F_SP_ENQ|RING_F_SC_DEQ); + struct rte_ring *ring[NUM_RINGS]; + int port0, port1; - /* create an ethdev where RX and TX are done to/from r1, and * another from r2 */ + ring[0] = rte_ring_create("R0", RING_SIZE, SOCKET0, RING_F_SP_ENQ|RING_F_SC_DEQ); + ring[1] = rte_ring_create("R1", RING_SIZE, SOCKET0, RING_F_SP_ENQ|RING_F_SC_DEQ); - port1 = rte_eth_from_rings(r1, 1, r1, 1, SOCKET0); - port2 = rte_eth_from_rings(r2, 1, r2, 1, SOCKET0); + /* create two ethdev's */ + + port0 = rte_eth_from_rings("eth_ring0", ring, NUM_RINGS, ring, NUM_RINGS, SOCKET0); + port1 = rte_eth_from_rings("eth_ring1", ring, NUM_RINGS, ring, NUM_RINGS, SOCKET0); To create two pseudo-Ethernet ports where the traffic is switched between them, -that is, traffic sent to port 1 is read back from port 2 and vice-versa, +that is, traffic sent to port 0 is read back from port 1 and vice-versa, the final two lines could be changed as below: .. code-block:: c - port1 = rte_eth_from_rings(r1, 1, r2, 1, SOCKET0); - port2 = rte_eth_from_rings(r2, 1, r1, 1, SOCKET0); + port0 = rte_eth_from_rings("eth_ring0", &ring[0], 1, &ring[1], 1, SOCKET0); + port1 = rte_eth_from_rings("eth_ring1", &ring[1], 1, &ring[0], 1, SOCKET0); This type of configuration could be useful in a pipeline model, for example, where one may want to have inter-core communication using pseudo Ethernet devices rather than raw rings, -- 1.9.1