Commit 34295850 authored by Hejing Li's avatar Hejing Li
Browse files

Merge branch 'master' of github.com:simbricks/simbricks

parents 113c8fbd 15bb217d
...@@ -78,13 +78,13 @@ void Runner::IssueDma(DMAOp &op) { ...@@ -78,13 +78,13 @@ void Runner::IssueDma(DMAOp &op) {
// can directly issue // can directly issue
#ifdef DEBUG_NICBM #ifdef DEBUG_NICBM
printf("nicbm: issuing dma op %p addr %lx len %zu pending %zu\n", &op, printf("nicbm: issuing dma op %p addr %lx len %zu pending %zu\n", &op,
op.dma_addr, op.len, dma_pending); op.dma_addr_, op.len_, dma_pending_);
#endif #endif
DmaDo(op); DmaDo(op);
} else { } else {
#ifdef DEBUG_NICBM #ifdef DEBUG_NICBM
printf("nicbm: enqueuing dma op %p addr %lx len %zu pending %zu\n", &op, printf("nicbm: enqueuing dma op %p addr %lx len %zu pending %zu\n", &op,
op.dma_addr, op.len, dma_pending); op.dma_addr_, op.len_, dma_pending_);
#endif #endif
dma_queue_.push_back(&op); dma_queue_.push_back(&op);
} }
...@@ -229,8 +229,8 @@ void Runner::H2DReadcomp(volatile struct SimbricksProtoPcieH2DReadcomp *rc) { ...@@ -229,8 +229,8 @@ void Runner::H2DReadcomp(volatile struct SimbricksProtoPcieH2DReadcomp *rc) {
DMAOp *op = (DMAOp *)(uintptr_t)rc->req_id; DMAOp *op = (DMAOp *)(uintptr_t)rc->req_id;
#ifdef DEBUG_NICBM #ifdef DEBUG_NICBM
printf("nicbm: completed dma read op %p addr %lx len %zu\n", op, op->dma_addr, printf("nicbm: completed dma read op %p addr %lx len %zu\n", op, op->dma_addr_,
op->len); op->len_);
#endif #endif
memcpy(op->data_, (void *)rc->data, op->len_); memcpy(op->data_, (void *)rc->data, op->len_);
...@@ -245,7 +245,7 @@ void Runner::H2DWritecomp(volatile struct SimbricksProtoPcieH2DWritecomp *wc) { ...@@ -245,7 +245,7 @@ void Runner::H2DWritecomp(volatile struct SimbricksProtoPcieH2DWritecomp *wc) {
#ifdef DEBUG_NICBM #ifdef DEBUG_NICBM
printf("nicbm: completed dma write op %p addr %lx len %zu\n", op, printf("nicbm: completed dma write op %p addr %lx len %zu\n", op,
op->dma_addr, op->len); op->dma_addr_, op->len_);
#endif #endif
dev_.DmaComplete(*op); dev_.DmaComplete(*op);
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#include <cassert> #include <cassert>
// #define DEBUG 1
static nicbm::Runner *runner; static nicbm::Runner *runner;
namespace corundum { namespace corundum {
...@@ -118,7 +120,7 @@ bool DescRing::empty() { ...@@ -118,7 +120,7 @@ bool DescRing::empty() {
} }
bool DescRing::full() { bool DescRing::full() {
return (this->_currHead - this->_tailPtr >= this->_size); return (this->_currHead - this->_tailPtr >= (int)this->_size);
} }
bool DescRing::updatePtr(ptr_t ptr, bool head) { bool DescRing::updatePtr(ptr_t ptr, bool head) {
...@@ -187,6 +189,9 @@ void EventRing::issueEvent(unsigned type, unsigned source) { ...@@ -187,6 +189,9 @@ void EventRing::issueEvent(unsigned type, unsigned source) {
memset(event, 0, sizeof(Event)); memset(event, 0, sizeof(Event));
event->type = type; event->type = type;
event->source = source; event->source = source;
#ifdef DEBUG
printf("corundum_bm: event ring issue dma addr %lx index %lu len %lu\n", op->dma_addr_, op->tag, op->len_);
#endif
runner->IssueDma(*op); runner->IssueDma(*op);
this->_currHead++; this->_currHead++;
this->armed = false; this->armed = false;
...@@ -253,6 +258,9 @@ TxRing::~TxRing() { ...@@ -253,6 +258,9 @@ TxRing::~TxRing() {
} }
void TxRing::setHeadPtr(ptr_t ptr) { void TxRing::setHeadPtr(ptr_t ptr) {
#ifdef DEBUG
printf("corundum_bm: tx ring %u\n", ptr);
#endif
DescRing::setHeadPtr(ptr); DescRing::setHeadPtr(ptr);
while (this->_currTail != this->_headPtr) { while (this->_currTail != this->_headPtr) {
unsigned index = this->_currTail & this->_sizeMask; unsigned index = this->_currTail & this->_sizeMask;
...@@ -265,6 +273,9 @@ void TxRing::setHeadPtr(ptr_t ptr) { ...@@ -265,6 +273,9 @@ void TxRing::setHeadPtr(ptr_t ptr) {
op->ring = this; op->ring = this;
op->tag = this->_currTail; op->tag = this->_currTail;
op->write_ = false; op->write_ = false;
#ifdef DEBUG
printf("corundum_bm: tx issue dma addr %lx index %lu len %lu\n", op->dma_addr_, op->tag, op->len_);
#endif
runner->IssueDma(*op); runner->IssueDma(*op);
this->_currTail++; this->_currTail++;
} }
...@@ -275,6 +286,9 @@ void TxRing::dmaDone(DMAOp *op) { ...@@ -275,6 +286,9 @@ void TxRing::dmaDone(DMAOp *op) {
case DMA_TYPE_DESC: { case DMA_TYPE_DESC: {
assert(!op->write_); assert(!op->write_);
Desc *desc = (Desc *)op->data_; Desc *desc = (Desc *)op->data_;
#ifdef DEBUG
printf("corundum_bm: tx dma desc done addr %lx index %lu len %u\n", desc->addr, op->tag, desc->len);
#endif
op->type = DMA_TYPE_MEM; op->type = DMA_TYPE_MEM;
op->dma_addr_ = desc->addr; op->dma_addr_ = desc->addr;
op->len_ = desc->len; op->len_ = desc->len;
...@@ -284,13 +298,16 @@ void TxRing::dmaDone(DMAOp *op) { ...@@ -284,13 +298,16 @@ void TxRing::dmaDone(DMAOp *op) {
} }
case DMA_TYPE_MEM: case DMA_TYPE_MEM:
assert(!op->write_); assert(!op->write_);
#ifdef DEBUG
printf("corundum_bm: tx dma memory done index %lu len %lu\n", op->tag, op->len_);
#endif
runner->EthSend(op->data_, op->len_); runner->EthSend(op->data_, op->len_);
updatePtr((ptr_t)op->tag, false); updatePtr((ptr_t)op->tag, false);
this->txCplRing->complete(op->tag, op->len_, true); this->txCplRing->complete(op->tag, op->len_, true);
delete op; delete op;
break; break;
default: default:
fprintf(stderr, "Unknown DMA type %u\n", op->type); fprintf(stderr, "Unknown DMA type %d\n", op->type);
abort(); abort();
} }
} }
...@@ -306,6 +323,9 @@ void RxRing::dmaDone(DMAOp *op) { ...@@ -306,6 +323,9 @@ void RxRing::dmaDone(DMAOp *op) {
case DMA_TYPE_DESC: { case DMA_TYPE_DESC: {
assert(!op->write_); assert(!op->write_);
Desc *desc = (Desc *)op->data_; Desc *desc = (Desc *)op->data_;
#ifdef DEBUG
printf("corundum_bm: rx dma desc done addr %lx index %lu len %lu\n", desc->addr, op->tag, op->rx_data->len);
#endif
op->type = DMA_TYPE_MEM; op->type = DMA_TYPE_MEM;
op->dma_addr_ = desc->addr; op->dma_addr_ = desc->addr;
op->len_ = op->rx_data->len; op->len_ = op->rx_data->len;
...@@ -317,6 +337,9 @@ void RxRing::dmaDone(DMAOp *op) { ...@@ -317,6 +337,9 @@ void RxRing::dmaDone(DMAOp *op) {
} }
case DMA_TYPE_MEM: case DMA_TYPE_MEM:
assert(op->write_); assert(op->write_);
#ifdef DEBUG
printf("corundum_bm: rx dma memory done index %lu len %lu\n", op->tag, op->len_);
#endif
updatePtr((ptr_t)op->tag, false); updatePtr((ptr_t)op->tag, false);
this->rxCplRing->complete(op->tag, op->len_, false); this->rxCplRing->complete(op->tag, op->len_, false);
delete op; delete op;
...@@ -343,6 +366,9 @@ void RxRing::rx(RxData *rx_data) { ...@@ -343,6 +366,9 @@ void RxRing::rx(RxData *rx_data) {
op->rx_data = rx_data; op->rx_data = rx_data;
op->tag = this->_currTail; op->tag = this->_currTail;
op->write_ = false; op->write_ = false;
#ifdef DEBUG
printf("corundum_bm: rx issue dma addr %lx index %lu len %lu\n", op->dma_addr_, op->tag, op->len_);
#endif
runner->IssueDma(*op); runner->IssueDma(*op);
this->_currTail++; this->_currTail++;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment