Ensō 0.4.6
Software API reference
Loading...
Searching...
No Matches
consts.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022, Carnegie Mellon University
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted (subject to the limitations in the disclaimer
6 * below) provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * * Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY
20 * THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
21 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
22 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
41#ifndef SOFTWARE_INCLUDE_ENSO_CONSTS_H_
42#define SOFTWARE_INCLUDE_ENSO_CONSTS_H_
43
44#include <cstdint>
45#include <string>
46
47namespace enso {
48
49// These determine the maximum number of notification buffers and enso pipes,
50// these macros also exist in hardware and **must be kept in sync**. Update the
51// variables with the same name on `hardware/src/constants.sv`,
52// `software/kernel/linux/intel_fpga_pcie_setup.h`, and
53// `scripts/hwtest/my_stats.tcl`.
54#define MAX_NB_APPS 1024
55#define MAX_NB_FLOWS 8192
56
57constexpr uint32_t kMaxNbApps = MAX_NB_APPS;
58constexpr uint32_t kMaxNbFlows = MAX_NB_FLOWS;
59
60constexpr uint32_t kMaxTransferLen = 131072;
61
62// Maximum number of tails to process at once.
63constexpr uint32_t kBatchSize = 64;
64
65#ifndef NOTIFICATION_BUF_SIZE
66// This should be the max buffer supported by the hardware, we may override this
67// value when compiling. It is defined in number of flits (64 bytes).
68#define NOTIFICATION_BUF_SIZE 16384
69#endif
70constexpr uint32_t kNotificationBufSize = NOTIFICATION_BUF_SIZE;
71
72#ifndef ENSO_PIPE_SIZE
73// This should be the max buffer supported by the hardware, we may override this
74// value when compiling. It is defined in number of flits (64 bytes).
75#define ENSO_PIPE_SIZE 32768
76#endif
77constexpr uint32_t kEnsoPipeSize = ENSO_PIPE_SIZE;
78
79constexpr uint32_t kMaxPendingTxRequests = kNotificationBufSize - 1;
80
81// Using 2MB huge pages (size in bytes).
82constexpr uint32_t kBufPageSize = 1UL << 21;
83
84// Huge page paths.
85static constexpr std::string_view kHugePageDefaultPrefix = "/mnt/huge/enso";
86static constexpr std::string_view kHugePageRxPipePathPrefix = "_rx_pipe:";
87static constexpr std::string_view kHugePagePathPrefix = "_tx_pipe:";
88static constexpr std::string_view kHugePageNotifBufPathPrefix = "_notif_buf:";
89static constexpr std::string_view kHugePageQueuePathPrefix = "_queue:";
90
91// We need this to allow the same huge page to be mapped to adjacent memory
92// regions.
93// TODO(sadok): support other buffer sizes. It may be possible to support
94// other buffer sizes by overlaying regular pages on top of the huge pages.
95// We might use those only for requests that overlap to avoid adding too
96// many entries to the TLB.
97static_assert(ENSO_PIPE_SIZE * 64 == kBufPageSize, "Unsupported buffer size");
98
103constexpr uint32_t kAlignedDscBufPairSize =
104 ((kNotificationBufSize * 64 * 2 - 1) / kBufPageSize + 1) * kBufPageSize;
105
112constexpr uint32_t kNsPerTimestampCycle = 5;
113
118constexpr uint8_t kDefaultRttOffset = 18;
119
126constexpr uint32_t kMaxHardwareFlitRate = 200e6;
127
128constexpr uint32_t kMemorySpacePerQueue = 1 << 12;
129
130constexpr uint32_t kCacheLineSize = 64; // bytes.
131
132// Software backend definitions.
133
134// IPC queue names for software backend.
135static constexpr std::string_view kIpcQueueToAppName = "enso_ipc_queue_to_app";
136static constexpr std::string_view kIpcQueueFromAppName =
137 "enso_ipc_queue_from_app";
138
139enum class NotifType : uint8_t {
140 kWrite = 0,
141 kRead = 1,
142 kTranslAddr = 2, // Used to translate physical address to virtual address in
143 // the software backend address space.
144 kAllocatePipe = 3,
145 kAllocateNotifBuf = 4,
146 kGetNbFallbackQueues = 5,
147 kSetRrStatus = 6,
148 kGetRrStatus = 7,
149 kFreeNotifBuf = 8,
150 kFreePipe = 9
151};
152
154 NotifType type;
155 uint64_t address;
156 uint64_t value;
157};
158
160 NotifType type;
161 uint64_t nb_fallback_queues;
162 uint64_t result;
163};
164
166 NotifType type;
167 uint64_t round_robin;
168 uint64_t result;
169};
170
172 NotifType type;
173 uint64_t notif_buf_id;
174 uint64_t result;
175};
176
178 NotifType type;
179 uint64_t fallback;
180 uint64_t pipe_id;
181};
182
184 NotifType type;
185 uint64_t pipe_id;
186 uint64_t result;
187};
188
190 NotifType type;
191 uint64_t data[2];
192};
193
194} // namespace enso
195
196#endif // SOFTWARE_INCLUDE_ENSO_CONSTS_H_
constexpr uint32_t kMaxHardwareFlitRate
Maximum number of flits (64 byte chunks) that the hardware can send per second.
Definition: consts.h:126
constexpr uint32_t kNsPerTimestampCycle
The clock period of the timestamp module in nanoseconds.
Definition: consts.h:112
constexpr uint8_t kDefaultRttOffset
Default timestamp offset of the RTT when timestamp is enabled (in bytes). Uses bytes 4–7 of IPv4 head...
Definition: consts.h:118
constexpr uint32_t kAlignedDscBufPairSize
Definition: consts.h:103