1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2020 Dmitry Kozlyuk
5 #ifndef _EAL_WINDOWS_H_
6 #define _EAL_WINDOWS_H_
9 * @file Facilities private to Windows EAL
12 #include <rte_errno.h>
13 #include <rte_windows.h>
16 * Log current function as not implemented and set rte_errno.
18 #define EAL_LOG_NOT_IMPLEMENTED() \
20 RTE_LOG(DEBUG, EAL, "%s() is not implemented\n", __func__); \
21 rte_errno = ENOTSUP; \
25 * Log current function as a stub.
27 #define EAL_LOG_STUB() \
28 RTE_LOG(DEBUG, EAL, "Windows: %s() is a stub\n", __func__)
31 * Create a map of processors and cores on the system.
34 * 0 on success, (-1) on failure and rte_errno is set.
36 int eal_create_cpu_map(void);
42 * The location to store the thread id if successful.
44 * The lcore_id of this worker thread.
46 * 0 for success, -1 if the thread is not created.
48 int eal_thread_create(pthread_t *thread, unsigned int lcore_id);
51 * Get system NUMA node number for a socket ID.
54 * Valid EAL socket ID.
56 * NUMA node number to use with Win32 API.
58 unsigned int eal_socket_numa_node(unsigned int socket_id);
61 * Get pointer to the group affinity for the cpu.
64 * Index of the cpu, as it comes from rte_cpuset_t.
66 * Pointer to the group affinity for the cpu.
68 PGROUP_AFFINITY eal_get_cpu_affinity(size_t cpu_index);
71 * Schedule code for execution in the interrupt thread.
76 * Argument to the called function.
78 * 0 on success, negative error code on failure.
80 int eal_intr_thread_schedule(void (*func)(void *arg), void *arg);
83 * Request interrupt thread to stop and wait its termination.
85 void eal_intr_thread_cancel(void);
88 * Open virt2phys driver interface device.
90 * @return 0 on success, (-1) on failure.
92 int eal_mem_virt2iova_init(void);
95 * Cleanup resources used for virtual to physical address translation.
97 void eal_mem_virt2iova_cleanup(void);
100 * Locate Win32 memory management routines in system libraries.
102 * @return 0 on success, (-1) on failure.
104 int eal_mem_win32api_init(void);
107 * Allocate new memory in hugepages on the specified NUMA node.
110 * Number of bytes to allocate. Must be a multiple of huge page size.
114 * Address of the memory allocated on success or NULL on failure.
116 void *eal_mem_alloc_socket(size_t size, int socket_id);
119 * Commit memory previously reserved with eal_mem_reserve()
120 * or decommitted from hugepages by eal_mem_decommit().
122 * @param requested_addr
123 * Address within a reserved region. Must not be NULL.
125 * Number of bytes to commit. Must be a multiple of page size.
127 * Socket ID to allocate on. Can be SOCKET_ID_ANY.
129 * On success, address of the committed memory, that is, requested_addr.
130 * On failure, NULL and rte_errno is set.
132 void *eal_mem_commit(void *requested_addr, size_t size, int socket_id);
135 * Put allocated or committed memory back into reserved state.
138 * Address of the region to decommit.
140 * Number of bytes to decommit, must be the size of a page
141 * (hugepage or regular one).
143 * The *addr* and *size* must match location and size
144 * of a previously allocated or committed region.
147 * 0 on success, (-1) on failure.
149 int eal_mem_decommit(void *addr, size_t size);
151 #endif /* _EAL_WINDOWS_H_ */