DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::dpdklibs::sender::DpdkTxBackend Struct Reference

#include <DpdkTxBackend.hpp>

Public Member Functions

void * alloc ()
std::uint8_t * prepare (void *buf, std::size_t bytes)
bool transmit (void *buf)
void free (void *buf)

Public Attributes

rte_mempool * pool = nullptr
std::uint16_t port = 0
std::uint16_t queue = 0

Detailed Description

Definition at line 23 of file DpdkTxBackend.hpp.

Member Function Documentation

◆ alloc()

void * dunedaq::dpdklibs::sender::DpdkTxBackend::alloc ( )

Definition at line 22 of file DpdkTxBackend.cpp.

23{
24 return rte_pktmbuf_alloc(pool);
25}

◆ free()

void dunedaq::dpdklibs::sender::DpdkTxBackend::free ( void * buf)

Definition at line 50 of file DpdkTxBackend.cpp.

51{
52 rte_pktmbuf_free(static_cast<rte_mbuf*>(buf));
53}

◆ prepare()

std::uint8_t * dunedaq::dpdklibs::sender::DpdkTxBackend::prepare ( void * buf,
std::size_t bytes )

Definition at line 28 of file DpdkTxBackend.cpp.

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}

◆ transmit()

bool dunedaq::dpdklibs::sender::DpdkTxBackend::transmit ( void * buf)

Definition at line 42 of file DpdkTxBackend.cpp.

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}

Member Data Documentation

◆ pool

rte_mempool* dunedaq::dpdklibs::sender::DpdkTxBackend::pool = nullptr

Definition at line 25 of file DpdkTxBackend.hpp.

◆ port

std::uint16_t dunedaq::dpdklibs::sender::DpdkTxBackend::port = 0

Definition at line 26 of file DpdkTxBackend.hpp.

◆ queue

std::uint16_t dunedaq::dpdklibs::sender::DpdkTxBackend::queue = 0

Definition at line 27 of file DpdkTxBackend.hpp.


The documentation for this struct was generated from the following files: