Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw when failing iface setup #110

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions include/dpdklibs/Issues.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* @file DPDKIssues.hpp DPDK system related ERS issues
*
* This is part of the DUNE DAQ , copyright 2020.
* Licensing/copyright details are in the COPYING file that you should have
* received with this code.
*/
#ifndef DPDKLIBS_INCLUDE_DPDKLIBS_DPDKISSUES_HPP_
#define DPDKLIBS_INCLUDE_DPDKLIBS_DPDKISSUES_HPP_

#include <ers/Issue.hpp>

#include <string>

namespace dunedaq {
ERS_DECLARE_ISSUE(dpdklibs,
FailedToSetupInterface,
"Interface [" << ifaceid << "] setup failed: " << error,
((int)ifaceid)((int)error)
);

ERS_DECLARE_ISSUE(dpdklibs,
InvalidEALPort,
"Interface [" << ifaceid << "] is not a valid port: ",
((int)ifaceid)
);


ERS_DECLARE_ISSUE(dpdklibs,
LinkOffline,
"Link offline for interface [" << ifaceid << "]",
((int)ifaceid)
);

ERS_DECLARE_ISSUE(dpdklibs,
FailedToRetrieveInterfaceInfo,
"Failed to retrieve device info for interfce [" << ifaceid << "]: " << error,
((int)ifaceid)((int)error)
);

ERS_DECLARE_ISSUE(dpdklibs,
FailedToRetrieveLinkStatus,
"Failed to retrieve link status for interfce [" << ifaceid << "]: " << error,
((int)ifaceid)((int)error)
);

ERS_DECLARE_ISSUE(dpdklibs,
FailedToResetInterface,
"Failed to reset interfce [" << ifaceid << "]: " << error,
((int)ifaceid)((int)error)
);

ERS_DECLARE_ISSUE(dpdklibs,
FailedToConfigureInterface,
"Failed to configure interface [" << ifaceid << "], stage " << stage << " : " << error,
((int)ifaceid)((std::string)stage)((int)error)
);

}

#endif /* DPDKLIBS_INCLUDE_DPDKLIBS_DPDKISSUES_HPP_ */
2 changes: 1 addition & 1 deletion plugins/NICReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ NICReceiver::NICReceiver(const std::string& name)
{
register_command("conf", &NICReceiver::do_configure);
register_command("start", &NICReceiver::do_start);
register_command("stop", &NICReceiver::do_stop);
register_command("stop_trigger_sources", &NICReceiver::do_stop);
register_command("scrap", &NICReceiver::do_scrap);
}

Expand Down
67 changes: 40 additions & 27 deletions src/EALSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <boost/program_options/parsers.hpp>

#include "dpdklibs/EALSetup.hpp"
#include "dpdklibs/Issues.hpp"

#include <rte_eal.h>
#include <rte_ethdev.h>

