From: Nipun Gupta <nipun.gupta@nxp.com>
To: <thomas@monjalon.net>
Cc: <dev@dpdk.org>, <hemant.agrawal@nxp.com>,
<shreyansh.jain@nxp.com>, <stable@dpdk.org>
Subject: [dpdk-stable] [PATCH 4/7] bus/dpaa: fix port order shuffling
Date: Tue, 23 Jan 2018 18:01:08 +0530 [thread overview]
Message-ID: <1516710671-13897-5-git-send-email-nipun.gupta@nxp.com> (raw)
In-Reply-To: <1516710671-13897-1-git-send-email-nipun.gupta@nxp.com>
From: Shreyansh Jain <shreyansh.jain@nxp.com>
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 <shreyansh.jain@nxp.com>
---
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
prev parent reply other threads:[~2018-01-23 7:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1516710671-13897-1-git-send-email-nipun.gupta@nxp.com>
[not found] ` <1516710427-22843-1-git-send-email-nipun.gupta@nxp.com>
2018-01-23 12:27 ` [dpdk-stable] [PATCH 1/7 v2] bus/dpaa: check flag in qman multi enqueue Nipun Gupta
2018-01-24 5:24 ` Hemant Agrawal
2018-01-31 12:45 ` [dpdk-stable] [dpdk-dev] " Thomas Monjalon
2018-01-23 12:27 ` [dpdk-stable] [PATCH 2/7 v2] bus/dpaa: allocate qman portals in thread safe manner Nipun Gupta
2018-01-23 12:27 ` [dpdk-stable] [PATCH 3/7 v2] mempool/dpaa: fix the phy to virt optimization Nipun Gupta
2018-01-23 12:27 ` [dpdk-stable] [PATCH 4/7 v2] bus/dpaa: fix port order shuffling Nipun Gupta
2018-01-23 12:31 ` [dpdk-stable] [PATCH 1/7] bus/dpaa: check flag in qman multi enqueue Nipun Gupta
2018-01-23 12:31 ` [dpdk-stable] [PATCH 2/7] bus/dpaa: allocate qman portals in thread safe manner Nipun Gupta
2018-01-23 12:31 ` [dpdk-stable] [PATCH 3/7] mempool/dpaa: fix the phy to virt optimization Nipun Gupta
2018-01-23 12:31 ` Nipun Gupta [this message]
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=1516710671-13897-5-git-send-email-nipun.gupta@nxp.com \
--to=nipun.gupta@nxp.com \
--cc=dev@dpdk.org \
--cc=hemant.agrawal@nxp.com \
--cc=shreyansh.jain@nxp.com \
--cc=stable@dpdk.org \
--cc=thomas@monjalon.net \
/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).