From patchwork Thu Jan 4 09:05:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wisam Jaddo X-Patchwork-Id: 32882 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AD1C68E01; Thu, 4 Jan 2018 10:05:46 +0100 (CET) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50050.outbound.protection.outlook.com [40.107.5.50]) by dpdk.org (Postfix) with ESMTP id 7DA251D7 for ; Thu, 4 Jan 2018 10:05:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=L47FjVyEaWik8JsLuY+jpKXfxxMfq7aA/iWSk5/OlJo=; b=KZ7Cc8MJsXRRofTv85Sr22tu4ERecw79WbrB8wj5g6qSLYLxKOczo03MtgKT67N27oI1p3HtKt9rFNDn3MgaDd/qWADJOslg04zTe3KibSE7NJGe+GG3d+2uPWQkKLkAfrvu8rSCn6u7/4e+a67iBiU5tmKcgXfuwAtIE17NImM= Received: from AM5PR0502MB2865.eurprd05.prod.outlook.com (10.175.44.7) by AM5PR0502MB2868.eurprd05.prod.outlook.com (10.175.44.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Thu, 4 Jan 2018 09:05:44 +0000 Received: from AM5PR0502MB2865.eurprd05.prod.outlook.com ([fe80::d50c:a2ef:3510:3e6b]) by AM5PR0502MB2865.eurprd05.prod.outlook.com ([fe80::d50c:a2ef:3510:3e6b%18]) with mapi id 15.20.0386.006; Thu, 4 Jan 2018 09:05:43 +0000 From: Wisam Monther To: "jingjing.wu@intel.com" , Raslan Darawsheh CC: "dev@dpdk.org" , Ori Kam , Shahaf Shuler , Wisam Monther Thread-Topic: [PATCH] app/testpmd: add eth peer CLI command Thread-Index: AQHTfX31SSQFPLGBgkCrX2TFTgiGM6Njez7A Date: Thu, 4 Jan 2018 09:05:43 +0000 Message-ID: References: <1514205777-22188-1-git-send-email-wisamm@mellanox.com> In-Reply-To: <1514205777-22188-1-git-send-email-wisamm@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=wisamm@mellanox.com; x-originating-ip: [82.213.2.186] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM5PR0502MB2868; 6:7LVDoLiKJ8IFMNPFHnmsTye5MUojFGzpDJIxnSV0yDqdESfqeEKwgFMzn9Y7IuFqCmAn6Hk6P4e6M7+EzkgzOEQ8EFeK878nYFTlSmzCnfh/wdBi1NxOcTOe8cChV158dYZUafjZZVBkMRAuDWp2fiSc40SLB7Uy0hBrjLoYmrgL1rJ9Haf1MU+5HjpAqfEIiGbiM55Urh3AbJgyoxvLdXqyNMB6AxZ3CFbgkBO/8oDf61aoZJs20PSDZnassh4iZ1iKHRPpTshSK+eHfmDyrovlccLC70A6r1OYPCHpNbKjK+yH0mLZbbsEL4mMrJ2hfcazUjC3dkyAMUP2ssDlQ4L8NkuPbq/t6tpXXrpp9/6sfKi4T+TM6AkH25lwez9c; 5:Zs41PF/kHo4KtwDJrwfXngroXbJteGtGLEN7o6sg3N2awSKckXP3fDfKZ84HS5dhVqnevlUr4u4Mfe6M3CNuinW0wVrYzJUWUWQBg9A5gXjC12egB7TaXqVEU+hmrsLW7UOp37bQOfySf/QTiJkSQED5Pq2cthmIhYzEmGCM96Q=; 24:FP6oTiDr2mDdV6o5MAAJZoOhFS+CoWQ2xtMQMBo4ZgTE1ey4cCkn+14VlyqhTjIrFV1mkxz0XGGRFJPCgsZlfrAPwsNBikSa4TfPFaP4oog=; 7:6mTJnkljSM6tKhihUfJZ1gWXDhqCtCx/EHxAWI37kBDYcIDqq9CypaLtjYpSFPzTbTUZDKTjaAWOiefDceGghq8WEifaMOcl1ae2Sz7RjDxYkue77ft+VNZ4af9QT5iNiOHBMA6NDbuy2+wVxlUEkElEnXMmHWBZb8ZMQAuWUEvfrRFeyAzlNNaXuzYxl7aaTsJwhoeCMMZ5/6X44FHCxOx/j9kmO3D9ZxNWgLVcrMHB0EdVT8cA9VNnIGhxLRv9 x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: e4a706c8-4321-40b2-3dfd-08d553525619 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7153060); SRVR:AM5PR0502MB2868; x-ms-traffictypediagnostic: AM5PR0502MB2868: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231023)(944501075)(3002001)(10201501046)(6055026)(6041268)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:AM5PR0502MB2868; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:AM5PR0502MB2868; x-forefront-prvs: 054231DC40 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(396003)(366004)(39860400002)(39380400002)(376002)(189003)(199004)(13464003)(3660700001)(478600001)(3280700002)(5250100002)(8936002)(8676002)(81156014)(81166006)(316002)(3846002)(97736004)(53546011)(4326008)(68736007)(229853002)(2906002)(6506007)(86362001)(2501003)(25786009)(107886003)(6116002)(53936002)(6246003)(102836004)(6436002)(105586002)(76176011)(33656002)(99286004)(106356001)(55016002)(66066001)(14454004)(7696005)(9686003)(2900100001)(6636002)(2950100002)(110136005)(54906003)(305945005)(5660300001)(7736002)(74316002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0502MB2868; H:AM5PR0502MB2865.eurprd05.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: tvzL+AzOf9dXFgzZzp+yzsu2fqDlXKsWLbC1Dwigqo9DZEOBjpXJhwX72eIp9yqYrOPeGW3IuxFO+EqqlLkYcA== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4a706c8-4321-40b2-3dfd-08d553525619 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Jan 2018 09:05:43.8774 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0502MB2868 Subject: Re: [dpdk-dev] [PATCH] app/testpmd: add eth peer CLI command X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" +Raslan. BRs, Wisam Jaddo -----Original Message----- From: Wisam Jaddo [mailto:wisamm@mellanox.com] Sent: Monday, December 25, 2017 2:43 PM To: jingjing.wu@intel.com Cc: dev@dpdk.org; Ori Kam; Wisam Monther; Shahaf Shuler Subject: [PATCH] app/testpmd: add eth peer CLI command This command will simulate the process of setting the eth-peer from command line. It will be useful to preform extra testing. usage: testpmd> set eth-peer . Signed-off-by: Wisam Jaddo Acked-by: Wenzhuo Lu --- app/test-pmd/cmdline.c | 49 +++++++++++++++++++++++++++++ app/test-pmd/config.c | 19 +++++++++++ app/test-pmd/testpmd.h | 1 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 ++++++ 4 files changed, 78 insertions(+) -- 2.7.4 diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index f71d963..605720d 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -277,6 +277,9 @@ static void cmd_help_long_parsed(void *parsed_result, "set nbcore (num)\n" " Set number of cores.\n\n" + "set eth-peer (port_id) (peer_addr)\n" + " set the peer address for certain port.\n\n" + "set coremask (mask)\n" " Set the forwarding cores hexadecimal mask.\n\n" @@ -2954,6 +2957,51 @@ cmdline_parse_inst_t cmd_set_fwd_mask = { }, }; +/* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */ struct +cmd_eth_peer_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t eth_peer; + portid_t port_id; + cmdline_fixed_string_t peer_addr; +}; + +static void cmd_set_eth_peer_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_eth_peer_result *res = parsed_result; + + if (test_done == 0) { + printf("Please stop forwarding first\n"); + return; + } + if (!strcmp(res->eth_peer, "eth-peer")) { + set_fwd_eth_peer(res->port_id, res->peer_addr); + fwd_config_setup(); + } +} +cmdline_parse_token_string_t cmd_eth_peer_set = + TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set"); +cmdline_parse_token_string_t cmd_eth_peer = + TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, +"eth-peer"); cmdline_parse_token_num_t cmd_eth_peer_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16); +cmdline_parse_token_string_t cmd_eth_peer_addr = + TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL); + +cmdline_parse_inst_t cmd_set_fwd_eth_peer = { + .f = cmd_set_eth_peer_parsed, + .data = NULL, + .help_str = "set eth-peer ", + .tokens = { + (void *)&cmd_eth_peer_set, + (void *)&cmd_eth_peer, + (void *)&cmd_eth_peer_port_id, + (void *)&cmd_eth_peer_addr, + NULL, + }, +}; + /* * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION */ @@ -15558,6 +15606,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_txsplit, (cmdline_parse_inst_t *)&cmd_set_fwd_list, (cmdline_parse_inst_t *)&cmd_set_fwd_mask, + (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, (cmdline_parse_inst_t *)&cmd_set_fwd_mode, (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode, (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index cd2ac11..876ee83 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -78,6 +78,7 @@ #include #endif #include +#include #include "testpmd.h" @@ -2234,6 +2235,24 @@ set_fwd_lcores_list(unsigned int *lcorelist, unsigned int nb_lc) return 0; } +void +set_fwd_eth_peer(portid_t port_id, char *peer_addr) { + uint8_t c, new_peer_addr[6]; + if (!rte_eth_dev_is_valid_port(port_id)) { + printf("Error: Invalid port number %i\n", port_id); + return; + } + if (cmdline_parse_etheraddr(NULL, peer_addr, &new_peer_addr, + sizeof(new_peer_addr)) < 0) { + printf("Error: Invalid ethernet address: %s\n", peer_addr); + return; + } + for (c = 0; c < 6; c++) + peer_eth_addrs[port_id].addr_bytes[c] = + new_peer_addr[c]; +} + int set_fwd_lcores_mask(uint64_t lcoremask) { diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 1639d27..a2e1a5c 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -632,6 +632,7 @@ int set_fwd_lcores_list(unsigned int *lcorelist, unsigned int nb_lc); int set_fwd_lcores_mask(uint64_t lcoremask); void set_fwd_lcores_number(uint16_t nb_lc); +void set_fwd_eth_peer(portid_t port_id, char *peer_addr); void set_fwd_ports_list(unsigned int *portlist, unsigned int nb_pt); void set_fwd_ports_mask(uint64_t portmask); void set_fwd_ports_number(uint16_t nb_pt); diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 9789139..7f09cf9 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -459,6 +459,15 @@ set nbport (num) This is equivalent to the ``--nb-ports`` command-line option. +set eth-peer +~~~~~~~~~~~~ + +Set the forwarding peer address for certain port:: + + testpmd> set eth-peer (port_id) (perr_addr) + +This is equivalent to the ``--eth-peer`` command-line option. + set nbcore ~~~~~~~~~~