From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0058.outbound.protection.outlook.com [104.47.38.58]) by dpdk.org (Postfix) with ESMTP id 3FF712C2E; Tue, 23 Jan 2018 08:24:54 +0100 (CET) Received: from BN3PR03CA0115.namprd03.prod.outlook.com (2603:10b6:400:4::33) by BY1PR03MB1420.namprd03.prod.outlook.com (2a01:111:e400:5255::22) 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 07:24:52 +0000 Received: from BN1BFFO11FD028.protection.gbl (2a01:111:f400:7c10::1:111) by BN3PR03CA0115.outlook.office365.com (2603:10b6:400:4::33) 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 07:24:52 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) 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.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD028.mail.protection.outlook.com (10.58.144.91) 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 07:24:50 +0000 Received: from b27504-OptiPlex-790.ap.freescale.net (b27504-OptiPlex-790.ap.freescale.net [10.232.132.60]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id w0N6G0dw023569; Mon, 22 Jan 2018 23:16:16 -0700 From: Nipun Gupta To: CC: , , , Date: Tue, 23 Jan 2018 18:01:08 +0530 Message-ID: <1516710671-13897-5-git-send-email-nipun.gupta@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1516710671-13897-1-git-send-email-nipun.gupta@nxp.com> References: <1516710671-13897-1-git-send-email-nipun.gupta@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131611658923964282; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(346002)(376002)(39380400002)(39860400002)(396003)(2980300002)(1109001)(1110001)(339900001)(189003)(199004)(50226002)(8936002)(2906002)(76176011)(81156014)(47776003)(36756003)(81166006)(68736007)(59450400001)(16586007)(316002)(8676002)(356003)(86362001)(54906003)(305945005)(51416003)(498600001)(6666003)(105606002)(106466001)(2351001)(2950100002)(104016004)(5660300001)(6862004)(53936002)(4326008)(48376002)(50466002)(450100002)(77096007)(336011)(85426001)(97736004)(26005); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR03MB1420; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD028; 1:NNcjPw4jxhRBCBZROwmhzsYm6TLqhN8yKWD6EXs7bxPUOOhS3f1I8hoRMISJz+NHajHibnPRmeQhtU5eGI77nfZa/BFxvoeoAIj7wsp3I9rzbZdUhqHap7ljIXUgCG1W MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a4247194-5ce9-4557-1619-08d5623264eb X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(5600026)(4604075)(2017052603307); SRVR:BY1PR03MB1420; X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1420; 3:SsFd7MY9VUzRT/TXtEjpmojugf6KRGNQDZp0e36U6OH2AdQKzE1I0MX1a2H6i+xB16zpkOCaEfEF3p6LMkXa484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iHKrCockEaNWu6AmNYi4JcTUudy7wTn344SXnDMEFswT6dIp2GH8AI4TdeLnPu/5n2gB3+EupmBhVRVFkz8K+/M8cdBCQBSEu0O+0Jkf91gLgM3MJ2iJvxyVqB0N/9e2XQjMuELfth6YJa3uHN17XsIWppKb8blVLfsyepgLvT X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(5005006)(8121501046)(3231023)(2400081)(944501161)(93006095)(93001095)(10201501046)(3002001)(6055026)(6096035)(201703131430075)(201703131433075)(201703131448075)(201703151042153)(20161123556025)(20161123561025)(20161123559100)(20161123565025)(20161123563025)(201708071742011); SRVR:BY1PR03MB1420; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:BY1PR03MB1420; X-Forefront-PRVS: 05610E64EE X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR03MB1420; 23:Ez285pZ4CvW0bC7xkbbq0rIkZTXzlCuX9OW8a0b3h?= =?us-ascii?Q?Yc8Q7tTH+Op5L1Ws6fdT+EhJJ9r4g2PZaIuE+Oty8MvosjBAjQVfyNJuLF/e?= =?us-ascii?Q?35VdXiTvLd/r1zodpSpROW4Q9N51ddAU5CXL08LiPXASiKN2n6zrOvWgFNJJ?= =?us-ascii?Q?YqffF73cju7XhDUQ9gFL7DWoQSChd1LqEanGSaxVyRs/H0Q+SCgaFUajymgo?= =?us-ascii?Q?jrrfQX7ZI8mwVDMm+Ws/HXAc+g11KpagoeGrkIh1+kvwCM989JfPQ0iCgLm3?= =?us-ascii?Q?eV6uB9lCFHvtGpcqomQfWX/WIK0A9UmH87TjvAss5DVUNQa0UR/XMWwq6BfY?= =?us-ascii?Q?g7kik2sWSIlYXSUlbdFMrYcoEBQQQyuks1Q3D9F+ESwSJl49nkvSQGAKmlub?= =?us-ascii?Q?yYBwm9/FPzWqQ2rDYoVXW8XdgHdEquryav6kH6hfOxXAV6PEunksnRyrYem6?= =?us-ascii?Q?4nhu4CcGuPwz00myb89ppWzveLwp1Hdbucuu3He3XTEQqX9DkLhiNGLvBH5g?= =?us-ascii?Q?sYDen+RncJic9QIOhSKxnXP/4aBqdnoUQOwFX+sLT8ax/mUt9BoG8z1KYn/A?= =?us-ascii?Q?cVcUvEluQkKy8SDBhS8spD/5kkP/R/o0rwIp90op7QJXFvD8yH58rwdCqBPV?= =?us-ascii?Q?jHRZ8jOwZXI7qOck/QD6OpE6T1gkb/Vwrp4PZfQQL67ZsYauqzqWw5s7zurK?= =?us-ascii?Q?YETDmi3qWQuEx0NAO/7c495Topvkj5JHU16hm1UlETvswb7PtkodJtaf32Jy?= =?us-ascii?Q?+e4xOKYAI5cYDNr7ihwqqykjbh6yZaVB7xa9CzIHLQglJtyogq65DCBOX/hg?= =?us-ascii?Q?i4xR7ix4CYSew+4AnNZaazXTgtEYdh1wsTwxTzJi25pbfu0KP+XUeT6cndiX?= =?us-ascii?Q?2OT68EPC6g0jff1vTfW3LQO4wMsKZHPgHBiTfEy6uWEQvao2USyze66i5NSb?= =?us-ascii?Q?YWrPfj8epi/QVoU/NLGA5B3ILFuPzyTvwjDvAghvIgHX3WUi45djd6ctKhB7?= =?us-ascii?Q?rtT3d4GP8eA3Fai20BLgAvkHjvpWC5kkZzqMUe2N57KAdXNtwGvUgg8ZVAX4?= =?us-ascii?Q?Ig5Yh9oJcy1BilnNcoLPMc+XT4dyCPsvMnunUmtCoygbVJHfBP7v1uX6JCvE?= =?us-ascii?Q?Gi16VnsQYY=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1420; 6:MdrLbijPvRN56cMGVOWcpcQ/QaPyerfQ106DcTYyontDURCETH7kYyxZtC95vWhRuH7aML0sDaHbZVfXMyEOHNyebZFvx1T2zxsgLJaJ7uaXw9mpjU1qUYbDKAwww30QyN3YUudmgFzwNP7fNKMPFPotIzrxj3jAZzYVDv6VXYMKnoeM1+f34oKtbGkrutEPMfvEwMtiKj/RLkQ2oQd1TFhlIU8J709D/a4PZBvSdjZei7suSRhCdS3K22ipznbGrNQKQJUcAu36lPpAGNIbBUPeU9l+6wFe1GGRJMaTEHw0Av7oBkecDWkEUou7XY2KcFvp9tJxW/3p0YKH8nLhTHYOcqyle2NqoxZ5pK6No+g=; 5:BD/EUmlrENOrd8HF8hvQfH57+7w+8v5LRYnEb/XrO6rd++o2+cR5JzBku0f7dX1Pppq+4igbEml9rDSeHRZZNXHjylgDPN+UjeJEWk6rxMOb6pS3HB5IyBfdJb4IylA2YGbGAmI5xIhME1dQvTn+7wknucS8pE0qaZ6BDGXFnnc=; 24:SW8DIAo1kJHN3+IQg9UqVyy4DMmveEGvYa6OTyReK2XIUsGLfd2YrEhkMG7Yq0yMfmbZtEWKMCo4frbOrD7Vioz6ULfNaRV6HRA7RV5kJqE=; 7:+Lg8ehgT1Am7LZ7wEiJsc7doP2P8g+Fygf5l1FiCfv08ffXLwU1ah5OmHHgnrKuiuP08h0BwMmwjT25wGiV27/gFL9Cplptazu1AfKU01hoMJD5SXEa4XN983KtaxSrgwQ/9qQGTQO+jwtpVMJhV2AoMPkgkq0dFMCRpWyKKApoqXlrrmpprgXK9vaG26H2yZ3qDepjp3QaBhT4aV/Ty6Zie7RaRd1UaEbke1TKOu70xJu/80lIH7gj7EclSAMRF SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2018 07:24:50.9300 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a4247194-5ce9-4557-1619-08d5623264eb X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR03MB1420 Subject: [dpdk-stable] [PATCH 4/7] 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 07:24:54 -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