From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B272E43252; Tue, 31 Oct 2023 15:29:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AEB99427D7; Tue, 31 Oct 2023 15:28:36 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2045.outbound.protection.outlook.com [40.107.244.45]) by mails.dpdk.org (Postfix) with ESMTP id 9ADA340DDE for ; Tue, 31 Oct 2023 15:28:32 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CDXhq+l+zUFqNoAi/9kBF3q5xH1Dtxx63bEzkiuxh2xAz5j/PZkEjr+r0yfst7NuxrnNVyWxFHEpAnQuwkFZ91h+TapnOm+PPQTVz7WTh/WG3dgpitrb41gMVEL3+g9A0baQfoIntTruFDwrquPPpLq5k5Ak5JcS6InIXXbNp7NO4NjMiaMzTyhN6wYccXktbKs2F3Xl2txjLF9L21S0V801IhF8ZgLiMi96Emea8gkTd/I0iUNAsz1xkoSf73TY8CgeCeCr2NzrW/inNOx91rnK9ja10DZ9TZ2HW39iPPNoX+fsRvdi8WEiimiy76QVU6hgRiDlfFazlhu/FZDxFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=y3OHLAgipFBSsniTjKPMa1KUodxOVyq9Vfa9i7A/N6M=; b=C6/lqRSs4VikYQJ9lY5Ra6e2DfZhH+8WyBYPnR2ZieFAFEgjeaBhQ8/pjbVAHj1DGNYv059ZpiWoo9fz8qE09UTrKAYvrIjUzzk69MozsjuJCDoXYCsLrK1WvRrb7que/8P335ov+tL1ur4vIkANrk3jarfngap1wzJIFR4z8XeWsYxPxLPb2fTgn2g7VqyDlTCGsHBLEmk24p14G988wA8T8Qofbp18FLZxkOtOu1YR/hJDCIzYuzfKTL4LM/F01DLUlD+Gh1Ake/LNRjIA4oFPfKx2FACblZ1/xH29/FhMz0tOH0kyixVSSRw61AfvNfcgLx3AHAAUyqjYei/B6A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=y3OHLAgipFBSsniTjKPMa1KUodxOVyq9Vfa9i7A/N6M=; b=pWojvNXY1fkA3j2mTyix7OTX0KQ0joFM2myFSNrpr5SV2kC0PqK76XA3P8LcRjCSZOpWsq4vp+4zKubaEge4G3Mzx22A6Wv1C4f1xNXGneqQvdZCdg0SttyFs3a+uzCliZyBjUEUko3xvHbZddv/7C5i0WfPbGB//dkOFpQ04QX5g6GeGS9ruOJIRmynYx4Xt+2ZbzEUG1g97xGlwZ2SGfulr25Ivxtm0jgxwLVlo5lcs8P3/PszgzPL6Q0lrHpiTIbpFwee9EDrcJ5u6x4p4e+2CIKYfdcLzkBS/6UCAsWLkqXIkiIu4Q+IDsWDdGS22qmfolJBWJ0q1VjrkubYdQ== Received: from MW4PR04CA0242.namprd04.prod.outlook.com (2603:10b6:303:88::7) by CH3PR12MB8535.namprd12.prod.outlook.com (2603:10b6:610:160::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.29; Tue, 31 Oct 2023 14:28:30 +0000 Received: from MWH0EPF000971E6.namprd02.prod.outlook.com (2603:10b6:303:88:cafe::a) by MW4PR04CA0242.outlook.office365.com (2603:10b6:303:88::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.29 via Frontend Transport; Tue, 31 Oct 2023 14:28:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by MWH0EPF000971E6.mail.protection.outlook.com (10.167.243.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.19 via Frontend Transport; Tue, 31 Oct 2023 14:28:30 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 31 Oct 2023 07:28:08 -0700 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Tue, 31 Oct 2023 07:28:06 -0700 From: Dariusz Sosnowski To: Matan Azrad , Viacheslav Ovsiienko , Ori Kam , Suanming Mou CC: , Raslan Darawsheh Subject: [PATCH 7/8] net/mlx5: sort port spawn data with uplink ports first Date: Tue, 31 Oct 2023 16:27:32 +0200 Message-ID: <20231031142733.2009166-8-dsosnowski@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231031142733.2009166-1-dsosnowski@nvidia.com> References: <20231031142733.2009166-1-dsosnowski@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E6:EE_|CH3PR12MB8535:EE_ X-MS-Office365-Filtering-Correlation-Id: a9b1553b-42bd-4928-172c-08dbda1da7a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oks3NSJKjvR7iawyxLsKxsE52r/R+AUpvw2UJgFvOUOkpFda9aqSyBg7nLmLiiwE1T/SWO9KkMl0XjqNK0cAZbxS+SkhwLpmlNMCs0XURogvnLsi3ovNKKkfTIu1Zh7xjNNuHQjEUPAyjzMND5QhNa24EBeFtyaqA2H5Ce4KF4zpgYr+EXcbq480rfTxXQsDGfd/Pg3D5FInXouZcWgofdIk050OigXjEGZd9MpZ+CZFNEISOkUuXXtngVmw+cCiSRbDxB2L6g6gdxNe+QD/LdrkO1XDIc+Eo4zPGZfzlWU+XlKHqPn0mJhm5aHzpGuUPwjrHGL5JaQ6PpdlSvMm1zav5Be5IG9JDV36E0Pig9UyekPwpUL0o4AJQLcclclTwmZe8O6H1QGv+ljRRAcPRLICCgvD0ESpZfdBIaYThIKq5H4ssKDFA/4ToAyj2abBY3Ulqop5cSwJIiQ2Pwr0oRXWIMMh08W523HkLF4IhuyREbb8r74zny8NzfRCJzp6KH4D1ZA3pUP4u+jkiJoxFXh5EoDKiYBuJJSDV9jM4OEW7vLhGANtUWJrO002t4KKLyTdYpEw0RqGFfKwCM0ixUWnNlpexOxCdDjct9dP7y57N5N8TPaD1mxYqAUnc5+v/RiuH13ua1MullNaIVqBA6O+YHeEiGmTTEA/qoztazUd/cJnB+zt+N9zhlt71m5syj+bP+KjKZ2kubG422QUX+hdDDWz8SMTbRFQoYYTp1JYY1camMgBDyyCfu5l2w9t X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(346002)(396003)(376002)(136003)(39860400002)(230922051799003)(1800799009)(82310400011)(451199024)(186009)(64100799003)(40470700004)(36840700001)(46966006)(2906002)(40460700003)(40480700001)(478600001)(55016003)(6666004)(2616005)(107886003)(1076003)(16526019)(6286002)(26005)(426003)(336012)(82740400003)(47076005)(7636003)(356005)(36756003)(83380400001)(86362001)(36860700001)(7696005)(54906003)(110136005)(41300700001)(6636002)(316002)(70586007)(70206006)(5660300002)(8936002)(8676002)(4326008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2023 14:28:30.2753 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9b1553b-42bd-4928-172c-08dbda1da7a1 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000971E6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8535 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This patch changes the behavior of the comparator used to sort mlx5_dev_spawn_data structures, to put them in a more user friendly order Before this patch, ports were sorted assuming there is only a single master port. It resulted in an order where master port first comes second, then representors in ascending order of IDs. This approach however is not desirable with devices configured for Multiport E-Switch, since uplink ports which do not correspond to the owning PCI device are representors as well and they will be mixed with VF/SF representors. To change that, this patch amends the comparator to force uplink ports to be first. If there are many uplink ports, the master port will come first and the rest will be sorted by port index. Signed-off-by: Dariusz Sosnowski Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/linux/mlx5_os.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 8ddf38288e..07f31de5ae 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1797,9 +1797,15 @@ mlx5_dev_spawn_data_cmp(const void *a, const void *b) &((const struct mlx5_dev_spawn_data *)a)->info; const struct mlx5_switch_info *si_b = &((const struct mlx5_dev_spawn_data *)b)->info; + int uplink_a = si_a->name_type == MLX5_PHYS_PORT_NAME_TYPE_UPLINK; + int uplink_b = si_b->name_type == MLX5_PHYS_PORT_NAME_TYPE_UPLINK; int ret; - /* Master device first. */ + /* Uplink ports first. */ + ret = uplink_b - uplink_a; + if (ret) + return ret; + /* Then master devices. */ ret = si_b->master - si_a->master; if (ret) return ret; -- 2.25.1