[PATCH 04/14] init: deps: order network interfaces by link order
From: Alexander Holler
Date: Sat Oct 17 2015 - 13:15:42 EST
In order to provide stable interface numbers, network interface drivers
will be ordered by the link order. This is easy to accomplish by adding
dependencies.
Assuming three different ethernet-drivers, without any special code,
the dependency graph would not require any special order inbetween them
and would look like that:
eth-driver-base
/ | \
eth-x eth-y eth-z
Now we just add dependencies. With the additional dependencies the graph
looks like:
eth-driver-base
| | |
eth-x | |
| | |
eth-y -| |
| |
eth-z ---|
Signed-off-by: Alexander Holler <holler@xxxxxxxxxxxxx>
---
include/linux/driver_ids.h | 11 +++++++++++
init/dependencies.c | 9 +++++++++
2 files changed, 20 insertions(+)
diff --git a/include/linux/driver_ids.h b/include/linux/driver_ids.h
index 60964fe..1133a68 100644
--- a/include/linux/driver_ids.h
+++ b/include/linux/driver_ids.h
@@ -15,6 +15,17 @@
enum {
drvid_unused,
/* To be filled */
+
+ /*
+ * Network drivers will be ordered according to the link order
+ * (which means not necessarily according to their appearance
+ * here).
+ * This provides stable interface numbers.
+ * Therefor their IDs have to be in the following block.
+ */
+ drvid_network_drivers_start,
+ drvid_network_drivers_end,
+
drvid_max
};
diff --git a/init/dependencies.c b/init/dependencies.c
index b484f67..027fc4b 100644
--- a/init/dependencies.c
+++ b/init/dependencies.c
@@ -301,12 +301,21 @@ static int __init add_dependencies(void)
static void __init build_inventory(void)
{
const struct _annotated_initcall *ac;
+ unsigned id_last_network_driver = 0;
ac = __annotated_initcall_start;
for (; ac < __annotated_initcall_end; ++ac) {
include_node[ac->id] = true;
annotated_initcall_by_drvid[ac->id] = ac;
nvertices = max(nvertices, ac->id);
+ /* order network drivers by link order*/
+ if (ac->id > drvid_network_drivers_start &&
+ ac->id < drvid_network_drivers_end) {
+ if (id_last_network_driver)
+ add_initcall_dependency(ac->id,
+ id_last_network_driver);
+ id_last_network_driver = ac->id;
+ }
}
}
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/