Expand Down Expand Up @@ -102,18 +104,18 @@ iface_init(uint16_t iface, uint16_t rx_rings, uint16_t tx_rings,
uint16_t q;
struct rte_eth_dev_info dev_info;
struct rte_eth_txconf txconf;
struct rte_eth_link link;

// Get interface validity
if (!rte_eth_dev_is_valid_port(iface)) {
TLOG() << "Specified interface " << iface << " is not valid in EAL!";
return retval;
throw InvalidEALPort(ERS_HERE, iface);
}

// Get interface info
retval = rte_eth_dev_info_get(iface, &dev_info);
if (retval != 0) {
if ((retval = rte_eth_dev_info_get(iface, &dev_info)) != 0) {
TLOG() << "Error during getting device (iface " << iface << ") retval: " << retval;
return retval;
throw FailedToRetrieveInterfaceInfo(ERS_HERE, iface, retval);
}

TLOG() << "Iface " << iface << " RX Ring info :"
Expand All @@ -124,12 +126,19 @@ iface_init(uint16_t iface, uint16_t rx_rings, uint16_t tx_rings,

// Carry out a reset of the interface
if (with_reset) {
retval = rte_eth_dev_reset(iface);
if (retval != 0) {
TLOG() << "Resetting device (iface " << iface << ") failed. Retval: " << retval;
if ((retval = rte_eth_dev_reset(iface)) != 0) {
throw FailedToResetInterface(ERS_HERE, iface, retval);
}
}

if ((retval = rte_eth_link_get_nowait(iface, &link)) < 0) {
throw FailedToRetrieveLinkStatus(ERS_HERE, iface, retval);
}

if (link.link_status == 0 ) {
throw LinkOffline(ERS_HERE, iface);
}

// Should we configure MQ RSS and offload?
if (with_mq_rss) {
iface_conf_rss_mode(iface_conf, true, true); // with_rss, with_offload
Expand All @@ -143,9 +152,9 @@ iface_init(uint16_t iface, uint16_t rx_rings, uint16_t tx_rings,
}

// Configure the Ethernet interface
retval = rte_eth_dev_configure(iface, rx_rings, tx_rings, &iface_conf);
if (retval != 0)
return retval;
if ((retval = rte_eth_dev_configure(iface, rx_rings, tx_rings, &iface_conf)) != 0) {
throw FailedToConfigureInterface(ERS_HERE, iface, "Device Configuration", retval);
}

// Set MTU of interface
rte_eth_dev_set_mtu(iface, RTE_JUMBO_ETHER_MTU);
Expand All @@ -155,16 +164,22 @@ iface_init(uint16_t iface, uint16_t rx_rings, uint16_t tx_rings,
TLOG() << "Interface: " << iface << " MTU: " << mtu;
}

// Adjust RX/TX ring sizes
retval = rte_eth_dev_adjust_nb_rx_tx_desc(iface, &nb_rxd, &nb_txd);
if (retval != 0)
return retval;
// // Adjust RX/TX ring sizes
// retval = rte_eth_dev_adjust_nb_rx_tx_desc(iface, &nb_rxd, &nb_txd);
// if (retval != 0)
// return retval;

if ((retval = rte_eth_dev_adjust_nb_rx_tx_desc(iface, &nb_rxd, &nb_txd)) != 0) {
throw FailedToConfigureInterface(ERS_HERE, iface, "Adjust tx/rx descriptors", retval);
}

// Allocate and set up RX queues for interface.
for (q = 0; q < rx_rings; q++) {
retval = rte_eth_rx_queue_setup(iface, q, nb_rxd, rte_eth_dev_socket_id(iface), NULL, mbuf_pool[q].get());
if (retval < 0)
return retval;
// retval = rte_eth_rx_queue_setup(iface, q, nb_rxd, rte_eth_dev_socket_id(iface), NULL, mbuf_pool[q].get());
if ((retval = rte_eth_rx_queue_setup(iface, q, nb_rxd, rte_eth_dev_socket_id(iface), NULL, mbuf_pool[q].get())) < 0) {
// return retval;
throw FailedToConfigureInterface(ERS_HERE, iface, "Rx queues setup", retval);
}
}

txconf = dev_info.default_txconf;
Expand All @@ -177,9 +192,9 @@ iface_init(uint16_t iface, uint16_t rx_rings, uint16_t tx_rings,

// Allocate and set up TX queues for interface.
for (q = 0; q < tx_rings; q++) {
retval = rte_eth_tx_queue_setup(iface, q, nb_txd, rte_eth_dev_socket_id(iface), &txconf);
if (retval < 0)
return retval;
if ((retval = rte_eth_tx_queue_setup(iface, q, nb_txd, rte_eth_dev_socket_id(iface), &txconf)) < 0) {
throw FailedToConfigureInterface(ERS_HERE, iface, "Tx queues setup", retval);
}
}

// Start the Ethernet interface.
Expand All @@ -189,18 +204,16 @@ iface_init(uint16_t iface, uint16_t rx_rings, uint16_t tx_rings,

// Display the interface MAC address.
struct rte_ether_addr addr;
retval = rte_eth_macaddr_get(iface, &addr);
if (retval == 0) {
if ((retval = rte_eth_macaddr_get(iface, &addr)) == 0) {
TLOG() << "MAC address: " << get_mac_addr_str(addr);
} else {
return retval;
throw FailedToConfigureInterface(ERS_HERE, iface, "MAC address retrival", retval);
}

// Get interface info
retval = rte_eth_dev_info_get(iface, &dev_info);
if (retval != 0) {
if ((retval = rte_eth_dev_info_get(iface, &dev_info)) != 0) {
TLOG() << "Error during getting device (iface " << iface << ") retval: " << retval;
return retval;
throw FailedToConfigureInterface(ERS_HERE, iface, "Device information retrival", retval);
}

TLOG() << "Iface[" << iface << "] Rx Ring info:"
Expand All @@ -219,7 +232,7 @@ iface_init(uint16_t iface, uint16_t rx_rings, uint16_t tx_rings,

retval = rte_eth_rx_queue_info_get(iface, j, &queue_info);
if (retval != 0)
break;
continue;

count = rte_eth_rx_queue_count(iface, j);
TLOG() << "rx[" << j << "] descriptors=" << count << "/" << queue_info.nb_desc
Expand Down
8 changes: 6 additions & 2 deletions src/IfaceWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#include "logging/Logging.hpp"
#include "readoutlibs/ReadoutIssues.hpp"

#include "dpdklibs/Issues.hpp"

#include "dpdklibs/nicreader/Structs.hpp"
#include "dpdklibs/nicreaderinfo/InfoNljs.hpp"

#include "dpdklibs/EALSetup.hpp"
// #include "dpdklibs/RTEIfaceSetup.hpp"
#include "dpdklibs/FlowControl.hpp"
#include "dpdklibs/udp/PacketCtor.hpp"
#include "dpdklibs/udp/Utils.hpp"
Expand Down Expand Up @@ -93,7 +93,11 @@ IfaceWrapper::setup_interface()
{
TLOG() << "Initialize interface " << m_iface_id;
bool with_reset = true, with_mq_mode = true; // go to config
ealutils::iface_init(m_iface_id, m_rx_qs.size(), m_tx_qs.size(), m_rx_ring_size, m_tx_ring_size, m_mbuf_pools, with_reset, with_mq_mode);

int retval = ealutils::iface_init(m_iface_id, m_rx_qs.size(), m_tx_qs.size(), m_rx_ring_size, m_tx_ring_size, m_mbuf_pools, with_reset, with_mq_mode);
if (retval != 0 ) {
throw FailedToSetupInterface(ERS_HERE, m_iface_id, retval);
}
// Promiscuous mode
ealutils::iface_promiscuous_mode(m_iface_id, m_prom_mode); // should come from config
}
Expand Down