From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) by dpdk.org (Postfix) with ESMTP id A286258CB for ; Wed, 17 Oct 2018 03:04:41 +0200 (CEST) Received: by mail-qk1-f193.google.com with SMTP id m8-v6so15432468qka.12 for ; Tue, 16 Oct 2018 18:04:41 -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=Nu2FQsaWEPNQQlPYUjX6Jf9UUv5Errbh07snQSA60GI=; b=SoA39RFrhq0E/gzn4Mhoyw4uEW9lj9FgsfsYRJ4m7I/VzRda26Uckp5l78DllZpNZv iGS25cdbTfMlfuv6PG+8lnIpgQX2GBg9vtLbcAqo5jYLoPlJZW+9Q/Ml7hWBGPdx4NSd YJQmP1hAazgg/T7iJyAYsT1HfRhwUX2vIhg62OqZmr8RUbfKN7uTTECWteiXBC3YfTXo I/FZPXDu8ifrnHobGpIHp4icWAczTjSw8E7SeT81m1CvJPRDpt4pLDqN2yRwfgTwP2J2 2BJPnrzPFCMMMTUN7YRvINIZRnor3iTwqbnb7TX8gad1wgeu+pPS3Uti3xChGEeUNSUy lmhQ== 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=Nu2FQsaWEPNQQlPYUjX6Jf9UUv5Errbh07snQSA60GI=; b=BlPmD0VV0U5+v+iHBE+e922FO3KmdMMYA1j4Ysz0xsC+v4fC2pAeW+7HXzGg1cXzqG 2V694JNNQHrVDlPumFNN44u9mvxSAtH5gDD2MYBUeF9ff9tIIotTkIb1vxn7BktfTzym CtMHzPVNlMCiliqmVrJQY/DuC4m8NCWP36tbfdtDcF+8Gf/lefmtsPOeY0QcpKijZ86v Yy7C6kyOiDW2VZGll3x5u/ki6wukTOxuKgdii/JLYS0fdOVwFhu5+e1QqgfUZf/MYL72 5ieSBWxtyVR1gTwEneu2347gwjDYa8OhPB6npTs60F1/qT/hrToC7g5b1UrpJt7+fgMS FCig== X-Gm-Message-State: ABuFfohEXUmvqy9NqkIC0wDAd+BgvnRSoLIJrtXBP2qIUGpadzxOp2Yz xvH1wGiyzUt0ZWfYRc81/j3E8POPTco= X-Google-Smtp-Source: ACcGV60I9A9u/OzcdTSQElz5l26pJx4Gxjb2DJQLxcrqO6d1UA2fYxdp5KubKPhNIOiIpNmcQlB/ig== X-Received: by 2002:ae9:df02:: with SMTP id t2-v6mr22472239qkf.161.1539738280692; Tue, 16 Oct 2018 18:04:40 -0700 (PDT) Received: from snappy.local.lan ([187.74.142.5]) by smtp.gmail.com with ESMTPSA id v54-v6sm19547508qtc.81.2018.10.16.18.04.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Oct 2018 18:04:39 -0700 (PDT) Sender: Dan Gora From: Dan Gora To: dev@dpdk.org Cc: Igor Ryzhov , Stephen Hemminger , Ferruh Yigit , Dan Gora Date: Tue, 16 Oct 2018 22:04:09 -0300 Message-Id: <20181017010412.23141-3-dg@adax.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180911232906.18352-1-dg@adax.com> References: <20180911232906.18352-1-dg@adax.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 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: Wed, 17 Oct 2018 01:04:42 -0000 Test changing the link status of the KNI interface with rte_kni_update_link(). Signed-off-by: Dan Gora --- test/test/test_kni.c | 77 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/test/test/test_kni.c b/test/test/test_kni.c index cf64c0b27..e38206905 100644 --- a/test/test/test_kni.c +++ b/test/test/test_kni.c @@ -118,6 +118,79 @@ 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) +{ + 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; + } + + ret = rte_kni_update_link(test_kni_ctx, 1); + if (ret < 0) { + printf("Failed to change link state to Up ret=%d.\n", + ret); + goto error; + } + rte_delay_ms(1000); + printf("KNI: Set LINKUP, previous state=%d\n", ret); + + ret = rte_kni_update_link(test_kni_ctx, 0); + if (ret != 1) { + printf( + "Failed! Previous link state should be 1, returned %d.\n", + ret); + goto error; + } + rte_delay_ms(1000); + printf("KNI: Set LINKDOWN, previous state=%d\n", ret); + + ret = rte_kni_update_link(test_kni_ctx, 1); + if (ret != 0) { + printf( + "Failed! Previous link state should be 0, returned %d.\n", + ret); + goto error; + } + printf("KNI: Set LINKUP, previous state=%d\n", ret); + + ret = 0; + 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 +474,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