diff --git a/src/native/Cpu.cc b/src/native/Cpu.cc index 38ea019f..cce44a3e 100644 --- a/src/native/Cpu.cc +++ b/src/native/Cpu.cc @@ -61,4 +61,4 @@ ebbrt::Cpu* ebbrt::Cpu::GetByApicId(size_t apic_id) { return &(*it); } -size_t ebbrt::Cpu::Count() { return cpus->size(); } +size_t ebbrt::Cpu::Count() { return 16; } //return cpus->size(); } diff --git a/src/native/IxgbeDriver.cc b/src/native/IxgbeDriver.cc index 76320fb6..69b927b0 100644 --- a/src/native/IxgbeDriver.cc +++ b/src/native/IxgbeDriver.cc @@ -63,7 +63,7 @@ void ebbrt::IxgbeDriver::DumpStats() { ixgmq[i]->stat_num_rx = 0; ixgmq[i]->stat_num_tx = 0; - if(ixgmq[i]->stat_perf == false) { + /*if(ixgmq[i]->stat_perf == false) { ixgmq[i]->perfCycles = ebbrt::perf::PerfCounter(ebbrt::perf::PerfEvent::cycles); ixgmq[i]->perfCycles.Start(); ixgmq[i]->perfInst = ebbrt::perf::PerfCounter(ebbrt::perf::PerfEvent::instructions); @@ -80,8 +80,8 @@ void ebbrt::IxgbeDriver::DumpStats() { ebbrt::kprintf("\t instructions:%llf\n", inst); ebbrt::kprintf("\t ipc: %llf\n", inst/cyc); ixgmq[i]->stat_perf = false; - } - } + }*/ + } } void ebbrt::IxgbeDriver::Send(std::unique_ptr buf, PacketInfo pinfo) { @@ -334,6 +334,19 @@ void ebbrt::IxgbeDriverRep::Send(std::unique_ptr buf, PacketInfo pinfo) { } else { AddTx(data, len, len, true, true, 0, ip_cksum, tcpudp_cksum, len > 1514, static_cast(pinfo.hdr_len)); } + + // dump eth packet info + ebbrt::kprintf("\t Send() on core: %d len=%d\n", mcore, len); + auto p1 = reinterpret_cast(data); + for (int i = 0; i < (int)len; i+=8) { + if (i+8 < (int)len) { + ebbrt::kprintf("%02X%02X%02X%02X%02X%02X%02X%02X\n", p1[i], p1[i+1], p1[i+2], p1[i+3], p1[i+4], p1[i+5], p1[i+6], p1[i+7]); + } + else{ + ebbrt::kprintf("%02X\n", p1[i]); + } + } + ebbrt::kprintf("\n"); } // bump tx_tail @@ -1527,13 +1540,49 @@ void ebbrt::IxgbeDriver::Init() { WriteReta(i+2, 0x3020100); WriteReta(i+3, 0x7060504); } else { - WriteReta(i, 0x3020100); - WriteReta(i+1, 0x7060504); - WriteReta(i+2, 0xB0A0908); - WriteReta(i+3, 0xF0E0D0C); + WriteReta(i, 0x3020100); //8 + WriteReta(i+1, 0x7060504); //8 + WriteReta(i+2, 0xB0A0908); // 8 + //WriteReta(i+3, 0x3020100); + //WriteReta(i+2, 0xB0A0908); + //WriteReta(i+3, 0xF0E0D0C); } } + //temp +/* WriteReta(3, 0x3020100); + WriteReta(7, 0x7060504); + WriteReta(11, 0xB0A0908); + WriteReta(15, 0x3020100); + WriteReta(19, 0x7060504); + WriteReta(23, 0xB0A0908); + WriteReta(27, 0x3020100); + WriteReta(31, 0x7060504); + WriteReta(35, 0xB0A0908); + WriteReta(39, 0x3020100); + WriteReta(43, 0x7060504); + WriteReta(47, 0xB0A0908); + WriteReta(51, 0x3020100); + WriteReta(55, 0x7060504); + WriteReta(59, 0xB0A0908); + WriteReta(63, 0x3020100); + WriteReta(67, 0x7060504); + WriteReta(71, 0xB0A0908); + WriteReta(75, 0x3020100); + WriteReta(79, 0x7060504); + WriteReta(83, 0xB0A0908); + WriteReta(87, 0x3020100); + WriteReta(91, 0x7060504); + WriteReta(95, 0xB0A0908); + WriteReta(99, 0x3020100); + WriteReta(103, 0x7060504); + WriteReta(107, 0xB0A0908); + WriteReta(111, 0x3020100); + WriteReta(115, 0x7060504); + WriteReta(119, 0xB0A0908); + WriteReta(123, 0x3020100); + WriteReta(127, 0x3080400);*/ + for (auto i = 0; i < 128; i++) { WriteFtqf(i, 0x0); WriteSaqf(i, 0x0); @@ -2005,6 +2054,7 @@ void ebbrt::IxgbeDriverRep::ReceivePoll() { rxflag = 0; count = 0; rnt = 0; + uint32_t mcore = static_cast(Cpu::GetMine()); // get address of buffer with data while (GetRxBuf(&len, &bAddr, &rxflag, &process_rsc, &rnt) == 0) { @@ -2037,6 +2087,8 @@ void ebbrt::IxgbeDriverRep::ReceivePoll() { ReclaimRx(); + ebbrt::kprintf("\t ReceivePoll() RSC on core: %d len=%d\n", mcore, static_cast(rsclen)); + root_.itf_.Receive(std::move(b), rxflag); } else { // done with buffer addr above, now to reuse it @@ -2049,7 +2101,7 @@ void ebbrt::IxgbeDriverRep::ReceivePoll() { if (count > 0) { auto tail = ixgmq_.rx_tail_; - + // TODO hack - need to set actual length of data otherwise it'll send // leftover 0's ixgmq_.circ_buffer_[tail]->SetLength(len); @@ -2064,15 +2116,26 @@ void ebbrt::IxgbeDriverRep::ReceivePoll() { ixgmq_.rx_ring_[tail].buffer_address = rxphys; - root_.itf_.Receive(std::move(b), rxflag); + // dump eth packet info + ebbrt::kprintf("\t ReceivePoll() on core: %d len=%d\n", mcore, len); + auto p1 = reinterpret_cast(b->MutData()); + for (int i = 0; i < (int)len; i+=8) { + if (i+8 < (int)len) { + ebbrt::kprintf("%02X%02X%02X%02X%02X%02X%02X%02X\n", p1[i], p1[i+1], p1[i+2], p1[i+3], p1[i+4], p1[i+5], p1[i+6], p1[i+7]); + } + else{ + ebbrt::kprintf("%02X\n", p1[i]); + } + } + root_.itf_.Receive(std::move(b), rxflag); } - } + } } - + // TODO: Update tail register here or above? if (count > 0) { // update reg - WriteRdt_1(Cpu::GetMine(), ixgmq_.rx_tail_); + WriteRdt_1(mcore, ixgmq_.rx_tail_); } } diff --git a/src/native/IxgbeDriver.h b/src/native/IxgbeDriver.h index a8d23c4e..0bd6cfd1 100644 --- a/src/native/IxgbeDriver.h +++ b/src/native/IxgbeDriver.h @@ -28,7 +28,8 @@ //#define TX_HEAD_WB // Collect Statistics Flag -#define STATS_EN +//#define STATS_EN +//#define MAX_DESC namespace ebbrt { @@ -95,14 +96,19 @@ class IxgbeDriver : public EthernetDevice { * against the system mbuf pool limit, you can tune nmbclusters * to adjust for this. */ - // Linux Defaults + +#ifdef MAX_DESC + static const constexpr uint32_t NTXDESCS = 8192; + static const constexpr uint32_t NRXDESCS = 8192; +#else static const constexpr uint32_t NTXDESCS = 512; - static const constexpr uint32_t NRXDESCS = 512; + static const constexpr uint32_t NRXDESCS = 512; +#endif + + // Linux Defaults static const constexpr uint32_t RXBUFSZ = 2048; static const constexpr uint32_t BSIZEHEADER = 256; - - //static const constexpr uint32_t NTXDESCS = 8192; - //static const constexpr uint32_t NRXDESCS = 8192; + //static const constexpr uint32_t RXBUFSZ = 4096; //static const constexpr uint32_t RXBUFSZ = 16384; diff --git a/src/native/NetIcmp.cc b/src/native/NetIcmp.cc index e52076ce..3012637d 100644 --- a/src/native/NetIcmp.cc +++ b/src/native/NetIcmp.cc @@ -49,7 +49,7 @@ void ebbrt::NetworkManager::Interface::ReceiveIcmp( PacketInfo pinfo; pinfo.flags = 0; // hijacking ping to dump ixgbe statistics - pinfo.get_stats = true; + pinfo.get_stats = false; #ifdef __EBBRT_ENABLE_BAREMETAL_NIC__ // hardware ip checksum offload pinfo.flags |= PacketInfo::kNeedsIpCsum;