From 63b2a149da3a00d3ea892a68bbb54307634b86a9 Mon Sep 17 00:00:00 2001 From: erj Date: Wed, 29 May 2019 22:24:10 +0000 Subject: [PATCH] iflib: provide probe wrapper for vendor drivers From Jake: Vendor drivers that exist out-of-tree generally should return BUS_PROBE_VENDOR from their device probe functions. This helps ensure that a vendor replacement driver will supersede the in-kernel driver for a given device. Currently, if a vendor wants to implement a driver based on iflib, it will always report BUS_PROBE_DEFAULT. Add a wrapper function, iflib_device_probe_vendor() which can be used in place of iflib_device_probe(). This function will just return BUS_PROBE_VENDOR whenever iflib_device_probe() would return BUS_PROBE_DEFAULT. While vendor drivers can already implement such a wrapper themselves, providing it in the iflib.h header makes it easier for the vendor driver to do the right thing. Submitted by: Jacob Keller Reviewed by: erj@, gallatin@, marius@ MFC after: 1 week Sponsored by: Intel Corporation Differential Revision: https://reviews.freebsd.org/D20221 --- sys/net/iflib.c | 12 ++++++++++++ sys/net/iflib.h | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 63b440303524..5c15ff51df92 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -4377,6 +4377,18 @@ iflib_device_probe(device_t dev) return (ENXIO); } +int +iflib_device_probe_vendor(device_t dev) +{ + int probe; + + probe = iflib_device_probe(dev); + if (probe == BUS_PROBE_DEFAULT) + return (BUS_PROBE_VENDOR); + else + return (probe); +} + static void iflib_reset_qvalues(if_ctx_t ctx) { diff --git a/sys/net/iflib.h b/sys/net/iflib.h index 156d318a1027..77f69354765b 100644 --- a/sys/net/iflib.h +++ b/sys/net/iflib.h @@ -399,6 +399,13 @@ int iflib_device_suspend(device_t); int iflib_device_resume(device_t); int iflib_device_shutdown(device_t); +/* + * Use this instead of iflib_device_probe if the driver should report + * BUS_PROBE_VENDOR instead of BUS_PROBE_DEFAULT. (For example, an out-of-tree + * driver based on iflib). + */ +int iflib_device_probe_vendor(device_t); + int iflib_device_iov_init(device_t, uint16_t, const nvlist_t *); void iflib_device_iov_uninit(device_t);