| 304 | } |
| 305 | |
| 306 | int |
| 307 | rte_dev_event_monitor_start(void) |
| 308 | { |
| 309 | int ret = 0; |
| 310 | |
| 311 | rte_rwlock_write_lock(&monitor_lock); |
| 312 | |
| 313 | if (monitor_refcount) { |
| 314 | monitor_refcount++; |
| 315 | goto exit; |
| 316 | } |
| 317 | |
| 318 | intr_handle = rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE); |
| 319 | if (intr_handle == NULL) { |
| 320 | RTE_LOG(ERR, EAL, "Fail to allocate intr_handle\n"); |
| 321 | goto exit; |
| 322 | } |
| 323 | |
| 324 | ret = rte_intr_type_set(intr_handle, RTE_INTR_HANDLE_DEV_EVENT); |
| 325 | if (ret) |
| 326 | goto exit; |
| 327 | |
| 328 | ret = rte_intr_fd_set(intr_handle, -1); |
| 329 | if (ret) |
| 330 | goto exit; |
| 331 | |
| 332 | ret = dev_uev_socket_fd_create(); |
| 333 | if (ret) { |
| 334 | RTE_LOG(ERR, EAL, "error create device event fd.\n"); |
| 335 | goto exit; |
| 336 | } |
| 337 | |
| 338 | ret = rte_intr_callback_register(intr_handle, dev_uev_handler, NULL); |
| 339 | |
| 340 | if (ret) { |
| 341 | close(rte_intr_fd_get(intr_handle)); |
| 342 | goto exit; |
| 343 | } |
| 344 | |
| 345 | monitor_refcount++; |
| 346 | |
| 347 | exit: |
| 348 | if (ret) { |
| 349 | rte_intr_instance_free(intr_handle); |
| 350 | intr_handle = NULL; |
| 351 | } |
| 352 | rte_rwlock_write_unlock(&monitor_lock); |
| 353 | return ret; |
| 354 | } |
| 355 | |
| 356 | int |
| 357 | rte_dev_event_monitor_stop(void) |