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;
13 static HANDLE intr_thread_handle;
16 eal_intr_process(const OVERLAPPED_ENTRY *event)
22 eal_intr_thread_handle_init(void)
24 DWORD thread_id = GetCurrentThreadId();
26 intr_thread_handle = OpenThread(THREAD_ALL_ACCESS, FALSE, thread_id);
27 if (intr_thread_handle == NULL) {
28 RTE_LOG_WIN32_ERR("OpenThread(%lu)", thread_id);
35 eal_intr_thread_main(LPVOID arg __rte_unused)
37 if (eal_intr_thread_handle_init() < 0) {
38 RTE_LOG(ERR, EAL, "Cannot open interrupt thread handle\n");
43 OVERLAPPED_ENTRY events[16];
47 result = GetQueuedCompletionStatusEx(
48 intr_iocp, events, RTE_DIM(events), &event_count,
49 INFINITE, /* no timeout */
50 TRUE); /* alertable wait for alarm APCs */
53 DWORD error = GetLastError();
54 if (error != WAIT_IO_COMPLETION) {
55 RTE_LOG_WIN32_ERR("GetQueuedCompletionStatusEx()");
56 RTE_LOG(ERR, EAL, "Failed waiting for interrupts\n");
60 /* No I/O events, all work is done in completed APCs. */
64 for (i = 0; i < event_count; i++)
65 eal_intr_process(&events[i]);
68 CloseHandle(intr_thread_handle);
69 intr_thread_handle = NULL;
74 CloseHandle(intr_iocp);
81 rte_eal_intr_init(void)
85 intr_iocp = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1);
86 if (intr_iocp == NULL) {
87 RTE_LOG_WIN32_ERR("CreateIoCompletionPort()");
88 RTE_LOG(ERR, EAL, "Cannot create interrupt IOCP\n");
92 ret = rte_ctrl_thread_create(&intr_thread, "eal-intr-thread", NULL,
93 eal_intr_thread_main, NULL);
96 RTE_LOG(ERR, EAL, "Cannot create interrupt thread\n");
103 rte_thread_is_intr(void)
105 return pthread_equal(intr_thread, pthread_self());
109 rte_intr_rx_ctl(__rte_unused struct rte_intr_handle *intr_handle,
110 __rte_unused int epfd, __rte_unused int op,
111 __rte_unused unsigned int vec, __rte_unused void *data)
117 eal_intr_thread_schedule(void (*func)(void *arg), void *arg)
119 if (!QueueUserAPC((PAPCFUNC)(ULONG_PTR)func,
120 intr_thread_handle, (ULONG_PTR)arg)) {
121 RTE_LOG_WIN32_ERR("QueueUserAPC()");
129 rte_intr_callback_register(
130 __rte_unused const struct rte_intr_handle *intr_handle,
131 __rte_unused rte_intr_callback_fn cb, __rte_unused void *cb_arg)
137 rte_intr_callback_unregister_pending(
138 __rte_unused const struct rte_intr_handle *intr_handle,
139 __rte_unused rte_intr_callback_fn cb_fn, __rte_unused void *cb_arg,
140 __rte_unused rte_intr_unregister_callback_fn ucb_fn)
146 rte_intr_callback_unregister(
147 __rte_unused const struct rte_intr_handle *intr_handle,
148 __rte_unused rte_intr_callback_fn cb_fn, __rte_unused void *cb_arg)
154 rte_intr_callback_unregister_sync(
155 __rte_unused const struct rte_intr_handle *intr_handle,
156 __rte_unused rte_intr_callback_fn cb_fn, __rte_unused void *cb_arg)
162 rte_intr_enable(__rte_unused const struct rte_intr_handle *intr_handle)
168 rte_intr_ack(__rte_unused const struct rte_intr_handle *intr_handle)
174 rte_intr_disable(__rte_unused const struct rte_intr_handle *intr_handle)
180 rte_intr_efd_enable(struct rte_intr_handle *intr_handle, uint32_t nb_efd)
182 RTE_SET_USED(intr_handle);
183 RTE_SET_USED(nb_efd);
189 rte_intr_efd_disable(struct rte_intr_handle *intr_handle)
191 RTE_SET_USED(intr_handle);
195 rte_intr_dp_is_en(struct rte_intr_handle *intr_handle)
197 RTE_SET_USED(intr_handle);
203 rte_intr_allow_others(struct rte_intr_handle *intr_handle)
205 RTE_SET_USED(intr_handle);
211 rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)
213 RTE_SET_USED(intr_handle);
219 rte_epoll_wait(int epfd, struct rte_epoll_event *events,
220 int maxevents, int timeout)
223 RTE_SET_USED(events);
224 RTE_SET_USED(maxevents);
225 RTE_SET_USED(timeout);
231 rte_epoll_wait_interruptible(int epfd, struct rte_epoll_event *events,
232 int maxevents, int timeout)
235 RTE_SET_USED(events);
236 RTE_SET_USED(maxevents);
237 RTE_SET_USED(timeout);
243 rte_epoll_ctl(int epfd, int op, int fd, struct rte_epoll_event *event)
254 rte_intr_tls_epfd(void)
260 rte_intr_free_epoll_fd(struct rte_intr_handle *intr_handle)
262 RTE_SET_USED(intr_handle);