From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id ED0399E3 for ; Mon, 19 Jun 2017 04:27:10 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP; 18 Jun 2017 19:27:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,359,1493708400"; d="scan'208";a="1184122599" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga002.fm.intel.com with ESMTP; 18 Jun 2017 19:27:09 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 18 Jun 2017 19:27:09 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 18 Jun 2017 19:27:09 -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; Mon, 19 Jun 2017 10:27:06 +0800 From: "Wu, Jingjing" To: "Hu, Jiayu" , "dev@dpdk.org" CC: "Ananyev, Konstantin" , "yliu@fridaylinux.org" , "Wiles, Keith" , "Tan, Jianfeng" , "Bie, Tiwei" , "Yao, Lei A" , "Hu, Jiayu" Thread-Topic: [dpdk-dev] [PATCH v5 3/3] app/testpmd: enable TCP/IPv4 GRO Thread-Index: AQHS6ANqGo1jBJSdb0OVDBW28RMKdKIrdZOQ Date: Mon, 19 Jun 2017 02:27:05 +0000 Message-ID: <9BB6961774997848B5B42BEC655768F810DA943D@SHSMSX103.ccr.corp.intel.com> References: <1496833731-53653-1-git-send-email-jiayu.hu@intel.com> <1497770469-16661-1-git-send-email-jiayu.hu@intel.com> <1497770469-16661-4-git-send-email-jiayu.hu@intel.com> In-Reply-To: <1497770469-16661-4-git-send-email-jiayu.hu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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 v5 3/3] app/testpmd: enable TCP/IPv4 GRO 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: Mon, 19 Jun 2017 02:27:11 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jiayu Hu > Sent: Sunday, June 18, 2017 3:21 PM > To: dev@dpdk.org > Cc: Ananyev, Konstantin ; yliu@fridaylinux.= org; > Wiles, Keith ; Tan, Jianfeng ; > Bie, Tiwei ; Yao, Lei A ; Hu, J= iayu > > Subject: [dpdk-dev] [PATCH v5 3/3] app/testpmd: enable TCP/IPv4 GRO >=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 po= rt; > command, "gro off (port_id)", turns off GRO for the given port. Currently= , GRO > only supports to process TCP/IPv4 packets and works in IO forward mode. > Besides, only GRO lightweight mode is enabled. >=20 > Signed-off-by: Jiayu Hu > --- > app/test-pmd/cmdline.c | 45 > +++++++++++++++++++++++++++++++++++++++++++++ > app/test-pmd/config.c | 29 +++++++++++++++++++++++++++++ > app/test-pmd/iofwd.c | 6 ++++++ > app/test-pmd/testpmd.c | 3 +++ > app/test-pmd/testpmd.h | 11 +++++++++++ > 5 files changed, 94 insertions(+) >=20 > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index > 105c71f..d1ca8df 100644 > --- a/app/test-pmd/cmdline.c > +++ b/app/test-pmd/cmdline.c > @@ -76,6 +76,7 @@ > #include > #include > #include > +#include >=20 > #include > #include > @@ -423,6 +424,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 > @@ -3831,6 +3835,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, "on#off"); > +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; > @@ -13710,6 +13754,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 3cd4f31..858342d > 100644 > --- a/app/test-pmd/config.c > +++ b/app/test-pmd/config.c > @@ -71,6 +71,7 @@ > #ifdef RTE_LIBRTE_BNXT_PMD > #include > #endif > +#include >=20 > #include "testpmd.h" >=20 > @@ -2414,6 +2415,34 @@ set_tx_pkt_segments(unsigned *seg_lengths, > unsigned 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; > + } > + gro_ports[port_id].enable =3D 1; > + gro_ports[port_id].param.max_flow_num =3D 4; > + gro_ports[port_id].param.max_item_per_flow =3D 32; Is 4 and 32 the default value for GRO? If so, how about to define the MACRO= in rte_gro.h > + gro_ports[port_id].param.desired_gro_types =3D GRO_TCP_IPV4; > + gro_ports[port_id].param.max_packet_size =3D UINT16_MAX; > + } else if (strcmp(mode, "off") =3D=3D 0) { "else" is enough, no need to compare it with "off". > + if (test_done =3D=3D 0) { > + printf("before disable GRO," > + " please stop forwarding first\n"); > + return; > + } How about to move the test_done before the mode checking? > + gro_ports[port_id].enable =3D 0; > + } > +} > + > char* > list_pkt_forwarding_modes(void) > { > diff --git a/app/test-pmd/iofwd.c b/app/test-pmd/iofwd.c index > 15cb4a2..d9ec528 100644 > --- a/app/test-pmd/iofwd.c > +++ b/app/test-pmd/iofwd.c > @@ -65,6 +65,7 @@ > #include > #include > #include > +#include >=20 > #include "testpmd.h" >=20 > @@ -99,6 +100,11 @@ pkt_burst_io_forward(struct fwd_stream *fs) > pkts_burst, nb_pkt_per_burst); > if (unlikely(nb_rx =3D=3D 0)) > return; > + if (unlikely(gro_ports[fs->rx_port].enable)) { > + nb_rx =3D rte_gro_reassemble_burst(pkts_burst, > + nb_rx, > + gro_ports[fs->rx_port].param); > + } > fs->rx_packets +=3D nb_rx; >=20 > #ifdef RTE_TEST_PMD_RECORD_BURST_STATS > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index > b29328a..ed27c7a 100644 > --- a/app/test-pmd/testpmd.c > +++ b/app/test-pmd/testpmd.c > @@ -90,6 +90,7 @@ > #ifdef RTE_LIBRTE_LATENCY_STATS > #include > #endif > +#include >=20 > #include "testpmd.h" >=20 > @@ -378,6 +379,8 @@ lcoreid_t bitrate_lcore_id; uint8_t bitrate_enabled; > #endif >=20 > +struct gro_status gro_ports[RTE_MAX_ETHPORTS]; > + > /* Forward function declarations */ > static void map_port_queue_stats_mapping_registers(uint8_t pi, struct > rte_port *port); static void check_all_ports_link_status(uint32_t port_m= ask); > diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index > 364502d..0471e99 100644 > --- a/app/test-pmd/testpmd.h > +++ b/app/test-pmd/testpmd.h > @@ -34,6 +34,8 @@ > #ifndef _TESTPMD_H_ > #define _TESTPMD_H_ >=20 > +#include > + > #define RTE_PORT_ALL (~(portid_t)0x0) >=20 > #define RTE_TEST_RX_DESC_MAX 2048 > @@ -109,6 +111,8 @@ struct fwd_stream { > queueid_t tx_queue; /**< TX queue to send forwarded packets */ > streamid_t peer_addr; /**< index of peer ethernet address of packets > */ >=20 > + uint16_t tbl_idx; /**< TCP IPv4 GRO lookup tale index */ > + > unsigned int retry_enabled; >=20 > /* "read-write" results */ > @@ -428,6 +432,12 @@ extern struct ether_addr > peer_eth_addrs[RTE_MAX_ETHPORTS]; extern uint32_t burst_tx_delay_time; > /**< Burst tx delay time(us) for mac-retry. */ extern uint32_t > burst_tx_retry_num; /**< Burst tx retry number for mac-retry. */ >=20 > +struct gro_status { > + struct rte_gro_param param; > + uint8_t enable; > +}; > +extern struct gro_status gro_ports[RTE_MAX_ETHPORTS]; > + > static inline unsigned int > lcore_num(void) > { > @@ -626,6 +636,7 @@ void get_2tuple_filter(uint8_t port_id, uint16_t inde= x); > void get_5tuple_filter(uint8_t port_id, uint16_t index); int > rx_queue_id_is_invalid(queueid_t rxq_id); int > tx_queue_id_is_invalid(queueid_t txq_id); > +void setup_gro(const char *mode, uint8_t port_id); >=20 > /* Functions to manage the set of filtered Multicast MAC addresses */ v= oid > mcast_addr_add(uint8_t port_id, struct ether_addr *mc_addr); > -- > 2.7.4 Looks fine to me, just don't forget the doc update "doc/guides/testpmd_app_= ug/" due to new command line