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