From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0065.outbound.protection.outlook.com [104.47.34.65]) by dpdk.org (Postfix) with ESMTP id 017E51B00C; Tue, 23 Jan 2018 14:03:21 +0100 (CET) Received: from BLUPR0301CA0027.namprd03.prod.outlook.com (10.162.113.165) by BY2PR03MB475.namprd03.prod.outlook.com (10.141.141.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Tue, 23 Jan 2018 13:03:19 +0000 Received: from BN1BFFO11FD047.protection.gbl (2a01:111:f400:7c10::1:170) by BLUPR0301CA0027.outlook.office365.com (2a01:111:e400:5259::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.428.17 via Frontend Transport; Tue, 23 Jan 2018 13:03:19 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11FD047.mail.protection.outlook.com (10.58.145.2) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.428.12 via Frontend Transport; Tue, 23 Jan 2018 13:03:19 +0000 Received: from b27504-OptiPlex-790.ap.freescale.net (b27504-OptiPlex-790.ap.freescale.net [10.232.132.60]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id w0NCR9X3020973; Tue, 23 Jan 2018 05:27:27 -0700 From: Nipun Gupta To: CC: , , , Date: Tue, 23 Jan 2018 17:57:04 +0530 Message-ID: <1516710427-22843-5-git-send-email-nipun.gupta@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1516710427-22843-1-git-send-email-nipun.gupta@nxp.com> References: <1516710671-13897-1-git-send-email-nipun.gupta@nxp.com> <1516710427-22843-1-git-send-email-nipun.gupta@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131611861995233922; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(346002)(39380400002)(396003)(39860400002)(376002)(2980300002)(1110001)(1109001)(339900001)(199004)(189003)(106466001)(8676002)(36756003)(26005)(77096007)(2351001)(69596002)(8936002)(105606002)(59450400001)(5660300001)(51416003)(53936002)(336011)(81166006)(47776003)(81156014)(6666003)(76176011)(16586007)(305945005)(85426001)(2950100002)(97736004)(104016004)(68736007)(50466002)(48376002)(54906003)(498600001)(2906002)(86362001)(6862004)(450100002)(50226002)(4326008)(316002)(356003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR03MB475; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD047; 1:96H9RD7CiKlS2X1FlPj1uQBWYCa246mUQ6mmRZsamVWteyHPuRSNBhRjAP0/X7hQhAWWtmbtQ5uV7H8y4FXxnnarhoScTUk1M8PNskciKBBbfw2m+RO44r0chhpXeAuQ MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: da6dba3f-4fb9-4ce9-c124-08d56261ace8 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(5600026)(4604075)(2017052603307); SRVR:BY2PR03MB475; X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB475; 3:PCRXQdECoOZWsBU8Y0XFfNIy89Rqg+NWCVdR+j99kpfXxxK82pt1Uh3gIFLYtk0b6Xgr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42IHqTgr3esnBxMHructrmN/1N1ig2BJzykbbQZ58BJ0SFA7toL5BmWEoMbvdG/sLOr+667mskZFnVK4+BrCg8MF5+F4aKFmEsSqBrLztdh5qHcw/C+JYxUIww5R9yhTmHVkxTtSV3KwVrFt6fJl7BNE/yvm6EnApR1ayV/vxGpQd7tTzCLXAIgMVDJTjkJF6Js X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(3231023)(2400081)(944501161)(6055026)(6096035)(20161123561025)(20161123559100)(201703131430075)(201703131433075)(201703131448075)(201703151042153)(20161123556025)(20161123563025)(20161123565025)(201708071742011); SRVR:BY2PR03MB475; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:BY2PR03MB475; X-Forefront-PRVS: 05610E64EE X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR03MB475; 23:no6gnPUlvx2o8IBIhFaSJdeBu93TJwwBnq/hmUutCM?= =?us-ascii?Q?Fy1LXk0rjBJS6OvSgfpDgRPvnNisOVdfVgt+ZPtOs1A8dS/JTk2Yj/RGzAps?= =?us-ascii?Q?5d9t6gB5Hii8DGU5G7OuFETj23jBI+jfLa9aTrV/ees5JQo2M8OlM8F1AUPo?= =?us-ascii?Q?/kuDSN6Bh9g9RvT3ArDoIBZd/9Vo1ZZfdlGE1J653Ql65mkuxle/5/Jsxuiu?= =?us-ascii?Q?QXbtblclccrU8BV7M8ptpkIWCKokofkcdon1Uw8E4MlVTyaZU2yPyV4TtoIm?= =?us-ascii?Q?q6ZOxc0CMOZfN0b7jOPsj4isyQaFJw2795BctdUJ/H05IhpW921f53cTrv1e?= =?us-ascii?Q?XuBB773ebJUQXvDpmDUFHOObuj5euTghuz/pSqQCc05s4hERQosxw9MAzdWY?= =?us-ascii?Q?n69h3amDZ5CUQZAL553n4I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mOBAqLRFa4phKmNVAeOq/OgvQwEdMb5wrDTmiu7jCTPvFtn5IW1OE7nmFQGPihHOE5WJshILi94x6piK50DKnd3SD6q/XS3tL7XpaZLsYO6o1dXstTk9CLJwgZZRDd9xPY3Llh4d5nQ2LezDjhcVh3qN0FQstgsRqLddmBe0NngjdsZsNJ/gwdtGjPLXEYHykHUw1DInX0Z9QPiShu2TC4=; 5:XXG5VoNtsa+hcxrUAHTWcUkz+zDcQHGTjcywQ4qSqguCKfWhz6QpImPVLHs+FD+H+3OD6HCpcSJpMFc/QOOrE3ZNXQH9xTy9dsCz49ROX1iMz1i/ptl1xGvtrVf8LMJgEuN8yJXOJNYaMIstF31irmFd8CJDH0EVZusb4LXvHcc=; 24:C1ScSbr5MB3jQMtnwEEkGPcWVOjkshMQ4AfFHrJefcBOAL9R32BuEXK23QPhKJ/ibtrq3rGxDtHg/i71UfOoTiH02HFHcICltEyQ0dZRXyE=; 7:v+f2hwDJvpZdhD2oN3swiIkm63sZbAmbinkL2qJy23cJERYm1eGEz+ajaKcRMO8FEzp1zTUQzpeSmAcNQijpMVEbDBQQUa4zAtX8jCLtb1OO9vzN598y3j8gMVLVV/m4fRsdofZWmcBUhhUV33/KrvQaTzRX64YXk5oN1cdzsoMcWa9U1/3rRRpmXgQl9loCFtwqwKuZCnRzVgJDFgOXaeo/sIsDL6wdaSUMmERVCYjOUSkqDB/7uOsA24govEAr SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2018 13:03:19.2581 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: da6dba3f-4fb9-4ce9-c124-08d56261ace8 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB475 Subject: [dpdk-stable] [PATCH 4/7 v2] bus/dpaa: fix port order shuffling X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Jan 2018 13:03:22 -0000 From: Shreyansh Jain While scanning for devices, the order in which devices appear is different as compared to MAC sequence. This can cause confusion for users and automated scripts. This patch create a sorted list of devices. Fixes: 919eeaccb2ba ("bus/dpaa: introduce NXP DPAA bus driver skeleton") Cc: stable@dpdk.org Signed-off-by: Shreyansh Jain --- drivers/bus/dpaa/dpaa_bus.c | 52 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c index ba33566..ef2df48 100644 --- a/drivers/bus/dpaa/dpaa_bus.c +++ b/drivers/bus/dpaa/dpaa_bus.c @@ -57,10 +57,58 @@ RTE_DEFINE_PER_LCORE(bool, _dpaa_io); RTE_DEFINE_PER_LCORE(struct dpaa_portal_dqrr, held_bufs); +static int +compare_dpaa_devices(struct rte_dpaa_device *dev1, + struct rte_dpaa_device *dev2) +{ + int comp = 0; + + /* Segragating ETH from SEC devices */ + if (dev1->device_type > dev2->device_type) + comp = 1; + else if (dev1->device_type < dev2->device_type) + comp = -1; + else + comp = 0; + + if ((comp != 0) || (dev1->device_type != FSL_DPAA_ETH)) + return comp; + + if (dev1->id.fman_id > dev2->id.fman_id) { + comp = 1; + } else if (dev1->id.fman_id < dev2->id.fman_id) { + comp = -1; + } else { + /* FMAN ids match, check for mac_id */ + if (dev1->id.mac_id > dev2->id.mac_id) + comp = 1; + else if (dev1->id.mac_id < dev2->id.mac_id) + comp = -1; + else + comp = 0; + } + + return comp; +} + static inline void -dpaa_add_to_device_list(struct rte_dpaa_device *dev) +dpaa_add_to_device_list(struct rte_dpaa_device *newdev) { - TAILQ_INSERT_TAIL(&rte_dpaa_bus.device_list, dev, next); + int comp, inserted = 0; + struct rte_dpaa_device *dev = NULL; + struct rte_dpaa_device *tdev = NULL; + + TAILQ_FOREACH_SAFE(dev, &rte_dpaa_bus.device_list, next, tdev) { + comp = compare_dpaa_devices(newdev, dev); + if (comp < 0) { + TAILQ_INSERT_BEFORE(dev, newdev, next); + inserted = 1; + break; + } + } + + if (!inserted) + TAILQ_INSERT_TAIL(&rte_dpaa_bus.device_list, newdev, next); } static inline void -- 1.9.1