enable notifier (only enable req now) */
| 327 | |
| 328 | /* enable notifier (only enable req now) */ |
| 329 | static int |
| 330 | pci_vfio_enable_notifier(struct rte_pci_device *dev, int vfio_dev_fd) |
| 331 | { |
| 332 | int ret; |
| 333 | int fd = -1; |
| 334 | |
| 335 | /* set up an eventfd for req notifier */ |
| 336 | fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); |
| 337 | if (fd < 0) { |
| 338 | RTE_LOG(ERR, EAL, "Cannot set up eventfd, error %i (%s)\n", |
| 339 | errno, strerror(errno)); |
| 340 | return -1; |
| 341 | } |
| 342 | |
| 343 | if (rte_intr_fd_set(dev->vfio_req_intr_handle, fd)) |
| 344 | return -1; |
| 345 | |
| 346 | if (rte_intr_type_set(dev->vfio_req_intr_handle, RTE_INTR_HANDLE_VFIO_REQ)) |
| 347 | return -1; |
| 348 | |
| 349 | if (rte_intr_dev_fd_set(dev->vfio_req_intr_handle, vfio_dev_fd)) |
| 350 | return -1; |
| 351 | |
| 352 | ret = rte_intr_callback_register(dev->vfio_req_intr_handle, |
| 353 | pci_vfio_req_handler, |
| 354 | (void *)&dev->device); |
| 355 | if (ret) { |
| 356 | RTE_LOG(ERR, EAL, "Fail to register req notifier handler.\n"); |
| 357 | goto error; |
| 358 | } |
| 359 | |
| 360 | ret = rte_intr_enable(dev->vfio_req_intr_handle); |
| 361 | if (ret) { |
| 362 | RTE_LOG(ERR, EAL, "Fail to enable req notifier.\n"); |
| 363 | ret = rte_intr_callback_unregister(dev->vfio_req_intr_handle, |
| 364 | pci_vfio_req_handler, |
| 365 | (void *)&dev->device); |
| 366 | if (ret < 0) |
| 367 | RTE_LOG(ERR, EAL, |
| 368 | "Fail to unregister req notifier handler.\n"); |
| 369 | goto error; |
| 370 | } |
| 371 | |
| 372 | return 0; |
| 373 | error: |
| 374 | close(fd); |
| 375 | |
| 376 | rte_intr_fd_set(dev->vfio_req_intr_handle, -1); |
| 377 | rte_intr_type_set(dev->vfio_req_intr_handle, RTE_INTR_HANDLE_UNKNOWN); |
| 378 | rte_intr_dev_fd_set(dev->vfio_req_intr_handle, -1); |
| 379 | |
| 380 | return -1; |
| 381 | } |
| 382 | |
| 383 | /* disable notifier (only disable req now) */ |
| 384 | static int |
no test coverage detected