From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 5FA0B2C15 for ; Wed, 7 Jun 2017 11:25:02 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jun 2017 02:25:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,310,1493708400"; d="scan'208";a="1157573386" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga001.fm.intel.com with ESMTP; 07 Jun 2017 02:25:01 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 7 Jun 2017 02:25:01 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.116]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0319.002; Wed, 7 Jun 2017 17:24:59 +0800 From: "Wu, Jingjing" To: "Hu, Jiayu" , "dev@dpdk.org" CC: "Ananyev, Konstantin" , "Wiles, Keith" , "yuanhan.liu@linux.intel.com" , "Hu, Jiayu" Thread-Topic: [dpdk-dev] [PATCH v3 3/3] app/testpmd: enable GRO feature Thread-Index: AQHSvNI4T/oSX80pGku+kyMZEDNGUaIZZUXw Date: Wed, 7 Jun 2017 09:24:58 +0000 Message-ID: <9BB6961774997848B5B42BEC655768F810D9CC24@SHSMSX103.ccr.corp.intel.com> References: <1491309106-94264-1-git-send-email-jiayu.hu@intel.com> <1493021398-115955-1-git-send-email-jiayu.hu@intel.com> <1493021398-115955-4-git-send-email-jiayu.hu@intel.com> In-Reply-To: <1493021398-115955-4-git-send-email-jiayu.hu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v3 3/3] app/testpmd: enable GRO feature 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, 07 Jun 2017 09:25:04 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jiayu Hu > Sent: Monday, April 24, 2017 4:10 PM > To: dev@dpdk.org > Cc: Ananyev, Konstantin ; Wiles, Keith > ; yuanhan.liu@linux.intel.com; Hu, Jiayu > Subject: [dpdk-dev] [PATCH v3 3/3] app/testpmd: enable GRO feature >=20 > This patch demonstrates the usage of GRO library in testpmd. By default, > GRO is turned off. Command, "gro on (port_id)", turns on GRO for the > given port; command, "gro off (port_id)", turns off GRO for the given > port. Note that, current GRO only supports TCP IPv4 packets. >=20 > Once the feature is turned on, all received packets are performed GRO > procedure before returned from rte_eth_rx_burst. >=20 > Signed-off-by: Jiayu Hu > --- > app/test-pmd/cmdline.c | 45 ++++++++++++++++++++++++++++++++++++++++++++= + > app/test-pmd/config.c | 26 ++++++++++++++++++++++++++ > app/test-pmd/iofwd.c | 1 + > app/test-pmd/testpmd.c | 5 +++++ > app/test-pmd/testpmd.h | 3 +++ > 5 files changed, 80 insertions(+) >=20 > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c > index f6bd75b..200ac3c 100644 > --- a/app/test-pmd/cmdline.c > +++ b/app/test-pmd/cmdline.c > @@ -76,6 +76,7 @@ > #include > #include > #include > +#include >=20 > #include > #include > @@ -420,6 +421,9 @@ static void cmd_help_long_parsed(void *parsed_result, > "tso show (portid)" > " Display the status of TCP Segmentation Offload.\n\n" >=20 > + "gro (on|off) (port_id)" > + " Enable or disable Generic Receive Offload.\n\n" > + > "set fwd (%s)\n" > " Set packet forwarding mode.\n\n" >=20 > @@ -3825,6 +3829,46 @@ cmdline_parse_inst_t cmd_tunnel_tso_show =3D { > }, > }; >=20 > +/* *** SET GRO FOR A PORT *** */ > +struct cmd_gro_result { > + cmdline_fixed_string_t cmd_keyword; > + cmdline_fixed_string_t mode; > + uint8_t port_id; > +}; > + > +static void > +cmd_set_gro_parsed(void *parsed_result, > + __attribute__((unused)) struct cmdline *cl, > + __attribute__((unused)) void *data) > +{ > + struct cmd_gro_result *res; > + > + res =3D parsed_result; > + setup_gro(res->mode, res->port_id); > +} > + > +cmdline_parse_token_string_t cmd_gro_keyword =3D > + TOKEN_STRING_INITIALIZER(struct cmd_gro_result, > + cmd_keyword, "gro"); > +cmdline_parse_token_string_t cmd_gro_mode =3D > + TOKEN_STRING_INITIALIZER(struct cmd_gro_result, > + mode, NULL); You can define gro_mode like cmdline_parse_token_string_t cmd_gro_mode =3D TOKEN_STRING_INITIALIZER(struct cmd_gro_result, mode, "on#off"); Then only two options are valid in this command. > +cmdline_parse_token_num_t cmd_gro_pid =3D > + TOKEN_NUM_INITIALIZER(struct cmd_gro_result, > + port_id, UINT8); > + > +cmdline_parse_inst_t cmd_set_gro =3D { > + .f =3D cmd_set_gro_parsed, > + .data =3D NULL, > + .help_str =3D "gro (on|off) (port_id)", > + .tokens =3D { > + (void *)&cmd_gro_keyword, > + (void *)&cmd_gro_mode, > + (void *)&cmd_gro_pid, > + NULL, > + }, > +}; > + > /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */ > struct cmd_set_flush_rx { > cmdline_fixed_string_t set; > @@ -13592,6 +13636,7 @@ cmdline_parse_ctx_t main_ctx[] =3D { > (cmdline_parse_inst_t *)&cmd_tso_show, > (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, > (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, > + (cmdline_parse_inst_t *)&cmd_set_gro, > (cmdline_parse_inst_t *)&cmd_link_flow_control_set, > (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, > (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx, > diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c > index ef07925..525f83b 100644 > --- a/app/test-pmd/config.c > +++ b/app/test-pmd/config.c > @@ -97,6 +97,7 @@ > #ifdef RTE_LIBRTE_IXGBE_PMD > #include > #endif > +#include >=20 > #include "testpmd.h" >=20 > @@ -2423,6 +2424,31 @@ set_tx_pkt_segments(unsigned *seg_lengths, unsigne= d nb_segs) > tx_pkt_nb_segs =3D (uint8_t) nb_segs; > } >=20 > +void > +setup_gro(const char *mode, uint8_t port_id) > +{ > + if (!rte_eth_dev_is_valid_port(port_id)) { > + printf("invalid port id %u\n", port_id); > + return; > + } > + if (strcmp(mode, "on") =3D=3D 0) { > + if (test_done =3D=3D 0) { > + printf("before enable GRO," > + " please stop forwarding first\n"); > + return; > + } > + rte_gro_enable(port_id, rte_eth_dev_socket_id(port_id)); > + } else if (strcmp(mode, "off") =3D=3D 0) { > + if (test_done =3D=3D 0) { > + printf("before disable GRO," > + " please stop forwarding first\n"); > + return; > + } > + rte_gro_disable(port_id); > + } else > + printf("unsupported GRO mode\n"); When you change gro mode to "on#off", then the else branch is not needed. And you can move the checking of forwarding to the beginning of this functi= on. At last, you also need to update the testpmd doc: doc/guides/testpmd_app_ug= / due to new command line. Thanks Jingjing