1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2020 Mellanox Technologies, Ltd
5 #include <rte_interrupts.h>
7 #include "eal_private.h"
8 #include "eal_windows.h"
10 static pthread_t intr_thread;
12 static HANDLE intr_iocp;
15 eal_intr_process(const OVERLAPPED_ENTRY *event)
21 eal_intr_thread_main(LPVOID arg __rte_unused)
24 OVERLAPPED_ENTRY events[16];
28 result = GetQueuedCompletionStatusEx(
29 intr_iocp, events, RTE_DIM(events), &event_count,
30 INFINITE, /* no timeout */
31 TRUE); /* alertable wait for alarm APCs */
34 DWORD error = GetLastError();
35 if (error != WAIT_IO_COMPLETION) {
36 RTE_LOG_WIN32_ERR("GetQueuedCompletionStatusEx()");
37 RTE_LOG(ERR, EAL, "Failed waiting for interrupts\n");
41 /* No I/O events, all work is done in completed APCs. */
45 for (i = 0; i < event_count; i++)
46 eal_intr_process(&events[i]);
49 CloseHandle(intr_iocp);
55 rte_eal_intr_init(void)
59 intr_iocp = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1);
60 if (intr_iocp == NULL) {
61 RTE_LOG_WIN32_ERR("CreateIoCompletionPort()");
62 RTE_LOG(ERR, EAL, "Cannot create interrupt IOCP\n");
66 ret = rte_ctrl_thread_create(&intr_thread, "eal-intr-thread", NULL,
67 eal_intr_thread_main, NULL);
70 RTE_LOG(ERR, EAL, "Cannot create interrupt thread\n");
77 rte_thread_is_intr(void)
79 return pthread_equal(intr_thread, pthread_self());
83 rte_intr_rx_ctl(__rte_unused struct rte_intr_handle *intr_handle,
84 __rte_unused int epfd, __rte_unused int op,
85 __rte_unused unsigned int vec, __rte_unused void *data)
91 eal_intr_thread_schedule(void (*func)(void *arg), void *arg)
95 handle = OpenThread(THREAD_ALL_ACCESS, FALSE, intr_thread);
97 RTE_LOG_WIN32_ERR("OpenThread(%llu)", intr_thread);
101 if (!QueueUserAPC((PAPCFUNC)(ULONG_PTR)func, handle, (ULONG_PTR)arg)) {
102 RTE_LOG_WIN32_ERR("QueueUserAPC()");