Ensō 0.4.6
Software API reference
Loading...
Searching...
No Matches
internals.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// TODO(sadok): Do not expose this header.
42#ifndef SOFTWARE_INCLUDE_ENSO_INTERNALS_H_
43#define SOFTWARE_INCLUDE_ENSO_INTERNALS_H_
44
45#include <stdint.h>
46
47#include <string>
48
49namespace enso {
50
51#if MAX_NB_FLOWS < 65536
52using enso_pipe_id_t = uint16_t;
53#else
54using enso_pipe_id_t = uint32_t;
55#endif
56
57struct QueueRegs {
58 uint32_t rx_tail;
59 uint32_t rx_head;
60 uint32_t rx_mem_low;
61 uint32_t rx_mem_high;
62 uint32_t tx_tail;
63 uint32_t tx_head;
64 uint32_t tx_mem_low;
65 uint32_t tx_mem_high;
66 uint32_t padding[8];
67};
68
69struct __attribute__((__packed__)) RxNotification {
70 uint64_t signal;
71 uint64_t queue_id;
72 uint64_t tail;
73 uint64_t pad[5];
74};
75
76struct __attribute__((__packed__)) TxNotification {
77 uint64_t signal;
78 uint64_t phys_addr;
79 uint64_t length; // In bytes (up to 1MB).
80 uint64_t pad[5];
81};
82
84 // First cache line:
85 struct RxNotification* rx_buf;
86 enso_pipe_id_t* next_rx_pipe_ids; // Next pipe ids to consume from rx_buf.
87 struct TxNotification* tx_buf;
88 uint32_t* rx_head_ptr;
89 uint32_t* tx_tail_ptr;
90 uint32_t rx_head;
91 uint32_t tx_head;
92 uint32_t tx_tail;
93 uint16_t next_rx_ids_head;
94 uint16_t next_rx_ids_tail;
95 uint32_t nb_unreported_completions;
96 uint32_t id;
97
98 // Second cache line:
99 struct QueueRegs* regs;
100 uint64_t tx_full_cnt;
101 uint32_t ref_cnt;
102
103 uint8_t* wrap_tracker;
104 uint32_t* pending_rx_pipe_tails;
105
106 void* fpga_dev; // Avoid exposing `DevBackend` externally.
107 void* uio_mmap_bar2_addr; // UIO mmap address for BAR 2.
108 std::string huge_page_prefix;
109};
110
112 uint32_t* buf;
113 uint64_t buf_phys_addr;
114 struct QueueRegs* regs;
115 uint32_t* buf_head_ptr;
116 uint32_t rx_head;
117 uint32_t rx_tail;
118 uint64_t phys_buf_offset; // Use to convert between phys and virt address.
119 enso_pipe_id_t id;
120 std::string huge_page_prefix;
121};
122
123} // namespace enso
124
125#endif // SOFTWARE_INCLUDE_ENSO_INTERNALS_H_