Xiaoming Jiang | 2d76657 | 2022-06-08 15:28:59 +0000 | [diff] [blame] | 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 |
| 5 | |
| 6 | --- |
| 7 | drivers/bus/vmbus/vmbus_common.c | 32 +++++++++++++++++++++++++++++--- |
| 8 | 1 file changed, 29 insertions(+), 3 deletions(-) |
| 9 | |
| 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); |
| 17 | |
| 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"); |
| 23 | + return 1; |
| 24 | + } |
| 25 | |
| 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, |
| 29 | |
| 30 | /* |
| 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. |
| 36 | */ |
| 37 | @@ -163,6 +168,25 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev) |
| 38 | return 1; |
| 39 | } |
| 40 | |
| 41 | +static bool |
| 42 | +rte_vmbus_ignore_device(struct rte_vmbus_device *dev) |
| 43 | +{ |
| 44 | + struct rte_devargs *devargs = vmbus_devargs_lookup(dev); |
| 45 | + |
| 46 | + switch (rte_vmbus_bus.bus.conf.scan_mode) { |
| 47 | + case RTE_BUS_SCAN_ALLOWLIST: |
| 48 | + if (devargs && devargs->policy == RTE_DEV_ALLOWED) |
| 49 | + return false; |
| 50 | + break; |
| 51 | + case RTE_BUS_SCAN_UNDEFINED: |
| 52 | + case RTE_BUS_SCAN_BLOCKLIST: |
| 53 | + if (devargs == NULL || devargs->policy != RTE_DEV_BLOCKED) |
| 54 | + return false; |
| 55 | + break; |
| 56 | + } |
| 57 | + return true; |
| 58 | +} |
| 59 | + |
| 60 | /* |
| 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) |
| 64 | |
| 65 | rte_uuid_unparse(dev->device_id, ubuf, sizeof(ubuf)); |
| 66 | |
| 67 | - /* TODO: add allowlist/blocklist */ |
| 68 | + if (rte_vmbus_ignore_device(dev)) { |
| 69 | + continue; |
| 70 | + } |
| 71 | |
| 72 | if (vmbus_probe_all_drivers(dev) < 0) { |
| 73 | VMBUS_LOG(NOTICE, |
| 74 | -- |
| 75 | 2.32.0 |
| 76 | |