Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/7294/?format=api
https://patches.dpdk.org/api/patches/7294/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1443603881-4700-3-git-send-email-remy.horton@intel.com/", "project": { "id": 1, "url": "https://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<1443603881-4700-3-git-send-email-remy.horton@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1443603881-4700-3-git-send-email-remy.horton@intel.com", "date": "2015-09-30T09:04:40", "name": "[dpdk-dev,v2,2/3] l2fwd: keep alive sample application", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "88cc7b32145c79ac04eea65c6015d82a33deec21", "submitter": { "id": 326, "url": "https://patches.dpdk.org/api/people/326/?format=api", "name": "Remy Horton", "email": "remy.horton@intel.com" }, "delegate": null, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1443603881-4700-3-git-send-email-remy.horton@intel.com/mbox/", "series": [], "comments": "https://patches.dpdk.org/api/patches/7294/comments/", "check": "pending", "checks": "https://patches.dpdk.org/api/patches/7294/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id BBC438DAD;\n\tWed, 30 Sep 2015 11:05:05 +0200 (CEST)", "from mga03.intel.com (mga03.intel.com [134.134.136.65])\n\tby dpdk.org (Postfix) with ESMTP id 2A2998D99\n\tfor <dev@dpdk.org>; Wed, 30 Sep 2015 11:05:02 +0200 (CEST)", "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby orsmga103.jf.intel.com with ESMTP; 30 Sep 2015 02:04:44 -0700", "from rhorton-mobl.ger.corp.intel.com (HELO localhost.ir.intel.com)\n\t([163.33.229.80])\n\tby fmsmga002.fm.intel.com with ESMTP; 30 Sep 2015 02:04:44 -0700" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.17,611,1437462000\"; d=\"scan'208\";a=\"816043129\"", "From": "Remy Horton <remy.horton@intel.com>", "To": "dev@dpdk.org", "Date": "Wed, 30 Sep 2015 10:04:40 +0100", "Message-Id": "<1443603881-4700-3-git-send-email-remy.horton@intel.com>", "X-Mailer": "git-send-email 1.9.3", "In-Reply-To": "<1443603881-4700-1-git-send-email-remy.horton@intel.com>", "References": "<1443603881-4700-1-git-send-email-remy.horton@intel.com>", "Subject": "[dpdk-dev] [PATCH v2 2/3] l2fwd: keep alive sample application", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "patches and discussions about DPDK <dev.dpdk.org>", "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Modification of l2fwd to demonstrate keep-alive functionality.\n\nSigned-off-by: Remy Horton <remy.horton@intel.com>\n---\n examples/l2fwd/Makefile | 2 +-\n examples/l2fwd/main.c | 125 ++++++++++++++++++++++++++++++++++++++++++++----\n 2 files changed, 118 insertions(+), 9 deletions(-)", "diff": "diff --git a/examples/l2fwd/Makefile b/examples/l2fwd/Makefile\nindex 78feeeb..8647174 100644\n--- a/examples/l2fwd/Makefile\n+++ b/examples/l2fwd/Makefile\n@@ -39,7 +39,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc\n include $(RTE_SDK)/mk/rte.vars.mk\n \n # binary name\n-APP = l2fwd\n+APP = l2fwd-keepalive\n \n # all source are stored in SRCS-y\n SRCS-y := main.c\ndiff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c\nindex 720fd5a..131e5a2 100644\n--- a/examples/l2fwd/main.c\n+++ b/examples/l2fwd/main.c\n@@ -1,7 +1,7 @@\n /*-\n * BSD LICENSE\n *\n- * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+ * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n@@ -68,6 +68,8 @@\n #include <rte_ring.h>\n #include <rte_mempool.h>\n #include <rte_mbuf.h>\n+#include <rte_timer.h>\n+#include <rte_keepalive.h>\n \n #define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1\n \n@@ -135,13 +137,18 @@ struct l2fwd_port_statistics {\n struct l2fwd_port_statistics port_statistics[RTE_MAX_ETHPORTS];\n \n /* A tsc-based timer responsible for triggering statistics printout */\n-#define TIMER_MILLISECOND 2000000ULL /* around 1ms at 2 Ghz */\n+#define TIMER_MILLISECOND 1\n #define MAX_TIMER_PERIOD 86400 /* 1 day max */\n static int64_t timer_period = 10 * TIMER_MILLISECOND * 1000; /* default period is 10 seconds */\n+static int64_t check_period = 5; /* default check cycle is 5ms */\n+\n+/* Keepalive structure */\n+struct rte_keepalive * rte_global_keepalive_info;\n \n /* Print out statistics on packets dropped */\n static void\n-print_stats(void)\n+print_stats(__attribute__((unused)) struct rte_timer *ptr_timer,\n+\t__attribute__((unused)) void *ptr_data)\n {\n \tuint64_t total_packets_dropped, total_packets_tx, total_packets_rx;\n \tunsigned portid;\n@@ -283,11 +290,23 @@ l2fwd_main_loop(void)\n \t\t\tportid);\n \t}\n \n+\tuint64_t tsc_initial = rte_rdtsc();\n+\tuint64_t tsc_lifetime = (rand()&0x07) * rte_get_tsc_hz();\n+\n \twhile (1) {\n+\t\t/* Keepalive heartbeat */\n+\t\trte_keepalive_mark_alive(rte_global_keepalive_info);\n \n \t\tcur_tsc = rte_rdtsc();\n \n \t\t/*\n+\t\t * Die randomly within 7 secs for demo purposes if\n+\t\t * keepalive enables\n+\t\t */\n+\t\tif (check_period > 0 && cur_tsc - tsc_initial > tsc_lifetime)\n+\t\t\tbreak;\n+\n+\t\t/*\n \t\t * TX burst queue drain\n \t\t */\n \t\tdiff_tsc = cur_tsc - prev_tsc;\n@@ -313,7 +332,7 @@ l2fwd_main_loop(void)\n \n \t\t\t\t\t/* do this only on master core */\n \t\t\t\t\tif (lcore_id == rte_get_master_lcore()) {\n-\t\t\t\t\t\tprint_stats();\n+\t\t\t\t\t\tprint_stats(NULL, NULL);\n \t\t\t\t\t\t/* reset the timer */\n \t\t\t\t\t\ttimer_tsc = 0;\n \t\t\t\t\t}\n@@ -357,6 +376,7 @@ l2fwd_usage(const char *prgname)\n \tprintf(\"%s [EAL options] -- -p PORTMASK [-q NQ]\\n\"\n \t \" -p PORTMASK: hexadecimal bitmask of ports to configure\\n\"\n \t \" -q NQ: number of queue (=ports) per lcore (default is 1)\\n\"\n+\t \" -K PERIOD: Keepalive check period (5 default; 86400 max)\\n\"\n \t\t \" -T PERIOD: statistics will be refreshed each PERIOD seconds (0 to disable, 10 default, 86400 maximum)\\n\",\n \t prgname);\n }\n@@ -412,6 +432,22 @@ l2fwd_parse_timer_period(const char *q_arg)\n \treturn n;\n }\n \n+static int\n+l2fwd_parse_check_period(const char *q_arg)\n+{\n+\tchar *end = NULL;\n+\tint n;\n+\n+\t/* parse number string */\n+\tn = strtol(q_arg, &end, 10);\n+\tif ((q_arg[0] == '\\0') || (end == NULL) || (*end != '\\0'))\n+\t\treturn -1;\n+\tif (n >= MAX_TIMER_PERIOD)\n+\t\treturn -1;\n+\n+\treturn n;\n+}\n+\n /* Parse the argument given in the command line of the application */\n static int\n l2fwd_parse_args(int argc, char **argv)\n@@ -426,7 +462,7 @@ l2fwd_parse_args(int argc, char **argv)\n \n \targvopt = argv;\n \n-\twhile ((opt = getopt_long(argc, argvopt, \"p:q:T:\",\n+\twhile ((opt = getopt_long(argc, argvopt, \"p:q:T:K:\",\n \t\t\t\t lgopts, &option_index)) != EOF) {\n \n \t\tswitch (opt) {\n@@ -460,6 +496,16 @@ l2fwd_parse_args(int argc, char **argv)\n \t\t\t}\n \t\t\tbreak;\n \n+\t\t/* Check period */\n+\t\tcase 'K':\n+\t\t\tcheck_period = l2fwd_parse_check_period(optarg);\n+\t\t\tif (check_period < 0) {\n+\t\t\t\tprintf(\"invalid check period\\n\");\n+\t\t\t\tl2fwd_usage(prgname);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tbreak;\n+\n \t\t/* long options */\n \t\tcase 0:\n \t\t\tl2fwd_usage(prgname);\n@@ -534,6 +580,18 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)\n \t}\n }\n \n+static void\n+dead_core(__attribute__((unused)) void *ptr_data, const int id_core)\n+{\n+\tprintf(\"Dead core %i - restarting..\\n\", id_core);\n+\tif (rte_eal_get_lcore_state(id_core) == FINISHED) {\n+\t\trte_eal_wait_lcore(id_core);\n+\t\trte_eal_remote_launch(l2fwd_launch_one_lcore, NULL, id_core);\n+\t} else {\n+\t\tprintf(\"..false positive!\\n\");\n+\t}\n+}\n+\n int\n main(int argc, char **argv)\n {\n@@ -600,7 +658,7 @@ main(int argc, char **argv)\n \t\tl2fwd_dst_ports[last_port] = last_port;\n \t}\n \n-\trx_lcore_id = 0;\n+\trx_lcore_id = 1;\n \tqconf = NULL;\n \n \t/* Initialize the port/queue configuration of each logical core */\n@@ -696,8 +754,59 @@ main(int argc, char **argv)\n \n \tcheck_all_ports_link_status(nb_ports, l2fwd_enabled_port_mask);\n \n-\t/* launch per-lcore init on every lcore */\n-\trte_eal_mp_remote_launch(l2fwd_launch_one_lcore, NULL, CALL_MASTER);\n+\tstruct rte_timer hb_timer, stats_timer;\n+\n+\trte_timer_subsystem_init();\n+\trte_timer_init(&stats_timer);\n+\n+\tif (check_period > 0) {\n+\t\trte_global_keepalive_info = rte_keepalive_create(&dead_core, NULL);\n+\t\tif( rte_global_keepalive_info == NULL)\n+\t\t\trte_exit(EXIT_FAILURE, \"init_keep_alive() failed\");\n+\t\trte_timer_init(&hb_timer);\n+\t\tif (rte_timer_reset(&hb_timer,\n+\t\t\t\t(check_period * rte_get_timer_hz()) / 1000,\n+\t\t\t\tPERIODICAL,\n+\t\t\t\trte_lcore_id(),\n+\t\t\t\t(void(*)(struct rte_timer*, void*))\n+\t\t\t\t&rte_keepalive_dispatch_pings,\n+\t\t\t\trte_global_keepalive_info\n+\t\t\t\t) != 0 )\n+\t\t\trte_exit(EXIT_FAILURE, \"Keepalive setup failure.\\n\");\n+\t}\n+\tif (timer_period > 0) {\n+\t\tif (rte_timer_reset(&stats_timer,\n+\t\t\t\t(timer_period * rte_get_timer_hz()) / 1000,\n+\t\t\t\tPERIODICAL,\n+\t\t\t\trte_lcore_id(),\n+\t\t\t\t&print_stats, NULL\n+\t\t\t\t) != 0 )\n+\t\t\trte_exit(EXIT_FAILURE, \"Stats setup failure.\\n\");\n+\t}\n+\t/* launch per-lcore init on every slave lcore */\n+\tRTE_LCORE_FOREACH_SLAVE(lcore_id) {\n+\t\tstruct lcore_queue_conf *qconf = &lcore_queue_conf[lcore_id];\n+\n+\t\tif (qconf->n_rx_port == 0)\n+\t\t\tRTE_LOG(INFO, L2FWD,\n+\t\t\t\t\"lcore %u has nothing to do\\n\",\n+\t\t\t\tlcore_id\n+\t\t\t\t);\n+\t\telse {\n+\t\t\trte_eal_remote_launch(\n+\t\t\t\tl2fwd_launch_one_lcore,\n+\t\t\t\tNULL,\n+\t\t\t\tlcore_id\n+\t\t\t\t);\n+\t\t\trte_keepalive_register_core(rte_global_keepalive_info,\n+\t\t\t\tlcore_id);\n+\t\t}\n+\t}\n+\tfor (;;) {\n+\t\trte_timer_manage();\n+\t\trte_delay_ms(5);\n+\t\t}\n+\n \tRTE_LCORE_FOREACH_SLAVE(lcore_id) {\n \t\tif (rte_eal_wait_lcore(lcore_id) < 0)\n \t\t\treturn -1;\n", "prefixes": [ "dpdk-dev", "v2", "2/3" ] }{ "id": 7294, "url": "