Ensō 0.4.5
Software API reference
No Matches
helpers.h File Reference

Miscellaneous helper functions. More...

#include <endian.h>
#include <enso/consts.h>
#include <enso/internals.h>
#include <enso/ixy_helpers.h>
#include <immintrin.h>
#include <netinet/ether.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <pthread.h>
#include <cassert>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <thread>
#include <vector>

Go to the source code of this file.


struct  enso::stats_t


#define likely(x)   __builtin_expect((x), 1)
#define unlikely(x)   __builtin_expect((x), 0)
#define _enso_compiler_memory_barrier()
#define _enso_always_inline   __attribute__((always_inline)) inline


uint32_t enso::get_pkt_rtt (const uint8_t *pkt)
 Returns RTT, in number of cycles, for a given packet.
constexpr uint16_t enso::be_to_le_16 (const uint16_t le)
_enso_always_inline uint16_t enso::get_pkt_len (const uint8_t *addr)
_enso_always_inline uint8_t * enso::get_next_pkt (uint8_t *pkt)
uint16_t enso::get_bdf_from_pcie_addr (const std::string &pcie_addr)
void enso::print_ip (uint32_t ip)
void enso::print_pkt_ips (uint8_t *pkt)
void enso::print_pkt_header (uint8_t *pkt)
void enso::print_buf (void *buf, const uint32_t nb_cache_lines)
int enso::set_core_id (std::thread &thread, int core_id)
void enso::show_stats (const std::vector< stats_t > &thread_stats, volatile bool *keep_running)
_enso_always_inline void enso::mov64 (uint8_t *dst, const uint8_t *src)
_enso_always_inline void enso::memcpy_64_align (void *dst, const void *src, size_t n)
 Copies data from src to dst.

Detailed Description

Miscellaneous helper functions.

Hugo Sadok sadok.nosp@m.@cmu.nosp@m..edu

Definition in file helpers.h.

Macro Definition Documentation

◆ _enso_always_inline

#define _enso_always_inline   __attribute__((always_inline)) inline

Definition at line 78 of file helpers.h.

◆ _enso_compiler_memory_barrier

#define _enso_compiler_memory_barrier ( )
do { \
asm volatile("" : : : "memory"); \
} while (0)

Definition at line 73 of file helpers.h.

◆ likely

#define likely (   x)    __builtin_expect((x), 1)

Definition at line 66 of file helpers.h.

◆ unlikely

#define unlikely (   x)    __builtin_expect((x), 0)

Definition at line 70 of file helpers.h.

Function Documentation

◆ be_to_le_16()

constexpr uint16_t enso::be_to_le_16 ( const uint16_t  le)

Definition at line 103 of file helpers.h.

◆ get_bdf_from_pcie_addr()

uint16_t enso::get_bdf_from_pcie_addr ( const std::string &  pcie_addr)

Definition at line 48 of file helpers.cpp.

◆ get_next_pkt()

_enso_always_inline uint8_t * enso::get_next_pkt ( uint8_t *  pkt)

Definition at line 115 of file helpers.h.

◆ get_pkt_len()

_enso_always_inline uint16_t enso::get_pkt_len ( const uint8_t *  addr)

Definition at line 107 of file helpers.h.

◆ get_pkt_rtt()

uint32_t enso::get_pkt_rtt ( const uint8_t *  pkt)

Returns RTT, in number of cycles, for a given packet.

This assumes that the packet has been timestamped by hardware. To enable timestamping call the Device::EnableTimeStamping method.

To convert from number of cycles to ns. Do cycles * kNsPerTimestampCycle.

pktPacket to retrieve the RTT from.
Return RTT measure for the packet in number of cycles. If timestamp is not enabled on the NIC, the value returned is undefined.

Definition at line 98 of file helpers.h.

◆ memcpy_64_align()

_enso_always_inline void enso::memcpy_64_align ( void *  dst,
const void *  src,
size_t  n 

Copies data from src to dst.

dstDestination address.
srcSource address.
n64-byte aligned number of bytes to copy.

Definition at line 170 of file helpers.h.

◆ mov64()

_enso_always_inline void enso::mov64 ( uint8_t *  dst,
const uint8_t *  src 

Definition at line 137 of file helpers.h.

◆ print_buf()

void enso::print_buf ( void *  buf,
const uint32_t  nb_cache_lines 

Definition at line 64 of file helpers.cpp.

◆ print_ip()

void enso::print_ip ( uint32_t  ip)

Definition at line 79 of file helpers.cpp.

◆ print_pkt_header()

void enso::print_pkt_header ( uint8_t *  pkt)

Definition at line 97 of file helpers.cpp.

◆ print_pkt_ips()

void enso::print_pkt_ips ( uint8_t *  pkt)

Definition at line 84 of file helpers.cpp.

◆ set_core_id()

int enso::set_core_id ( std::thread &  thread,
int  core_id 

Definition at line 135 of file helpers.cpp.

◆ show_stats()

void enso::show_stats ( const std::vector< stats_t > &  thread_stats,
volatile bool *  keep_running 

Definition at line 157 of file helpers.cpp.