From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10071.outbound.protection.outlook.com [40.107.1.71]) by dpdk.org (Postfix) with ESMTP id 915721B511 for ; Thu, 13 Dec 2018 13:17:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dJke4kr9bWmWfFPXWpHb3tB/0JdtuKFcF056ulyk1SM=; b=Icf5yQGzA7f9zB5X3o4IBnmeJcBV8EwZmPoqncRGxhLVfiJxUQjmIzIADKffaRgr+m/GhgQhCSt1MnrzsHvlX5+emJb9USlcBRtK52Fg2yLVEH11YcLKMB4QSyHyBkgkVyp3gE0NQDENsiY92hDuQQjG2LT5RtHcHkXEa/ANsXg= Received: from AM0PR05MB4388.eurprd05.prod.outlook.com (52.134.91.161) by AM0PR05MB6132.eurprd05.prod.outlook.com (20.178.117.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.21; Thu, 13 Dec 2018 12:17:54 +0000 Received: from AM0PR05MB4388.eurprd05.prod.outlook.com ([fe80::a0bf:9230:60f1:c586]) by AM0PR05MB4388.eurprd05.prod.outlook.com ([fe80::a0bf:9230:60f1:c586%3]) with mapi id 15.20.1425.016; Thu, 13 Dec 2018 12:17:54 +0000 From: Noa Ezra To: "konstantin.ananyev@intel.com" CC: "dev@dpdk.org" , Noa Ezra Thread-Topic: [PATCH] examples/ip_fragmentation: support bigger packets Thread-Index: AQHUkt3gu0iuodRfTUegpyTPHcPA0A== Date: Thu, 13 Dec 2018 12:17:54 +0000 Message-ID: <1544703399-32621-1-git-send-email-noae@mellanox.com> Accept-Language: en-US, he-IL Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 1.8.3.1 x-clientproxiedby: VI1PR07CA0229.eurprd07.prod.outlook.com (2603:10a6:802:58::32) To AM0PR05MB4388.eurprd05.prod.outlook.com (2603:10a6:208:59::33) authentication-results: spf=none (sender IP is ) smtp.mailfrom=noae@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [37.142.13.130] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM0PR05MB6132; 6:nQO7VhE3OXPhF8NmSoVARVMrLAwUsa56v2x5s/JIkH6ZxrsXr4f1MMW6XRjCq6QFFhBWS0Qr76kPPRbLlrVpuSQ2bdw0XDZ4+Gm/O1lxIIzGPYg0ZgAQiytbGE1jGmQRm6bQXLmKUivYj34J5cymqVsqFxq9nJP05A7SP1qc0z4i/Dsz6fEcxk37GA3H5vpfEUfEboWCqvAQQDMOxXFdctQE4htl98SxqG803N3U8OjyPtLK28pqyUQBynMqKbAixVd0NJGlqs87CbeThMk+nDsh5Faiqh+lEgo4O/Ishcdm4eVUmp2kbjBcNKJA/tyWgYb8ciesvV6sTvt/VJSMEoDwG2mGDXmwzTOx6D0jYIvbbn2gQBwilQ9EL01SHs8WQ2/TZrr4PxX1fVl9KMshaAmtWDv/URi5sN9Lm2pA8eHvJS9lrnNGaEYkBQZH4dm6x4uFyOl/eu9weTJTyLUazg==; 5:ZHhM0wP9vBy+Mo16xiVRmjTLkMOEP1/TBgAtDTIVrNRIxmfBK90QsJfuJ7mUCnr107iRaRLaYNQwX26TePPwcBLqWxqLTb9oqUskzyUt5GJv0yX5OjfXBy21kNB53ChGSXH/DYw+Q8/PhH+PuLekvRcZC2MEkpEtIj7ISqutucg=; 7:iUlDRhwP9MlaDtKGZGkEWfDNJBgVuy/bP+KkTrAn57vzPx5HzQlSa5tgYH2IBfO/2BhtkOa3zcRRLqz8fbizzXnm69MJs2YEeWTf6rT5nmeSo56UwePn2IxHXMwr3J7eMaIRyRQc/9b+gnsbHG83nw== x-ms-office365-filtering-correlation-id: 5789ffee-6883-4177-9b9c-08d660f50288 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM0PR05MB6132; x-ms-traffictypediagnostic: AM0PR05MB6132: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(3231475)(944501520)(52105112)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:AM0PR05MB6132; BCL:0; PCL:0; RULEID:; SRVR:AM0PR05MB6132; x-forefront-prvs: 088552DE73 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(396003)(366004)(376002)(39860400002)(346002)(189003)(199004)(386003)(86362001)(478600001)(6506007)(6436002)(102836004)(186003)(2616005)(476003)(36756003)(106356001)(105586002)(26005)(14454004)(52116002)(66066001)(99286004)(2351001)(25786009)(68736007)(6486002)(305945005)(81166006)(81156014)(2501003)(8676002)(4326008)(6916009)(54906003)(316002)(71190400001)(2906002)(8936002)(4720700003)(7736002)(97736004)(50226002)(53936002)(486006)(5640700003)(14444005)(256004)(5660300001)(71200400001)(107886003)(6116002)(3846002)(6512007)(135533001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR05MB6132; H:AM0PR05MB4388.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: RHxbJELtNPq+qzdLs/HIHQqNAitN9RgYe8X1P3oMF5AtzVJxDAe4YclaLhZU7vyND+AUOXLvu27oZawlLm8B6/8aMA0uFentZhmK7NpxP+CHs6fWNdCAiAp1WvPDcbD0eMESJSvDSQabKka8RSm4V3Zx3dTRNnnzuci1+yalofhIrF+nYoVpZ+8rNcznWReGK6Q04X8TELAVUgbT2cTrkD+TOXMtt5u0VKz4c6JN/FcnmhgrgHNrKL5Ldq7jyOST1drkcrpKUD+I5oflH6Yva88eT312YG5C/cfGAtc3M8YCsT1Nf5VQUKyeButUnnJB spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5789ffee-6883-4177-9b9c-08d660f50288 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Dec 2018 12:17:54.8702 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB6132 Subject: [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, 13 Dec 2018 12:17:57 -0000 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. 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. 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_u= g/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 MBUF= SIZE] [-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 transmitted = over the network, therefore it must be +greater than the requested max packet size, otherwise the NIC won't be abl= e 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 th= e DPDK will not be able to receive the +packet. To run the example in linuxapp environment with 2 lcores (2,4) over 2 port= s(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 lcore= (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 bye= s: + +.. 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. =20 diff --git a/examples/ip_fragmentation/main.c b/examples/ip_fragmentation/m= ain.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 MTUSIZE= ]\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 */ + mbuf =3D strtoul(q_arg, &end, 10); + if ((q_arg[0] =3D=3D '\0') || (end =3D=3D NULL) || (*end !=3D '\0')) + return -1; + if (mbuf =3D=3D 0) + return -1; + + return mbuf; +} + +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) { --=20 1.8.3.1