Ensō 0.4.5
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
117constexpr uint32_t kPacketRttOffset = 18;
118
125constexpr uint32_t kMaxHardwareFlitRate = 200e6;
126
127constexpr uint32_t kMemorySpacePerQueue = 1 << 12;
128
129constexpr uint32_t kCacheLineSize = 64; // bytes.
130
131// Software backend definitions.
132
133// IPC queue names for software backend.
134static constexpr std::string_view kIpcQueueToAppName = "enso_ipc_queue_to_app";
135static constexpr std::string_view kIpcQueueFromAppName =
136 "enso_ipc_queue_from_app";
137
138enum class NotifType : uint8_t {
139 kWrite = 0,
140 kRead = 1,
141 kTranslAddr = 2, // Used to translate physical address to virtual address in
142 // the software backend address space.
143 kAllocatePipe = 3,
144 kAllocateNotifBuf = 4,
145 kGetNbFallbackQueues = 5,
146 kSetRrStatus = 6,
147 kGetRrStatus = 7,
148 kFreeNotifBuf = 8,
149 kFreePipe = 9
150};
151
153 NotifType type;
154 uint64_t address;
155 uint64_t value;
156};
157
159 NotifType type;
160 uint64_t nb_fallback_queues;
161 uint64_t result;
162};
163
165 NotifType type;
166 uint64_t round_robin;
167 uint64_t result;
168};
169
171 NotifType type;
172 uint64_t notif_buf_id;
173 uint64_t result;
174};
175
177 NotifType type;
178 uint64_t fallback;
179 uint64_t pipe_id;
180};
181
183 NotifType type;
184 uint64_t pipe_id;
185 uint64_t result;
186};
187
189 NotifType type;
190 uint64_t data[2];
191};
192
193} // namespace enso
194
195#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:125
constexpr uint32_t kPacketRttOffset
Offset of the RTT when timestamp is enabled (in bytes).
Definition: consts.h:117
constexpr uint32_t kNsPerTimestampCycle
The clock period of the timestamp module in nanoseconds.
Definition: consts.h:112
constexpr uint32_t kAlignedDscBufPairSize
Definition: consts.h:103