DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::dpdklibs::ifaceutils Namespace Reference

Functions

int get_num_available_ifaces ()
void iface_conf_rss_mode (struct rte_eth_conf &iface_conf, bool mode=false, bool offload=false)
int iface_promiscuous_mode (std::uint16_t iface, bool mode=false)
bool iface_valid (uint16_t iface)
void hex_digits_to_stream (std::ostringstream &ostrs, int value, char separator=' ', char fill='0', int digits=2)
std::string get_iface_mac_str (uint16_t iface)
std::string get_iface_pci_str (uint16_t iface)
int iface_reset (uint16_t iface)

Variables

static volatile uint8_t dpdk_quit_signal
static const struct rte_eth_conf iface_conf_default

Function Documentation

◆ get_iface_mac_str()

std::string dunedaq::dpdklibs::ifaceutils::get_iface_mac_str ( uint16_t iface)
inline

Definition at line 109 of file RTEIfaceSetup.hpp.

110{
111 int retval = -1;
112 struct rte_ether_addr mac_addr;
113 retval = rte_eth_macaddr_get(iface, &mac_addr);
114 if (retval != 0) {
115 TLOG() << "Failed to get MAC address of interface! Err id: " << retval;
116 return std::string("");
117 } else {
118 std::ostringstream ostrs;
119 hex_digits_to_stream(ostrs, (int)mac_addr.addr_bytes[0], ':');
120 hex_digits_to_stream(ostrs, (int)mac_addr.addr_bytes[1], ':');
121 hex_digits_to_stream(ostrs, (int)mac_addr.addr_bytes[2], ':');
122 hex_digits_to_stream(ostrs, (int)mac_addr.addr_bytes[3], ':');
123 hex_digits_to_stream(ostrs, (int)mac_addr.addr_bytes[4], ':');
124 hex_digits_to_stream(ostrs, (int)mac_addr.addr_bytes[5]);
125 std::string mac_str = ostrs.str();
126 mac_str.erase(std::remove(mac_str.begin(), mac_str.end(), ' '), mac_str.end());
127 return mac_str;
128 }
129}
#define TLOG(...)
Definition macro.hpp:21
void hex_digits_to_stream(std::ostringstream &ostrs, int value, char separator=' ', char fill='0', int digits=2)

◆ get_iface_pci_str()

std::string dunedaq::dpdklibs::ifaceutils::get_iface_pci_str ( uint16_t iface)
inline

Definition at line 132 of file RTEIfaceSetup.hpp.

133{
134 std::string iface_pci_addr_str;
135 int retval = -1;
136 struct rte_eth_dev_info dev_info;
137 // Get interface info
138 retval = rte_eth_dev_info_get(iface, &dev_info);
139 if (retval != 0) {
140 TLOG() << "Error during getting device (iface " << iface << ") retval: " << retval;
141 } else if (dev_info.device) {
142 auto dev_name = rte_dev_name(dev_info.device);
143 iface_pci_addr_str = dev_name;
144 // TLOG() << "Dev name: " << dev_name;
145 // const auto bus = rte_dev_bus(dev_info.device);
146 // const auto bus_info = rte_dev_bus_info(dev_info.device);
147 // const auto dev_driver = rte_dev_driver(dev_info.device);
148 }
149 return iface_pci_addr_str;
150}

◆ get_num_available_ifaces()

int dunedaq::dpdklibs::ifaceutils::get_num_available_ifaces ( )
inline

Definition at line 53 of file RTEIfaceSetup.hpp.

54{
55 unsigned nb_ifaces = rte_eth_dev_count_avail();
56 TLOG() << "Available interfaces: " << nb_ifaces;
57 return nb_ifaces;
58}

◆ hex_digits_to_stream()

void dunedaq::dpdklibs::ifaceutils::hex_digits_to_stream ( std::ostringstream & ostrs,
int value,
char separator = ' ',
char fill = '0',
int digits = 2 )
inline

Definition at line 102 of file RTEIfaceSetup.hpp.

103{
104 ostrs << std::setfill(fill) << std::setw(digits) << std::hex << value << std::dec << separator;
105}

◆ iface_conf_rss_mode()

void dunedaq::dpdklibs::ifaceutils::iface_conf_rss_mode ( struct rte_eth_conf & iface_conf,
bool mode = false,
bool offload = false )
inline

Definition at line 62 of file RTEIfaceSetup.hpp.

63{
64 if (mode) {
65 iface_conf.rxmode.mq_mode = RTE_ETH_MQ_RX_RSS;
66 if (offload) {
67 iface_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
68 }
69 } else {
70 iface_conf.rxmode.mq_mode = RTE_ETH_MQ_RX_NONE;
71 }
72}

◆ iface_promiscuous_mode()

int dunedaq::dpdklibs::ifaceutils::iface_promiscuous_mode ( std::uint16_t iface,
bool mode = false )
inline

Definition at line 76 of file RTEIfaceSetup.hpp.

77{
78 int retval = -1;
79 retval = rte_eth_promiscuous_get(iface);
80 TLOG() << "Before modification attempt, promiscuous mode is: " << retval;
81 if (mode) {
82 retval = rte_eth_promiscuous_enable(iface);
83 } else {
84 retval = rte_eth_promiscuous_disable(iface);
85 }
86 if (retval != 0) {
87 TLOG() << "Couldn't modify promiscuous mode of iface[" << iface << "]! Error code: " << retval;
88 }
89 retval = rte_eth_promiscuous_get(iface);
90 TLOG() << "New promiscuous mode of iface[" << iface << "] is: " << retval;
91 return retval;
92}

◆ iface_reset()

int dunedaq::dpdklibs::ifaceutils::iface_reset ( uint16_t iface)
inline

Definition at line 153 of file RTEIfaceSetup.hpp.

154{
155 int retval = -1;
156 struct rte_eth_dev_info dev_info;
157
158 // Get interface validity
159 if (!rte_eth_dev_is_valid_port(iface)) {
160 TLOG() << "Specified interface " << iface << " is not valid in EAL!";
161 return retval;
162 }
163
164 // Carry out a reset of the interface
165 retval = rte_eth_dev_reset(iface);
166 if (retval != 0) {
167 TLOG() << "Error during resetting device (iface " << iface << ") retval: " << retval;
168 return retval;
169 }
170
171 return retval;
172}

◆ iface_valid()

bool dunedaq::dpdklibs::ifaceutils::iface_valid ( uint16_t iface)
inline

Definition at line 96 of file RTEIfaceSetup.hpp.

97{
98 return rte_eth_dev_is_valid_port(iface);
99}

Variable Documentation

◆ dpdk_quit_signal

volatile uint8_t dunedaq::dpdklibs::ifaceutils::dpdk_quit_signal
static

Definition at line 34 of file RTEIfaceSetup.hpp.

◆ iface_conf_default

const struct rte_eth_conf dunedaq::dpdklibs::ifaceutils::iface_conf_default
static
Initial value:
= {
.rxmode = {
.mtu = 9000,
.max_lro_pkt_size = 9000,
.offloads = (RTE_ETH_RX_OFFLOAD_TIMESTAMP
| RTE_ETH_RX_OFFLOAD_IPV4_CKSUM
| RTE_ETH_RX_OFFLOAD_UDP_CKSUM),
},
.txmode = {
.offloads = (RTE_ETH_TX_OFFLOAD_MULTI_SEGS),
},
}

Definition at line 36 of file RTEIfaceSetup.hpp.