Commit 803110a8 authored by Antoine Kaufmann's avatar Antoine Kaufmann
Browse files

lib/proto/network: rename definitions cosim->simbricks

Also fix identifier case
parent 69f0e0d1
...@@ -37,8 +37,8 @@ static uint64_t current_epoch = 0; ...@@ -37,8 +37,8 @@ static uint64_t current_epoch = 0;
int netsim_init(struct netsim_interface *nsif, const char *eth_socket_path, int netsim_init(struct netsim_interface *nsif, const char *eth_socket_path,
int *sync_eth) { int *sync_eth) {
struct cosim_eth_proto_dev_intro di; struct SimbricksProtoNetDevIntro di;
struct cosim_eth_proto_net_intro ni; struct SimbricksProtoNetNetIntro ni;
int cfd, shm_fd; int cfd, shm_fd;
void *p; void *p;
...@@ -49,7 +49,7 @@ int netsim_init(struct netsim_interface *nsif, const char *eth_socket_path, ...@@ -49,7 +49,7 @@ int netsim_init(struct netsim_interface *nsif, const char *eth_socket_path,
memset(&ni, 0, sizeof(ni)); memset(&ni, 0, sizeof(ni));
if (*sync_eth) if (*sync_eth)
ni.flags |= COSIM_ETH_PROTO_FLAGS_NI_SYNC; ni.flags |= SIMBRICKS_PROTO_NET_FLAGS_NI_SYNC;
if (send(cfd, &ni, sizeof(ni), 0) != sizeof(ni)) { if (send(cfd, &ni, sizeof(ni), 0) != sizeof(ni)) {
perror("sending net intro failed"); perror("sending net intro failed");
...@@ -65,7 +65,7 @@ int netsim_init(struct netsim_interface *nsif, const char *eth_socket_path, ...@@ -65,7 +65,7 @@ int netsim_init(struct netsim_interface *nsif, const char *eth_socket_path,
} }
close(shm_fd); close(shm_fd);
if ((di.flags & COSIM_ETH_PROTO_FLAGS_DI_SYNC) == 0) { if ((di.flags & SIMBRICKS_PROTO_NET_FLAGS_DI_SYNC) == 0) {
*sync_eth = 0; *sync_eth = 0;
nsif->sync = 0; nsif->sync = 0;
} else { } else {
...@@ -89,15 +89,15 @@ void netsim_cleanup(struct netsim_interface *nsif) { ...@@ -89,15 +89,15 @@ void netsim_cleanup(struct netsim_interface *nsif) {
abort(); abort();
} }
volatile union cosim_eth_proto_d2n *netsim_d2n_poll( volatile union SimbricksProtoNetD2N *netsim_d2n_poll(
struct netsim_interface *nsif, uint64_t timestamp) { struct netsim_interface *nsif, uint64_t timestamp) {
volatile union cosim_eth_proto_d2n *msg = volatile union SimbricksProtoNetD2N *msg =
(volatile union cosim_eth_proto_d2n *)(nsif->d2n_queue + (volatile union SimbricksProtoNetD2N *)(nsif->d2n_queue +
nsif->d2n_pos * nsif->d2n_elen); nsif->d2n_pos * nsif->d2n_elen);
/* message not ready */ /* message not ready */
if ((msg->dummy.own_type & COSIM_ETH_PROTO_D2N_OWN_MASK) != if ((msg->dummy.own_type & SIMBRICKS_PROTO_NET_D2N_OWN_MASK) !=
COSIM_ETH_PROTO_D2N_OWN_NET) SIMBRICKS_PROTO_NET_D2N_OWN_NET)
return NULL; return NULL;
/* if in sync mode, wait till message is ready */ /* if in sync mode, wait till message is ready */
...@@ -110,19 +110,20 @@ volatile union cosim_eth_proto_d2n *netsim_d2n_poll( ...@@ -110,19 +110,20 @@ volatile union cosim_eth_proto_d2n *netsim_d2n_poll(
} }
void netsim_d2n_done(struct netsim_interface *nsif, void netsim_d2n_done(struct netsim_interface *nsif,
volatile union cosim_eth_proto_d2n *msg) { volatile union SimbricksProtoNetD2N *msg) {
msg->dummy.own_type = (msg->dummy.own_type & COSIM_ETH_PROTO_D2N_MSG_MASK) | msg->dummy.own_type =
COSIM_ETH_PROTO_D2N_OWN_DEV; (msg->dummy.own_type & SIMBRICKS_PROTO_NET_D2N_MSG_MASK) |
SIMBRICKS_PROTO_NET_D2N_OWN_DEV;
} }
volatile union cosim_eth_proto_n2d *netsim_n2d_alloc( volatile union SimbricksProtoNetN2D *netsim_n2d_alloc(
struct netsim_interface *nsif, uint64_t timestamp, uint64_t latency) { struct netsim_interface *nsif, uint64_t timestamp, uint64_t latency) {
volatile union cosim_eth_proto_n2d *msg = volatile union SimbricksProtoNetN2D *msg =
(volatile union cosim_eth_proto_n2d *)(nsif->n2d_queue + (volatile union SimbricksProtoNetN2D *)(nsif->n2d_queue +
nsif->n2d_pos * nsif->n2d_elen); nsif->n2d_pos * nsif->n2d_elen);
if ((msg->dummy.own_type & COSIM_ETH_PROTO_N2D_OWN_MASK) != if ((msg->dummy.own_type & SIMBRICKS_PROTO_NET_N2D_OWN_MASK) !=
COSIM_ETH_PROTO_N2D_OWN_NET) { SIMBRICKS_PROTO_NET_N2D_OWN_NET) {
return NULL; return NULL;
} }
...@@ -135,8 +136,8 @@ volatile union cosim_eth_proto_n2d *netsim_n2d_alloc( ...@@ -135,8 +136,8 @@ volatile union cosim_eth_proto_n2d *netsim_n2d_alloc(
int netsim_n2d_sync(struct netsim_interface *nsif, uint64_t timestamp, int netsim_n2d_sync(struct netsim_interface *nsif, uint64_t timestamp,
uint64_t latency, uint64_t sync_delay, int sync_mode) { uint64_t latency, uint64_t sync_delay, int sync_mode) {
volatile union cosim_eth_proto_n2d *msg; volatile union SimbricksProtoNetN2D *msg;
volatile struct cosim_eth_proto_n2d_sync *sync; volatile struct SimbricksProtoNetN2DSync *sync;
int do_sync; int do_sync;
if (!nsif->sync) if (!nsif->sync)
...@@ -165,7 +166,8 @@ int netsim_n2d_sync(struct netsim_interface *nsif, uint64_t timestamp, ...@@ -165,7 +166,8 @@ int netsim_n2d_sync(struct netsim_interface *nsif, uint64_t timestamp,
sync = &msg->sync; sync = &msg->sync;
// WMB(); // WMB();
sync->own_type = COSIM_ETH_PROTO_N2D_MSG_SYNC | COSIM_ETH_PROTO_N2D_OWN_DEV; sync->own_type = SIMBRICKS_PROTO_NET_N2D_MSG_SYNC |
SIMBRICKS_PROTO_NET_N2D_OWN_DEV;
return 0; return 0;
} }
......
...@@ -53,15 +53,15 @@ int netsim_init(struct netsim_interface *nsif, const char *eth_socket_path, ...@@ -53,15 +53,15 @@ int netsim_init(struct netsim_interface *nsif, const char *eth_socket_path,
int *sync_eth); int *sync_eth);
void netsim_cleanup(struct netsim_interface *nsif); void netsim_cleanup(struct netsim_interface *nsif);
volatile union cosim_eth_proto_d2n *netsim_d2n_poll( volatile union SimbricksProtoNetD2N *netsim_d2n_poll(
struct netsim_interface *nsif, uint64_t timestamp); struct netsim_interface *nsif, uint64_t timestamp);
void netsim_d2n_done(struct netsim_interface *nsif, void netsim_d2n_done(struct netsim_interface *nsif,
volatile union cosim_eth_proto_d2n *msg); volatile union SimbricksProtoNetD2N *msg);
static inline uint64_t netsim_d2n_timestamp(struct netsim_interface *nsif) { static inline uint64_t netsim_d2n_timestamp(struct netsim_interface *nsif) {
return nsif->d2n_timestamp; return nsif->d2n_timestamp;
} }
volatile union cosim_eth_proto_n2d *netsim_n2d_alloc( volatile union SimbricksProtoNetN2D *netsim_n2d_alloc(
struct netsim_interface *nsif, uint64_t timestamp, uint64_t latency); struct netsim_interface *nsif, uint64_t timestamp, uint64_t latency);
int netsim_n2d_sync(struct netsim_interface *nsif, uint64_t timestamp, int netsim_n2d_sync(struct netsim_interface *nsif, uint64_t timestamp,
uint64_t latency, uint64_t sync_delay, int sync_mode); uint64_t latency, uint64_t sync_delay, int sync_mode);
......
...@@ -61,8 +61,8 @@ volatile union SimbricksProtoPcieD2H *Runner::d2h_alloc(void) { ...@@ -61,8 +61,8 @@ volatile union SimbricksProtoPcieD2H *Runner::d2h_alloc(void) {
return msg; return msg;
} }
volatile union cosim_eth_proto_d2n *Runner::d2n_alloc(void) { volatile union SimbricksProtoNetD2N *Runner::d2n_alloc(void) {
volatile union cosim_eth_proto_d2n *msg; volatile union SimbricksProtoNetD2N *msg;
while ((msg = nicsim_d2n_alloc(&nsparams, main_time)) == NULL) { while ((msg = nicsim_d2n_alloc(&nsparams, main_time)) == NULL) {
fprintf(stderr, "d2n_alloc: no entry available\n"); fprintf(stderr, "d2n_alloc: no entry available\n");
} }
...@@ -257,7 +257,7 @@ void Runner::h2d_devctrl(volatile struct SimbricksProtoPcieH2DDevctrl *dc) { ...@@ -257,7 +257,7 @@ void Runner::h2d_devctrl(volatile struct SimbricksProtoPcieH2DDevctrl *dc) {
dev.devctrl_update(*(struct SimbricksProtoPcieH2DDevctrl *)dc); dev.devctrl_update(*(struct SimbricksProtoPcieH2DDevctrl *)dc);
} }
void Runner::eth_recv(volatile struct cosim_eth_proto_n2d_recv *recv) { void Runner::eth_recv(volatile struct SimbricksProtoNetN2DRecv *recv) {
#ifdef DEBUG_NICBM #ifdef DEBUG_NICBM
printf("nicbm: eth rx: port %u len %u\n", recv->port, recv->len); printf("nicbm: eth rx: port %u len %u\n", recv->port, recv->len);
#endif #endif
...@@ -270,12 +270,13 @@ void Runner::eth_send(const void *data, size_t len) { ...@@ -270,12 +270,13 @@ void Runner::eth_send(const void *data, size_t len) {
printf("nicbm: eth tx: len %zu\n", len); printf("nicbm: eth tx: len %zu\n", len);
#endif #endif
volatile union cosim_eth_proto_d2n *msg = d2n_alloc(); volatile union SimbricksProtoNetD2N *msg = d2n_alloc();
volatile struct cosim_eth_proto_d2n_send *send = &msg->send; volatile struct SimbricksProtoNetD2NSend *send = &msg->send;
send->port = 0; // single port send->port = 0; // single port
send->len = len; send->len = len;
memcpy((void *)send->data, data, len); memcpy((void *)send->data, data, len);
send->own_type = COSIM_ETH_PROTO_D2N_MSG_SEND | COSIM_ETH_PROTO_D2N_OWN_NET; send->own_type = SIMBRICKS_PROTO_NET_D2N_MSG_SEND |
SIMBRICKS_PROTO_NET_D2N_OWN_NET;
} }
void Runner::poll_h2d() { void Runner::poll_h2d() {
...@@ -320,20 +321,20 @@ void Runner::poll_h2d() { ...@@ -320,20 +321,20 @@ void Runner::poll_h2d() {
} }
void Runner::poll_n2d() { void Runner::poll_n2d() {
volatile union cosim_eth_proto_n2d *msg = volatile union SimbricksProtoNetN2D *msg =
nicif_n2d_poll(&nsparams, main_time); nicif_n2d_poll(&nsparams, main_time);
uint8_t t; uint8_t t;
if (msg == NULL) if (msg == NULL)
return; return;
t = msg->dummy.own_type & COSIM_ETH_PROTO_N2D_MSG_MASK; t = msg->dummy.own_type & SIMBRICKS_PROTO_NET_N2D_MSG_MASK;
switch (t) { switch (t) {
case COSIM_ETH_PROTO_N2D_MSG_RECV: case SIMBRICKS_PROTO_NET_N2D_MSG_RECV:
eth_recv(&msg->recv); eth_recv(&msg->recv);
break; break;
case COSIM_ETH_PROTO_N2D_MSG_SYNC: case SIMBRICKS_PROTO_NET_N2D_MSG_SYNC:
break; break;
default: default:
......
...@@ -128,7 +128,7 @@ class Runner { ...@@ -128,7 +128,7 @@ class Runner {
struct SimbricksProtoPcieDevIntro dintro; struct SimbricksProtoPcieDevIntro dintro;
volatile union SimbricksProtoPcieD2H *d2h_alloc(void); volatile union SimbricksProtoPcieD2H *d2h_alloc(void);
volatile union cosim_eth_proto_d2n *d2n_alloc(void); volatile union SimbricksProtoNetD2N *d2n_alloc(void);
void h2d_read(volatile struct SimbricksProtoPcieH2DRead *read); void h2d_read(volatile struct SimbricksProtoPcieH2DRead *read);
void h2d_write(volatile struct SimbricksProtoPcieH2DWrite *write); void h2d_write(volatile struct SimbricksProtoPcieH2DWrite *write);
...@@ -137,7 +137,7 @@ class Runner { ...@@ -137,7 +137,7 @@ class Runner {
void h2d_devctrl(volatile struct SimbricksProtoPcieH2DDevctrl *dc); void h2d_devctrl(volatile struct SimbricksProtoPcieH2DDevctrl *dc);
void poll_h2d(); void poll_h2d();
void eth_recv(volatile struct cosim_eth_proto_n2d_recv *recv); void eth_recv(volatile struct SimbricksProtoNetN2DRecv *recv);
void poll_n2d(); void poll_n2d();
bool event_next(uint64_t &retval); bool event_next(uint64_t &retval);
......
...@@ -101,7 +101,7 @@ static int accept_pci(struct SimbricksProtoPcieDevIntro *di, int pci_lfd, ...@@ -101,7 +101,7 @@ static int accept_pci(struct SimbricksProtoPcieDevIntro *di, int pci_lfd,
} }
static int accept_eth(int eth_lfd, int *sync_eth) { static int accept_eth(int eth_lfd, int *sync_eth) {
struct cosim_eth_proto_dev_intro di; struct SimbricksProtoNetDevIntro di;
if ((eth_cfd = accept(eth_lfd, NULL, NULL)) < 0) { if ((eth_cfd = accept(eth_lfd, NULL, NULL)) < 0) {
return -1; return -1;
...@@ -112,7 +112,7 @@ static int accept_eth(int eth_lfd, int *sync_eth) { ...@@ -112,7 +112,7 @@ static int accept_eth(int eth_lfd, int *sync_eth) {
memset(&di, 0, sizeof(di)); memset(&di, 0, sizeof(di));
di.flags = 0; di.flags = 0;
if (*sync_eth) if (*sync_eth)
di.flags |= COSIM_ETH_PROTO_FLAGS_DI_SYNC; di.flags |= SIMBRICKS_PROTO_NET_FLAGS_DI_SYNC;
di.d2n_offset = d2n_off; di.d2n_offset = d2n_off;
di.d2n_elen = D2N_ELEN; di.d2n_elen = D2N_ELEN;
...@@ -230,11 +230,11 @@ int nicsim_init(struct nicsim_params *params, ...@@ -230,11 +230,11 @@ int nicsim_init(struct nicsim_params *params,
printf("pci host info received\n"); printf("pci host info received\n");
} }
if (params->eth_socket_path != NULL) { if (params->eth_socket_path != NULL) {
struct cosim_eth_proto_net_intro ni; struct SimbricksProtoNetNetIntro ni;
if (recv(eth_cfd, &ni, sizeof(ni), 0) != sizeof(ni)) { if (recv(eth_cfd, &ni, sizeof(ni), 0) != sizeof(ni)) {
return -1; return -1;
} }
if ((ni.flags & COSIM_ETH_PROTO_FLAGS_NI_SYNC) == 0) if ((ni.flags & SIMBRICKS_PROTO_NET_FLAGS_NI_SYNC) == 0)
params->sync_eth = 0; params->sync_eth = 0;
printf("eth net info received\n"); printf("eth net info received\n");
} }
...@@ -253,7 +253,7 @@ void nicsim_cleanup(void) { ...@@ -253,7 +253,7 @@ void nicsim_cleanup(void) {
int nicsim_sync(struct nicsim_params *params, uint64_t timestamp) { int nicsim_sync(struct nicsim_params *params, uint64_t timestamp) {
int ret = 0; int ret = 0;
volatile union SimbricksProtoPcieD2H *d2h; volatile union SimbricksProtoPcieD2H *d2h;
volatile union cosim_eth_proto_d2n *d2n; volatile union SimbricksProtoNetD2N *d2n;
/* sync PCI if necessary */ /* sync PCI if necessary */
if (params->sync_pci) { if (params->sync_pci) {
...@@ -307,7 +307,7 @@ int nicsim_sync(struct nicsim_params *params, uint64_t timestamp) { ...@@ -307,7 +307,7 @@ int nicsim_sync(struct nicsim_params *params, uint64_t timestamp) {
ret = -1; ret = -1;
} else { } else {
d2n->sync.own_type = d2n->sync.own_type =
COSIM_ETH_PROTO_D2N_MSG_SYNC | COSIM_ETH_PROTO_D2N_OWN_NET; SIMBRICKS_PROTO_NET_D2N_MSG_SYNC | SIMBRICKS_PROTO_NET_D2N_OWN_NET;
} }
} }
} }
...@@ -402,14 +402,14 @@ volatile union SimbricksProtoPcieD2H *nicsim_d2h_alloc( ...@@ -402,14 +402,14 @@ volatile union SimbricksProtoPcieD2H *nicsim_d2h_alloc(
/******************************************************************************/ /******************************************************************************/
/* Ethernet */ /* Ethernet */
volatile union cosim_eth_proto_n2d *nicif_n2d_poll(struct nicsim_params *params, volatile union SimbricksProtoNetN2D *nicif_n2d_poll(
uint64_t timestamp) { struct nicsim_params *params, uint64_t timestamp) {
volatile union cosim_eth_proto_n2d *msg = volatile union SimbricksProtoNetN2D *msg =
(volatile union cosim_eth_proto_n2d *)(n2d_queue + n2d_pos * N2D_ELEN); (volatile union SimbricksProtoNetN2D *)(n2d_queue + n2d_pos * N2D_ELEN);
/* message not ready */ /* message not ready */
if ((msg->dummy.own_type & COSIM_ETH_PROTO_N2D_OWN_MASK) != if ((msg->dummy.own_type & SIMBRICKS_PROTO_NET_N2D_OWN_MASK) !=
COSIM_ETH_PROTO_N2D_OWN_DEV) SIMBRICKS_PROTO_NET_N2D_OWN_DEV)
return NULL; return NULL;
/* if in sync mode, wait till message is ready */ /* if in sync mode, wait till message is ready */
...@@ -420,22 +420,23 @@ volatile union cosim_eth_proto_n2d *nicif_n2d_poll(struct nicsim_params *params, ...@@ -420,22 +420,23 @@ volatile union cosim_eth_proto_n2d *nicif_n2d_poll(struct nicsim_params *params,
return msg; return msg;
} }
void nicif_n2d_done(volatile union cosim_eth_proto_n2d *msg) { void nicif_n2d_done(volatile union SimbricksProtoNetN2D *msg) {
msg->dummy.own_type = (msg->dummy.own_type & COSIM_ETH_PROTO_N2D_MSG_MASK) | msg->dummy.own_type =
COSIM_ETH_PROTO_N2D_OWN_NET; (msg->dummy.own_type & SIMBRICKS_PROTO_NET_N2D_MSG_MASK) |
SIMBRICKS_PROTO_NET_N2D_OWN_NET;
} }
void nicif_n2d_next(void) { void nicif_n2d_next(void) {
n2d_pos = (n2d_pos + 1) % N2D_ENUM; n2d_pos = (n2d_pos + 1) % N2D_ENUM;
} }
volatile union cosim_eth_proto_d2n *nicsim_d2n_alloc( volatile union SimbricksProtoNetD2N *nicsim_d2n_alloc(
struct nicsim_params *params, uint64_t timestamp) { struct nicsim_params *params, uint64_t timestamp) {
volatile union cosim_eth_proto_d2n *msg = volatile union SimbricksProtoNetD2N *msg =
(volatile union cosim_eth_proto_d2n *)(d2n_queue + d2n_pos * D2N_ELEN); (volatile union SimbricksProtoNetD2N *)(d2n_queue + d2n_pos * D2N_ELEN);
if ((msg->dummy.own_type & COSIM_ETH_PROTO_D2N_OWN_MASK) != if ((msg->dummy.own_type & SIMBRICKS_PROTO_NET_D2N_OWN_MASK) !=
COSIM_ETH_PROTO_D2N_OWN_DEV) { SIMBRICKS_PROTO_NET_D2N_OWN_DEV) {
return NULL; return NULL;
} }
......
...@@ -62,12 +62,12 @@ void nicif_h2d_next(void); ...@@ -62,12 +62,12 @@ void nicif_h2d_next(void);
volatile union SimbricksProtoPcieD2H *nicsim_d2h_alloc( volatile union SimbricksProtoPcieD2H *nicsim_d2h_alloc(
struct nicsim_params *params, uint64_t timestamp); struct nicsim_params *params, uint64_t timestamp);
volatile union cosim_eth_proto_n2d *nicif_n2d_poll(struct nicsim_params *params, volatile union SimbricksProtoNetN2D *nicif_n2d_poll(
uint64_t timestamp); struct nicsim_params *params, uint64_t timestamp);
void nicif_n2d_done(volatile union cosim_eth_proto_n2d *msg); void nicif_n2d_done(volatile union SimbricksProtoNetN2D *msg);
void nicif_n2d_next(void); void nicif_n2d_next(void);
volatile union cosim_eth_proto_d2n *nicsim_d2n_alloc( volatile union SimbricksProtoNetD2N *nicsim_d2n_alloc(
struct nicsim_params *params, uint64_t timestamp); struct nicsim_params *params, uint64_t timestamp);
#endif // SIMBRICKS_NICIF_NICSIM_H_ #endif // SIMBRICKS_NICIF_NICSIM_H_
...@@ -31,14 +31,14 @@ ...@@ -31,14 +31,14 @@
/* Initialization messages on Unix socket */ /* Initialization messages on Unix socket */
/** in dev_intro.flags to indicate that sender supports issuing syncs. */ /** in dev_intro.flags to indicate that sender supports issuing syncs. */
#define COSIM_ETH_PROTO_FLAGS_DI_SYNC (1 << 0) #define SIMBRICKS_PROTO_NET_FLAGS_DI_SYNC (1 << 0)
/** /**
* welcome message sent by device to network. This message comes with the shared * welcome message sent by device to network. This message comes with the shared
* memory file descriptor attached. * memory file descriptor attached.
*/ */
struct cosim_eth_proto_dev_intro { struct SimbricksProtoNetDevIntro {
/** flags: see COSIM_ETH_PROTO_FLAGS_DI_* */ /** flags: see SIMBRICKS_PROTO_NET_FLAGS_DI_* */
uint64_t flags; uint64_t flags;
/** offset of the device-to-network queue in shared memory region */ /** offset of the device-to-network queue in shared memory region */
...@@ -56,11 +56,11 @@ struct cosim_eth_proto_dev_intro { ...@@ -56,11 +56,11 @@ struct cosim_eth_proto_dev_intro {
uint64_t n2d_nentries; uint64_t n2d_nentries;
} __attribute__((packed)); } __attribute__((packed));
#define COSIM_ETH_PROTO_FLAGS_NI_SYNC (1 << 0) #define SIMBRICKS_PROTO_NET_FLAGS_NI_SYNC (1 << 0)
/** welcome message sent by network to device */ /** welcome message sent by network to device */
struct cosim_eth_proto_net_intro { struct SimbricksProtoNetNetIntro {
/** flags: see COSIM_ETH_PROTO_FLAGS_IN_* */ /** flags: see SIMBRICKS_PROTO_NET_FLAGS_IN_* */
uint64_t flags; uint64_t flags;
} __attribute__((packed)); } __attribute__((packed));
...@@ -68,32 +68,32 @@ struct cosim_eth_proto_net_intro { ...@@ -68,32 +68,32 @@ struct cosim_eth_proto_net_intro {
/* Messages on in-memory device to network channel */ /* Messages on in-memory device to network channel */
/** Mask for ownership bit in own_type field */ /** Mask for ownership bit in own_type field */
#define COSIM_ETH_PROTO_D2N_OWN_MASK 0x80 #define SIMBRICKS_PROTO_NET_D2N_OWN_MASK 0x80
/** Message is owned by device */ /** Message is owned by device */
#define COSIM_ETH_PROTO_D2N_OWN_DEV 0x00 #define SIMBRICKS_PROTO_NET_D2N_OWN_DEV 0x00
/** Message is owned by network */ /** Message is owned by network */
#define COSIM_ETH_PROTO_D2N_OWN_NET 0x80 #define SIMBRICKS_PROTO_NET_D2N_OWN_NET 0x80
/** Mask for type value in own_type field */ /** Mask for type value in own_type field */
#define COSIM_ETH_PROTO_D2N_MSG_MASK 0x7f #define SIMBRICKS_PROTO_NET_D2N_MSG_MASK 0x7f
#define COSIM_ETH_PROTO_D2N_MSG_SYNC 0x1 #define SIMBRICKS_PROTO_NET_D2N_MSG_SYNC 0x1
#define COSIM_ETH_PROTO_D2N_MSG_SEND 0x2 #define SIMBRICKS_PROTO_NET_D2N_MSG_SEND 0x2
struct cosim_eth_proto_d2n_dummy { struct SimbricksProtoNetD2NDummy {
uint8_t pad[48]; uint8_t pad[48];
uint64_t timestamp; uint64_t timestamp;
uint8_t pad_[7]; uint8_t pad_[7];
uint8_t own_type; uint8_t own_type;
} __attribute__((packed)); } __attribute__((packed));
struct cosim_eth_proto_d2n_sync { struct SimbricksProtoNetD2NSync {
uint8_t pad[48]; uint8_t pad[48];
uint64_t timestamp; uint64_t timestamp;
uint8_t pad_[7]; uint8_t pad_[7];
uint8_t own_type; uint8_t own_type;
} __attribute__((packed)); } __attribute__((packed));
struct cosim_eth_proto_d2n_send { struct SimbricksProtoNetD2NSend {
uint16_t len; uint16_t len;
uint8_t port; uint8_t port;
uint8_t pad[45]; uint8_t pad[45];
...@@ -103,40 +103,40 @@ struct cosim_eth_proto_d2n_send { ...@@ -103,40 +103,40 @@ struct cosim_eth_proto_d2n_send {
uint8_t data[]; uint8_t data[];
} __attribute__((packed)); } __attribute__((packed));
union cosim_eth_proto_d2n { union SimbricksProtoNetD2N {
struct cosim_eth_proto_d2n_dummy dummy; struct SimbricksProtoNetD2NDummy dummy;
struct cosim_eth_proto_d2n_sync sync; struct SimbricksProtoNetD2NSync sync;
struct cosim_eth_proto_d2n_send send; struct SimbricksProtoNetD2NSend send;
}; };
/******************************************************************************/ /******************************************************************************/
/* Messages on in-memory network to device channel */ /* Messages on in-memory network to device channel */
#define COSIM_ETH_PROTO_N2D_OWN_MASK 0x80 #define SIMBRICKS_PROTO_NET_N2D_OWN_MASK 0x80
/** Message is owned by host */ /** Message is owned by host */
#define COSIM_ETH_PROTO_N2D_OWN_NET 0x00 #define SIMBRICKS_PROTO_NET_N2D_OWN_NET 0x00
/** Message is owned by device */ /** Message is owned by device */
#define COSIM_ETH_PROTO_N2D_OWN_DEV 0x80 #define SIMBRICKS_PROTO_NET_N2D_OWN_DEV 0x80
#define COSIM_ETH_PROTO_N2D_MSG_MASK 0x7f #define SIMBRICKS_PROTO_NET_N2D_MSG_MASK 0x7f
#define COSIM_ETH_PROTO_N2D_MSG_SYNC 0x1 #define SIMBRICKS_PROTO_NET_N2D_MSG_SYNC 0x1
#define COSIM_ETH_PROTO_N2D_MSG_RECV 0x2 #define SIMBRICKS_PROTO_NET_N2D_MSG_RECV 0x2
struct cosim_eth_proto_n2d_dummy { struct SimbricksProtoNetN2DDummy {
uint8_t pad[48]; uint8_t pad[48];
uint64_t timestamp; uint64_t timestamp;
uint8_t pad_[7]; uint8_t pad_[7];
uint8_t own_type; uint8_t own_type;
} __attribute__((packed)); } __attribute__((packed));
struct cosim_eth_proto_n2d_sync { struct SimbricksProtoNetN2DSync {
uint8_t pad[48]; uint8_t pad[48];
uint64_t timestamp; uint64_t timestamp;
uint8_t pad_[7]; uint8_t pad_[7];
uint8_t own_type; uint8_t own_type;
} __attribute__((packed)); } __attribute__((packed));
struct cosim_eth_proto_n2d_recv { struct SimbricksProtoNetN2DRecv {
uint16_t len; uint16_t len;
uint8_t port; uint8_t port;
uint8_t pad[45]; uint8_t pad[45];
...@@ -146,10 +146,10 @@ struct cosim_eth_proto_n2d_recv { ...@@ -146,10 +146,10 @@ struct cosim_eth_proto_n2d_recv {
uint8_t data[]; uint8_t data[];
}; };
union cosim_eth_proto_n2d { union SimbricksProtoNetN2D {
struct cosim_eth_proto_n2d_dummy dummy; struct SimbricksProtoNetN2DDummy dummy;
struct cosim_eth_proto_n2d_sync sync; struct SimbricksProtoNetN2DSync sync;
struct cosim_eth_proto_n2d_recv recv; struct SimbricksProtoNetN2DRecv recv;
}; };
#endif // SIMBRICKS_PROTO_NETWORK_H_ #endif // SIMBRICKS_PROTO_NETWORK_H_
Subproject commit 20b07886c898a232741d93911c70a4d5bb15c2ad Subproject commit 160793a40cc120da2a3175b62e813bb750683c69
...@@ -81,33 +81,35 @@ static void sigint_handler(int dummy) { ...@@ -81,33 +81,35 @@ static void sigint_handler(int dummy) {
exiting = 1; exiting = 1;
} }
static void forward_pkt(volatile struct cosim_eth_proto_d2n_send *tx, static void forward_pkt(volatile struct SimbricksProtoNetD2NSend *tx,
int port) { int port) {
volatile union cosim_eth_proto_n2d *msg_to; volatile union SimbricksProtoNetN2D *msg_to;
msg_to = netsim_n2d_alloc(&nsifs[port], cur_ts, eth_latency); msg_to = netsim_n2d_alloc(&nsifs[port], cur_ts, eth_latency);
if (msg_to != NULL) { if (msg_to != NULL) {
volatile struct cosim_eth_proto_n2d_recv *rx; volatile struct SimbricksProtoNetN2DRecv *rx;
rx = &msg_to->recv; rx = &msg_to->recv;
rx->len = tx->len; rx->len = tx->len;
rx->port = 0; rx->port = 0;
memcpy((void *)rx->data, (void *)tx->data, tx->len); memcpy((void *)rx->data, (void *)tx->data, tx->len);
// WMB(); // WMB();
rx->own_type = COSIM_ETH_PROTO_N2D_MSG_RECV | COSIM_ETH_PROTO_N2D_OWN_DEV; rx->own_type = SIMBRICKS_PROTO_NET_N2D_MSG_RECV |
SIMBRICKS_PROTO_NET_N2D_OWN_DEV;
} else { } else {
fprintf(stderr, "forward_pkt: dropping packet\n"); fprintf(stderr, "forward_pkt: dropping packet\n");
} }
} }
static void switch_pkt(struct netsim_interface *nsif, int iport) { static void switch_pkt(struct netsim_interface *nsif, int iport) {
volatile union cosim_eth_proto_d2n *msg_from = netsim_d2n_poll(nsif, cur_ts); volatile union SimbricksProtoNetD2N *msg_from =
netsim_d2n_poll(nsif, cur_ts);
if (msg_from == NULL) { if (msg_from == NULL) {
return; return;
} }
uint8_t type = msg_from->dummy.own_type & COSIM_ETH_PROTO_D2N_MSG_MASK; uint8_t type = msg_from->dummy.own_type & SIMBRICKS_PROTO_NET_D2N_MSG_MASK;
if (type == COSIM_ETH_PROTO_D2N_MSG_SEND) { if (type == SIMBRICKS_PROTO_NET_D2N_MSG_SEND) {
volatile struct cosim_eth_proto_d2n_send *tx; volatile struct SimbricksProtoNetD2NSend *tx;
tx = &msg_from->send; tx = &msg_from->send;
// Get MAC addresses // Get MAC addresses
MAC dst(tx->data), src(tx->data + 6); MAC dst(tx->data), src(tx->data + 6);
...@@ -128,7 +130,7 @@ static void switch_pkt(struct netsim_interface *nsif, int iport) { ...@@ -128,7 +130,7 @@ static void switch_pkt(struct netsim_interface *nsif, int iport) {
} }
} }
} }
} else if (type == COSIM_ETH_PROTO_D2N_MSG_SYNC) { } else if (type == SIMBRICKS_PROTO_NET_D2N_MSG_SYNC) {
} else { } else {
fprintf(stderr, "switch_pkt: unsupported type=%u\n", type); fprintf(stderr, "switch_pkt: unsupported type=%u\n", type);
abort(); abort();
......
...@@ -62,7 +62,7 @@ static int tap_open(const char *name) { ...@@ -62,7 +62,7 @@ static int tap_open(const char *name) {
return fd; return fd;
} }
static void d2n_send(volatile struct cosim_eth_proto_d2n_send *s) { static void d2n_send(volatile struct SimbricksProtoNetD2NSend *s) {
#ifdef DEBUG_PKTMETA #ifdef DEBUG_PKTMETA
printf("sent packet: len=%u\n", s->len); printf("sent packet: len=%u\n", s->len);
#endif #endif
...@@ -73,16 +73,16 @@ static void d2n_send(volatile struct cosim_eth_proto_d2n_send *s) { ...@@ -73,16 +73,16 @@ static void d2n_send(volatile struct cosim_eth_proto_d2n_send *s) {
} }
static void poll_d2n(void) { static void poll_d2n(void) {
volatile union cosim_eth_proto_d2n *msg = netsim_d2n_poll(&nsif, 0); volatile union SimbricksProtoNetD2N *msg = netsim_d2n_poll(&nsif, 0);
uint8_t type; uint8_t type;
/* message not ready */ /* message not ready */
if (msg == NULL) if (msg == NULL)
return; return;
type = msg->dummy.own_type & COSIM_ETH_PROTO_D2N_MSG_MASK; type = msg->dummy.own_type & SIMBRICKS_PROTO_NET_D2N_MSG_MASK;
switch (type) { switch (type) {
case COSIM_ETH_PROTO_D2N_MSG_SEND: case SIMBRICKS_PROTO_NET_D2N_MSG_SEND:
d2n_send(&msg->send); d2n_send(&msg->send);
break; break;
...@@ -94,8 +94,8 @@ static void poll_d2n(void) { ...@@ -94,8 +94,8 @@ static void poll_d2n(void) {
} }
static void *rx_handler(void *arg) { static void *rx_handler(void *arg) {
volatile union cosim_eth_proto_n2d *msg; volatile union SimbricksProtoNetN2D *msg;
volatile struct cosim_eth_proto_n2d_recv *rx; volatile struct SimbricksProtoNetN2DRecv *rx;
ssize_t len; ssize_t len;
while (1) { while (1) {
...@@ -117,7 +117,8 @@ static void *rx_handler(void *arg) { ...@@ -117,7 +117,8 @@ static void *rx_handler(void *arg) {
#endif #endif
// WMB(); // WMB();
rx->own_type = COSIM_ETH_PROTO_N2D_MSG_RECV | COSIM_ETH_PROTO_N2D_OWN_DEV; rx->own_type = SIMBRICKS_PROTO_NET_N2D_MSG_RECV |
SIMBRICKS_PROTO_NET_N2D_OWN_DEV;
} }
} }
......
...@@ -54,18 +54,19 @@ static void sigusr1_handler(int dummy) { ...@@ -54,18 +54,19 @@ static void sigusr1_handler(int dummy) {
static void move_pkt(struct netsim_interface *from, static void move_pkt(struct netsim_interface *from,
struct netsim_interface *to) { struct netsim_interface *to) {
volatile union cosim_eth_proto_d2n *msg_from = netsim_d2n_poll(from, cur_ts); volatile union SimbricksProtoNetD2N *msg_from =
volatile union cosim_eth_proto_n2d *msg_to; netsim_d2n_poll(from, cur_ts);
volatile struct cosim_eth_proto_d2n_send *tx; volatile union SimbricksProtoNetN2D *msg_to;
volatile struct cosim_eth_proto_n2d_recv *rx; volatile struct SimbricksProtoNetD2NSend *tx;
volatile struct SimbricksProtoNetN2DRecv *rx;
struct pcap_pkthdr ph; struct pcap_pkthdr ph;
uint8_t type; uint8_t type;
if (msg_from == NULL) if (msg_from == NULL)
return; return;
type = msg_from->dummy.own_type & COSIM_ETH_PROTO_D2N_MSG_MASK; type = msg_from->dummy.own_type & SIMBRICKS_PROTO_NET_D2N_MSG_MASK;
if (type == COSIM_ETH_PROTO_D2N_MSG_SEND) { if (type == SIMBRICKS_PROTO_NET_D2N_MSG_SEND) {
tx = &msg_from->send; tx = &msg_from->send;
// log to pcap file if initialized // log to pcap file if initialized
...@@ -86,11 +87,12 @@ static void move_pkt(struct netsim_interface *from, ...@@ -86,11 +87,12 @@ static void move_pkt(struct netsim_interface *from,
memcpy((void *)rx->data, (void *)tx->data, tx->len); memcpy((void *)rx->data, (void *)tx->data, tx->len);
// WMB(); // WMB();
rx->own_type = COSIM_ETH_PROTO_N2D_MSG_RECV | COSIM_ETH_PROTO_N2D_OWN_DEV; rx->own_type = SIMBRICKS_PROTO_NET_N2D_MSG_RECV |
SIMBRICKS_PROTO_NET_N2D_OWN_DEV;
} else { } else {
fprintf(stderr, "move_pkt: dropping packet\n"); fprintf(stderr, "move_pkt: dropping packet\n");
} }
} else if (type == COSIM_ETH_PROTO_D2N_MSG_SYNC) { } else if (type == SIMBRICKS_PROTO_NET_D2N_MSG_SYNC) {
} else { } else {
fprintf(stderr, "move_pkt: unsupported type=%u\n", type); fprintf(stderr, "move_pkt: unsupported type=%u\n", type);
abort(); abort();
......
...@@ -594,9 +594,9 @@ class EthernetTx { ...@@ -594,9 +594,9 @@ class EthernetTx {
} }
void packet_done() { void packet_done() {
volatile union cosim_eth_proto_d2n *msg = volatile union SimbricksProtoNetD2N *msg =
nicsim_d2n_alloc(&nsparams, main_time); nicsim_d2n_alloc(&nsparams, main_time);
volatile struct cosim_eth_proto_d2n_send *send; volatile struct SimbricksProtoNetD2NSend *send;
if (!msg) if (!msg)
throw "completion alloc failed"; throw "completion alloc failed";
...@@ -607,7 +607,8 @@ class EthernetTx { ...@@ -607,7 +607,8 @@ class EthernetTx {
send->timestamp = main_time + eth_latency; send->timestamp = main_time + eth_latency;
// WMB(); // WMB();
send->own_type = COSIM_ETH_PROTO_D2N_MSG_SEND | COSIM_ETH_PROTO_D2N_OWN_NET; send->own_type = SIMBRICKS_PROTO_NET_D2N_MSG_SEND |
SIMBRICKS_PROTO_NET_D2N_OWN_NET;
#ifdef ETH_DEBUG #ifdef ETH_DEBUG
std::cerr << main_time << " EthernetTx: packet len=" << std::hex std::cerr << main_time << " EthernetTx: packet len=" << std::hex
...@@ -726,26 +727,26 @@ class EthernetRx { ...@@ -726,26 +727,26 @@ class EthernetRx {
}; };
static void n2d_recv(EthernetRx &rx, static void n2d_recv(EthernetRx &rx,
volatile struct cosim_eth_proto_n2d_recv *recv) { volatile struct SimbricksProtoNetN2DRecv *recv) {
rx.packet_received((const void *)recv->data, recv->len); rx.packet_received((const void *)recv->data, recv->len);
} }
static void poll_n2d(EthernetRx &rx) { static void poll_n2d(EthernetRx &rx) {
volatile union cosim_eth_proto_n2d *msg = volatile union SimbricksProtoNetN2D *msg =
nicif_n2d_poll(&nsparams, main_time); nicif_n2d_poll(&nsparams, main_time);
uint8_t t; uint8_t t;
if (msg == NULL) if (msg == NULL)
return; return;
t = msg->dummy.own_type & COSIM_ETH_PROTO_N2D_MSG_MASK; t = msg->dummy.own_type & SIMBRICKS_PROTO_NET_N2D_MSG_MASK;
switch (t) { switch (t) {
case COSIM_ETH_PROTO_N2D_MSG_RECV: case SIMBRICKS_PROTO_NET_N2D_MSG_RECV:
n2d_recv(rx, &msg->recv); n2d_recv(rx, &msg->recv);
break; break;
case COSIM_ETH_PROTO_N2D_MSG_SYNC: case SIMBRICKS_PROTO_NET_N2D_MSG_SYNC:
break; break;
default: default:
......
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