From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0054.outbound.protection.outlook.com [104.47.40.54]) by dpdk.org (Postfix) with ESMTP id 8F6EB1B53 for ; Thu, 28 Dec 2017 21:19:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=KERZSFNfD/v9ulVlImENDYmLZrrgObSAbX3tgtUpZd0=; b=UiU7U2Eg8zkq9DhYsNVIGYvKzPLR2S+mC2+MMQjeJLRYKgFwJnUfskU0IWfGCTsgut4x6zOFD4ifWe3tyUSmAooU6LrQODtE6qcy2vkermn4ZWE6+FyAkmBuNOda8i9WV0P5seedeYqlaRAm/Z000k1Js0gNsUZgq6p4WvxG+jc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from localhost.localdomain (111.93.218.67) by DM5PR07MB3468.namprd07.prod.outlook.com (10.164.153.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.345.14; Thu, 28 Dec 2017 20:19:41 +0000 From: Pavan Nikhilesh To: bruce.richardson@intel.com, pablo.de.lara.guarch@intel.com Cc: dev@dpdk.org, Pavan Nikhilesh Date: Fri, 29 Dec 2017 01:49:06 +0530 Message-Id: <20171228201906.22770-1-pbhagavatula@caviumnetworks.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: SG2PR0601CA0017.apcprd06.prod.outlook.com (10.170.128.27) To DM5PR07MB3468.namprd07.prod.outlook.com (10.164.153.23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e3b1a81c-4391-4983-5594-08d54e30551d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:DM5PR07MB3468; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3468; 3:VGKetoWufTbXvkyAMq0u0TzEb/jkl6rDTPKz/M3t0IGJ77ZGYpSM06XzRUlJ8onYkuBMq2oXPd68bmu8YxAtXLXcEXNPArdbKp1XFId87JMSemBEPb/KTMEfInEHYsnGhpe1pSHcHjFpTs8LqaTvKn9vZo4pW/pJxfEiZC0MgueTg3OxStsullShHfcvTnGOTQ7lhVq+t6QU/80ZlJvfIu/mrZ14NFndt2Bk+Zcm6+lZcDpmdymvks5AG8fDu/JI; 25:OBitiaMocSeR9lnhimT23oYnUUwe+rvhD1WlGK51EOX82Xyu9k5HSU9H5NyjNBm8XmR/LlizhQ0k3zVaXc3SdkrhE4ye5TUxtj+KwxsDittlXt2QpNc0ol08O9nWDvMrYUiDCvo0Ql7PFUlKoKsbakz1C17REVo2IDVlTIykNYpo6oFP7a3/KWj8pCmYzh6pF+bdYOiXYQtYX6/IHEl+9lUQAiD3a6DTgABY+HmQY65DKe57F9OztdWXdu7Gx7WnNmLjghCl6Fn0rdPEGpYr3k1qa67O3VNy4kMv+7UUvqmAqqHG8CuCctzfhMci1SHD91O4dh4eR87tEhQp9Z3SOw==; 31:PfWJa0efCjcaMogDRQO4/jrMLyJYexTZViYjgl8TdzwXQehP2RmwHCdDGJZfez8SlvdjLcnSXON0HfHMtz6uhxRX4pB1C0JCHxIHr5D0YCreTbmVtLJh/LRSM8BQwIkcUP2bRVOHq5nbvmqdAFB+yYj9wbGXeK+QpSOlACVdX1qw70VWj1A2Iqs0WrbrOzRVNQx0WiVOH+QlXV4chA6Py/UgxWGjplY1suW6FEHH5ms= X-MS-TrafficTypeDiagnostic: DM5PR07MB3468: X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3468; 20:kKG+c+vlcWJtzP/VJIMQYQE2U+JRBffT0vWB5vszlVlL0coLNEMOvWbLP/loqsOx5bzxxbKXz9nKlsn984smrLjuaVKrBBIaToUkoYJ+rdf8RB7zuMtrFuWrr7JSC9B1m9JAaJNWsCDbAQTWed3kixx8kUqKopdoL1HzrIWcO7K6zRuPJ4YApA0xQcMEiaCjfGlqERcjsSrDOJXceUIxPhXN/XaZojeija4jSiMaUI0R0kHPyDhJLbvoPBMTgmKmIqR6R4ObJ9cat+96RhsV0g5FtBW3gvwBO5ImqQVVSk2REwYmTExVh5ib3k97L3lKl8rL87I5v/AyPSZ+DExQBQnl4WfskF9C/Y/M6XSz81pNiRbNp4Mtc/dZdWSuuFk72lZYiIAUsjaUnM2wwcIe5AV+Q4bfxjisLnsCLFM5LcNQ/mi7zJh5bOiY5mAWkjeNPwkMFDTQ5kLwiRoDIzVbO1xxp9KGv69pa32HFMztaWn25Tc29OWlbNM5lXJkiTGLNaV1hzP8qzIX+WYbo4JNK6fx21Z6OeCmqYBplEyHz8O4+MpyzuKWAaovutecNOG/rRQFr1+o/+L+o+0nV1i9hX2hpi0/2RxMkVCyYK38Qqs=; 4:KaazE5eOFce4zdzXvWMMGJcVLO128c2oMrv9x4vOLPQlsbNLth1UCAxNdygr5QidOgmuTYpyqNlncTDYZdBrHAVYDE3GEcBB3LEJqMvGfAFosYkfIL0xZu6zBqCFgihBZ8P2fHEdGH9Nu/uqTwQBYGhVKpk8oX4lNKCPMOOBhmWRBzLKV9dPM3zvvso6brO1M555Y0Hz2Epc3dMWsgwE8JpA4vW0GEYN3odfOsJh/8+VGfNLg3ksPLtk2Ipp3AP9R9qMNFgcRxRqBj7MPDrVHw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(93006095)(3231023)(944501075)(10201501046)(3002001)(6041268)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(6072148)(201708071742011); SRVR:DM5PR07MB3468; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:DM5PR07MB3468; X-Forefront-PRVS: 05352A48BE X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(396003)(39380400002)(376002)(346002)(39860400002)(366004)(189003)(199004)(5660300001)(7736002)(6506007)(50226002)(16586007)(59450400001)(97736004)(386003)(25786009)(107886003)(8676002)(81156014)(66066001)(8936002)(51416003)(5009440100003)(305945005)(53936002)(50466002)(36756003)(81166006)(4326008)(42882006)(6666003)(52116002)(72206003)(478600001)(6486002)(1076002)(6116002)(3846002)(2906002)(16526018)(47776003)(48376002)(68736007)(106356001)(105586002)(6512007)(316002)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR07MB3468; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR07MB3468; 23:yOTWHdp4R4gguhckuRHrrrVUxFvdMi0xgxAFFAwqN?= =?us-ascii?Q?gEjfpoNyGY2K4UZPLZcNfMm5Bgu51UinDWP8uJcsI0JVIfsw82miqBXEuTSp?= =?us-ascii?Q?Y8DB6qWOR/TtKNMC11KVULOQ5shPp7+GCFlQc5U0GXCoX/0k76SOH02c9ZUZ?= =?us-ascii?Q?HTjRInvyHIBV7rEsH9cT2J/jRpGw7wjCTYNWJr4n3s1KLcpWSKm38e98OrgA?= =?us-ascii?Q?X9Cg6AlrVlKjDSEZjkks4NXoRN8O23LOe6OXtfx1hZd/kEk6HaX75NWBfEdk?= =?us-ascii?Q?fMOE8whie/Be24Xk+H5AHT/JcDS1nBlMdwEvAc5vJXw8ZgWaVrE+GqHBAjQN?= =?us-ascii?Q?ybndkuOyFJhrlBYTT87aQPaYcflzCmm6YvQsQAucLv0Jh7fIBuECEqBOnOfQ?= =?us-ascii?Q?yhwLy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kkc4+Ic3KRuXcROBXOGqM3CMSr8ks5uEEH1xyhfg1SV3WCZwBKdsdb4XNWmYjP1uk2UcGgjQ8zNDcxeV2xMXehg7KyoVkd+pSMSSOxO/QfisqKOoqJ8hzsZqpMvAmI1lbS6zOeTgJcHcFdSoH7BzJKxOoAZD4LoT+SYf8wihRQJ6CLviAzFC2O2+v61yS5JL1cmw8rvjsjr1iNtm1Ps3BUUizT+9rdlE8XkBmTuxX49nBMrAnGotU1bRv7/wZkxEoqzOfP27gp2c=; 5:+fVcyPFchg5e12byDhENePEXAU5EU2KkD7XwP7lv6J8tr/owzWvs5Jbr62aUkAISwJAvxQX1hhhJQUXUYx3f3lr9D+pVA4ioqU2Zw9m5aU/iKV5vSM5UUK7+fgXc3sQw2f8DUOkYIO0dijAKPftuKzGPH5G/WiWTWnva3uZf2lY=; 24:L9VPda70yu9Ek/tjDHlIOKBCCzi1rNF4aG8DI2xdZRQYGWqcogtostg5cO/NQch13Iuh8edKPxvmefZneFhWzi3f3OD7oqqEe0ZTMqaAvtw=; 7:lIZmBTSOj/qXISMsrX+meP6swVvC33sMbW9++HVSKVDeTkGS6waNBYBSqkPKBQ3gkc44A1ikK1fXDURNkRuayO8AXmioiXJNWTCKGQOC9a04WWuuDGOcEhV74lzhrvvq81ZC2cBNWE9+kc0kzuDL6GkuahbJELZzAxCD8UveLQIBkpsB0vGXKz9tiUUr7EoJp+/EB+YEOAFblHG7q9/Lj73g2wxtJS/zGdf5PJfl0vOZhC227/QaHYvRiXQEYw82 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2017 20:19:41.9769 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e3b1a81c-4391-4983-5594-08d54e30551d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3468 Subject: [dpdk-dev] [PATCH] examples/l2fwd: increase pktmbuf pool size 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, 28 Dec 2017 20:19:46 -0000 Make pktmbuf pool size a function of ports and lcores detected instead of using constant 8192. Signed-off-by: Pavan Nikhilesh --- Check patch generates warning `Unnecessary typecast of c90 int constant` but it is needed to make compiler happy (generates error comparison between signed and unsigned integer). examples/l2fwd/main.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c index e89e2e1bf..9ec544840 100644 --- a/examples/l2fwd/main.c +++ b/examples/l2fwd/main.c @@ -75,8 +75,6 @@ static int mac_updating = 1; #define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1 -#define NB_MBUF 8192 - #define MAX_PKT_BURST 32 #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */ #define MEMPOOL_CACHE_SIZE 256 @@ -124,6 +122,17 @@ static const struct rte_eth_conf port_conf = { }, }; +/* + * This expression is used to calculate the number of mbufs needed + * depending on user input, taking into account memory for rx and + * tx hardware rings, cache per lcore and mbuf pkt burst per port + * per lcore. RTE_MAX is used to ensure that NB_MBUF never goes below + * a minimum value of 8192 + */ +#define NB_MBUF RTE_MAX(\ + nb_ports * (nb_rxd + nb_txd + MAX_PKT_BURST +\ + nb_lcores * MEMPOOL_CACHE_SIZE), (unsigned int)8192) + struct rte_mempool * l2fwd_pktmbuf_pool = NULL; /* Per-port statistics struct */ @@ -556,6 +565,7 @@ main(int argc, char **argv) uint16_t portid, last_port; unsigned lcore_id, rx_lcore_id; unsigned nb_ports_in_mask = 0; + unsigned int nb_lcores = 0; /* init EAL */ ret = rte_eal_init(argc, argv); @@ -578,13 +588,6 @@ main(int argc, char **argv) /* convert to number of cycles */ timer_period *= rte_get_timer_hz(); - /* create the mbuf pool */ - l2fwd_pktmbuf_pool = rte_pktmbuf_pool_create("mbuf_pool", NB_MBUF, - MEMPOOL_CACHE_SIZE, 0, RTE_MBUF_DEFAULT_BUF_SIZE, - rte_socket_id()); - if (l2fwd_pktmbuf_pool == NULL) - rte_exit(EXIT_FAILURE, "Cannot init mbuf pool\n"); - nb_ports = rte_eth_dev_count(); if (nb_ports == 0) rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n"); @@ -636,9 +639,11 @@ main(int argc, char **argv) rte_exit(EXIT_FAILURE, "Not enough cores\n"); } - if (qconf != &lcore_queue_conf[rx_lcore_id]) + if (qconf != &lcore_queue_conf[rx_lcore_id]) { /* Assigned a new logical core in the loop above. */ qconf = &lcore_queue_conf[rx_lcore_id]; + nb_lcores++; + } qconf->rx_port_list[qconf->n_rx_port] = portid; qconf->n_rx_port++; @@ -647,6 +652,13 @@ main(int argc, char **argv) nb_ports_available = nb_ports; + /* create the mbuf pool */ + l2fwd_pktmbuf_pool = rte_pktmbuf_pool_create("mbuf_pool", NB_MBUF, + MEMPOOL_CACHE_SIZE, 0, RTE_MBUF_DEFAULT_BUF_SIZE, + rte_socket_id()); + if (l2fwd_pktmbuf_pool == NULL) + rte_exit(EXIT_FAILURE, "Cannot init mbuf pool\n"); + /* Initialise each port */ for (portid = 0; portid < nb_ports; portid++) { /* skip ports that are not enabled */ -- 2.15.1