Ensō 0.4.6
Software API reference
Loading...
Searching...
No Matches
pcie.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
40#ifndef SOFTWARE_SRC_PCIE_H_
41#define SOFTWARE_SRC_PCIE_H_
42
43#include <endian.h>
44#include <enso/helpers.h>
45#include <enso/internals.h>
46#include <netinet/ether.h>
47#include <netinet/ip.h>
48
49#include <string>
50
51namespace enso {
52
54 struct NotificationBufPair* notification_buf_pair;
55 struct RxEnsoPipeInternal enso_pipe;
56};
57
68int notification_buf_init(uint32_t bdf, int32_t bar,
69 struct NotificationBufPair* notification_buf_pair,
70 const std::string& huge_page_prefix);
71
81int enso_pipe_init(struct RxEnsoPipeInternal* enso_pipe,
82 struct NotificationBufPair* notification_buf_pair,
83 bool fallback);
84
90int dma_init(struct NotificationBufPair* notification_buf_pair,
91 struct RxEnsoPipeInternal* enso_pipe, uint32_t bdf, int32_t bar,
92 const std::string& huge_page_prefix, bool fallback);
93
101uint16_t get_new_tails(struct NotificationBufPair* notification_buf_pair);
102
113 struct RxEnsoPipeInternal* enso_pipe,
114 struct NotificationBufPair* notification_buf_pair, void** buf);
115
128 struct RxEnsoPipeInternal* enso_pipe,
129 struct NotificationBufPair* notification_buf_pair, void** buf);
130
139 struct NotificationBufPair* notification_buf_pair);
140
150uint32_t get_next_batch(struct NotificationBufPair* notification_buf_pair,
151 struct SocketInternal* socket_entries,
152 int* enso_pipe_id, void** buf);
153
162void advance_pipe(struct RxEnsoPipeInternal* enso_pipe, size_t len);
163
170void fully_advance_pipe(struct RxEnsoPipeInternal* enso_pipe);
171
177void prefetch_pipe(struct RxEnsoPipeInternal* enso_pipe);
178
197uint32_t send_to_queue(struct NotificationBufPair* notification_buf_pair,
198 uint64_t phys_addr, uint32_t len);
199
216 struct NotificationBufPair* notification_buf_pair);
217
223void update_tx_head(struct NotificationBufPair* notification_buf_pair);
224
235int send_config(struct NotificationBufPair* notification_buf_pair,
236 struct TxNotification* config_notification);
237
245int get_nb_fallback_queues(struct NotificationBufPair* notification_buf_pair);
246
255int set_round_robin_status(struct NotificationBufPair* notification_buf_pair,
256 bool round_robin);
257
266int get_round_robin_status(struct NotificationBufPair* notification_buf_pair);
267
277 struct NotificationBufPair* notification_buf_pair, void* virt_addr);
278
284void notification_buf_free(struct NotificationBufPair* notification_buf_pair);
285
293void enso_pipe_free(struct NotificationBufPair* notification_buf_pair,
294 struct RxEnsoPipeInternal* enso_pipe,
295 enso_pipe_id_t enso_pipe_id);
296
302int dma_finish(struct SocketInternal* socket_entry);
303
309uint32_t get_enso_pipe_id_from_socket(struct SocketInternal* socket_entry);
310
316void print_stats(struct SocketInternal* socket_entry, bool print_global);
317
318} // namespace enso
319
320#endif // SOFTWARE_SRC_PCIE_H_
Miscellaneous helper functions.
Definitions that are internal to Enso. They should not be exposed to applications.
int notification_buf_init(uint32_t bdf, int32_t bar, struct NotificationBufPair *notification_buf_pair, const std::string &huge_page_prefix)
Initializes the notification buffer pair.
Definition: pcie.cpp:75
void prefetch_pipe(struct RxEnsoPipeInternal *enso_pipe)
Prefetches a given Enso Pipe.
Definition: pcie.cpp:460
void update_tx_head(struct NotificationBufPair *notification_buf_pair)
Updates the tx head and the number of TX completions.
Definition: pcie.cpp:530
uint16_t get_new_tails(struct NotificationBufPair *notification_buf_pair)
Gets latest tails for the pipes associated with the given notification buffer.
Definition: pcie.cpp:353
void print_stats(struct SocketInternal *socket_entry, bool print_global)
Prints statistics for a given socket.
Definition: pcie.cpp:711
void fully_advance_pipe(struct RxEnsoPipeInternal *enso_pipe)
Frees all the received bytes in the buffer associated with the socket_entry socket.
Definition: pcie.cpp:455
uint32_t get_next_batch(struct NotificationBufPair *notification_buf_pair, struct SocketInternal *socket_entries, int *enso_pipe_id, void **buf)
Get next batch of data from the next available Enso Pipe.
Definition: pcie.cpp:429
uint32_t get_next_batch_from_queue(struct RxEnsoPipeInternal *enso_pipe, struct NotificationBufPair *notification_buf_pair, void **buf)
Gets the next batch of data from the given Enso Pipe.
Definition: pcie.cpp:385
int set_round_robin_status(struct NotificationBufPair *notification_buf_pair, bool round_robin)
Sets the round robin status for the device.
Definition: pcie.cpp:614
int32_t get_next_enso_pipe_id(struct NotificationBufPair *notification_buf_pair)
Get next Enso Pipe with pending data.
Definition: pcie.cpp:423
uint64_t get_dev_addr_from_virt_addr(struct NotificationBufPair *notification_buf_pair, void *virt_addr)
Converts an address in the application's virtual address space to an address that can be used by the ...
Definition: pcie.cpp:627
void notification_buf_free(struct NotificationBufPair *notification_buf_pair)
Frees the notification buffer pair.
Definition: pcie.cpp:635
int send_config(struct NotificationBufPair *notification_buf_pair, struct TxNotification *config_notification)
Sends configuration to the NIC.
Definition: pcie.cpp:569
uint32_t peek_next_batch_from_queue(struct RxEnsoPipeInternal *enso_pipe, struct NotificationBufPair *notification_buf_pair, void **buf)
Gets the next batch of data from the given Enso Pipe without consuming it. So the next call to get_ne...
Definition: pcie.cpp:391
uint32_t send_to_queue(struct NotificationBufPair *notification_buf_pair, uint64_t phys_addr, uint32_t len)
Sends data through a given queue.
Definition: pcie.cpp:515
uint32_t get_unreported_completions(struct NotificationBufPair *notification_buf_pair)
Returns the number of transmission requests that were completed since the last call to this function.
Definition: pcie.cpp:520
int get_nb_fallback_queues(struct NotificationBufPair *notification_buf_pair)
Get number of fallback queues currently in use.
Definition: pcie.cpp:608
int dma_init(struct NotificationBufPair *notification_buf_pair, struct RxEnsoPipeInternal *enso_pipe, uint32_t bdf, int32_t bar, const std::string &huge_page_prefix, bool fallback)
Initializes an enso pipe and the notification buffer if needed.
Definition: pcie.cpp:285
int get_round_robin_status(struct NotificationBufPair *notification_buf_pair)
Gets the round robin status for the device.
Definition: pcie.cpp:621
void advance_pipe(struct RxEnsoPipeInternal *enso_pipe, size_t len)
Frees the next len bytes in the buffer associated with the socket_entry socket. If len is greater tha...
Definition: pcie.cpp:446
void enso_pipe_free(struct NotificationBufPair *notification_buf_pair, struct RxEnsoPipeInternal *enso_pipe, enso_pipe_id_t enso_pipe_id)
Frees the Enso Pipe.
Definition: pcie.cpp:661
int dma_finish(struct SocketInternal *socket_entry)
Frees the notification buffer and all pipes.
Definition: pcie.cpp:684
int enso_pipe_init(struct RxEnsoPipeInternal *enso_pipe, struct NotificationBufPair *notification_buf_pair, bool fallback)
Initializes an Enso Pipe.
Definition: pcie.cpp:214
uint32_t get_enso_pipe_id_from_socket(struct SocketInternal *socket_entry)
Gets the Enso Pipe ID associated with a given socket.
Definition: pcie.cpp:707