...
 
Commits (2)
......@@ -50,8 +50,8 @@ LinkUnqueue::configure(Vector<String> &conf, ErrorHandler *errh)
.read_mp("LATENCY", _latency)
.read_mp("BANDWIDTH", BandwidthArg(), _bandwidth).complete() < 0)
return -1;
if (_bandwidth < 100)
return errh->error("bandwidth too small, minimum 100Bps");
if (_bandwidth < 100 && _bandwidth != 0)
return errh->error("bandwidth too small, minimum 100Bps, or 0 to disable bandwidth");
_bandwidth /= 100;
return 0;
}
......@@ -81,8 +81,12 @@ LinkUnqueue::cleanup(CleanupStage)
void
LinkUnqueue::delay_by_bandwidth(Packet *p, const Timestamp &tv) const
{
uint32_t length = p->length() + EXTRA_LENGTH_ANNO(p);
uint32_t delay = (length * 10000) / _bandwidth;
uint32_t delay = 0;
if (_bandwidth > 0) {
uint32_t length = p->length() + EXTRA_LENGTH_ANNO(p);
delay = (length * 10000) / _bandwidth;
}
p->set_timestamp_anno(tv + Timestamp::make_usec(delay));
}
......
......@@ -24,7 +24,7 @@ serial link with latency LATENCY (microsecond precision) and bandwidth
BANDWIDTH (such as "384kbps"). Thus, every packet is delayed at least
by LATENCY, and additionally delayed by its packet size and BANDWIDTH, and
by any packets ahead of it in the virtual link. Packets are pushed out the
single output port when their time comes.
single output port when their time comes. If BANDWITH is 0, only the LATENCY will introduce some delay.
LinkUnqueue listens for upstream notification, such as that available from
Queue.
......
......@@ -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() {
......