@@ -340,19 +340,21 @@ DpdkDriver::Impl::receivePackets(uint32_t maxPackets,
340340 // attempt to dequeue a batch of received packets from the NIC
341341 // as well as from the loopback ring.
342342 uint32_t incomingPkts = 0 ;
343+ uint32_t loopbackPkts = 0 ;
343344 {
344345 SpinLock::Lock lock (rx.mutex );
346+
345347 incomingPkts = rte_eth_rx_burst (
346348 port, 0 , mPkts , Homa::Util::downCast<uint16_t >(maxPackets));
347- }
348349
349- uint32_t loopbackPkts = rte_ring_count (loopbackRing);
350- if (incomingPkts + loopbackPkts > maxPackets) {
351- loopbackPkts = maxPackets - incomingPkts;
352- }
353- for (uint32_t i = 0 ; i < loopbackPkts; i++) {
354- rte_ring_dequeue (loopbackRing,
355- reinterpret_cast <void **>(&mPkts [incomingPkts + i]));
350+ loopbackPkts = rte_ring_count (loopbackRing);
351+ if (incomingPkts + loopbackPkts > maxPackets) {
352+ loopbackPkts = maxPackets - incomingPkts;
353+ }
354+ for (uint32_t i = 0 ; i < loopbackPkts; i++) {
355+ rte_ring_dequeue (loopbackRing, reinterpret_cast <void **>(
356+ &mPkts [incomingPkts + i]));
357+ }
356358 }
357359 uint32_t totalPkts = incomingPkts + loopbackPkts;
358360
@@ -388,6 +390,7 @@ DpdkDriver::Impl::receivePackets(uint32_t maxPackets,
388390 }
389391 }
390392
393+ assert (rte_pktmbuf_pkt_len (m) >= headerLength);
391394 uint32_t length = rte_pktmbuf_pkt_len (m) - headerLength;
392395 assert (length <= MAX_PAYLOAD_SIZE);
393396
0 commit comments