Commit 82bd1894 authored by Antoine Kaufmann's avatar Antoine Kaufmann
Browse files

libnicbm: add devctrl support

parent c93522ab
#include <set> #include <set>
#include <deque> #include <deque>
extern "C" {
#include <nicsim.h>
}
namespace nicbm { namespace nicbm {
#include <cassert> #include <cassert>
extern "C" {
#include <nicsim.h>
}
static const size_t MAX_DMA_LEN = 2048; static const size_t MAX_DMA_LEN = 2048;
...@@ -36,6 +36,11 @@ class TimedEvent { ...@@ -36,6 +36,11 @@ class TimedEvent {
class Runner { class Runner {
public: public:
class Device { class Device {
protected:
bool int_intx_en;
bool int_msi_en;
bool int_msix_en;
public: public:
/** /**
* Initialize device specific parameters (pci dev/vendor id, * Initialize device specific parameters (pci dev/vendor id,
...@@ -74,6 +79,12 @@ class Runner { ...@@ -74,6 +79,12 @@ class Runner {
* A timed event is due. * A timed event is due.
*/ */
virtual void timed_event(TimedEvent &ev); virtual void timed_event(TimedEvent &ev);
/**
* Device control update
*/
virtual void devctrl_update(
struct cosim_pcie_proto_h2d_devctrl &devctrl);
}; };
protected: protected:
...@@ -99,6 +110,7 @@ class Runner { ...@@ -99,6 +110,7 @@ class Runner {
void h2d_write(volatile struct cosim_pcie_proto_h2d_write *write); void h2d_write(volatile struct cosim_pcie_proto_h2d_write *write);
void h2d_readcomp(volatile struct cosim_pcie_proto_h2d_readcomp *rc); void h2d_readcomp(volatile struct cosim_pcie_proto_h2d_readcomp *rc);
void h2d_writecomp(volatile struct cosim_pcie_proto_h2d_writecomp *wc); void h2d_writecomp(volatile struct cosim_pcie_proto_h2d_writecomp *wc);
void h2d_devctrl(volatile struct cosim_pcie_proto_h2d_devctrl *dc);
void poll_h2d(); void poll_h2d();
void eth_recv(volatile struct cosim_eth_proto_n2d_recv *recv); void eth_recv(volatile struct cosim_eth_proto_n2d_recv *recv);
......
...@@ -245,6 +245,11 @@ void Runner::h2d_writecomp(volatile struct cosim_pcie_proto_h2d_writecomp *wc) ...@@ -245,6 +245,11 @@ void Runner::h2d_writecomp(volatile struct cosim_pcie_proto_h2d_writecomp *wc)
dma_trigger(); dma_trigger();
} }
void Runner::h2d_devctrl(volatile struct cosim_pcie_proto_h2d_devctrl *dc)
{
dev.devctrl_update(*(struct cosim_pcie_proto_h2d_devctrl *) dc);
}
void Runner::eth_recv(volatile struct cosim_eth_proto_n2d_recv *recv) void Runner::eth_recv(volatile struct cosim_eth_proto_n2d_recv *recv)
{ {
#ifdef DEBUG_NICBM #ifdef DEBUG_NICBM
...@@ -296,6 +301,10 @@ void Runner::poll_h2d() ...@@ -296,6 +301,10 @@ void Runner::poll_h2d()
h2d_writecomp(&msg->writecomp); h2d_writecomp(&msg->writecomp);
break; break;
case COSIM_PCIE_PROTO_H2D_MSG_DEVCTRL:
h2d_devctrl(&msg->devctrl);
break;
case COSIM_PCIE_PROTO_H2D_MSG_SYNC: case COSIM_PCIE_PROTO_H2D_MSG_SYNC:
break; break;
...@@ -452,3 +461,11 @@ int Runner::runMain(int argc, char *argv[]) ...@@ -452,3 +461,11 @@ int Runner::runMain(int argc, char *argv[])
void Runner::Device::timed_event(TimedEvent &te) void Runner::Device::timed_event(TimedEvent &te)
{ {
} }
void Runner::Device::devctrl_update(
struct cosim_pcie_proto_h2d_devctrl &devctrl)
{
int_intx_en = devctrl.flags & COSIM_PCIE_PROTO_CTRL_INTX_EN;
int_msi_en = devctrl.flags & COSIM_PCIE_PROTO_CTRL_MSI_EN;
int_msix_en = devctrl.flags & COSIM_PCIE_PROTO_CTRL_MSIX_EN;
}
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