Skip to content

Commit

Permalink
virtionet: Fix a few issues with sendq
Browse files Browse the repository at this point in the history
  • Loading branch information
fwsGonzo authored and alfreb committed Nov 2, 2018
1 parent 052682f commit e34facc
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/drivers/virtionet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ void VirtioNet::msix_xmit_handler()
while (tx_q.new_incoming())
{
auto res = tx_q.dequeue();
// get packet offset, and call destructor
auto* packet = (net::Packet*) (res.data() - sizeof(net::Packet));
delete packet; // call deleter on Packet to release it
assert(res.data() != nullptr);
// get packet offset, and call placement Packet deleter directly
net::Packet::operator delete(res.data() - sizeof(net::Packet));
dequeued_tx++;
}
tx_q.enable_interrupts();
Expand Down Expand Up @@ -339,14 +339,13 @@ VirtioNet::create_packet(int link_offset)

void VirtioNet::transmit(net::Packet_ptr pckt)
{
assert(pckt != nullptr);
VDBG_TX("[virtionet] tx: Transmitting %#zu sized packet \n",
pckt->size());
while (pckt != nullptr) {
if (not Nic::sendq_still_available(sendq.size())) {
stat_sendq_limit_dropped_++;
return;
stat_sendq_limit_dropped_ += pckt->chain_length();
break;
}
VDBG_TX("[virtionet] tx: Transmitting %#zu sized packet \n",
pckt->size());
auto tail = pckt->detach_tail();
sendq.emplace_back(std::move(pckt));
pckt = std::move(tail);
Expand All @@ -363,7 +362,7 @@ void VirtioNet::transmit(net::Packet_ptr pckt)
sendq.size());

// Transmit all we can directly
while (tx_q.num_free() > 1 and sendq.size() > 0)
while (tx_q.num_free() > 1 and !sendq.empty())
{
VDBG_TX("[virtionet] tx: %u tokens left in TX ring \n",
tx_q.num_free());
Expand Down

0 comments on commit e34facc

Please sign in to comment.