From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by dpdk.org (Postfix) with ESMTP id 6DED36AC4 for ; Sat, 1 Mar 2014 13:13:41 +0100 (CET) Received: by mail-wi0-f181.google.com with SMTP id hi5so1561121wib.14 for ; Sat, 01 Mar 2014 04:15:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=h+7dc3h++RWnvvailso6FtT/+AVkkP2eh5fTutX9YqU=; b=OO3a4fJMQUDBDbV+2eYDNlkWRuc1Qm7j5hyUEn1mQSSPEB52tkwyVHTRjgxROE78ta VLRdoYKHz0KRStpu8I3OAC1hbf+yUz4hFkDKEpY3G4MIvsdpHibMyBH5ql96HJxX3Edd 9k2fBhUWDm5MRUpPJ0crHtaxqG9QxFJ/vtVPTzv/O+VEFYo2vrVaLFScoytsvaT+nCnC G3gNmDehoUiGD4lpB5SOerlKLZl6ZJR/MhhuXjgeUYXDX+rsuDm8s34c7mDmZU3k5QH7 nfKvsCmgLtlOvC7R7bc5Fdm9oGbdtxXwT17amKz0jUyh/C2Br2CA5ASm/0dPTQeyfdFR Iqkw== X-Gm-Message-State: ALoCoQl9YLbAjkgEH4J8xqJeQocEivl5z0+l/2dMPJsN7Hb4IqpBZIUKn7zY5mgA/Q3Dxhn0vO68 X-Received: by 10.194.216.68 with SMTP id oo4mr92516wjc.79.1393676108609; Sat, 01 Mar 2014 04:15:08 -0800 (PST) Received: from glumotte.dev.6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by mx.google.com with ESMTPSA id br10sm12085475wjb.3.2014.03.01.04.15.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Mar 2014 04:15:08 -0800 (PST) From: Olivier Matz To: dev@dpdk.org Date: Sat, 1 Mar 2014 13:15:01 +0100 Message-Id: <1393676101-17830-1-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1393608350-4431-12-git-send-email-olivier.matz@6wind.com> References: <1393608350-4431-12-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH v2 11/11] testpmd: add several dump commands, useful for debug X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Mar 2014 12:13:41 -0000 Copy all the dump commands provided in app/test into app/testpmd. These commands are useful to debug a problem when using testpmd. Signed-off-by: Olivier Matz --- app/test-pmd/cmdline.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) v2 changes: * passed checkpatch.pl diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 37aa3d2..7becedc 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -2,6 +2,7 @@ * BSD LICENSE * * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + * Copyright(c) 2014 6WIND S.A. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -72,6 +73,7 @@ #include #include #include +#include #include #include @@ -4998,6 +5000,115 @@ cmdline_parse_inst_t cmd_reset_mirror_rule = { /* ******************************************************************************** */ +struct cmd_dump_result { + cmdline_fixed_string_t dump; +}; + +static void +dump_struct_sizes(void) +{ +#define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t)); + DUMP_SIZE(struct rte_mbuf); + DUMP_SIZE(struct rte_pktmbuf); + DUMP_SIZE(struct rte_ctrlmbuf); + DUMP_SIZE(struct rte_mempool); + DUMP_SIZE(struct rte_ring); +#undef DUMP_SIZE +} + +static void cmd_dump_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_dump_result *res = parsed_result; + + if (!strcmp(res->dump, "dump_physmem")) + rte_dump_physmem_layout(); + else if (!strcmp(res->dump, "dump_memzone")) + rte_memzone_dump(); + else if (!strcmp(res->dump, "dump_log_history")) + rte_log_dump_history(); + else if (!strcmp(res->dump, "dump_struct_sizes")) + dump_struct_sizes(); + else if (!strcmp(res->dump, "dump_ring")) + rte_ring_list_dump(); + else if (!strcmp(res->dump, "dump_mempool")) + rte_mempool_list_dump(); + else if (!strcmp(res->dump, "dump_devargs")) + rte_eal_devargs_dump(); +} + +cmdline_parse_token_string_t cmd_dump_dump = + TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, + "dump_physmem#" + "dump_memzone#" + "dump_log_history#" + "dump_struct_sizes#" + "dump_ring#" + "dump_mempool#" + "dump_devargs"); + +cmdline_parse_inst_t cmd_dump = { + .f = cmd_dump_parsed, /* function to call */ + .data = NULL, /* 2nd arg of func */ + .help_str = "dump status", + .tokens = { /* token list, NULL terminated */ + (void *)&cmd_dump_dump, + NULL, + }, +}; + +/* ******************************************************************************** */ + +struct cmd_dump_one_result { + cmdline_fixed_string_t dump; + cmdline_fixed_string_t name; +}; + +static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_dump_one_result *res = parsed_result; + + if (!strcmp(res->dump, "dump_ring")) { + struct rte_ring *r; + r = rte_ring_lookup(res->name); + if (r == NULL) { + cmdline_printf(cl, "Cannot find ring\n"); + return; + } + rte_ring_dump(r); + } else if (!strcmp(res->dump, "dump_mempool")) { + struct rte_mempool *mp; + mp = rte_mempool_lookup(res->name); + if (mp == NULL) { + cmdline_printf(cl, "Cannot find mempool\n"); + return; + } + rte_mempool_dump(mp); + } +} + +cmdline_parse_token_string_t cmd_dump_one_dump = + TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump, + "dump_ring#dump_mempool"); + +cmdline_parse_token_string_t cmd_dump_one_name = + TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL); + +cmdline_parse_inst_t cmd_dump_one = { + .f = cmd_dump_one_parsed, /* function to call */ + .data = NULL, /* 2nd arg of func */ + .help_str = "dump one ring/mempool: dump_ring|dump_mempool ", + .tokens = { /* token list, NULL terminated */ + (void *)&cmd_dump_one_dump, + (void *)&cmd_dump_one_name, + NULL, + }, +}; + +/* ******************************************************************************** */ + /* list of instructions */ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_help_brief, @@ -5076,6 +5187,8 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_mirror_mask, (cmdline_parse_inst_t *)&cmd_set_mirror_link, (cmdline_parse_inst_t *)&cmd_reset_mirror_rule, + (cmdline_parse_inst_t *)&cmd_dump, + (cmdline_parse_inst_t *)&cmd_dump_one, NULL, }; -- 1.8.5.3