From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id EDCFA58D4 for ; Wed, 10 Aug 2016 08:31:08 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 09 Aug 2016 23:31:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,498,1464678000"; d="scan'208";a="1022844788" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga001.fm.intel.com with ESMTP; 09 Aug 2016 23:31:07 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 9 Aug 2016 23:31:07 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.181]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.107]) with mapi id 14.03.0248.002; Wed, 10 Aug 2016 14:31:05 +0800 From: "Lin, Xueqin" To: "Liu, Yong" , xueqin.lin , "dts@dpdk.org" Thread-Topic: [dts][PATCH] tests: add ftag test suite and plan Thread-Index: AQHR8gYD2GIeCvdTIUWIWVqX5H/gtaBA7eyAgADPJmA= Date: Wed, 10 Aug 2016 06:31:04 +0000 Message-ID: <0D300480287911409D9FF92C1FA2A3351A7C0F29@SHSMSX103.ccr.corp.intel.com> References: <1470723536-16674-1-git-send-email-xlin15@shecgisg005.sh.intel.com> <57AA8C89.9090203@intel.com> In-Reply-To: <57AA8C89.9090203@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH] tests: add ftag test suite and plan X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Aug 2016 06:31:10 -0000 Hi marvin, Many thanks for review and guide. Agreed, will send next version according to the comments. Best regards, Xueqin > -----Original Message----- > From: Liu, Yong > Sent: Wednesday, August 10, 2016 10:08 AM > To: xueqin.lin; dts@dpdk.org > Cc: Lin, Xueqin > Subject: Re: [dts][PATCH] tests: add ftag test suite and plan >=20 > Thanks xueqin, please check with my comments. >=20 > On 08/09/2016 02:18 PM, xueqin.lin wrote: > > From: Xueqin Lin > > > > FTAG is placed at the begingging of the frame, which is essential for a= set of > switches to behave like one switch.The case validates packet forwarding > function based on FTAG, uses FTAG unit test instead of testpmd to run. > > > > diff --git a/dep/unit_test_FTAG_devargs.patch > b/dep/unit_test_FTAG_devargs.patch > > new file mode 100644 > > index 0000000..d65666e > > --- /dev/null > > +++ b/dep/unit_test_FTAG_devargs.patch > > @@ -0,0 +1,316 @@ > > +From f8d65293caa2fc130241ef34e6418eb22373d05b Mon Sep 17 > 00:00:00 2001 > > +From: Wang Xiao W > > +Date: Wed, 3 Aug 2016 16:24:08 +0800 > > +Subject: [PATCH] fm10k: add a unit test for FTAG based forwardin > > + > > +This patch adds a unit test case for FTAG functional test. Before runn= ing > > +the test, set PORT0_GLORT and PORT1_GLORT environment variables, and > ensure > > +two fm10k ports are used for dpdk, glort info for each port can be sho= wn > in > > +TestPoint. In the unit test, a packet will be forwarded to the target = port > > +by the switch without changing the destination mac address. > > + > > +--- > > + app/test/Makefile | 1 + > > + app/test/test_fm10k_ftag.c | 267 > +++++++++++++++++++++++++++++++++++++++++++++ > > + config/common_linuxapp | 2 + > > + 3 files changed, 270 insertions(+) > > + create mode 100644 app/test/test_fm10k_ftag.c > > + > > +diff --git a/app/test/Makefile b/app/test/Makefile > > +index 49ea195..b6eed1e 100644 > > +--- a/app/test/Makefile > > ++++ b/app/test/Makefile > > +@@ -98,6 +98,7 @@ SRCS-y +=3D test_memzone.c > > + SRCS-y +=3D test_ring.c > > + SRCS-y +=3D test_ring_perf.c > > + SRCS-y +=3D test_pmd_perf.c > > ++SRCS-y +=3D test_fm10k_ftag.c >=20 > Test application's makefile may change in each release, suggest to add > this line in suite by sed command. >=20 > > + > > + ifeq ($(CONFIG_RTE_LIBRTE_TABLE),y) > > + SRCS-y +=3D test_table.c > > +diff --git a/app/test/test_fm10k_ftag.c b/app/test/test_fm10k_ftag.c > > +new file mode 100644 > > +index 0000000..c75a7b1 > > +--- /dev/null > > ++++ b/app/test/test_fm10k_ftag.c > > +@@ -0,0 +1,267 @@ > > ++/*- > > ++ * BSD LICENSE > > ++ * > > ++ * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. > > ++ * All rights reserved. > > ++ * > > ++ * Redistribution and use in source and binary forms, with or witho= ut > > ++ * modification, are permitted provided that the following conditio= ns > > ++ * are met: > > ++ * > > ++ * * Redistributions of source code must retain the above copyrig= ht > > ++ * notice, this list of conditions and the following disclaimer= . > > ++ * * Redistributions in binary form must reproduce the above copy= right > > ++ * notice, this list of conditions and the following disclaimer= in > > ++ * the documentation and/or other materials provided with the > > ++ * distribution. > > ++ * * Neither the name of Intel Corporation nor the names of its > > ++ * contributors may be used to endorse or promote products deri= ved > > ++ * from this software without specific prior written permission= . > > ++ * > > ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND > CONTRIBUTORS > > ++ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT > NOT > > ++ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND > FITNESS FOR > > ++ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE > COPYRIGHT > > ++ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, > INCIDENTAL, > > ++ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, > BUT NOT > > ++ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; > LOSS OF USE, > > ++ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED > AND ON ANY > > ++ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR > TORT > > ++ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT > OF THE USE > > ++ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH > DAMAGE. > > ++ */ > > ++ > > ++#include > > ++#include > > ++#include > > ++#include > > ++#include > > ++#include > > ++#include > > ++#include "test.h" > > ++ > > ++#define RX_RING_SIZE 128 > > ++#define TX_RING_SIZE 512 > > ++ > > ++#define NUM_MBUFS 8191 > > ++#define MBUF_CACHE_SIZE 250 > > ++#define BURST_SIZE 32 > > ++ > > ++struct fm10k_ftag { > > ++ uint16_t swpri_type_user; > > ++ uint16_t vlan; > > ++ uint16_t sglort; > > ++ uint16_t dglort; > > ++}; > > ++ > > ++static const struct rte_eth_conf port_conf_default =3D { > > ++ .rxmode =3D { .max_rx_pkt_len =3D ETHER_MAX_LEN } > > ++}; > > ++ > > ++/* > > ++ * Initializes a given port using global settings and with the RX buf= fers > > ++ * coming from the mbuf_pool passed as a parameter. > > ++ */ > > ++static inline int > > ++port_init(uint8_t port, struct rte_mempool *mbuf_pool) > > ++{ > > ++ struct rte_eth_conf port_conf =3D port_conf_default; > > ++ const uint16_t rx_rings =3D 1, tx_rings =3D 1; > > ++ int retval; > > ++ uint16_t q; > > ++ struct ether_addr addr; > > ++ > > ++ if (port >=3D rte_eth_dev_count()) > > ++ return -1; > > ++ > > ++ /* Configure the Ethernet device. */ > > ++ retval =3D rte_eth_dev_configure(port, rx_rings, tx_rings, &port_con= f); > > ++ if (retval !=3D 0) > > ++ return retval; > > ++ > > ++ /* Allocate and set up 1 RX queue per Ethernet port. */ > > ++ for (q =3D 0; q < rx_rings; q++) { > > ++ retval =3D rte_eth_rx_queue_setup(port, q, RX_RING_SIZE, > > ++ rte_eth_dev_socket_id(port), NULL, > mbuf_pool); > > ++ if (retval < 0) > > ++ return retval; > > ++ } > > ++ > > ++ /* Allocate and set up 1 TX queue per Ethernet port. */ > > ++ for (q =3D 0; q < tx_rings; q++) { > > ++ retval =3D rte_eth_tx_queue_setup(port, q, TX_RING_SIZE, > > ++ rte_eth_dev_socket_id(port), NULL); > > ++ if (retval < 0) > > ++ return retval; > > ++ } > > ++ > > ++ /* Start the Ethernet port. */ > > ++ retval =3D rte_eth_dev_start(port); > > ++ if (retval < 0) > > ++ return retval; > > ++ > > ++ /* Display the port MAC address. */ > > ++ rte_eth_macaddr_get(port, &addr); > > ++ printf("Port %u MAC: %02" PRIx8 " %02" PRIx8 " %02" PRIx8 > > ++ " %02" PRIx8 " %02" PRIx8 " %02" PRIx8 "\n", > > ++ (unsigned)port, > > ++ addr.addr_bytes[0], addr.addr_bytes[1], > > ++ addr.addr_bytes[2], addr.addr_bytes[3], > > ++ addr.addr_bytes[4], addr.addr_bytes[5]); > > ++ > > ++ return 0; > > ++} > > ++ > > ++static int set_glort_value(const char *str, uint16_t *glort) > > ++{ > > ++ const char *glort_str; > > ++ char *end =3D NULL; > > ++ > > ++ glort_str =3D getenv(str); > > ++ if (glort_str =3D=3D NULL) { > > ++ printf("Please set environment value %s first\n", str); > > ++ return -1; > > ++ } > > ++ *glort =3D (uint16_t)strtoul(glort_str, &end, 16); > > ++ if ((glort_str[0] =3D=3D '\0') || (end =3D=3D NULL) || (*end !=3D '\= 0')) { > > ++ printf("Glort value is not valid\n"); > > ++ return -1; > > ++ } > > ++ return 0; > > ++} > > ++ > > ++static int test_ftag_rxtx(void) > > ++{ > > ++ uint8_t port =3D 0; > > ++ uint16_t glort[2]; > > ++ > > ++ struct rte_mbuf *bufs[BURST_SIZE]; > > ++ uint16_t nb_rx, nb_tx, i; > > ++ struct fm10k_ftag *ftag_addr; > > ++ int ret =3D 0; > > ++ > > ++ /* Get the glort value of the two ports */ > > ++ if ((set_glort_value("PORT0_GLORT", &glort[0]) < 0) || > > ++ (set_glort_value("PORT1_GLORT", &glort[1]) < 0)) > > ++ return -1; > > ++ > > ++ /* Receive packets coming from EPL on any of the two ports */ > > ++ printf("Please send some packets from Ethernet port to one PEP\n"); > > ++ do { > > ++ port ^=3D 1; > > ++ nb_rx =3D rte_eth_rx_burst(port, 0, bufs, BURST_SIZE); > > ++ } while (nb_rx <=3D 0); > > ++ printf("Receive %d packets on port %d\n", nb_rx, port); > > ++ > > ++ /* Check sglort value on mbuf->vlan_tci_outer. */ > > ++ for (i =3D 0; i < nb_rx; i++) { > > ++ if (bufs[i]->vlan_tci_outer =3D=3D 0) { > > ++ printf("Find a packet with sglort 0\n"); > > ++ return -1; > > ++ } > > ++ } > > ++ printf("test for FTAG RX passed\n"); > > ++ > > ++ /* Put an FTAG header on each of the packets received and set FTAG > > ++ * TX flag > > ++ **/ > > ++ for (i =3D 0; i < nb_rx; i++) { > > ++ ftag_addr =3D (struct fm10k_ftag > *)rte_pktmbuf_prepend(bufs[i], > > ++ sizeof(struct fm10k_ftag)); > > ++ ftag_addr->swpri_type_user =3D 0; > > ++ ftag_addr->vlan =3D 0; > > ++ ftag_addr->dglort =3D rte_cpu_to_be_16(glort[port ^ 1]); > > ++ ftag_addr->sglort =3D rte_cpu_to_be_16(glort[port]); > > ++ bufs[i]->timesync =3D 1; > > ++ } > > ++ > > ++ /* Send packets to the other port by method of FTAG based > forwarding */ > > ++ nb_tx =3D rte_eth_tx_burst(port, 0, bufs, nb_rx); > > ++ if (nb_tx <=3D 0) { > > ++ printf("Can not send out packets with FTAG\n"); > > ++ return -1; > > ++ } > > ++ if (unlikely(nb_tx < nb_rx)) { > > ++ do { > > ++ rte_pktmbuf_free(bufs[nb_tx]); > > ++ } while (++nb_tx < nb_rx); > > ++ } > > ++ printf("Send out %d packets with FTAG on port %d\n", nb_tx, port); > > ++ > > ++ /* Wait enough time for a burst of packets forwarding */ > > ++ rte_delay_us(100); > > ++ > > ++ nb_rx =3D rte_eth_rx_burst(port ^ 1, 0, bufs, BURST_SIZE); > > ++ printf("Receive %d packets on port %d\n", nb_rx, port ^ 1); > > ++ if (nb_rx < nb_tx) { > > ++ printf("Packet loss happens in FTAG TX test\n"); > > ++ ret =3D -1; > > ++ } > > ++ > > ++ /* check if the sglort value is right on the other port */ > > ++ for (i =3D 0; i < nb_rx; i++) { > > ++ if (bufs[i]->vlan_tci_outer !=3D glort[port]) { > > ++ printf("sglort of the received packet is not right\n"); > > ++ ret =3D -1; > > ++ break; > > ++ } > > ++ } > > ++ for (i =3D 0; i < nb_rx; i++) > > ++ rte_pktmbuf_free(bufs[i]); > > ++ > > ++ if (!ret) > > ++ printf("test for FTAG TX passed\n"); > > ++ return ret; > > ++} > > ++ > > ++static int > > ++test_fm10k_ftag(void) > > ++{ > > ++ uint16_t nb_ports; > > ++ uint16_t portid, pid; > > ++ struct rte_mempool *mbuf_pool; > > ++ int ret =3D 0; > > ++ > > ++ printf("Dump the devices args\n"); > > ++ rte_eal_devargs_dump(stdout); > > ++ > > ++ nb_ports =3D rte_eth_dev_count(); > > ++ if (nb_ports !=3D 2) { > > ++ printf("2 ports needed for fm10k ftag based forwarding > test\n"); > > ++ return -1; > > ++ } > > ++ > > ++ /* Creates a new mempool in memory to hold the mbufs. */ > > ++ mbuf_pool =3D rte_mempool_lookup("MBUF_POOL_FTAG"); > > ++ if (mbuf_pool =3D=3D NULL) > > ++ mbuf_pool =3D rte_pktmbuf_pool_create("MBUF_POOL_FTAG", > > ++ NUM_MBUFS * nb_ports, MBUF_CACHE_SIZE, 0, > > ++ RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id()); > > ++ > > ++ if (mbuf_pool =3D=3D NULL) > > ++ rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n"); > > ++ > > ++ /* Initialize all ports. */ > > ++ for (portid =3D 0; portid < nb_ports; portid++) > > ++ if (port_init(portid, mbuf_pool) !=3D 0) { > > ++ for (pid =3D 0; pid < portid; pid++) { > > ++ rte_eth_dev_stop(portid); > > ++ //rte_eth_dev_close(portid); > > ++ } > > ++ rte_exit(EXIT_FAILURE, "Cannot init port %"PRIu8 "\n", > > ++ portid); > > ++ } > > ++ > > ++ if (test_ftag_rxtx() < 0) > > ++ ret =3D -1; > > ++ > > ++ /* port tear down */ > > ++ for (portid =3D 0; portid < nb_ports; portid++) { > > ++ rte_eth_dev_stop(portid); > > ++ //rte_eth_dev_close(portid); > > ++ } > > ++ > > ++ return ret; > > ++} > > ++ > > ++REGISTER_TEST_COMMAND(fm10k_ftag_autotest, test_fm10k_ftag); > > +diff --git a/config/common_linuxapp b/config/common_linuxapp > > +index 2483dfa..ac3e0bf 100644 > > +--- a/config/common_linuxapp > > ++++ b/config/common_linuxapp > > +@@ -44,3 +44,5 @@ CONFIG_RTE_LIBRTE_PMD_VHOST=3Dy > > + CONFIG_RTE_LIBRTE_PMD_AF_PACKET=3Dy > > + CONFIG_RTE_LIBRTE_POWER=3Dy > > + CONFIG_RTE_VIRTIO_USER=3Dy > > ++CONFIG_RTE_LIBRTE_FM10K_FTAG_FWD=3Dy > > ++ > > +-- >=20 > DPDK configuration file may change in each release, suggest to add this > line in suite by sed command. > > +1.9.3 > > + > > diff --git a/nics/rrc.py b/nics/rrc.py > > index 02fe6c5..398f744 100644 > > --- a/nics/rrc.py > > +++ b/nics/rrc.py > > @@ -28,7 +28,7 @@ > > # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > > # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF > THE USE > > # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH > DAMAGE. > > - > > +import re > > from crb import Crb > > from config import PortConf, PORTCONF > > from exception import PortConfigParseException > > @@ -239,3 +239,32 @@ class RedRockCanyou(NetDevice): > > self.ctrl_crb.send_expect("set port config 5 max_frame_si= ze %d" % > framesize, "<0>%") > > else: > > self.ctrl_crb.send_expect("set port config 1 max_frame_si= ze %d" % > framesize, "<0>%") > > + > > + def ftag_glortid(self, dmac): >=20 > This function is used to get glort id by mac address, support change > name to get_glortid_bymac. > > + out =3D self.ctrl_crb.send_expect("show mac table all", "<0>%"= ) > > + pattern =3D r"([0-9a-f]{2}:){5}([0-9a-f]{2})" > > + s =3D re.compile(pattern) > > + res =3D s.search(dmac) > > + if res is None: > > + print "search none mac filter" > > + return None > > + else: > > + mac_filter =3D res.group(2) > > + pattern =3D r"(?<=3D%s)+([\sA-Za-z0-9/])+([0-9]{4})" %mac_filt= er > > + s =3D re.compile(pattern) > > + res =3D s.search(out) > > + if res is None: > > + print "search none port value" > > + return None > > + else: > > + port_value =3D res.group(2) > > + out =3D self.ctrl_crb.send_expect("show stacking logical-port = all", > "<0>%",10000) > > + pattern =3D r"([0-9a-z]{6})+(\s)+(%s)+" %port_value > > + s =3D re.compile(pattern) > > + res =3D s.search(out) > > + if res is None: > > + print "search none port glort id" > > + return None > > + else: > > + port_glortid =3D res.group(1) > > + return port_glortid > > diff --git a/test_plans/ftag_test_plan.rst b/test_plans/ftag_test_plan.= rst > > new file mode 100644 > > index 0000000..55e387f > > --- /dev/null > > +++ b/test_plans/ftag_test_plan.rst > > @@ -0,0 +1,106 @@ > > +.. Copyright (c) <2016>, Intel Corporation > > + All rights reserved. > > + > > + Redistribution and use in source and binary forms, with or without > > + modification, are permitted provided that the following conditions > > + are met: > > + > > + - Redistributions of source code must retain the above copyright > > + notice, this list of conditions and the following disclaimer. > > + > > + - Redistributions in binary form must reproduce the above copyright > > + notice, this list of conditions and the following disclaimer in > > + the documentation and/or other materials provided with the > > + distribution. > > + > > + - Neither the name of Intel Corporation nor the names of its > > + contributors may be used to endorse or promote products derived > > + from this software without specific prior written permission. > > + > > + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND > CONTRIBUTORS > > + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT > > + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND > FITNESS > > + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE > > + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, > INDIRECT, > > + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES > > + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > OR > > + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > > + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN > CONTRACT, > > + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) > > + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF > ADVISED > > + OF THE POSSIBILITY OF SUCH DAMAGE. > > + > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > > +FM10k FTAG FORWARDING TEST > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > > + > > +FM10000 supports the addition of a Fabric Tag (FTAG) to carry special > > +information between Switches, between Switch and PCIe Host Interface o= r > > +between Switch and Tunneling Engines. This tag is essential for a set = of > > +switches to behave like one switch (switch aggregation). > > + > > +The FTAG is placed at the beginning of the frame. The case will valid= ate > > +packet forwarding function based on FTAG. > > + > > +Prerequisites > > +------------- > > +Turn on CONFIG_RTE_LIBRTE_FM10K_FTAG_FWD in common_linuxapp > configuration file. > > +Startup testpoint and export Port0 and Port1's GLORT ID. > > + > > +Strip port logic value from mac table information. > > +There's the sample output from RubyRapid. From the output, port0's log= ic > > +value is 4122 and port1's logic value is 4123. > > + > > + <0>% show mac table all > > + MAC Mode FID1 FID2 Type Value Trig ... > > + ------------------ --------- ---- ---- ------ ------ ----- > > + 00:00:00:00:01:01 Dynamic 1 NA Local 1 1 > > + a0:36:9f:60:b6:6e Static 1 NA PF/VF 4506 1 > > + a0:36:9f:60:b6:68 Static 1 NA PF/VF 4123 1 > > + 00:00:00:00:01:00 Dynamic 1 NA Local 1 1 > > + a0:36:9f:60:b6:66 Static 1 NA PF/VF 4122 1 > > + > > + > > +Strip port glort ID from stacking information. > > +There's the sample output from RubyRapid. Logic port0's GLORT ID is > 0x4000. > > +Logic port1's GLORT ID is 0x4200. > > + > > + show stacking logical-port all > > + <0>% show stacking logical-port all > > + > > + SW GLORT LOGICAL PORT PORT TYPE > > + ---- ----- --------------- --------- > > + ... > > + 0 0x4000 4122 ? > > + 0 0x4200 4123 ? > > + > > +Add port's GLORT ID into environment variables. > > + export PORT1_GLORT=3D0x4200 > > + export PORT0_GLORT=3D0x4000 > > + > > +Test Case: Ftag forwarding unit test > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > +1. port 0 pci 85:00.0, port 1 pci 87:00.0,start test application:: > > + > > + ./x86_64-native-linuxapp-gcc/app/test -c f -n 4 -w > 0000:85:00.0,enable_ftag=3D1 -w 0000:87:00.0,enable_ftag=3D1 > > + > > +2. Run FTAG test function:: > > + > > + RTE>>fm10k_ftag_autotest > > + > > +3. Send one packet to Port0 and verify packet with ftag forwarded to P= ort1 > > + Receive 1 packets on port 0 > > + test for FTAG RX passed > > + Send out 1 packets with FTAG on port 0 > > + Receive 1 packets on port 1 > > + test for FTAG TX passed > > + Test OK > > + > > +4. Send one packet to Port1 and verify packet with ftag forwarded to P= ort0 > > + Receive 1 packets on port 0 > > + test for FTAG RX passed > > + Send out 1 packets with FTAG on port 0 > > + Receive 1 packets on port 1 > > + test for FTAG TX passed > > + Test OK > > + > > diff --git a/tests/TestSuite_ftag.py b/tests/TestSuite_ftag.py > > new file mode 100644 > > index 0000000..5427972 > > --- /dev/null > > +++ b/tests/TestSuite_ftag.py > > @@ -0,0 +1,211 @@ > > +# BSD LICENSE > > +# > > +# Copyright(c) 2010-2015 Intel Corporation. All rights reserved. > > +# All rights reserved. > > +# > > +# Redistribution and use in source and binary forms, with or without > > +# modification, are permitted provided that the following conditions > > +# are met: > > +# > > +# * Redistributions of source code must retain the above copyright > > +# notice, this list of conditions and the following disclaimer. > > +# * Redistributions in binary form must reproduce the above copyrigh= t > > +# notice, this list of conditions and the following disclaimer in > > +# the documentation and/or other materials provided with the > > +# distribution. > > +# * Neither the name of Intel Corporation nor the names of its > > +# contributors may be used to endorse or promote products derived > > +# from this software without specific prior written permission. > > +# > > +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND > CONTRIBUTORS > > +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT > > +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND > FITNESS FOR > > +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE > COPYRIGHT > > +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, > INCIDENTAL, > > +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > NOT > > +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS > OF USE, > > +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND > ON ANY > > +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > > +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF > THE USE > > +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH > DAMAGE. > > + > > + > > + > > +""" > > +DPDK Test suite. > > + > > +Test ftag feature > > + > > +""" > > + > > +import dts > > +import time > > +import re > > +import os > > +import dut > > +from config import PortConf > > +from test_case import TestCase > > +from pmd_output import PmdOutput > > +from settings import FOLDERS > > +from packet import Packet > > + > > +# > > +# > > +# Test class. > > +# > > + > > + > > +class TestFtag(TestCase): > > + # > > + # Test cases. > > + # > > + > > + def set_up_all(self): > > + """ > > + Run at the start of each test suite. > > + """ > > + self.ports =3D self.dut.get_ports(self.nic) > > + self.verify(len(self.ports) >=3D 2, "Insufficient number of po= rts.") > > + > > + def set_up(self): > > + """ > > + Run before each test case. > > + """ > > + try: > > + patch_file =3D FOLDERS["Depends"] + > r'/unit_test_FTAG_devargs.patch' > > + except: > > + self.logger.warning(str(FOLDERS)) > > + patch_file =3D r'dep/unit_test_FTAG_devargs_org.patch' > > + FOLDERS["Depends"] =3D 'dep' > > + patch_dst =3D "/tmp/" > The patch will be merged in, so there's no need to check whether patch > file existed. > > + > > + # dpdk patch and build > > + try: > > + self.dut.session.copy_file_to(patch_file, patch_dst) > > + self.patch_hotfix_dpdk(patch_dst + > "unit_test_FTAG_devargs.patch", True) > > + out =3D self.dut.send_expect("make install T=3Dx86_64-nati= ve-linuxapp- > gcc -j", "# ", 300) > Target should be dynamic, it can be easily get from "self.dut.target". > > + self.verify('Build complete' in out, "Compilation failed") > > + > > + except Exception, e: > > + raise IOError("dpdk setup failure: %s" % e) > Applied patch and build is must for this feature, please move it to > set_up_all function. > Don't need to capture the exception. If failed in set_up_all, case > status will be "Blocked". >=20 > > + > > + def check_forwarding(self, txPort, rxPort, nic, received=3DTrue): > > + self.send_packet(txPort, rxPort, self.nic, received) > > + > > + def send_packet(self, txPort, rxPort, nic, received=3DTrue): > > + """ > > + Send packages according to parameters. > > + """ > > + rxitf =3D self.tester.get_interface(self.tester.get_local_port= (rxPort)) > > + txitf =3D self.tester.get_interface(self.tester.get_local_port= (txPort)) > > + > > + dmac_tx =3D self.dut.get_mac_address(txPort) > > + dmac_rx =3D self.dut.get_mac_address(rxPort) > > + > > + pkg =3D > 'Ether(dst=3D"%s",src=3D"52:00:00:00:00:00")/IP()/TCP()/("X"*46)' %dmac_r= x > > + self.tester.scapy_foreground() > > + self.tester.scapy_append('sendp(%s, iface=3D"%s")' % (pkg, txi= tf)) > > + self.tester.scapy_execute() > > + time.sleep(3) > > + > > + def patch_hotfix_dpdk(self, patch_dir, on =3D True): > > + """ > > + This function is to apply or remove patch for dpdk. > > + patch_dir: the abs path of the patch > > + on: True for apply, False for remove > > + """ > > + try: > > + if on: > > + self.dut.send_expect("git am %s" % patch_dir,"#",2) > > + else: > > + self.dut.send_expect("git reset --hard HEAD^1","#",2) > > + except Exception, e: > > + raise ValueError("patch_hotfix_dpdk failure: %s" % e) > dpdk folder will not contain git information by default, so please use > patch command to apply the patch. > Again, no need to capture the exception. Let it handled by dts framework. > > + > > + def test_ftag_function(self): > > + """ > > + ftag functional test > > + """ > > + try: > > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/tes= tpmd -c > f -n 4 -- -i","testpmd", 60) > > + > > + except Exception, e: > > + raise IOError("dpdk start failure: %s" % e) > No need to capture the exception. Let it handled by dts framework. > > + > > + self.tx_port =3D self.ports[0] > > + self.rx_port =3D self.ports[1] > > + > > + dmac_tx =3D self.dut.get_mac_address(self.tx_port) > > + dmac_rx =3D self.dut.get_mac_address(self.rx_port) > > + """ > > + get port glort id in the mac table of testpoint switch > > + """ > > + if self.kdriver =3D=3D "fm10k": > > + netobj =3D self.dut.ports_info[self.tx_port]['port'] > > + port0_glortid =3D netobj.ftag_glortid(dmac_tx) > > + port1_glortid =3D netobj.ftag_glortid(dmac_rx) > > + > This suite only support fm10k, please add nic type check in set_up_all > function. > > + try: > > + self.dut.send_expect("quit", "# ") > > + except Exception, e: > > + raise IOError("dpdk quit failure: %s" % e) > > + """ > > + export port glort id > > + """ > > + > > + try: > > + self.dut.send_expect("export PORT0_GLORT=3D%s" %port0_glor= tid, > "#", 2) > > + self.dut.send_expect("export PORT1_GLORT=3D%s" %port1_glor= tid, > "#", 2) > > + except Exception, e: > > + raise IOError("set port glort id failure: %s" % e) > > + > > + enable_ftag_ports =3D '' > > + for port in range(0,len(self.ports)): > > + pci_bus =3D self.dut.ports_info[port]['pci'] > > + enable_ftag_ports +=3D '-w %s,enable_ftag=3D1 ' % pci_bus > > + > > + try: > > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/tes= t -c f -n > 4 %s" % enable_ftag_ports,"R.*T.*E.*>.*>", 60) > > + > > + except Exception, e: > > + raise IOError("dpdk start failure: %s" % e) > > + > > + #fm10k ftag auto test > > + for txport in range(0,len(self.ports)): > > + for rxport in range(0,len(self.ports)): > > + try: > > + self.dut.send_expect("fm10k_ftag_autotest", "Dump"= , 100) > > + self.check_forwarding(txport, rxport, self.nic, re= ceived=3DFalse) > > + out =3D self.dut.get_session_output() > > + print "out:%s" %out > > + self.verify("Test OK" in out, "Fail to do fm10k ft= ag test") > > + > > + except Exception, e: > > + raise IOError("ftag test fail: %s" % e) > > + > > + > > + def tear_down(self): > > + """ > > + Run after each test case. > > + """ > > + patch_dst =3D "/tmp/" > > + > > + try: > > + print "quit ftag test" > > + self.dut.send_expect("quit", "# ") > > + except: > > + print "Failed to quit ftag test" > > + > > + self.dut.kill_all() > > + > > + try: > > + self.patch_hotfix_dpdk(patch_dst + > "unit_test_FTAG_devargs.patch", False) > > + except Exception, e: > > + print "patch_hotfix_dpdk remove failure :%s" %e > > + > > + def tear_down_all(self): > > + """ > > + Run after each test suite. > > + """ > > + self.dut.kill_all() > > + self.dut.send_expect("rm -rf /tmp/unit_test_FTAG_devargs.patch= ", "#") > No need to handle the temporary file, should reverse the changes in dpdk > like common_linuxapp and makefile.