From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id CC7FD1B9E1 for ; Thu, 20 Dec 2018 13:11:24 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Dec 2018 04:11:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,376,1539673200"; d="scan'208";a="127637428" Received: from irsmsx107.ger.corp.intel.com ([163.33.3.99]) by fmsmga002.fm.intel.com with ESMTP; 20 Dec 2018 04:11:22 -0800 Received: from irsmsx106.ger.corp.intel.com ([169.254.8.227]) by IRSMSX107.ger.corp.intel.com ([169.254.10.125]) with mapi id 14.03.0415.000; Thu, 20 Dec 2018 12:11:21 +0000 From: "Ananyev, Konstantin" To: Noa Ezra CC: "dev@dpdk.org" , Asaf Penso , "Matan Azrad" , Shahaf Shuler Thread-Topic: [PATCH] examples/ip_fragmentation: support bigger packets Thread-Index: AQHUkt3gu0iuodRfTUegpyTPHcPA0KWGyhzwgAChObCAABJboA== Date: Thu, 20 Dec 2018 12:11:21 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258010D8BD2C7@IRSMSX106.ger.corp.intel.com> References: <1544703399-32621-1-git-send-email-noae@mellanox.com> <2601191342CEEE43887BDE71AB977258010D8BCD9A@IRSMSX106.ger.corp.intel.com> In-Reply-To: Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZmZmNzYyNTUtMGE3MS00MjU3LWIxZWItMGU2OTA0OTE0YjcyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiVFV5dHlQd1FOXC9CcU1ic0d4VlduOWFkVk1mS1VtcW5tdGMzSXozNEQzQmw1YVVxUktMMklLdmQwWlJjYmlKRmwifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 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] examples/ip_fragmentation: support bigger packets 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: Thu, 20 Dec 2018 12:11:25 -0000 >=20 > Hi, > In some vendores (like Mellanox, that reflects the linux behavior in this= case) the Rx and Tx configurations must be the same, therefore it is > not enough to configure the max_rx_pkt_len to JUMBO_FRAME_MAX_SIZE, we al= so need to configure the MTU size in order to receive > large packets. Interesting, didn't know that. Does it mean that l3fwd and bunch of other sample apps that use max_rx_pkt_= len to setup MTU, don't work properly with mlx devices (not able to run with jumbo-frame enab= led)? > In order to avoid from adding another configuration to the command line, = we can configure the MTU to be equal to max_rx_pkt_len, and it > won't change the functionality of the test. I don't have any objections with new option for MTU size (-m) if you need i= t. It was just unclear to me why it was necessary for you. But yes, setting MTU to the correlated with max_rx_ptk_len value sounds lik= e a good idea. >=20 > In addition there are PMDs that need to enable the scatter-gather so it w= ill be functional for RX frames bigger then mbuf size. We can add > the configuration and avoid changing the mbuf size. You mean check if MTU is bigger than mbuf size, and if so setup (DEV_RX_OFF= LOAD_JUMBO_FRAME | DEV_RX_OFFLOAD_SCATTER) ? Konstantin >=20 > What do you think about this solution? >=20 > Thanks, > Noa. >=20 > -----Original Message----- > From: Ananyev, Konstantin [mailto:konstantin.ananyev@intel.com] > Sent: Thursday, December 20, 2018 2:18 AM > To: Noa Ezra > Cc: dev@dpdk.org > Subject: RE: [PATCH] examples/ip_fragmentation: support bigger packets >=20 > Hi, >=20 > > > > Adding MTU and mbuf size configuration to the application's command > > line, in order to be able to receive all packet sizes by the NIC and > > DPDK application. > > The maximum transmission unit (MTU) is the largest size packet in > > bytes that can be sent on the network, therefore before adding MTU > > parameter, the NIC could not receive packets larger than 1500 bytes, > > which is the default MTU size. >=20 > I wonder why is that? > Currently ip_fragmentation sets max_rx_pkt_len to up to 9.5KB: >=20 > static struct rte_eth_conf port_conf =3D { > .rxmode =3D { > .max_rx_pkt_len =3D JUMBO_FRAME_MAX_SIZE, ... >=20 > local_port_conf.rxmode.max_rx_pkt_len =3D RTE_MIN( > dev_info.max_rx_pktlen, > local_port_conf.rxmode.max_rx_pkt_len); >=20 > That in theory should be enough to enable jumbo frame RX. > Did you find it is not working as expected, if yes on which NIC? >=20 > > The mbuf is the memory buffer that contains the packet. Before adding > > mbuf parameter, the DPDK application could not receive packets larger > > than 2KB, which is the default mbuf size. >=20 > Again why is that? > All packets that do support scatter-gather RX should be able to RX frames= bigger then mbuf size (if properly configured of course). > Are you trying to make it work on NICs with no multi-segment support for = RX/TX? > But then how you plan to do TX (usually it is symmetric for RX/TX)? >=20 > > > > Signed-off-by: Noa Ezra > > --- > > doc/guides/sample_app_ug/ip_frag.rst | 18 ++++++++- > > examples/ip_fragmentation/main.c | 77 ++++++++++++++++++++++++++++= +++++--- > > 2 files changed, 88 insertions(+), 7 deletions(-) > > > > diff --git a/doc/guides/sample_app_ug/ip_frag.rst > > b/doc/guides/sample_app_ug/ip_frag.rst > > index 7914a97..13933c7 100644 > > --- a/doc/guides/sample_app_ug/ip_frag.rst > > +++ b/doc/guides/sample_app_ug/ip_frag.rst > > @@ -53,7 +53,7 @@ Application usage: > > > > .. code-block:: console > > > > - ./build/ip_fragmentation [EAL options] -- -p PORTMASK [-q NQ] > > + ./build/ip_fragmentation [EAL options] -- -p PORTMASK [-q NQ] [-b > > + MBUFSIZE] [-m MTUSIZE] > > > > where: > > > > @@ -61,6 +61,15 @@ where: > > > > * -q NQ is the number of queue (=3Dports) per lcore (the default is = 1) > > > > +* -b MBUFSIZE is the mbuf size in bytes (the default is 2048) > > + > > +* -m MTUSIZE is the mtu size in bytes (the default is 1500) > > + > > +The MTU is the maximum size of a single data unit that can be > > +transmitted over the network, therefore it must be greater than the re= quested max packet size, otherwise the NIC won't be able to get > the packet. > > +The mbuf is a buffer that is used by the DPDK application to store > > +message buffers.If not using scatter then the mbuf size must be > > +greater than the requested max packet size, otherwise the DPDK will no= t be able to receive the packet. > > To run the example in linuxapp environment with 2 lcores (2,4) over 2 = ports(0,2) with 1 RX queue per lcore: > > > > .. code-block:: console > > @@ -96,6 +105,13 @@ To run the example in linuxapp environment with 1 > > lcore (4) over 2 ports(0,2) wi > > > > ./build/ip_fragmentation -l 4 -n 3 -- -p 5 -q 2 > > > > +To run the example with defined MTU size 4000 bytes and mbuf size 9000= byes: > > + > > +.. code-block:: console > > + > > + ./build/ip_fragmentation -l 4 -n 3 -- -p 5 -m 4000 -b 9000 > > + > > + > > To test the application, flows should be set up in the flow generator > > that match the values in the l3fwd_ipv4_route_array and/or l3fwd_ipv6_= route_array table. > > > > diff --git a/examples/ip_fragmentation/main.c > > b/examples/ip_fragmentation/main.c > > index 17a877d..0cf23b4 100644 > > --- a/examples/ip_fragmentation/main.c > > +++ b/examples/ip_fragmentation/main.c > > @@ -111,6 +111,10 @@ > > > > static int rx_queue_per_lcore =3D 1; > > > > +static int mbuf_size =3D RTE_MBUF_DEFAULT_BUF_SIZE; > > + > > +static int mtu_size =3D ETHER_MTU; > > + > > #define MBUF_TABLE_SIZE (2 * MAX(MAX_PKT_BURST, MAX_PACKET_FRAG)) > > > > struct mbuf_table { > > @@ -425,7 +429,6 @@ struct rte_lpm6_config lpm6_config =3D { > > * Read packet from RX queues > > */ > > for (i =3D 0; i < qconf->n_rx_queue; i++) { > > - > > portid =3D qconf->rx_queue_list[i].portid; > > nb_rx =3D rte_eth_rx_burst(portid, 0, pkts_burst, > > MAX_PKT_BURST); > > @@ -455,9 +458,11 @@ struct rte_lpm6_config lpm6_config =3D { static > > void print_usage(const char *prgname) { > > - printf("%s [EAL options] -- -p PORTMASK [-q NQ]\n" > > + printf("%s [EAL options] -- -p PORTMASK [-q NQ] [-b MBUFSIZE] [-m MTU= SIZE]\n" > > " -p PORTMASK: hexadecimal bitmask of ports to configure\n" > > - " -q NQ: number of queue (=3Dports) per lcore (default is 1)\= n", > > + " -q NQ: number of queue (=3Dports) per lcore (default is 1)\= n" > > + " -b MBUFSIZE: set the data size of mbuf\n" > > + " -m MTUSIZE: set the MTU size\n", > > prgname); > > } > > > > @@ -496,6 +501,38 @@ struct rte_lpm6_config lpm6_config =3D { > > return n; > > } > > > > +static int > > +parse_mbufsize(const char *q_arg) > > +{ > > + char *end =3D NULL; > > + unsigned long mbuf; > > + > > + /* parse hexadecimal string */ >=20 > You expect decimal string below. >=20 > > + mbuf =3D strtoul(q_arg, &end, 10); > > + if ((q_arg[0] =3D=3D '\0') || (end =3D=3D NULL) || (*end !=3D '\0')) > > + return -1; >=20 > You probably need to set and test errno too. >=20 > > + if (mbuf =3D=3D 0) > > + return -1; > > + > > + return mbuf; > > +} >=20 >=20 > These 2 parse functions looks identical. > Why you need two of them? >=20 > > + > > +static int > > +parse_mtusize(const char *q_arg) > > +{ > > + char *end =3D NULL; > > + unsigned long mtu; > > + > > + /* parse hexadecimal string */ > > + mtu =3D strtoul(q_arg, &end, 10); > > + if ((q_arg[0] =3D=3D '\0') || (end =3D=3D NULL) || (*end !=3D '\0')) > > + return -1; > > + if (mtu =3D=3D 0) > > + return -1; > > + > > + return mtu; > > +} > > + > > /* Parse the argument given in the command line of the application */ > > static int parse_args(int argc, char **argv) @@ -510,7 +547,7 @@ > > struct rte_lpm6_config lpm6_config =3D { > > > > argvopt =3D argv; > > > > - while ((opt =3D getopt_long(argc, argvopt, "p:q:", > > + while ((opt =3D getopt_long(argc, argvopt, "p:q:b:m:", > > lgopts, &option_index)) !=3D EOF) { > > > > switch (opt) { > > @@ -534,6 +571,26 @@ struct rte_lpm6_config lpm6_config =3D { > > } > > break; > > > > + /* mbufsize */ > > + case 'b': > > + mbuf_size =3D parse_mbufsize(optarg); > > + if (mbuf_size < 0) { > > + printf("invalid mbuf size\n"); > > + print_usage(prgname); > > + return -1; > > + } > > + break; > > + > > + /* mtusize */ > > + case 'm': > > + mtu_size =3D parse_mtusize(optarg); > > + if (mtu_size < 0) { > > + printf("invalid mtu size\n"); > > + print_usage(prgname); > > + return -1; > > + } > > + break; > > + > > /* long options */ > > case 0: > > print_usage(prgname); > > @@ -777,9 +834,8 @@ struct rte_lpm6_config lpm6_config =3D { > > RTE_LOG(INFO, IP_FRAG, "Creating direct mempool on socket %i\n", > > socket); > > snprintf(buf, sizeof(buf), "pool_direct_%i", socket); > > - > > mp =3D rte_pktmbuf_pool_create(buf, NB_MBUF, 32, > > - 0, RTE_MBUF_DEFAULT_BUF_SIZE, socket); > > + 0, mbuf_size, socket); > > if (mp =3D=3D NULL) { > > RTE_LOG(ERR, IP_FRAG, "Cannot create direct mempool\n"); > > return -1; > > @@ -892,6 +948,15 @@ struct rte_lpm6_config lpm6_config =3D { > > dev_info.max_rx_pktlen, > > local_port_conf.rxmode.max_rx_pkt_len); > > > > + /* set the mtu to the maximum received packet size */ > > + ret =3D rte_eth_dev_set_mtu(portid, mtu_size); > > + if (ret < 0) { > > + printf("\n"); > > + rte_exit(EXIT_FAILURE, "Set MTU failed: " > > + "err=3D%d, port=3D%d\n", > > + ret, portid); > > + } > > + > > /* get the lcore_id for this port */ > > while (rte_lcore_is_enabled(rx_lcore_id) =3D=3D 0 || > > qconf->n_rx_queue =3D=3D (unsigned)rx_queue_per_lcore) { > > -- > > 1.8.3.1