Commit 947ccfff authored by Tom Barbette's avatar Tom Barbette

FromDPDKDevice: Allow to change MTU

parent 0f455982
Pipeline #1818 passed with stage
in 10 minutes and 13 seconds
......@@ -50,12 +50,15 @@ int FromDPDKDevice::configure(Vector<String> &conf, ErrorHandler *errh)
int maxqueues = 128;
String dev;
EtherAddress mac;
uint16_t mtu = 0;
bool has_mac = false;
bool has_mtu = false;
if (parse(Args(conf, this, errh)
.read_mp("PORT", dev))
.read("NDESC", ndesc)
.read("MAC", mac).read_status(has_mac)
.read("MTU", mtu).read_status(has_mtu)
.read("MAXQUEUES",maxqueues)
.read("ACTIVE", _active)
.complete() < 0)
......@@ -90,7 +93,10 @@ int FromDPDKDevice::configure(Vector<String> &conf, ErrorHandler *errh)
if (r != 0) return r;
if (has_mac)
_dev->set_mac(mac);
_dev->set_init_mac(mac);
if (has_mtu)
_dev->set_init_mtu(mtu);
return 0;
}
......
......@@ -60,7 +60,8 @@ public:
EtherAddress get_mac();
void set_mac(EtherAddress mac);
void set_init_mac(EtherAddress mac);
void set_init_mtu(uint16_t mtu);
unsigned int get_nb_txdesc();
......@@ -130,7 +131,7 @@ private:
inline DevInfo() :
vendor_id(PCI_ANY_ID), vendor_name(), device_id(PCI_ANY_ID), driver(0),
rx_queues(0,false), tx_queues(0,false), promisc(false), n_rx_descs(0),
n_tx_descs(0), mac() {
n_tx_descs(0), init_mac(), init_mtu(0) {
rx_queues.reserve(128);
tx_queues.reserve(128);
}
......@@ -141,7 +142,7 @@ private:
click_chatter(" Device ID: %d", device_id);
click_chatter(" Driver Name: %s", driver);
click_chatter("Promisc Mode: %s", promisc? "true":"false");
click_chatter(" MAC Address: %s", mac.unparse().c_str());
click_chatter(" MAC Address: %s", init_mac.unparse().c_str());
click_chatter("# of Rx Queues: %d", rx_queues.size());
click_chatter("# of Tx Queues: %d", tx_queues.size());
click_chatter("# of Rx Descs: %d", n_rx_descs);
......@@ -157,7 +158,8 @@ private:
bool promisc;
unsigned n_rx_descs;
unsigned n_tx_descs;
EtherAddress mac;
EtherAddress init_mac;
uint16_t init_mtu;
};
struct DevInfo info;
......
......@@ -315,6 +315,12 @@ int DPDKDevice::initialize_device(ErrorHandler *errh)
"Cannot initialize TX queue %u of port %u on node %u",
i, port_id, numa_node);
if (info.init_mtu != 0) {
if (rte_eth_dev_set_mtu(port_id, info.init_mtu) != 0) {
return errh->error("Could not set MTU %d",info.init_mtu);
}
}
int err = rte_eth_dev_start(port_id);
if (err < 0)
return errh->error(
......@@ -323,18 +329,25 @@ int DPDKDevice::initialize_device(ErrorHandler *errh)
if (info.promisc)
rte_eth_promiscuous_enable(port_id);
if (info.mac != EtherAddress()) {
if (info.init_mac != EtherAddress()) {
struct ether_addr addr;
memcpy(&addr,info.mac.data(),sizeof(struct ether_addr));
rte_eth_dev_default_mac_addr_set(port_id, &addr);
memcpy(&addr,info.init_mac.data(),sizeof(struct ether_addr));
if (rte_eth_dev_default_mac_addr_set(port_id, &addr) != 0) {
return errh->error("Could not set default MAC address");
}
}
return 0;
}
void DPDKDevice::set_mac(EtherAddress mac) {
void DPDKDevice::set_init_mac(EtherAddress mac) {
assert(!_is_initialized);
info.init_mac = mac;
}
void DPDKDevice::set_init_mtu(uint16_t mtu) {
assert(!_is_initialized);
info.mac = mac;
info.init_mtu = mtu;
}
EtherAddress DPDKDevice::get_mac() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment