8#ifndef DPDKLIBS_INCLUDE_DPDKLIBS_RTEIFACESETUP_HPP_
9#define DPDKLIBS_INCLUDE_DPDKLIBS_RTEIFACESETUP_HPP_
14#include <rte_ethdev.h>
23#define RX_RING_SIZE 1024
24#define TX_RING_SIZE 1024
27#define MBUF_CACHE_SIZE 250
29#define PG_JUMBO_FRAME_LEN (9600 + RTE_ETHER_CRC_LEN + RTE_ETHER_HDR_LEN)
30#ifndef RTE_JUMBO_ETHER_MTU
31#define RTE_JUMBO_ETHER_MTU (PG_JUMBO_FRAME_LEN - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN)
39 .max_lro_pkt_size = 9000,
41 .offloads = (RTE_ETH_RX_OFFLOAD_TIMESTAMP
42 | RTE_ETH_RX_OFFLOAD_IPV4_CKSUM
43 | RTE_ETH_RX_OFFLOAD_UDP_CKSUM),
47 .offloads = (RTE_ETH_TX_OFFLOAD_MULTI_SEGS),
54 unsigned nb_ifaces = rte_eth_dev_count_avail();
55 TLOG() <<
"Available interfaces: " << nb_ifaces;
64 iface_conf.rxmode.mq_mode = RTE_ETH_MQ_RX_RSS;
66 iface_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
69 iface_conf.rxmode.mq_mode = RTE_ETH_MQ_RX_NONE;
78 retval = rte_eth_promiscuous_get(iface);
79 TLOG() <<
"Before modification attempt, promiscuous mode is: " << retval;
81 retval = rte_eth_promiscuous_enable(iface);
83 retval = rte_eth_promiscuous_disable(iface);
86 TLOG() <<
"Couldn't modify promiscuous mode of iface[" << iface <<
"]! Error code: " << retval;
88 retval = rte_eth_promiscuous_get(iface);
89 TLOG() <<
"New promiscuous mode of iface[" << iface <<
"] is: " << retval;
97 return rte_eth_dev_is_valid_port(iface);
102 ostrs << std::setfill(
fill) << std::setw(digits) << std::hex << value << std::dec << separator;
110 struct rte_ether_addr mac_addr;
111 retval = rte_eth_macaddr_get(iface, &mac_addr);
113 TLOG() <<
"Failed to get MAC address of interface! Err id: " << retval;
114 return std::string(
"");
116 std::ostringstream ostrs;
123 std::string mac_str = ostrs.str();
124 mac_str.erase(std::remove(mac_str.begin(), mac_str.end(),
' '), mac_str.end());
132 std::string iface_pci_addr_str;
134 struct rte_eth_dev_info dev_info;
136 retval = rte_eth_dev_info_get(iface, &dev_info);
138 TLOG() <<
"Error during getting device (iface " << iface <<
") retval: " << retval;
139 }
else if (dev_info.device) {
140 auto dev_name = rte_dev_name(dev_info.device);
141 iface_pci_addr_str = dev_name;
147 return iface_pci_addr_str;
154 struct rte_eth_dev_info dev_info;
157 if (!rte_eth_dev_is_valid_port(iface)) {
158 TLOG() <<
"Specified interface " << iface <<
" is not valid in EAL!";
163 retval = rte_eth_dev_reset(iface);
165 TLOG() <<
"Error during resetting device (iface " << iface <<
") retval: " << retval;
static void fill(const ResourceSet &rs, std::vector< const ResourceSetOR * > &rs_or, std::vector< const ResourceSetAND * > &rs_and, TestCircularDependency &cd_fuse)
std::string get_iface_mac_str(uint16_t iface)
void hex_digits_to_stream(std::ostringstream &ostrs, int value, char separator=' ', char fill='0', int digits=2)
int iface_promiscuous_mode(std::uint16_t iface, bool mode=false)
bool iface_valid(uint16_t iface)
int get_num_available_ifaces()
std::string get_iface_pci_str(uint16_t iface)
static const struct rte_eth_conf iface_conf_default
static volatile uint8_t dpdk_quit_signal
int iface_reset(uint16_t iface)
void iface_conf_rss_mode(struct rte_eth_conf &iface_conf, bool mode=false, bool offload=false)