Skip to content

Commit

Permalink
keeping track of changes
Browse files Browse the repository at this point in the history
  • Loading branch information
handong32 committed Nov 4, 2019
1 parent 68caa40 commit 5c69645
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/native/Cpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
87 changes: 75 additions & 12 deletions src/native/IxgbeDriver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<IOBuf> buf, PacketInfo pinfo) {
Expand Down Expand Up @@ -334,6 +334,19 @@ void ebbrt::IxgbeDriverRep::Send(std::unique_ptr<IOBuf> buf, PacketInfo pinfo) {
} else {
AddTx(data, len, len, true, true, 0, ip_cksum, tcpudp_cksum, len > 1514, static_cast<int>(pinfo.hdr_len));
}

// dump eth packet info
ebbrt::kprintf("\t Send() on core: %d len=%d\n", mcore, len);
auto p1 = reinterpret_cast<uint8_t*>(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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -2005,6 +2054,7 @@ void ebbrt::IxgbeDriverRep::ReceivePoll() {
rxflag = 0;
count = 0;
rnt = 0;
uint32_t mcore = static_cast<uint32_t>(Cpu::GetMine());

// get address of buffer with data
while (GetRxBuf(&len, &bAddr, &rxflag, &process_rsc, &rnt) == 0) {
Expand Down Expand Up @@ -2037,6 +2087,8 @@ void ebbrt::IxgbeDriverRep::ReceivePoll() {

ReclaimRx();

ebbrt::kprintf("\t ReceivePoll() RSC on core: %d len=%d\n", mcore, static_cast<int>(rsclen));

root_.itf_.Receive(std::move(b), rxflag);
} else {
// done with buffer addr above, now to reuse it
Expand All @@ -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);
Expand All @@ -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<uint8_t*>(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_);
}
}

Expand Down
18 changes: 12 additions & 6 deletions src/native/IxgbeDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
//#define TX_HEAD_WB

// Collect Statistics Flag
#define STATS_EN
//#define STATS_EN
//#define MAX_DESC

namespace ebbrt {

Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/native/NetIcmp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5c69645

Please sign in to comment.