DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
dpdklibs
src
sender
DpdkTxBackend.cpp
Go to the documentation of this file.
1
8
#include "
dpdklibs/sender/DpdkTxBackend.hpp
"
9
10
#include <rte_ethdev.h>
11
#include <rte_ether.h>
12
#include <rte_ip.h>
13
#include <rte_mbuf.h>
14
#include <rte_udp.h>
15
16
#include <cstddef>
17
#include <cstdint>
18
19
namespace
dunedaq::dpdklibs::sender
{
20
21
void
*
22
DpdkTxBackend::alloc
()
23
{
24
return
rte_pktmbuf_alloc(
pool
);
25
}
26
27
std::uint8_t*
// NOLINT(build/unsigned)
28
DpdkTxBackend::prepare
(
void
* buf, std::size_t bytes)
29
{
30
auto
* mbuf =
static_cast<
rte_mbuf*
>
(buf);
31
char
* dst = rte_pktmbuf_append(mbuf,
static_cast<
std::uint16_t
>
(bytes));
// NOLINT(build/unsigned)
32
if
(dst ==
nullptr
) {
33
return
nullptr
;
34
}
35
mbuf->l2_len =
static_cast<
std::uint16_t
>
(
sizeof
(rte_ether_hdr));
// NOLINT(build/unsigned)
36
mbuf->l3_len =
static_cast<
std::uint16_t
>
(
sizeof
(rte_ipv4_hdr));
// NOLINT(build/unsigned)
37
mbuf->l4_len =
static_cast<
std::uint16_t
>
(
sizeof
(rte_udp_hdr));
// NOLINT(build/unsigned)
38
return
reinterpret_cast<
std::uint8_t*
>
(dst);
// NOLINT
39
}
40
41
bool
42
DpdkTxBackend::transmit
(
void
* buf)
43
{
44
auto
* mbuf =
static_cast<
rte_mbuf*
>
(buf);
45
rte_mbuf* one_packet = mbuf;
46
return
rte_eth_tx_burst(
port
,
queue
, &one_packet, 1) == 1;
47
}
48
49
void
50
DpdkTxBackend::free
(
void
* buf)
51
{
52
rte_pktmbuf_free(
static_cast<
rte_mbuf*
>
(buf));
53
}
54
55
}
// namespace dunedaq::dpdklibs::sender
DpdkTxBackend.hpp
dunedaq::dpdklibs::sender
Definition
CallbackGate.hpp:35
dunedaq::dpdklibs::sender::DpdkTxBackend::free
void free(void *buf)
Definition
DpdkTxBackend.cpp:50
dunedaq::dpdklibs::sender::DpdkTxBackend::alloc
void * alloc()
Definition
DpdkTxBackend.cpp:22
dunedaq::dpdklibs::sender::DpdkTxBackend::prepare
std::uint8_t * prepare(void *buf, std::size_t bytes)
Definition
DpdkTxBackend.cpp:28
dunedaq::dpdklibs::sender::DpdkTxBackend::queue
std::uint16_t queue
Definition
DpdkTxBackend.hpp:27
dunedaq::dpdklibs::sender::DpdkTxBackend::port
std::uint16_t port
Definition
DpdkTxBackend.hpp:26
dunedaq::dpdklibs::sender::DpdkTxBackend::transmit
bool transmit(void *buf)
Definition
DpdkTxBackend.cpp:42
dunedaq::dpdklibs::sender::DpdkTxBackend::pool
rte_mempool * pool
Definition
DpdkTxBackend.hpp:25
Generated on
for DUNE-DAQ by
1.18.0