From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 1901BBD34 for ; Wed, 16 May 2018 17:03:02 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 May 2018 08:03:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,406,1520924400"; d="scan'208";a="42290460" Received: from irsmsx151.ger.corp.intel.com ([163.33.192.59]) by orsmga006.jf.intel.com with ESMTP; 16 May 2018 08:03:00 -0700 Received: from irsmsx155.ger.corp.intel.com (163.33.192.3) by IRSMSX151.ger.corp.intel.com (163.33.192.59) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 16 May 2018 16:02:46 +0100 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.150]) by irsmsx155.ger.corp.intel.com ([169.254.14.95]) with mapi id 14.03.0319.002; Wed, 16 May 2018 16:02:46 +0100 From: "Iremonger, Bernard" To: Wisam Jaddo , "Wu, Jingjing" , "Lu, Wenzhuo" , "thomas@monjalon.net" CC: "rasland@mellanox.com" , "dev@dpdk.org" , "shahafs@mellanox.com" Thread-Topic: [dpdk-dev] [PATCH v3 1/2] app/testpmd: add custom topology command Thread-Index: AQHT55R5GuD6SaaW50eyvD9TplRDYKQyfiiQ Date: Wed, 16 May 2018 15:02:45 +0000 Message-ID: <8CEF83825BEC744B83065625E567D7C24E0CD4CF@IRSMSX108.ger.corp.intel.com> References: <1525870039-11261-1-git-send-email-wisamm@mellanox.com> <1525870039-11261-2-git-send-email-wisamm@mellanox.com> In-Reply-To: <1525870039-11261-2-git-send-email-wisamm@mellanox.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNjQ3YTZmODktZGQyZC00NGYzLWE1MGYtOWU5NDlmNTNjM2E3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoicFZoNU9tT2lTXC9hOExMaWMwTVdFNWZkYllEXC9FckhwNk1EVkYwNGt0SzVPRnFiazBXZGVkcFE0MjZcLzRqQzc3bCJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v3 1/2] app/testpmd: add custom topology 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: , X-List-Received-Date: Wed, 16 May 2018 15:03:03 -0000 Hi Wisam, > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wisam Jaddo > Sent: Wednesday, May 9, 2018 1:47 PM > To: Wu, Jingjing ; Lu, Wenzhuo > ; thomas@monjalon.net > Cc: rasland@mellanox.com; dev@dpdk.org; shahafs@mellanox.com; > wisamm@mellanox.com > Subject: [dpdk-dev] [PATCH v3 1/2] app/testpmd: add custom topology > command >=20 > Set custom topology for forwading packets by making the given two ports a= s > pair, in custom topology the active ports will be the defiend in custum-t= opo > only. >=20 > This command will be useful in testing, when special topology is needed. >=20 > usage: > testpmd> set custom-topo (port_id_1) (port_id_2) >=20 > Signed-off-by: Wisam Jaddo > --- > app/test-pmd/cmdline.c | 49 > +++++++++++++++++++++++++++++ > app/test-pmd/config.c | 41 +++++++++++++++++++++++= + > app/test-pmd/parameters.c | 6 ++-- > app/test-pmd/testpmd.h | 8 ++++- > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 8 +++++ > 5 files changed, 109 insertions(+), 3 deletions(-) >=20 > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index > 9615670..9d48048 100644 > --- a/app/test-pmd/cmdline.c > +++ b/app/test-pmd/cmdline.c > @@ -466,6 +466,9 @@ static void cmd_help_long_parsed(void > *parsed_result, > "set eth-peer (port_id) (peer_addr)\n" > " set the peer address for certain port.\n\n" >=20 > + "set custom-topo (port_id_1) (port_id_2)\n" > + " set custom topo.\n\n" > + > "set port (port_id) uta (mac_address|all) (on|off)\n" > " Add/Remove a or all unicast hash filter(s)" > "from port X.\n\n" > @@ -7649,6 +7652,51 @@ cmdline_parse_inst_t cmd_set_fwd_eth_peer =3D { > }, > }; >=20 > +/* *** SET CUSTOM TOPO FOR CERTAIN PORT *** */ struct > +cmd_custom_topo_result { > + cmdline_fixed_string_t set; > + cmdline_fixed_string_t custom_topo; > + portid_t port_id_1; > + portid_t port_id_2; > +}; > + > +static void cmd_set_custom_topo_parsed(void *parsed_result, > + __attribute__((unused)) struct cmdline *cl, > + __attribute__((unused)) void *data) { > + struct cmd_custom_topo_result *res =3D parsed_result; > + > + if (test_done =3D=3D 0) { > + printf("Please stop forwarding first\n"); > + return; > + } > + if (!strcmp(res->custom_topo, "custom-topo")) { > + set_custom_topo(res->port_id_1, res->port_id_2); > + fwd_config_setup(); > + } > +} > +cmdline_parse_token_string_t cmd_set_custom_topo_set =3D > + TOKEN_STRING_INITIALIZER(struct cmd_custom_topo_result, set, > "set"); > +cmdline_parse_token_string_t cmd_set_custom_topo_custom_topo =3D > + TOKEN_STRING_INITIALIZER(struct cmd_custom_topo_result, > custom_topo, > +"custom-topo"); cmdline_parse_token_num_t > cmd_set_custom_topo_port_id_1 =3D > + TOKEN_NUM_INITIALIZER(struct cmd_custom_topo_result, > port_id_1, > +UINT16); cmdline_parse_token_num_t cmd_set_custom_topo_port_id_2 > =3D > + TOKEN_NUM_INITIALIZER(struct cmd_custom_topo_result, > port_id_2, > +UINT16); > + > +cmdline_parse_inst_t cmd_set_custom_topo =3D { > + .f =3D cmd_set_custom_topo_parsed, > + .data =3D NULL, > + .help_str =3D "set custom-topo (port_id_1) (port_id_2)", > + .tokens =3D { > + (void *)&cmd_set_custom_topo_set, > + (void *)&cmd_set_custom_topo_custom_topo, > + (void *)&cmd_set_custom_topo_port_id_1, > + (void *)&cmd_set_custom_topo_port_id_2, > + NULL, > + }, > +}; > + > /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ struct > cmd_set_qmap_result { > cmdline_fixed_string_t set; > @@ -16540,6 +16588,7 @@ cmdline_parse_ctx_t main_ctx[] =3D { > (cmdline_parse_inst_t *)&cmd_stop, > (cmdline_parse_inst_t *)&cmd_mac_addr, > (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, > + (cmdline_parse_inst_t *)&cmd_set_custom_topo, > (cmdline_parse_inst_t *)&cmd_set_qmap, > (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, > (cmdline_parse_inst_t *)&cmd_operate_port, diff --git a/app/test- > pmd/config.c b/app/test-pmd/config.c index 16fc481..23799ad 100644 > --- a/app/test-pmd/config.c > +++ b/app/test-pmd/config.c > @@ -2069,6 +2069,8 @@ fwd_topology_tx_port_get(portid_t rxp) > return (rxp + 1) % cur_fwd_config.nb_fwd_ports; > case PORT_TOPOLOGY_LOOP: > return rxp; > + case PORT_TOPOLOGY_CUSTOM: > + return fwd_streams[rxp]->tx_port; > } > } >=20 > @@ -2378,6 +2380,45 @@ set_fwd_eth_peer(portid_t port_id, char > *peer_addr) > new_peer_addr[c]; > } >=20 > +static void > +print_ports_range(void) > +{ > + portid_t pid; > + printf("Valid port range is ["); > + RTE_ETH_FOREACH_DEV(pid) > + printf(", %d", pid); > + printf("]\n"); > +} > + > +void > +set_custom_topo(portid_t port_id_1, portid_t port_id_2) { > + unsigned int portlist[RTE_MAX_ETHPORTS]; > + unsigned int i; > + unsigned int nb_pt =3D 0; > + if (port_topology !=3D PORT_TOPOLOGY_CUSTOM) { > + printf("Please set the forward topology to custom first.\n"); > + return; > + } > + if (port_id_is_invalid(port_id_1, ENABLED_WARN)) { > + print_ports_range(); > + return; > + } > + if (port_id_is_invalid(port_id_2, ENABLED_WARN)) { > + print_ports_range(); > + return; > + } > + fwd_streams[port_id_1]->tx_port =3D port_id_2; > + fwd_streams[port_id_2]->tx_port =3D port_id_1; > + fwd_ports[port_id_1] =3D port_id_1; > + fwd_ports[port_id_2] =3D port_id_2; > + > + for (i =3D 0; i < RTE_MAX_ETHPORTS; i++) > + if (fwd_ports[i] =3D=3D i) > + portlist[nb_pt++] =3D i; > + set_fwd_ports_list(portlist, nb_pt); > +} > + > int > set_fwd_lcores_list(unsigned int *lcorelist, unsigned int nb_lc) { diff= --git > a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index > aea8af8..0db411d 100644 > --- a/app/test-pmd/parameters.c > +++ b/app/test-pmd/parameters.c > @@ -139,8 +139,8 @@ usage(char* progname) > printf(" --enable-hw-vlan-extend: enable hardware vlan > extend.\n"); > printf(" --enable-drop-en: enable per queue packet drop.\n"); > printf(" --disable-rss: disable rss.\n"); > - printf(" --port-topology=3DN: set port topology (N: paired (default) o= r " > - "chained).\n"); > + printf(" --port-topology=3DN: set port topology (N: paired (default)" > + "(loop), (custom) or (chained).\n"); > printf(" --forward-mode=3DN: set forwarding mode (N: %s).\n", > list_pkt_forwarding_modes()); > printf(" --rss-ip: set RSS functions to IPv4/IPv6 only .\n"); @@ -920,= 6 > +920,8 @@ launch_args_parse(int argc, char** argv) > port_topology =3D > PORT_TOPOLOGY_CHAINED; > else if (!strcmp(optarg, "loop")) > port_topology =3D > PORT_TOPOLOGY_LOOP; > + else if (!strcmp(optarg, "custom")) > + port_topology =3D > PORT_TOPOLOGY_CUSTOM; > else > rte_exit(EXIT_FAILURE, "port- > topology %s invalid -" > " must be: paired, chained or > loop\n", diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h > index 1af87b8..3250683 100644 > --- a/app/test-pmd/testpmd.h > +++ b/app/test-pmd/testpmd.h > @@ -67,6 +67,7 @@ enum { > PORT_TOPOLOGY_PAIRED, > PORT_TOPOLOGY_CHAINED, > PORT_TOPOLOGY_LOOP, > + PORT_TOPOLOGY_CUSTOM, > }; >=20 > #ifdef RTE_TEST_PMD_RECORD_BURST_STATS > @@ -363,6 +364,11 @@ extern uint8_t txring_numa[RTE_MAX_ETHPORTS]; > extern uint8_t socket_num; >=20 > /* > + * Store the custom topo. > + */ > +portid_t fwd_ports[RTE_MAX_ETHPORTS]; > + > +/* > * Configuration of logical cores: > * nb_fwd_lcores <=3D nb_cfg_lcores <=3D nb_lcores > */ > @@ -598,7 +604,7 @@ void reconfig(portid_t new_port_id, unsigned > socket_id); int init_fwd_streams(void); >=20 > void set_fwd_eth_peer(portid_t port_id, char *peer_addr); > - > +void set_custom_topo(portid_t port_id_1, portid_t port_id_2); > void port_mtu_set(portid_t port_id, uint16_t mtu); void > port_reg_bit_display(portid_t port_id, uint32_t reg_off, uint8_t bit_pos)= ; > void port_reg_bit_set(portid_t port_id, uint32_t reg_off, uint8_t bit_pos= , > diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > index 013a405..5edf210 100644 > --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > @@ -1090,6 +1090,14 @@ Set the forwarding peer address for certain port:: >=20 > This is equivalent to the ``--eth-peer`` command-line option. >=20 > +set custom-topo > +~~~~~~~~~~~~~~ > + > +Set custom topology for forwading packets by making the given two ports > as pair. > +In custom topology the active ports will be the defiend in custum-topo > only:: > + > + testpmd> set custom-topo (port_id_1) (port_id_2) > + > set port-uta > ~~~~~~~~~~~~ >=20 > -- > 2.7.4