From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) by dpdk.org (Postfix) with ESMTP id 9423C1B213 for ; Thu, 27 Sep 2018 02:34:07 +0200 (CEST) Received: by mail-qt1-f174.google.com with SMTP id z8-v6so937035qto.9 for ; Wed, 26 Sep 2018 17:34:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/JQjpf7+nI3prxOCKS0ftKi19F7w8+VllABK5QE4//0=; b=UUQfCeTuVD72wcVIgPpGwfx9Z5eqPXNrXENStjDXk5yv025jwbGZL1hNL2eRJBBtsZ k0+jQk+y9rcCnYySwpCAYiS79p2gLhJ40PE/Jqp/bvakFjC/0DPG5wBnrLxDUTuO/58/ a70vUctOpKbRo/wO2EULp5ateHXBgy8TFLvURk8cu+3DWttfYQ5QNHDrUZezJHETUs+P wIh4fZy+GiPwF20Y65mW8/rzK91WJUnVs7dutq2ZkLx7NUcE4L2fdi4pzaO//VhItzk1 IQoBumhumHWnUYgg00S2DiARAwO/TgEYNACe1YCrljvd5b8BCGR0EuU3Gfe+quNS+ZDl AMkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=/JQjpf7+nI3prxOCKS0ftKi19F7w8+VllABK5QE4//0=; b=NLvfYB6/C+NfIF9cI3fOiOFIbPutEXzrtSEXFq0i5Cu6qf8nsKWkBEMirbUGRb3n5b NJVxwKY/LpEe/qQpQP1kyRPiFdm/8jz5egp1GmlzyH3QhUV0em/8wpq1vZTtLvvFS/GN Sk9W5yzJiuzVpEi8lqV4YVYkEoVg1WnYM2bKc7wqfllJkHIBzvu5L/sUnANx8JEIrsDZ MIT88NSS5UWEbPJAK5gduuw6LJjYzpr6znXT57bQn/Mq35sOmyf+Pg9UzrgAsMsN3Yto DRM3x0wr5us5NBdwwlMf0CAL4lvUuIsgitRCTQxxCLDLlZKzxkpLQ2SPsc/Ou2MXohXE D9zw== X-Gm-Message-State: ABuFfohcFplE26b8w3/P1BVPjI7wRoY3KloMCqS7fCYno20Tu/MPiFld iFOYqw5RpS86e7E2aXIqF6cm1NkI X-Google-Smtp-Source: ACcGV6178JNQWlbc1kTtB+uz623lyqn9qiBNWnlZ0ACbu9qgIO/CMy8MAOq0ljOXAMr3GnfI85CBrw== X-Received: by 2002:a0c:d032:: with SMTP id u47-v6mr2555537qvg.245.1538008446670; Wed, 26 Sep 2018 17:34:06 -0700 (PDT) Received: from snappy.local.lan (189-46-124-178.dsl.telesp.net.br. [189.46.124.178]) by smtp.gmail.com with ESMTPSA id x26-v6sm463053qth.15.2018.09.26.17.34.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Sep 2018 17:34:05 -0700 (PDT) Sender: Dan Gora From: Dan Gora To: dev@dpdk.org Cc: Igor Ryzhov , Stephen Hemminger , Ferruh Yigit , Dan Gora Date: Wed, 26 Sep 2018 21:32:52 -0300 Message-Id: <20180927003256.6901-3-dg@adax.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180927003256.6901-1-dg@adax.com> References: <20180911232906.18352-1-dg@adax.com> <20180927003256.6901-1-dg@adax.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 2/6] kni: add link status test X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Sep 2018 00:34:07 -0000 Test changing the link, speed, duplex, etc. status of the KNI interface with rte_kni_update_link(). Signed-off-by: Dan Gora --- test/test/test_kni.c | 131 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/test/test/test_kni.c b/test/test/test_kni.c index 3dcadcebd..138bc9686 100644 --- a/test/test/test_kni.c +++ b/test/test/test_kni.c @@ -118,6 +118,133 @@ kni_change_mtu(uint16_t port_id, unsigned int new_mtu) port_id, kni_pkt_mtu); return 0; } + +static int +test_kni_link_change(void) +{ + struct rte_eth_link link; + int ret; + int pid; + + pid = fork(); + if (pid < 0) { + printf("Error: Failed to fork a process\n"); + return -1; + } + + if (pid == 0) { + printf("Starting KNI Link status change tests.\n"); + if (system(IFCONFIG TEST_KNI_PORT" up") == -1) { + ret = -1; + goto error; + } + + link.link_speed = 10; + link.link_status = ETH_LINK_UP; + link.link_autoneg = ETH_LINK_AUTONEG; + link.link_duplex = ETH_LINK_FULL_DUPLEX; + ret = rte_kni_update_link(test_kni_ctx, &link); + if (ret != 0) { + printf("Failed to change link state to " + "Up/10Mbps/AutoNeg/Full ret=%d.\n", ret); + goto error; + } + rte_delay_ms(1000); + + link.link_speed = 0; + link.link_status = ETH_LINK_DOWN; + link.link_autoneg = ETH_LINK_FIXED; + link.link_duplex = ETH_LINK_FULL_DUPLEX; + ret = rte_kni_update_link(test_kni_ctx, &link); + if (ret != 0) { + printf("Failed to change link state to Down ret=%d.\n", + ret); + goto error; + } + rte_delay_ms(1000); + + link.link_speed = 1000; + link.link_status = ETH_LINK_UP; + link.link_autoneg = ETH_LINK_AUTONEG; + link.link_duplex = ETH_LINK_HALF_DUPLEX; + ret = rte_kni_update_link(test_kni_ctx, &link); + if (ret != 0) { + printf("Failed to change link state to " + "Up/1Gbps/AutoNeg/Half ret=%d.\n", ret); + goto error; + } + rte_delay_ms(1000); + + link.link_speed = 0; + link.link_status = ETH_LINK_DOWN; + link.link_autoneg = ETH_LINK_FIXED; + link.link_duplex = ETH_LINK_FULL_DUPLEX; + ret = rte_kni_update_link(test_kni_ctx, &link); + if (ret != 0) { + printf("Failed to change link state to Down ret=%d.\n", + ret); + goto error; + } + rte_delay_ms(1000); + + link.link_speed = 40000; + link.link_status = ETH_LINK_UP; + link.link_autoneg = ETH_LINK_FIXED; + link.link_duplex = ETH_LINK_FULL_DUPLEX; + ret = rte_kni_update_link(test_kni_ctx, &link); + if (ret != 0) { + printf("Failed to change link state to " + "Up/40Gbps/Fixed/Full ret=%d.\n", ret); + goto error; + } + rte_delay_ms(1000); + + link.link_speed = 0; + link.link_status = ETH_LINK_DOWN; + link.link_autoneg = ETH_LINK_FIXED; + link.link_duplex = ETH_LINK_FULL_DUPLEX; + ret = rte_kni_update_link(test_kni_ctx, &link); + if (ret != 0) { + printf("Failed to change link state to Down ret=%d.\n", + ret); + goto error; + } + rte_delay_ms(1000); + + link.link_speed = 100000; + link.link_status = ETH_LINK_UP; + link.link_autoneg = ETH_LINK_FIXED; + link.link_duplex = ETH_LINK_FULL_DUPLEX; + ret = rte_kni_update_link(test_kni_ctx, &link); + if (ret != 0) { + printf("Failed to change link state to " + "Up/100Gbps/Fixed/Full ret=%d.\n", ret); + goto error; + } + rte_delay_ms(1000); + +error: + if (system(IFCONFIG TEST_KNI_PORT" down") == -1) + ret = -1; + + printf("KNI Link status change tests: %s.\n", + (ret == 0) ? "Passed" : "Failed"); + exit(ret); + } else { + int p_ret, status; + + while (1) { + p_ret = waitpid(pid, &status, WNOHANG); + if (p_ret != 0) { + if (WIFEXITED(status)) + return WEXITSTATUS(status); + return -1; + } + rte_delay_ms(10); + rte_kni_handle_request(test_kni_ctx); + } + } +} /** * This loop fully tests the basic functions of KNI. e.g. transmitting, * receiving to, from kernel space, and kernel requests. @@ -401,6 +528,10 @@ test_kni_processing(uint16_t port_id, struct rte_mempool *mp) goto fail_kni; } + ret = test_kni_link_change(); + if (ret != 0) + goto fail_kni; + rte_eal_mp_remote_launch(test_kni_loop, NULL, CALL_MASTER); RTE_LCORE_FOREACH_SLAVE(i) { if (rte_eal_wait_lcore(i) < 0) { -- 2.19.0