From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 99D041B598 for ; Thu, 20 Dec 2018 01:18:31 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Dec 2018 16:18:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,374,1539673200"; d="scan'208";a="120241795" Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by orsmga001.jf.intel.com with ESMTP; 19 Dec 2018 16:18:29 -0800 Received: from irsmsx106.ger.corp.intel.com ([169.254.8.227]) by IRSMSX103.ger.corp.intel.com ([169.254.3.157]) with mapi id 14.03.0415.000; Thu, 20 Dec 2018 00:18:28 +0000 From: "Ananyev, Konstantin" To: Noa Ezra CC: "dev@dpdk.org" Thread-Topic: [PATCH] examples/ip_fragmentation: support bigger packets Thread-Index: AQHUkt3gu0iuodRfTUegpyTPHcPA0KWGyhzw Date: Thu, 20 Dec 2018 00:18:28 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258010D8BCD9A@IRSMSX106.ger.corp.intel.com> References: <1544703399-32621-1-git-send-email-noae@mellanox.com> In-Reply-To: <1544703399-32621-1-git-send-email-noae@mellanox.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMjUxZGVkY2EtMjcxMy00MjYxLWEyOTQtZTFkMmU3MjY5OGU2IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiZUhNSXRzbWlGeXlaVVhBbzBVdzEyaHVaM2NpTEtsanVHbFI0d3U5MFRqSlR1a01qNHpmd2tHWFg5d0JDamY4bSJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [163.33.239.181] 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 00:18:32 -0000 Hi,=20 >=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. I wonder why is that? Currently ip_fragmentation sets max_rx_pkt_len to up to 9.5KB: static struct rte_eth_conf port_conf =3D { .rxmode =3D { .max_rx_pkt_len =3D JUMBO_FRAME_MAX_SIZE, ... local_port_conf.rxmode.max_rx_pkt_len =3D RTE_MIN( dev_info.max_rx_pktlen, local_port_conf.rxmode.max_rx_pkt_len); 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? > 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. 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(-) >=20 > 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: >=20 > .. code-block:: console >=20 > - ./build/ip_fragmentation [EAL options] -- -p PORTMASK [-q NQ] > + ./build/ip_fragmentation [EAL options] -- -p PORTMASK [-q NQ] [-b MB= UFSIZE] [-m MTUSIZE] >=20 > where: >=20 > @@ -61,6 +61,15 @@ where: >=20 > * -q NQ is the number of queue (=3Dports) per lcore (the default is 1) >=20 > +* -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 transmitte= d over the network, therefore it must be > +greater than the requested max packet size, otherwise the NIC won't be a= ble to get the packet. > +The mbuf is a buffer that is used by the DPDK application to store messa= ge buffers.If not using scatter then the > +mbuf size must be greater than the requested max packet size, otherwise = the DPDK will not be able to receive the > +packet. > To run the example in linuxapp environment with 2 lcores (2,4) over 2 po= rts(0,2) with 1 RX queue per lcore: >=20 > .. code-block:: console > @@ -96,6 +105,13 @@ To run the example in linuxapp environment with 1 lco= re (4) over 2 ports(0,2) wi >=20 > ./build/ip_fragmentation -l 4 -n 3 -- -p 5 -q 2 >=20 > +To run the example with defined MTU size 4000 bytes and mbuf size 9000 b= yes: > + > +.. 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 th= at match the values in the > l3fwd_ipv4_route_array and/or l3fwd_ipv6_route_array table. >=20 > 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 @@ >=20 > static int rx_queue_per_lcore =3D 1; >=20 > +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)) >=20 > 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 MTUSI= ZE]\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); > } >=20 > @@ -496,6 +501,38 @@ struct rte_lpm6_config lpm6_config =3D { > return n; > } >=20 > +static int > +parse_mbufsize(const char *q_arg) > +{ > + char *end =3D NULL; > + unsigned long mbuf; > + > + /* parse hexadecimal string */ You expect decimal string below. > + mbuf =3D strtoul(q_arg, &end, 10); > + if ((q_arg[0] =3D=3D '\0') || (end =3D=3D NULL) || (*end !=3D '\0')) > + return -1; You probably need to set and test errno too. > + if (mbuf =3D=3D 0) > + return -1; > + > + return mbuf; > +} These 2 parse functions looks identical. Why you need two of them? > + > +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 { >=20 > argvopt =3D argv; >=20 > - 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) { >=20 > switch (opt) { > @@ -534,6 +571,26 @@ struct rte_lpm6_config lpm6_config =3D { > } > break; >=20 > + /* 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); >=20 > + /* 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