From: "Tahhan, Maryam" <maryam.tahhan@intel.com>
To: "Horton, Remy" <remy.horton@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v2 2/3] l2fwd: keep alive sample application
Date: Fri, 23 Oct 2015 14:23:55 +0000 [thread overview]
Message-ID: <1A27633A6DA49C4A92FCD5D4312DBF536A5D9327@IRSMSX109.ger.corp.intel.com> (raw)
In-Reply-To: <1443603881-4700-3-git-send-email-remy.horton@intel.com>
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Remy Horton
> Sent: Wednesday, September 30, 2015 10:05 AM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v2 2/3] l2fwd: keep alive sample application
>
> Modification of l2fwd to demonstrate keep-alive functionality.
>
> Signed-off-by: Remy Horton <remy.horton@intel.com>
> ---
> examples/l2fwd/Makefile | 2 +-
> examples/l2fwd/main.c | 125
> ++++++++++++++++++++++++++++++++++++++++++++----
> 2 files changed, 118 insertions(+), 9 deletions(-)
>
> diff --git a/examples/l2fwd/Makefile b/examples/l2fwd/Makefile index
> 78feeeb..8647174 100644
> --- a/examples/l2fwd/Makefile
> +++ b/examples/l2fwd/Makefile
> @@ -39,7 +39,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc include
> $(RTE_SDK)/mk/rte.vars.mk
>
> # binary name
> -APP = l2fwd
> +APP = l2fwd-keepalive
>
Hi Remy,
Looks great overall, just a couple of comments
For backward compatibility the rename could be a nightmare? What do you think?
> # all source are stored in SRCS-y
> SRCS-y := main.c
> diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c index
> 720fd5a..131e5a2 100644
> --- a/examples/l2fwd/main.c
> +++ b/examples/l2fwd/main.c
> @@ -1,7 +1,7 @@
> /*-
> * BSD LICENSE
> *
> - * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
> + * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
> * All rights reserved.
> *
> * Redistribution and use in source and binary forms, with or without
> @@ -68,6 +68,8 @@
> #include <rte_ring.h>
> #include <rte_mempool.h>
> #include <rte_mbuf.h>
> +#include <rte_timer.h>
> +#include <rte_keepalive.h>
>
> #define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1
>
> @@ -135,13 +137,18 @@ struct l2fwd_port_statistics { struct
> l2fwd_port_statistics port_statistics[RTE_MAX_ETHPORTS];
>
> /* A tsc-based timer responsible for triggering statistics printout */ -#define
> TIMER_MILLISECOND 2000000ULL /* around 1ms at 2 Ghz */
> +#define TIMER_MILLISECOND 1
> #define MAX_TIMER_PERIOD 86400 /* 1 day max */ static int64_t
> timer_period = 10 * TIMER_MILLISECOND * 1000; /* default period is 10
> seconds */
> +static int64_t check_period = 5; /* default check cycle is 5ms */
> +
> +/* Keepalive structure */
> +struct rte_keepalive * rte_global_keepalive_info;
>
> /* Print out statistics on packets dropped */ static void
> -print_stats(void)
> +print_stats(__attribute__((unused)) struct rte_timer *ptr_timer,
> + __attribute__((unused)) void *ptr_data)
> {
> uint64_t total_packets_dropped, total_packets_tx, total_packets_rx;
> unsigned portid;
> @@ -283,11 +290,23 @@ l2fwd_main_loop(void)
> portid);
> }
>
> + uint64_t tsc_initial = rte_rdtsc();
> + uint64_t tsc_lifetime = (rand()&0x07) * rte_get_tsc_hz();
> +
> while (1) {
> + /* Keepalive heartbeat */
> + rte_keepalive_mark_alive(rte_global_keepalive_info);
>
> cur_tsc = rte_rdtsc();
>
> /*
> + * Die randomly within 7 secs for demo purposes if
> + * keepalive enables
> + */
Typo: If keepalive is enabled
> + if (check_period > 0 && cur_tsc - tsc_initial > tsc_lifetime)
> + break;
> +
> + /*
> * TX burst queue drain
> */
> diff_tsc = cur_tsc - prev_tsc;
> @@ -313,7 +332,7 @@ l2fwd_main_loop(void)
>
> /* do this only on master core */
> if (lcore_id ==
> rte_get_master_lcore()) {
> - print_stats();
> + print_stats(NULL, NULL);
> /* reset the timer */
> timer_tsc = 0;
> }
> @@ -357,6 +376,7 @@ l2fwd_usage(const char *prgname)
> printf("%s [EAL options] -- -p PORTMASK [-q NQ]\n"
> " -p PORTMASK: hexadecimal bitmask of ports to configure\n"
> " -q NQ: number of queue (=ports) per lcore (default is 1)\n"
> + " -K PERIOD: Keepalive check period (5 default; 86400 max)\n"
> " -T PERIOD: statistics will be refreshed each PERIOD
> seconds (0 to disable, 10 default, 86400 maximum)\n",
> prgname);
> }
> @@ -412,6 +432,22 @@ l2fwd_parse_timer_period(const char *q_arg)
> return n;
> }
>
> +static int
> +l2fwd_parse_check_period(const char *q_arg) {
> + char *end = NULL;
> + int n;
> +
> + /* parse number string */
> + n = strtol(q_arg, &end, 10);
> + if ((q_arg[0] == '\0') || (end == NULL) || (*end != '\0'))
> + return -1;
> + if (n >= MAX_TIMER_PERIOD)
> + return -1;
> +
> + return n;
> +}
> +
> /* Parse the argument given in the command line of the application */ static
> int l2fwd_parse_args(int argc, char **argv) @@ -426,7 +462,7 @@
> l2fwd_parse_args(int argc, char **argv)
>
> argvopt = argv;
>
> - while ((opt = getopt_long(argc, argvopt, "p:q:T:",
> + while ((opt = getopt_long(argc, argvopt, "p:q:T:K:",
> lgopts, &option_index)) != EOF) {
>
> switch (opt) {
> @@ -460,6 +496,16 @@ l2fwd_parse_args(int argc, char **argv)
> }
> break;
>
> + /* Check period */
> + case 'K':
> + check_period = l2fwd_parse_check_period(optarg);
> + if (check_period < 0) {
> + printf("invalid check period\n");
> + l2fwd_usage(prgname);
> + return -1;
> + }
> + break;
> +
> /* long options */
> case 0:
> l2fwd_usage(prgname);
> @@ -534,6 +580,18 @@ check_all_ports_link_status(uint8_t port_num,
> uint32_t port_mask)
> }
> }
>
> +static void
> +dead_core(__attribute__((unused)) void *ptr_data, const int id_core) {
> + printf("Dead core %i - restarting..\n", id_core);
> + if (rte_eal_get_lcore_state(id_core) == FINISHED) {
> + rte_eal_wait_lcore(id_core);
> + rte_eal_remote_launch(l2fwd_launch_one_lcore, NULL,
> id_core);
> + } else {
> + printf("..false positive!\n");
> + }
> +}
> +
> int
> main(int argc, char **argv)
> {
> @@ -600,7 +658,7 @@ main(int argc, char **argv)
> l2fwd_dst_ports[last_port] = last_port;
> }
>
> - rx_lcore_id = 0;
> + rx_lcore_id = 1;
> qconf = NULL;
>
> /* Initialize the port/queue configuration of each logical core */ @@ -
> 696,8 +754,59 @@ main(int argc, char **argv)
>
> check_all_ports_link_status(nb_ports, l2fwd_enabled_port_mask);
>
> - /* launch per-lcore init on every lcore */
> - rte_eal_mp_remote_launch(l2fwd_launch_one_lcore, NULL,
> CALL_MASTER);
> + struct rte_timer hb_timer, stats_timer;
> +
> + rte_timer_subsystem_init();
> + rte_timer_init(&stats_timer);
> +
> + if (check_period > 0) {
> + rte_global_keepalive_info =
> rte_keepalive_create(&dead_core, NULL);
> + if( rte_global_keepalive_info == NULL)
> + rte_exit(EXIT_FAILURE, "init_keep_alive() failed");
> + rte_timer_init(&hb_timer);
> + if (rte_timer_reset(&hb_timer,
> + (check_period * rte_get_timer_hz()) / 1000,
> + PERIODICAL,
> + rte_lcore_id(),
> + (void(*)(struct rte_timer*, void*))
> + &rte_keepalive_dispatch_pings,
> + rte_global_keepalive_info
> + ) != 0 )
> + rte_exit(EXIT_FAILURE, "Keepalive setup failure.\n");
> + }
> + if (timer_period > 0) {
> + if (rte_timer_reset(&stats_timer,
> + (timer_period * rte_get_timer_hz()) / 1000,
> + PERIODICAL,
> + rte_lcore_id(),
> + &print_stats, NULL
> + ) != 0 )
> + rte_exit(EXIT_FAILURE, "Stats setup failure.\n");
> + }
> + /* launch per-lcore init on every slave lcore */
> + RTE_LCORE_FOREACH_SLAVE(lcore_id) {
> + struct lcore_queue_conf *qconf =
> &lcore_queue_conf[lcore_id];
> +
> + if (qconf->n_rx_port == 0)
> + RTE_LOG(INFO, L2FWD,
> + "lcore %u has nothing to do\n",
> + lcore_id
> + );
> + else {
> + rte_eal_remote_launch(
> + l2fwd_launch_one_lcore,
> + NULL,
> + lcore_id
> + );
> +
> rte_keepalive_register_core(rte_global_keepalive_info,
> + lcore_id);
> + }
> + }
> + for (;;) {
> + rte_timer_manage();
> + rte_delay_ms(5);
> + }
> +
> RTE_LCORE_FOREACH_SLAVE(lcore_id) {
> if (rte_eal_wait_lcore(lcore_id) < 0)
> return -1;
> --
> 1.9.3
next prev parent reply other threads:[~2015-10-23 14:24 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-15 12:16 [dpdk-dev] [RFC PATCH v1] rte: LCore heartbeat example Remy Horton
2015-09-15 13:10 ` Thomas Monjalon
2015-09-23 9:00 ` Remy Horton
2015-10-05 11:16 ` Mcnamara, John
2015-09-30 9:04 ` [dpdk-dev] [PATCH v2 0/3] Keepalive monitoring & reporting Remy Horton
2015-09-30 9:04 ` [dpdk-dev] [PATCH v2 1/3] rte: add keep alive functionality Remy Horton
2015-10-23 11:40 ` Tahhan, Maryam
2015-10-23 14:27 ` Wiles, Keith
2015-10-26 16:36 ` Remy Horton
2015-09-30 9:04 ` [dpdk-dev] [PATCH v2 2/3] l2fwd: keep alive sample application Remy Horton
2015-10-23 14:23 ` Tahhan, Maryam [this message]
2015-10-27 8:48 ` Remy Horton
2015-10-27 10:10 ` Bruce Richardson
2015-09-30 9:04 ` [dpdk-dev] [PATCH v2 3/3] docs: add keep alive sample app guide Remy Horton
2015-10-28 8:52 ` [dpdk-dev] [PATCH v3 0/3] Keepalive monitoring & reporting Remy Horton
2015-10-28 8:52 ` [dpdk-dev] [PATCH v3 1/3] rte: add keep alive functionality Remy Horton
2015-10-28 12:25 ` Tahhan, Maryam
2015-11-04 1:48 ` Thomas Monjalon
2015-11-04 1:54 ` Thomas Monjalon
2015-10-28 8:52 ` [dpdk-dev] [PATCH v3 2/3] docs: add keep alive sample app guide Remy Horton
2015-10-28 11:22 ` Van Haaren, Harry
2015-10-28 8:52 ` [dpdk-dev] [PATCH v3 3/3] example: add keep alive sample application Remy Horton
2015-10-28 12:28 ` Tahhan, Maryam
2015-11-05 11:32 ` [dpdk-dev] [PATCH v4 0/3] Keepalive monitoring & reporting Remy Horton
2015-11-05 11:32 ` [dpdk-dev] [PATCH v4 1/3] rte: add keep alive functionality Remy Horton
2015-11-05 16:43 ` Tahhan, Maryam
2015-11-10 14:02 ` Thomas Monjalon
2015-11-11 9:21 ` Remy Horton
2015-11-11 16:28 ` Stephen Hemminger
2015-11-18 10:21 ` Remy Horton
2015-11-13 16:09 ` Thomas Monjalon
2015-11-05 11:32 ` [dpdk-dev] [PATCH v4 2/3] docs: add keep alive sample app guide & release notes Remy Horton
2015-11-05 16:40 ` Van Haaren, Harry
2015-11-05 11:32 ` [dpdk-dev] [PATCH v4 3/3] example: add keep alive sample application Remy Horton
2015-11-05 16:44 ` Tahhan, Maryam
2015-11-11 6:52 ` [dpdk-dev] [PATCH v4 0/3] Keepalive monitoring & reporting Cao, Min
2015-11-18 14:05 ` [dpdk-dev] [PATCH v5 " Remy Horton
2015-11-18 14:05 ` [dpdk-dev] [PATCH v5 1/3] rte: add keep alive functionality Remy Horton
2015-11-18 14:05 ` [dpdk-dev] [PATCH v5 2/3] docs: add keep alive sample app guide & release notes Remy Horton
2015-11-19 11:32 ` Thomas Monjalon
2015-11-19 11:43 ` Remy Horton
2015-11-18 14:05 ` [dpdk-dev] [PATCH v5 3/3] example: add keep alive sample application Remy Horton
2015-11-19 11:31 ` Thomas Monjalon
2015-11-19 14:49 ` [dpdk-dev] [PATCH v5 0/3] Keepalive monitoring & reporting Thomas Monjalon
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=1A27633A6DA49C4A92FCD5D4312DBF536A5D9327@IRSMSX109.ger.corp.intel.com \
--to=maryam.tahhan@intel.com \
--cc=dev@dpdk.org \
--cc=remy.horton@intel.com \
/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).