DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tomasz Duszynski <tdu@semihalf.com>
To: dev@dpdk.org
Cc: Tomasz Duszynski <tdu@semihalf.com>
Subject: [dpdk-dev] [PATCH 2/2] examples/kni: stop lcores while doing kni ops
Date: Mon, 16 Oct 2017 13:45:48 +0200	[thread overview]
Message-ID: <1508154348-10988-3-git-send-email-tdu@semihalf.com> (raw)
In-Reply-To: <1508154348-10988-1-git-send-email-tdu@semihalf.com>

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 <tdu@semihalf.com>
---
 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

  parent reply	other threads:[~2017-10-16 11:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-16 11:45 [dpdk-dev] [PATCH 0/2] examples/kni: update kni example application Tomasz Duszynski
2017-10-16 11:45 ` [dpdk-dev] [PATCH 1/2] examples/kni: check if pci_dev isn't NULL before using it Tomasz Duszynski
2017-10-21  0:26   ` Ferruh Yigit
2017-10-24 22:05     ` Thomas Monjalon
2017-10-16 11:45 ` Tomasz Duszynski [this message]
2017-10-21  0:42   ` [dpdk-dev] [PATCH 2/2] examples/kni: stop lcores while doing kni ops Ferruh Yigit
2017-10-25  9:28     ` Tomasz Duszynski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1508154348-10988-3-git-send-email-tdu@semihalf.com \
    --to=tdu@semihalf.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).