DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dariusz Sosnowski <dsosnowski@nvidia.com>
To: Matan Azrad <matan@nvidia.com>,
	Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
	Ori Kam <orika@nvidia.com>, Suanming Mou <suanmingm@nvidia.com>
Cc: <dev@dpdk.org>, Raslan Darawsheh <rasland@nvidia.com>
Subject: [PATCH 7/8] net/mlx5: sort port spawn data with uplink ports first
Date: Tue, 31 Oct 2023 16:27:32 +0200	[thread overview]
Message-ID: <20231031142733.2009166-8-dsosnowski@nvidia.com> (raw)
In-Reply-To: <20231031142733.2009166-1-dsosnowski@nvidia.com>

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 <dsosnowski@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 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


  parent reply	other threads:[~2023-10-31 14:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-31 14:27 [PATCH 0/8] net/mlx5: add Multiport E-Switch support Dariusz Sosnowski
2023-10-31 14:27 ` [PATCH 1/8] net/mlx5/hws: fix leak in FT management Dariusz Sosnowski
2023-10-31 14:27 ` [PATCH 2/8] common/mlx5: fix controller index parsing Dariusz Sosnowski
2023-10-31 14:27 ` [PATCH 3/8] common/mlx5: add Netlink check for Multiport E-Switch Dariusz Sosnowski
2023-10-31 14:27 ` [PATCH 4/8] net/mlx5: add sysfs " Dariusz Sosnowski
2023-10-31 16:09   ` Stephen Hemminger
2023-10-31 17:37     ` Dariusz Sosnowski
2023-10-31 14:27 ` [PATCH 5/8] net/mlx5: add checking Multiport E-Switch state Dariusz Sosnowski
2023-10-31 14:27 ` [PATCH 6/8] net/mlx5: support port probing of Multiport E-Switch device Dariusz Sosnowski
2023-10-31 14:27 ` Dariusz Sosnowski [this message]
2023-10-31 14:27 ` [PATCH 8/8] net/mlx5: add support for vport match selection Dariusz Sosnowski
2023-10-31 21:49 ` [PATCH 0/8] net/mlx5: add Multiport E-Switch support Raslan Darawsheh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231031142733.2009166-8-dsosnowski@nvidia.com \
    --to=dsosnowski@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=suanmingm@nvidia.com \
    --cc=viacheslavo@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).