1 From 16449a64d38c7f4b880601ddf3d34087da5e8577 Mon Sep 17 00:00:00 2001
2 From: Xiaoming Jiang <jiangxiaoming@outlook.com>
3 Date: Thu, 9 Jun 2022 06:15:51 +0000
4 Subject: [PATCH 1/1] bus/vmbus: add support allow/block scan mode
7 drivers/bus/vmbus/vmbus_common.c | 32 +++++++++++++++++++++++++++++---
8 1 file changed, 29 insertions(+), 3 deletions(-)
10 diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c
11 index 3677273..47edacb 100644
12 --- a/drivers/bus/vmbus/vmbus_common.c
13 +++ b/drivers/bus/vmbus/vmbus_common.c
14 @@ -102,7 +102,12 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr,
15 VMBUS_LOG(INFO, "VMBUS device %s on NUMA socket %i",
16 guid, dev->device.numa_node);
18 - /* TODO add block/allow logic */
19 + /* no initialization when marked as blocked, return without error */
20 + if (dev->device.devargs != NULL &&
21 + dev->device.devargs->policy == RTE_DEV_BLOCKED) {
22 + RTE_LOG(INFO, EAL, " Device is blocked, not initializing\n");
26 /* map resources for device */
27 ret = rte_vmbus_map_device(dev);
28 @@ -134,7 +139,7 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr,
31 * If device class GUID matches, call the probe function of
32 - * register drivers for the vmbus device.
33 + * registere drivers for the vmbus device.
34 * Return -1 if initialization failed,
35 * and 1 if no driver found for this device.
37 @@ -163,6 +168,25 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev)
42 +rte_vmbus_ignore_device(struct rte_vmbus_device *dev)
44 + struct rte_devargs *devargs = vmbus_devargs_lookup(dev);
46 + switch (rte_vmbus_bus.bus.conf.scan_mode) {
47 + case RTE_BUS_SCAN_ALLOWLIST:
48 + if (devargs && devargs->policy == RTE_DEV_ALLOWED)
51 + case RTE_BUS_SCAN_UNDEFINED:
52 + case RTE_BUS_SCAN_BLOCKLIST:
53 + if (devargs == NULL || devargs->policy != RTE_DEV_BLOCKED)
61 * Scan the vmbus, and call the devinit() function for
62 * all registered drivers that have a matching entry in its id_table
63 @@ -180,7 +204,9 @@ rte_vmbus_probe(void)
65 rte_uuid_unparse(dev->device_id, ubuf, sizeof(ubuf));
67 - /* TODO: add allowlist/blocklist */
68 + if (rte_vmbus_ignore_device(dev)) {
72 if (vmbus_probe_all_drivers(dev) < 0) {