MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pci_vfio_enable_notifier

Function pci_vfio_enable_notifier

dpdk/drivers/bus/pci/linux/pci_vfio.c:329–381  ·  view source on GitHub ↗

enable notifier (only enable req now) */

Source from the content-addressed store, hash-verified

327
328/* enable notifier (only enable req now) */
329static int
330pci_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;
373error:
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) */
384static int

Callers 1

Calls 8

eventfdClass · 0.85
rte_intr_fd_setFunction · 0.85
rte_intr_type_setFunction · 0.85
rte_intr_dev_fd_setFunction · 0.85
rte_intr_enableFunction · 0.50
closeFunction · 0.50

Tested by

no test coverage detected