| 83 | } |
| 84 | |
| 85 | static void |
| 86 | __handle_secondary_request(void *param) |
| 87 | { |
| 88 | struct mp_reply_bundle *bundle = param; |
| 89 | const struct rte_mp_msg *msg = &bundle->msg; |
| 90 | const struct eal_dev_mp_req *req = |
| 91 | (const struct eal_dev_mp_req *)msg->param; |
| 92 | struct eal_dev_mp_req tmp_req; |
| 93 | struct rte_devargs da; |
| 94 | struct rte_device *dev; |
| 95 | struct rte_bus *bus; |
| 96 | int ret = 0; |
| 97 | |
| 98 | tmp_req = *req; |
| 99 | |
| 100 | memset(&da, 0, sizeof(da)); |
| 101 | if (req->t == EAL_DEV_REQ_TYPE_ATTACH) { |
| 102 | ret = local_dev_probe(req->devargs, &dev); |
| 103 | if (ret != 0 && ret != -EEXIST) { |
| 104 | RTE_LOG(ERR, EAL, "Failed to hotplug add device on primary\n"); |
| 105 | goto finish; |
| 106 | } |
| 107 | ret = eal_dev_hotplug_request_to_secondary(&tmp_req); |
| 108 | if (ret != 0) { |
| 109 | RTE_LOG(ERR, EAL, "Failed to send hotplug request to secondary\n"); |
| 110 | ret = -ENOMSG; |
| 111 | goto rollback; |
| 112 | } |
| 113 | if (tmp_req.result != 0) { |
| 114 | ret = tmp_req.result; |
| 115 | RTE_LOG(ERR, EAL, "Failed to hotplug add device on secondary\n"); |
| 116 | if (ret != -EEXIST) |
| 117 | goto rollback; |
| 118 | } |
| 119 | } else if (req->t == EAL_DEV_REQ_TYPE_DETACH) { |
| 120 | ret = rte_devargs_parse(&da, req->devargs); |
| 121 | if (ret != 0) |
| 122 | goto finish; |
| 123 | |
| 124 | ret = eal_dev_hotplug_request_to_secondary(&tmp_req); |
| 125 | if (ret != 0) { |
| 126 | RTE_LOG(ERR, EAL, "Failed to send hotplug request to secondary\n"); |
| 127 | ret = -ENOMSG; |
| 128 | goto rollback; |
| 129 | } |
| 130 | |
| 131 | bus = rte_bus_find_by_name(da.bus->name); |
| 132 | if (bus == NULL) { |
| 133 | RTE_LOG(ERR, EAL, "Cannot find bus (%s)\n", da.bus->name); |
| 134 | ret = -ENOENT; |
| 135 | goto finish; |
| 136 | } |
| 137 | |
| 138 | dev = bus->find_device(NULL, cmp_dev_name, da.name); |
| 139 | if (dev == NULL) { |
| 140 | RTE_LOG(ERR, EAL, "Cannot find plugged device (%s)\n", da.name); |
| 141 | ret = -ENOENT; |
| 142 | goto finish; |
nothing calls this directly
no test coverage detected