From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com [209.85.215.49]) by dpdk.org (Postfix) with ESMTP id A0D851B6C8 for ; Mon, 16 Oct 2017 13:46:02 +0200 (CEST) Received: by mail-lf0-f49.google.com with SMTP id w21so9000551lfc.6 for ; Mon, 16 Oct 2017 04:46:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=54OO4Ts+SNHskwb6mNp92+vqmklSCbJJMYYfNwFTOW4=; b=wL79qO0tEd2SrI/Ul8cQPA2F9QF/7gojJIIY/MlkHAZzAicWPa11PWnV1+Toe/taM2 ND9rUB3h6WBuV7A063BRVqxdCFcMeSHSfeexpdrFPcnVFFHX62qFwy2zQrjNeWB99LEP cIMhcx1lyGL6i3OYU3sBGppxKvxKkDrozGHGZqaBiVyO+7VAIfszjzbn1fkXk4cvK3Nq HD68qLKZH0aiSQPOFxRW0LOEYClWR3J7H73LoWsQRarT0X1Wdi2ayU368aBARD0N5qvZ B+qkEJy3ph3D26Okp4WRtOwNYwjRxm5HatMvF6xUTjSXNEc/C/bqiwwQTEHKjcZmrepe 2r5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=54OO4Ts+SNHskwb6mNp92+vqmklSCbJJMYYfNwFTOW4=; b=i+nuqyrTuP6hrt6Wlc3UX4tqElWISc4AYjUxwsgn0TQHW0BeO/XA+AZZzQ9I0r4QSV YBdK8wbnAYd6mVgEojxkSiN18s5BySAXM17+BiwKy10LOIkWeh+y+XfAYUdLC2UqOSs8 jq10N4ZBGXRb1dspxKD61x3XzCt7t7F1ZEfT4u6PH8nhhLvnCX4REKkNSrjWfXe6aR4l MNG+bVV8h+Lf0iLqcsOQjzZlOg4YfpA4SQZkMuNfJ2osE6SrfYMY7FRPY9uCB6IHwYO5 Ic0I7yspele7UqqmH8VVP/w6OdIIsvwDgKMPz3Dr0O6uCOLWBMgVXsNBHgVA7jOMFlYX Wkjw== X-Gm-Message-State: AMCzsaVwV+30aRIhmHDM7PulunMZmOU6xo+gkrkHkiWpqrWru3HyaXww y2+uYrBFacOrHlD0m9UQCR6AJ9WPJNM= X-Google-Smtp-Source: ABhQp+SZs31cpjNb85c53HCTg+HCsrD3Lbz6fU3LLPkWtnBb9SjVzxW0mkcJ73gdu/+J7kcfghS1jg== X-Received: by 10.25.80.23 with SMTP id e23mr2454215lfb.160.1508154361491; Mon, 16 Oct 2017 04:46:01 -0700 (PDT) Received: from tdu.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id c23sm1469607lfh.65.2017.10.16.04.46.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Oct 2017 04:46:00 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: Tomasz Duszynski Date: Mon, 16 Oct 2017 13:45:48 +0200 Message-Id: <1508154348-10988-3-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508154348-10988-1-git-send-email-tdu@semihalf.com> References: <1508154348-10988-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH 2/2] examples/kni: stop lcores while doing kni ops 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: Mon, 16 Oct 2017 11:46:02 -0000 Since the transmit and receive functions should not be invoked when the device is stopped, stop lcores during kni ops and restart them after device is started once again. Signed-off-by: Tomasz Duszynski --- examples/kni/main.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/examples/kni/main.c b/examples/kni/main.c index cb48fb5..5c50448 100644 --- a/examples/kni/main.c +++ b/examples/kni/main.c @@ -166,6 +166,23 @@ static int kni_change_mtu(uint16_t port_id, unsigned int new_mtu); static int kni_config_network_interface(uint16_t port_id, uint8_t if_up); static rte_atomic32_t kni_stop = RTE_ATOMIC32_INIT(0); +static rte_atomic32_t kni_restart = RTE_ATOMIC32_INIT(0); + +static void +kni_stop_lcores(void) +{ + unsigned int i; + + rte_atomic32_inc(&kni_restart); + rte_atomic32_inc(&kni_stop); + + RTE_LCORE_FOREACH(i) { + if (i == rte_lcore_id()) + continue; + + rte_eal_wait_lcore(i); + } +} /* Print out statistics on packets handled */ static void @@ -712,6 +729,7 @@ kni_change_mtu(uint16_t port_id, unsigned int new_mtu) RTE_LOG(INFO, APP, "Change MTU of port %d to %u\n", port_id, new_mtu); + kni_stop_lcores(); /* Stop specific port */ rte_eth_dev_stop(port_id); @@ -755,6 +773,8 @@ kni_config_network_interface(uint16_t port_id, uint8_t if_up) RTE_LOG(INFO, APP, "Configure network interface of %d %s\n", port_id, if_up ? "up" : "down"); + kni_stop_lcores(); + if (if_up != 0) { /* Configure network interface up */ rte_eth_dev_stop(port_id); ret = rte_eth_dev_start(port_id); @@ -911,6 +931,7 @@ main(int argc, char** argv) } check_all_ports_link_status(nb_sys_ports, ports_mask); +restart: /* Launch per-lcore function on every lcore */ rte_eal_mp_remote_launch(main_loop, NULL, CALL_MASTER); RTE_LCORE_FOREACH_SLAVE(i) { @@ -918,6 +939,13 @@ main(int argc, char** argv) return -1; } + if (rte_atomic32_read(&kni_restart)) { + rte_atomic32_dec(&kni_stop); + rte_atomic32_dec(&kni_restart); + + goto restart; + } + /* Release resources */ for (port = 0; port < nb_sys_ports; port++) { if (!(ports_mask & (1 << port))) -- 2.7.4