From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0063.outbound.protection.outlook.com [104.47.36.63]) by dpdk.org (Postfix) with ESMTP id B6BEA1B014 for ; Wed, 13 Dec 2017 20:56:22 +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=lztoDLVkmPvABwrkF6FSJaRP7/OGHFJFW885L+jTUQ0=; b=SklgEl9e23Ej9rYpLeJbSGaY21YVnq2Y6XxkgdgiCXxkGzimAGt8vMja6vCwB0zb5wMivGDqp12ixsjivB8GgjZQg0VGvyyQBSC7KHEfxM0yuiOptvxViVvjQKrQ4wGb/cLf2CY4iKUX8SqP1+4zuh149dPucAbjATBBNQzrecI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from localhost.localdomain (111.93.218.67) by DM5PR07MB3466.namprd07.prod.outlook.com (10.164.153.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.302.9; Wed, 13 Dec 2017 19:56:18 +0000 From: Pavan Nikhilesh To: jerin.jacob@caviumnetworks.com, jingjing.wu@intel.com, bruce.richardson@intel.com, hemant.agrawal@nxp.com, ferruh.yigit@intel.com, thomas@monjalon.net, olivier.matz@6wind.com Cc: dev@dpdk.org, Pavan Nikhilesh Date: Thu, 14 Dec 2017 01:25:37 +0530 Message-Id: <20171213195538.14290-3-pbhagavatula@caviumnetworks.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171213195538.14290-1-pbhagavatula@caviumnetworks.com> References: <20171213195538.14290-1-pbhagavatula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: HK2PR02CA0186.apcprd02.prod.outlook.com (10.171.31.22) To DM5PR07MB3466.namprd07.prod.outlook.com (10.164.153.21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3cbe8a90-4740-4980-8e41-08d542639537 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307); SRVR:DM5PR07MB3466; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3466; 3:7BepdT2njrRxOqUOVsenyQWXrqe3PNtDeYDRhuqOfn9WoS0t0NsFsTVShfz/krJA+ZjoBu4Sr0/BaRLVq9rCHKyYID9AC3UMzONYLsCvzXhVkFuOG4wxYzreL1eWRB05CmgR3xk5WsFfUcdgBX5KIFzP6QrlrKr3i2evRTtDyMFvGjV52o/zhLO3iZL0gAjfUpvF6IFe+7HBsFjZCG3H7RZ6alOfP47KzHiKEVQhfWrkjtTssysJ/jQGCjFcZXP/; 25:LXQbVk6PqddBeSXi/hvfjeRkCMkfh9Mb6wSyc1hOmSkM2fBvmBqaJi/DRzsesXQPDhvnNkG96QlDTryNljfzsNwXfLxzxW+lfaLLxB6ywglrO6zCsSQ0vvRT3ZL7tUXlhdEijGZ8Agwp6ZwKLQ4GKf3c1wXH3iwkNnNV2YU0/mB6He1ZxzUJaPEmyyPv4+5/44kIKPSjca6lvoa0BOWvj2p2Euh6bek61oWJ21wL10xxR77iArYASE2I8EsrPJ1+ToY36AJgC5As7sBI95dbNzp//3mZhfasRDZArNM8x2+onXF9v9kQZ5rcbllibYOKoyuVxMKxj1KjX6ZRmF7LTQ==; 31:AOceGLUC0jNv8vbf71TTReGHynNUXyedEt488NY+u0CWrI3/ZBstxA5eEpE6KCvKfbEKEyLzqlFI7TrKj1oylMqmosEPyL1OUF3FEQAz1mZsLk4fVINkMKfOG27yMr0kJ1+IPDhJkLEOiE84LlFGA+PxvtT/cX1yBc7HDVlNy+QUxJyK2sQxNUWo0S6+dmOmCLSjNIiXJiIAIoBqo4waL/d/7j75ZEY+KgbJ7Yv4P8U= X-MS-TrafficTypeDiagnostic: DM5PR07MB3466: X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3466; 20:NE7aeTGeql1I0yUiF3P1NPBVcYShqz/E8KZdwLOoNLDtveHYT8UV5emI4iqFpzl9QSXQQbyxB4uzDhmlnGPAbTEVLR9aZJwezxiCIpia7W5f0glQCdXc1TDIZIYxutcgLBCI0Fjk2sIGHIPgPtPhaV+ZD/Ih1nEPn01K1KQp/y0qBgaWrpy4aLz8thC1oSWCFAEMq3M1sB4IO+hZGO3U9zqjZLs8Ab5Wd60Kynk1pzh/e5imhOgijfCAnNcLTH8bW46ABewGXT+xlO3PknAmAaaubsrvmM4soc4sR/DokIKNotRzVuIkZP1NwAZI+gNoZHTtzriog65aV8iK+nbwabKnUUi/Zpn/JDSNqiKv0phaeiGIaw0ahy6tfPFyC2ZGXpO4VqM3GGflRHu3knhPK1HbCZ2lXWu3iSTaV337fYxN6h5gEEBqkYk6wn+ymG5bCdbkMqaS86VFo2vqIE4MSdmEaFZ9g4RDBZIe+xHSC4oWn59tFW0oop+xn5cph5lHSIRWfG7bC2hu/+gRCOq25b3/J4Y4UMoj/s3o0vU87CWT+t+OX7G6JjkgycF7y05RLEGeqg8wcPddDwg3Ow05KRBwGC718tDpv1zHc+Y9xgk=; 4:XnP5jf5os3XpuBZ9ZLfveVU65w2BXnDWtTSr0oAzirDdaYimzxPi26BDuUvkvpN4cSp5+anoBb0S+LXa9Ukjn/WlAKmdHw57aOZoTQZsUbyo6QYcu+dJFj8YqJeYvtx4wcG60XnKbPDehl4kxDUGsqwgFZQI//b6TrF7sggbebQCeO8YWrk5tgAJagbvHP5a0lV8Q64/z7zqQFdv0Fh3ZacIZZN3KQb6Y6JJ/i/lZoZBS5qWjDT+FJFxBY9HsQYJCHCC4cbaF6yXIlFXmlgS7g== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(3231023)(6041248)(20161123555025)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:DM5PR07MB3466; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:DM5PR07MB3466; X-Forefront-PRVS: 052017CAF1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(366004)(39860400002)(346002)(376002)(189003)(199004)(97736004)(2950100002)(6512007)(47776003)(2906002)(36756003)(1076002)(5660300001)(52116002)(6116002)(105586002)(305945005)(7736002)(3846002)(66066001)(6486002)(72206003)(50466002)(50226002)(25786009)(48376002)(8676002)(81166006)(81156014)(478600001)(4326008)(316002)(8936002)(68736007)(16586007)(53936002)(6666003)(8656006)(107886003)(51416003)(106356001)(76176011)(16526018)(6506007)(42882006)(5009440100003)(386003)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR07MB3466; 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; DM5PR07MB3466; 23:PSFmILYXtCtGF0giOWeLuuGDbPuueY9699X/StbWn?= =?us-ascii?Q?lpvy+72FKERV2jT6tbEb1r/QXfrwO3Npdjrszbu20Mq8myZut2xHkCI6Bfvi?= =?us-ascii?Q?N7tmlpf4kL6mQw3O74OTIPstLF53mzhjOIAsBHU1vQ7n4giZ/9ljT0Br/yHH?= =?us-ascii?Q?O1lEUt+usJq9hr44xWFXpZo3Cgnha1EmFxPRwS1mOuDOTPPWQlJosli3oC7P?= =?us-ascii?Q?Q5gViEJLQGP0OgeBSuoume40Tb8+u/ysrIXwAT36Dyit6EDtUWZgeQSRU6Nx?= =?us-ascii?Q?FWrNhXam8t94F8Yp/I1wTdE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= X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3466; 6:+0xMqGM09I+O9coHJIBSSiloTFWQXrSHzoYscjXCLmSJiiww7j2l71Cb9yRbDkBwh4YuCi2yaqZnhZwmAHbeNQS75Cu9KAfKmiAfII4PxD9+x96Fp0GuLxduvvzfUKe6lB/7XhsLSTTSfFxw8rf+uVqjWW2EHJla7O8fCiaes1vhwLuDyZ/m3880uuKxLNFeJH17Gqy3r7DVZPLHEr94bAKoW8OMHfb1GpVyVb71XSvyvCV9SIXi3Fx4J3j6aj4/w8YTrfiHLcb1mfXqYSmKkqiH5BqfbZxxImVElyVx+J2skNPCi0EJAitenVWrLHHB29oMl+1Sl9Q5J0iDvfneDyx3jTKDntTnyS7nSBvYYLQ=; 5:Z29NbjJrGOCa2psHzTraOC/zxnf8vvufpuU9qOGVbXlTsq7BJwAgcixiR9NysGS4CKB6iBgF5qUSoXxcqFcANmMwh/qrBq1D6R9llggHh8jSj5UISlFdnrzJ0p1JW1JO+xWqygvSM8tYOC9BxBfjOpDnVUT3QVHF2HvRnI8myZo=; 24:uzG+h/6IZhfs4g0cLNGzI8j4DbtSUQHpUBYCRDEwtLs3SFxIf8Ygkty1FktGRhff7hnioAVmdOZ1R+aphIpFyCS/4bOrxlXHI5R+00gMi7k=; 7:3yJCT/do8BDFEUUBhdISzDaxLyTgkan3ROj7eF0as+LaXPzOHLkOa8NRMCPXY4fpKVepE0mP5wEbwCc1066HXA64K5x7Pn+1PevkgMCLP2Pp5L+RiMYvMeOxLf+NVajDUkJvrwov8EWKhd+aW3Px3TVMb+RMMz/BHyfHWeNrGk4YV9aOc6nmFLwV5AHMS7TPaIAbkrs1/iCUFUW9N3Q0d69VA9x6CK4cZOuBUhNdleZjO/YIWa2qoTPPlvvsz6Kz SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2017 19:56:18.4809 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3cbe8a90-4740-4980-8e41-08d542639537 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3466 Subject: [dpdk-dev] [PATCH 2/3] ethdev: add API to get preferred mempool ops name 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: Wed, 13 Dec 2017 19:56:23 -0000 Add API to scan through the ethernet devices and return the best mbuf mempool ops name. If no such mempool is found it returns the default mempool configured. Signed-off-by: Pavan Nikhilesh --- lib/librte_ether/rte_ethdev.c | 41 +++++++++++++++++++++++++++++++++ lib/librte_ether/rte_ethdev.h | 12 ++++++++++ lib/librte_ether/rte_ethdev_version.map | 7 ++++++ lib/librte_mempool/rte_mempool.h | 12 ++++++++++ 4 files changed, 72 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 318af2869..514037ec2 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -3591,3 +3591,44 @@ rte_eth_dev_pool_ops_supported(uint16_t port_id, const char *pool) return (*dev->dev_ops->pool_ops_supported)(dev, pool); } + +const char * +rte_eth_dev_get_preferred_pool_name(uint8_t set_default) +{ + int i, j; + int ret; + int best_weight = 0; + int default_pool_weight = 0; + const char *default_pool_name = rte_eal_mbuf_default_mempool_ops(); + const char *preferred_pool_name = NULL; + + for (i = 0; i < rte_mempool_ops_count(); i++) { + int weight = 0; + const char *name = rte_mempool_get_ops(i)->name; + + for (j = 0; j < rte_eth_dev_count(); j++) { + ret = rte_eth_dev_pool_ops_supported(j, name); + if (ret < 0) { + weight = -1; + break; + } + weight += ret ? 1 : 2; + } + + if (weight > best_weight) { + best_weight = weight; + preferred_pool_name = name; + } + + if (!strcmp(name, default_pool_name)) + default_pool_weight = weight; + } + + if (!best_weight || best_weight == default_pool_weight) + preferred_pool_name = default_pool_name; + + if (set_default) + rte_eal_set_mbuf_default_mempool_ops(preferred_pool_name); + + return preferred_pool_name; +} diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 341c2d624..3f4b234a0 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -4606,6 +4606,18 @@ int rte_eth_dev_adjust_nb_rx_tx_desc(uint16_t port_id, int rte_eth_dev_pool_ops_supported(uint16_t port_id, const char *pool); +/** + * Scan through the ethernet devices and select the best mempool ops supported + * across them. + * + * @param set_default + * Set the selected mempool ops as default. + * @return + * The name of the selected mempool ops. + */ +const char * +rte_eth_dev_get_preferred_pool_name(uint8_t set_default); + #ifdef __cplusplus } #endif diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map index e9681ac8e..674a59c92 100644 --- a/lib/librte_ether/rte_ethdev_version.map +++ b/lib/librte_ether/rte_ethdev_version.map @@ -198,6 +198,13 @@ DPDK_17.11 { } DPDK_17.08; +DPDK_18.02 { + global: + + rte_eth_dev_get_preferred_pool_name; + +} DPDK_17.11; + EXPERIMENTAL { global: diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index 721227f6d..27033102d 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -485,6 +485,18 @@ rte_mempool_get_ops(int ops_index) return &rte_mempool_ops_table.ops[ops_index]; } +/** + * @internal Get the total number of mempool ops. + * + * @return + * The number of mempool ops in the ops table. + */ +static inline int +rte_mempool_ops_count(void) +{ + return rte_mempool_ops_table.num_ops; +} + /** * @internal Wrapper for mempool_ops alloc callback. * -- 2.14.1