From: Xueming Li <xuemingl@mellanox.com>
To: Wu Jingjing <jingjing.wu@intel.com>,
Harry van Haaren <harry.van.haaren@intel.com>
Cc: Xueming Li <xuemingl@mellanox.com>, dev@dpdk.org
Subject: [dpdk-dev] [RFC v1 5/9] app/testpmd: add python command
Date: Fri, 8 Dec 2017 16:22:21 +0800 [thread overview]
Message-ID: <20171208082225.44913-6-xuemingl@mellanox.com> (raw)
In-Reply-To: <20171208082225.44913-1-xuemingl@mellanox.com>
In-Reply-To: <20171019140649.26668-2-xuemingl@mellanox.com>
py shell: invoke python shell, Ctrl+d to quit
py <any>: run python clause
Signed-off-by: Xueming Li <xuemingl@mellanox.com>
Conflicts:
app/test-pmd/cmdline.c
---
app/test-pmd/cmdline.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4acce9f07..6654a62cb 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -95,6 +95,9 @@
#ifdef RTE_LIBRTE_I40E_PMD
#include <rte_pmd_i40e.h>
#endif
+#ifdef RTE_LIBRTE_PYTHON
+#include <rte_python.h>
+#endif
#ifdef RTE_LIBRTE_BNXT_PMD
#include <rte_pmd_bnxt.h>
#endif
@@ -150,6 +153,8 @@ struct cmd_help_long_result {
cmdline_fixed_string_t section;
};
+extern cmdline_parse_ctx_t main_ctx[];
+
static void cmd_help_long_parsed(void *parsed_result,
struct cmdline *cl,
__attribute__((unused)) void *data)
@@ -15535,6 +15540,58 @@ cmdline_parse_inst_t cmd_load_from_file = {
},
};
+#ifdef RTE_LIBRTE_PYTHON
+
+/* "py" command */
+struct cmd_py_run_result {
+ cmdline_fixed_string_t py;
+ cmdline_fixed_string_t code;
+};
+
+cmdline_parse_token_string_t cmd_py_run_py =
+ TOKEN_STRING_INITIALIZER(struct cmd_py_run_result, py, "py");
+cmdline_parse_token_string_t cmd_py_run_code =
+ TOKEN_STRING_INITIALIZER(struct cmd_py_run_result, code, "");
+
+static void
+cmd_py_run_parsed(
+ void *parsed_result,
+ __attribute__((unused)) struct cmdline *cl,
+ __attribute__((unused)) void *data)
+{
+ struct cmd_py_run_result *res = parsed_result;
+
+ if (rte_python_init())
+ return;
+ if (!strcmp("shell", res->code)) {
+ cmdline_stdin_exit(testpmd_cl);
+ if (rte_python_shell())
+ printf("Failed to open python shell!\n");
+ testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> ");
+
+ } else if (!strcmp("debug", res->code)) {
+ rte_python_debug = 1;
+ rte_log_set_level(RTE_LOGTYPE_PYTHON, RTE_LOG_DEBUG);
+ } else if (!strcmp("nodebug", res->code))
+ rte_python_debug = 0;
+ else
+ rte_python_run(res->code);
+}
+
+cmdline_parse_inst_t cmd_py_run = {
+ .f = cmd_py_run_parsed,
+ .data = NULL,
+ .help_str = "run python code like: hex(123)\n"
+ "\t'py shell' to enter shell (ctrl + d to quit)\n"
+ "\t'py debug|nodebug' to toggle debug output, --log-level=9",
+ .tokens = {
+ (void *)&cmd_py_run_py,
+ (void *)&cmd_py_run_code,
+ NULL,
+ },
+};
+#endif
+
/* ******************************************************************************** */
/* list of instructions */
@@ -15543,6 +15600,9 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_help_long,
(cmdline_parse_inst_t *)&cmd_quit,
(cmdline_parse_inst_t *)&cmd_load_from_file,
+#ifdef RTE_LIBRTE_PYTHON
+ (cmdline_parse_inst_t *)&cmd_py_run,
+#endif
(cmdline_parse_inst_t *)&cmd_showport,
(cmdline_parse_inst_t *)&cmd_showqueue,
(cmdline_parse_inst_t *)&cmd_showportall,
--
2.13.3
next prev parent reply other threads:[~2017-12-08 8:23 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-19 14:06 [dpdk-dev] [RFC PATCH 0/2] using scapy to generate packet templates Xueming Li
2017-10-19 14:06 ` [dpdk-dev] [RFC PATCH 1/2] app/testpmd: add packet template Xueming Li
2017-12-05 4:43 ` [dpdk-dev] [RFC v1 00/11] scapy/python extension Xueming Li
2017-12-05 4:45 ` Xueming Li
2017-12-05 4:48 ` Xueming Li
2017-12-05 4:55 ` Xueming Li
2017-12-05 6:14 ` Xueming(Steven) Li
2017-12-05 5:00 ` Xueming Li
2017-12-05 5:03 ` [dpdk-dev] [RFC v1 00/11] scappy/pythoon extension Xueming Li
2017-12-05 5:04 ` [dpdk-dev] [RFC v1 00/11] scapy/python extension Xueming Li
2017-12-10 23:16 ` Wiles, Keith
2019-01-10 13:06 ` Eelco Chaudron
2019-01-16 13:24 ` Xueming(Steven) Li
2017-12-08 8:22 ` [dpdk-dev] [RFC v1 0/9] " Xueming Li
2017-12-08 8:22 ` [dpdk-dev] [RFC v1 1/9] lib/cmdline: add echo support in batch loading from file Xueming Li
2017-12-08 8:22 ` [dpdk-dev] [RFC v1 2/9] app/testpmd: support command echo in CLI batch loading Xueming Li
2017-12-08 8:22 ` [dpdk-dev] [RFC v1 3/9] test: update batch loading test Xueming Li
2017-12-08 8:22 ` [dpdk-dev] [RFC v1 4/9] lib/python: add embedded python lib Xueming Li
2017-12-08 8:22 ` Xueming Li [this message]
2017-12-08 8:22 ` [dpdk-dev] [RFC v1 6/9] app/testpmd: add pktgen forwarding engine Xueming Li
2017-12-08 8:22 ` [dpdk-dev] [RFC v1 7/9] app/testpmd: add pktgen engine scapy commands Xueming Li
2017-12-08 8:22 ` [dpdk-dev] [RFC v1 8/9] test/expect: add expect test scripts Xueming Li
2017-12-08 8:22 ` [dpdk-dev] [RFC v1 9/9] doc/scapy: add scapy how-to guide Xueming Li
2017-10-19 14:06 ` [dpdk-dev] [RFC PATCH 2/2] app/testpmd: add scapy command as pkt template Xueming Li
2017-10-19 15:21 ` [dpdk-dev] [RFC PATCH 0/2] using scapy to generate packet templates Van Haaren, Harry
2017-10-21 16:04 ` Xueming(Steven) Li
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=20171208082225.44913-6-xuemingl@mellanox.com \
--to=xuemingl@mellanox.com \
--cc=dev@dpdk.org \
--cc=harry.van.haaren@intel.com \
--cc=jingjing.wu@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).