Commit 84da17e3 authored by Antoine Kaufmann's avatar Antoine Kaufmann
Browse files

Format changes for google code style

parent e888d686
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <simbricks/netif/netif.h> #include "lib/simbricks/netif/netif.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -31,13 +31,14 @@ ...@@ -31,13 +31,14 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <unistd.h> #include <unistd.h>
#include "lib/simbricks/netif/internal.h"
#include <simbricks/proto/base.h> #include <simbricks/proto/base.h>
#include "lib/simbricks/netif/internal.h"
static uint64_t current_epoch = 0; static uint64_t current_epoch = 0;
int SimbricksNetIfInit(struct SimbricksNetIf *nsif, const char *eth_socket_path, int SimbricksNetIfInit(struct SimbricksNetIf *nsif, const char *eth_socket_path,
int *sync_eth) { int *sync_eth) {
struct SimbricksProtoNetDevIntro di; struct SimbricksProtoNetDevIntro di;
struct SimbricksProtoNetNetIntro ni; struct SimbricksProtoNetNetIntro ni;
int cfd, shm_fd; int cfd, shm_fd;
...@@ -94,7 +95,7 @@ volatile union SimbricksProtoNetD2N *SimbricksNetIfD2NPoll( ...@@ -94,7 +95,7 @@ volatile union SimbricksProtoNetD2N *SimbricksNetIfD2NPoll(
struct SimbricksNetIf *nsif, uint64_t timestamp) { struct SimbricksNetIf *nsif, uint64_t timestamp) {
volatile union SimbricksProtoNetD2N *msg = volatile union SimbricksProtoNetD2N *msg =
(volatile union SimbricksProtoNetD2N *)(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 & SIMBRICKS_PROTO_NET_D2N_OWN_MASK) != if ((msg->dummy.own_type & SIMBRICKS_PROTO_NET_D2N_OWN_MASK) !=
...@@ -111,7 +112,7 @@ volatile union SimbricksProtoNetD2N *SimbricksNetIfD2NPoll( ...@@ -111,7 +112,7 @@ volatile union SimbricksProtoNetD2N *SimbricksNetIfD2NPoll(
} }
void SimbricksNetIfD2NDone(struct SimbricksNetIf *nsif, void SimbricksNetIfD2NDone(struct SimbricksNetIf *nsif,
volatile union SimbricksProtoNetD2N *msg) { volatile union SimbricksProtoNetD2N *msg) {
msg->dummy.own_type = msg->dummy.own_type =
(msg->dummy.own_type & SIMBRICKS_PROTO_NET_D2N_MSG_MASK) | (msg->dummy.own_type & SIMBRICKS_PROTO_NET_D2N_MSG_MASK) |
SIMBRICKS_PROTO_NET_D2N_OWN_DEV; SIMBRICKS_PROTO_NET_D2N_OWN_DEV;
...@@ -121,7 +122,7 @@ volatile union SimbricksProtoNetN2D *SimbricksNetIfN2DAlloc( ...@@ -121,7 +122,7 @@ volatile union SimbricksProtoNetN2D *SimbricksNetIfN2DAlloc(
struct SimbricksNetIf *nsif, uint64_t timestamp, uint64_t latency) { struct SimbricksNetIf *nsif, uint64_t timestamp, uint64_t latency) {
volatile union SimbricksProtoNetN2D *msg = volatile union SimbricksProtoNetN2D *msg =
(volatile union SimbricksProtoNetN2D *)(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 & SIMBRICKS_PROTO_NET_N2D_OWN_MASK) != if ((msg->dummy.own_type & SIMBRICKS_PROTO_NET_N2D_OWN_MASK) !=
SIMBRICKS_PROTO_NET_N2D_OWN_NET) { SIMBRICKS_PROTO_NET_N2D_OWN_NET) {
...@@ -136,7 +137,8 @@ volatile union SimbricksProtoNetN2D *SimbricksNetIfN2DAlloc( ...@@ -136,7 +137,8 @@ volatile union SimbricksProtoNetN2D *SimbricksNetIfN2DAlloc(
} }
int SimbricksNetIfN2DSync(struct SimbricksNetIf *nsif, uint64_t timestamp, int SimbricksNetIfN2DSync(struct SimbricksNetIf *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 SimbricksProtoNetN2D *msg; volatile union SimbricksProtoNetN2D *msg;
volatile struct SimbricksProtoNetN2DSync *sync; volatile struct SimbricksProtoNetN2DSync *sync;
int do_sync; int do_sync;
...@@ -167,14 +169,14 @@ int SimbricksNetIfN2DSync(struct SimbricksNetIf *nsif, uint64_t timestamp, ...@@ -167,14 +169,14 @@ int SimbricksNetIfN2DSync(struct SimbricksNetIf *nsif, uint64_t timestamp,
sync = &msg->sync; sync = &msg->sync;
// WMB(); // WMB();
sync->own_type = SIMBRICKS_PROTO_NET_N2D_MSG_SYNC | sync->own_type =
SIMBRICKS_PROTO_NET_N2D_OWN_DEV; SIMBRICKS_PROTO_NET_N2D_MSG_SYNC | SIMBRICKS_PROTO_NET_N2D_OWN_DEV;
return 0; return 0;
} }
void SimbricksNetIfAdvanceEpoch(uint64_t timestamp, uint64_t sync_delay, void SimbricksNetIfAdvanceEpoch(uint64_t timestamp, uint64_t sync_delay,
int sync_mode) { int sync_mode) {
if (sync_mode == SIMBRICKS_PROTO_SYNC_BARRIER) { if (sync_mode == SIMBRICKS_PROTO_SYNC_BARRIER) {
if (timestamp - current_epoch >= sync_delay) { if (timestamp - current_epoch >= sync_delay) {
current_epoch = timestamp; current_epoch = timestamp;
...@@ -183,7 +185,7 @@ void SimbricksNetIfAdvanceEpoch(uint64_t timestamp, uint64_t sync_delay, ...@@ -183,7 +185,7 @@ void SimbricksNetIfAdvanceEpoch(uint64_t timestamp, uint64_t sync_delay,
} }
uint64_t SimbricksNetIfAdvanceTime(uint64_t timestamp, uint64_t sync_delay, uint64_t SimbricksNetIfAdvanceTime(uint64_t timestamp, uint64_t sync_delay,
int sync_mode) { int sync_mode) {
switch (sync_mode) { switch (sync_mode) {
case SIMBRICKS_PROTO_SYNC_SIMBRICKS: case SIMBRICKS_PROTO_SYNC_SIMBRICKS:
return timestamp; return timestamp;
......
...@@ -47,13 +47,13 @@ struct SimbricksNetIf { ...@@ -47,13 +47,13 @@ struct SimbricksNetIf {
}; };
int SimbricksNetIfInit(struct SimbricksNetIf *nsif, const char *eth_socket_path, int SimbricksNetIfInit(struct SimbricksNetIf *nsif, const char *eth_socket_path,
int *sync_eth); int *sync_eth);
void SimbricksNetIfCleanup(struct SimbricksNetIf *nsif); void SimbricksNetIfCleanup(struct SimbricksNetIf *nsif);
volatile union SimbricksProtoNetD2N *SimbricksNetIfD2NPoll( volatile union SimbricksProtoNetD2N *SimbricksNetIfD2NPoll(
struct SimbricksNetIf *nsif, uint64_t timestamp); struct SimbricksNetIf *nsif, uint64_t timestamp);
void SimbricksNetIfD2NDone(struct SimbricksNetIf *nsif, void SimbricksNetIfD2NDone(struct SimbricksNetIf *nsif,
volatile union SimbricksProtoNetD2N *msg); volatile union SimbricksProtoNetD2N *msg);
static inline uint64_t SimbricksNetIfD2NTimestamp(struct SimbricksNetIf *nsif) { static inline uint64_t SimbricksNetIfD2NTimestamp(struct SimbricksNetIf *nsif) {
return nsif->d2n_timestamp; return nsif->d2n_timestamp;
} }
...@@ -61,10 +61,10 @@ static inline uint64_t SimbricksNetIfD2NTimestamp(struct SimbricksNetIf *nsif) { ...@@ -61,10 +61,10 @@ static inline uint64_t SimbricksNetIfD2NTimestamp(struct SimbricksNetIf *nsif) {
volatile union SimbricksProtoNetN2D *SimbricksNetIfN2DAlloc( volatile union SimbricksProtoNetN2D *SimbricksNetIfN2DAlloc(
struct SimbricksNetIf *nsif, uint64_t timestamp, uint64_t latency); struct SimbricksNetIf *nsif, uint64_t timestamp, uint64_t latency);
int SimbricksNetIfN2DSync(struct SimbricksNetIf *nsif, uint64_t timestamp, int SimbricksNetIfN2DSync(struct SimbricksNetIf *nsif, uint64_t timestamp,
uint64_t latency, uint64_t sync_delay, int sync_mode); uint64_t latency, uint64_t sync_delay, int sync_mode);
void SimbricksNetIfAdvanceEpoch(uint64_t timestamp, uint64_t sync_delay, void SimbricksNetIfAdvanceEpoch(uint64_t timestamp, uint64_t sync_delay,
int sync_mode); int sync_mode);
uint64_t SimbricksNetIfAdvanceTime(uint64_t timestamp, uint64_t sync_delay, uint64_t SimbricksNetIfAdvanceTime(uint64_t timestamp, uint64_t sync_delay,
int sync_mode); int sync_mode);
#endif // SIMBRICKS_NETIF_NETIF_H_ #endif // SIMBRICKS_NETIF_NETIF_H_
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <simbricks/nicbm/nicbm.h> #include "lib/simbricks/nicbm/nicbm.h"
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
...@@ -156,9 +156,8 @@ void Runner::MsiIssue(uint8_t vec) { ...@@ -156,9 +156,8 @@ void Runner::MsiIssue(uint8_t vec) {
intr->inttype = SIMBRICKS_PROTO_PCIE_INT_MSI; intr->inttype = SIMBRICKS_PROTO_PCIE_INT_MSI;
// WMB(); // WMB();
intr->own_type = intr->own_type = SIMBRICKS_PROTO_PCIE_D2H_MSG_INTERRUPT |
SIMBRICKS_PROTO_PCIE_D2H_MSG_INTERRUPT | SIMBRICKS_PROTO_PCIE_D2H_OWN_HOST;
SIMBRICKS_PROTO_PCIE_D2H_OWN_HOST;
} }
void Runner::MsiXIssue(uint8_t vec) { void Runner::MsiXIssue(uint8_t vec) {
...@@ -171,9 +170,8 @@ void Runner::MsiXIssue(uint8_t vec) { ...@@ -171,9 +170,8 @@ void Runner::MsiXIssue(uint8_t vec) {
intr->inttype = SIMBRICKS_PROTO_PCIE_INT_MSIX; intr->inttype = SIMBRICKS_PROTO_PCIE_INT_MSIX;
// WMB(); // WMB();
intr->own_type = intr->own_type = SIMBRICKS_PROTO_PCIE_D2H_MSG_INTERRUPT |
SIMBRICKS_PROTO_PCIE_D2H_MSG_INTERRUPT | SIMBRICKS_PROTO_PCIE_D2H_OWN_HOST;
SIMBRICKS_PROTO_PCIE_D2H_OWN_HOST;
} }
void Runner::EventSchedule(TimedEvent &evt) { void Runner::EventSchedule(TimedEvent &evt) {
...@@ -223,9 +221,8 @@ void Runner::H2DWrite(volatile struct SimbricksProtoPcieH2DWrite *write) { ...@@ -223,9 +221,8 @@ void Runner::H2DWrite(volatile struct SimbricksProtoPcieH2DWrite *write) {
wc->req_id = write->req_id; wc->req_id = write->req_id;
// WMB(); // WMB();
wc->own_type = wc->own_type = SIMBRICKS_PROTO_PCIE_D2H_MSG_WRITECOMP |
SIMBRICKS_PROTO_PCIE_D2H_MSG_WRITECOMP | SIMBRICKS_PROTO_PCIE_D2H_OWN_HOST;
SIMBRICKS_PROTO_PCIE_D2H_OWN_HOST;
} }
void Runner::H2DReadcomp(volatile struct SimbricksProtoPcieH2DReadcomp *rc) { void Runner::H2DReadcomp(volatile struct SimbricksProtoPcieH2DReadcomp *rc) {
...@@ -279,8 +276,8 @@ void Runner::EthSend(const void *data, size_t len) { ...@@ -279,8 +276,8 @@ void Runner::EthSend(const void *data, size_t len) {
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 = SIMBRICKS_PROTO_NET_D2N_MSG_SEND | send->own_type =
SIMBRICKS_PROTO_NET_D2N_OWN_NET; SIMBRICKS_PROTO_NET_D2N_MSG_SEND | SIMBRICKS_PROTO_NET_D2N_OWN_NET;
} }
void Runner::PollH2D() { void Runner::PollH2D() {
...@@ -433,7 +430,7 @@ int Runner::RunMain(int argc, char *argv[]) { ...@@ -433,7 +430,7 @@ int Runner::RunMain(int argc, char *argv[]) {
nsparams_.eth_latency = eth_latency; nsparams_.eth_latency = eth_latency;
nsparams_.sync_delay = sync_period; nsparams_.sync_delay = sync_period;
assert(sync_mode == SIMBRICKS_PROTO_SYNC_SIMBRICKS || assert(sync_mode == SIMBRICKS_PROTO_SYNC_SIMBRICKS ||
sync_mode == SIMBRICKS_PROTO_SYNC_BARRIER); sync_mode == SIMBRICKS_PROTO_SYNC_BARRIER);
nsparams_.sync_mode = sync_mode; nsparams_.sync_mode = sync_mode;
if (SimbricksNicIfInit(&nsparams_, &dintro_)) { if (SimbricksNicIfInit(&nsparams_, &dintro_)) {
......
...@@ -179,7 +179,7 @@ class SimpleDevice : public Runner::Device { ...@@ -179,7 +179,7 @@ class SimpleDevice : public Runner::Device {
} }
void RegWrite(uint8_t bar, uint64_t addr, const void *src, void RegWrite(uint8_t bar, uint64_t addr, const void *src,
size_t len) override { size_t len) override {
assert(len == sizeof(TReg)); assert(len == sizeof(TReg));
TReg r; TReg r;
memcpy(&r, src, sizeof(r)); memcpy(&r, src, sizeof(r));
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include <simbricks/nicif/nicif.h> #include "lib/simbricks/nicif/nicif.h"
#include <poll.h> #include <poll.h>
#include <stdio.h> #include <stdio.h>
...@@ -31,9 +31,10 @@ ...@@ -31,9 +31,10 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <unistd.h> #include <unistd.h>
#include "lib/simbricks/nicif/internal.h"
#include <simbricks/proto/base.h> #include <simbricks/proto/base.h>
#include "lib/simbricks/nicif/internal.h"
#define D2H_ELEN (9024 + 64) #define D2H_ELEN (9024 + 64)
#define D2H_ENUM 1024 #define D2H_ENUM 1024
...@@ -178,7 +179,7 @@ static int accept_conns(struct SimbricksProtoPcieDevIntro *di, int pci_lfd, ...@@ -178,7 +179,7 @@ static int accept_conns(struct SimbricksProtoPcieDevIntro *di, int pci_lfd,
} }
int SimbricksNicIfInit(struct SimbricksNicIfParams *params, int SimbricksNicIfInit(struct SimbricksNicIfParams *params,
struct SimbricksProtoPcieDevIntro *di) { struct SimbricksProtoPcieDevIntro *di) {
int pci_lfd = -1, eth_lfd = -1; int pci_lfd = -1, eth_lfd = -1;
void *shmptr; void *shmptr;
size_t shm_size; size_t shm_size;
...@@ -279,9 +280,8 @@ int SimbricksNicIfSync(struct SimbricksNicIfParams *params, ...@@ -279,9 +280,8 @@ int SimbricksNicIfSync(struct SimbricksNicIfParams *params,
if (d2h == NULL) { if (d2h == NULL) {
ret = -1; ret = -1;
} else { } else {
d2h->sync.own_type = d2h->sync.own_type = SIMBRICKS_PROTO_PCIE_D2H_MSG_SYNC |
SIMBRICKS_PROTO_PCIE_D2H_MSG_SYNC | SIMBRICKS_PROTO_PCIE_D2H_OWN_HOST;
SIMBRICKS_PROTO_PCIE_D2H_OWN_HOST;
} }
} }
} }
......
...@@ -94,8 +94,8 @@ static void forward_pkt(volatile struct SimbricksProtoNetD2NSend *tx, ...@@ -94,8 +94,8 @@ static void forward_pkt(volatile struct SimbricksProtoNetD2NSend *tx,
memcpy((void *)rx->data, (void *)tx->data, tx->len); memcpy((void *)rx->data, (void *)tx->data, tx->len);
// WMB(); // WMB();
rx->own_type = SIMBRICKS_PROTO_NET_N2D_MSG_RECV | rx->own_type =
SIMBRICKS_PROTO_NET_N2D_OWN_DEV; 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");
} }
...@@ -169,7 +169,7 @@ int main(int argc, char *argv[]) { ...@@ -169,7 +169,7 @@ int main(int argc, char *argv[]) {
case 'm': case 'm':
sync_mode = strtol(optarg, NULL, 0); sync_mode = strtol(optarg, NULL, 0);
assert(sync_mode == SIMBRICKS_PROTO_SYNC_SIMBRICKS || assert(sync_mode == SIMBRICKS_PROTO_SYNC_SIMBRICKS ||
sync_mode == SIMBRICKS_PROTO_SYNC_BARRIER); sync_mode == SIMBRICKS_PROTO_SYNC_BARRIER);
break; break;
default: default:
...@@ -194,7 +194,7 @@ int main(int argc, char *argv[]) { ...@@ -194,7 +194,7 @@ int main(int argc, char *argv[]) {
// Sync all interfaces // Sync all interfaces
for (auto &nsif : nsifs) { for (auto &nsif : nsifs) {
if (SimbricksNetIfN2DSync(&nsif, cur_ts, eth_latency, sync_period, if (SimbricksNetIfN2DSync(&nsif, cur_ts, eth_latency, sync_period,
sync_mode) != 0) { sync_mode) != 0) {
fprintf(stderr, "SimbricksNetIfN2DSync failed\n"); fprintf(stderr, "SimbricksNetIfN2DSync failed\n");
abort(); abort();
} }
......
...@@ -117,8 +117,8 @@ static void *rx_handler(void *arg) { ...@@ -117,8 +117,8 @@ static void *rx_handler(void *arg) {
#endif #endif
// WMB(); // WMB();
rx->own_type = SIMBRICKS_PROTO_NET_N2D_MSG_RECV | rx->own_type =
SIMBRICKS_PROTO_NET_N2D_OWN_DEV; SIMBRICKS_PROTO_NET_N2D_MSG_RECV | SIMBRICKS_PROTO_NET_N2D_OWN_DEV;
} }
} }
......
...@@ -53,8 +53,7 @@ static void sigusr1_handler(int dummy) { ...@@ -53,8 +53,7 @@ static void sigusr1_handler(int dummy) {
fprintf(stderr, "main_time = %lu\n", cur_ts); fprintf(stderr, "main_time = %lu\n", cur_ts);
} }
static void move_pkt(struct SimbricksNetIf *from, static void move_pkt(struct SimbricksNetIf *from, struct SimbricksNetIf *to) {
struct SimbricksNetIf *to) {
volatile union SimbricksProtoNetD2N *msg_from = volatile union SimbricksProtoNetD2N *msg_from =
SimbricksNetIfD2NPoll(from, cur_ts); SimbricksNetIfD2NPoll(from, cur_ts);
volatile union SimbricksProtoNetN2D *msg_to; volatile union SimbricksProtoNetN2D *msg_to;
...@@ -88,8 +87,8 @@ static void move_pkt(struct SimbricksNetIf *from, ...@@ -88,8 +87,8 @@ static void move_pkt(struct SimbricksNetIf *from,
memcpy((void *)rx->data, (void *)tx->data, tx->len); memcpy((void *)rx->data, (void *)tx->data, tx->len);
// WMB(); // WMB();
rx->own_type = SIMBRICKS_PROTO_NET_N2D_MSG_RECV | rx->own_type =
SIMBRICKS_PROTO_NET_N2D_OWN_DEV; 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");
} }
...@@ -141,7 +140,7 @@ int main(int argc, char *argv[]) { ...@@ -141,7 +140,7 @@ int main(int argc, char *argv[]) {
} }
assert(sync_mode == SIMBRICKS_PROTO_SYNC_SIMBRICKS || assert(sync_mode == SIMBRICKS_PROTO_SYNC_SIMBRICKS ||
sync_mode == SIMBRICKS_PROTO_SYNC_BARRIER); sync_mode == SIMBRICKS_PROTO_SYNC_BARRIER);
sync_a = sync_b = 1; sync_a = sync_b = 1;
if (SimbricksNetIfInit(&nsif_a, argv[1], &sync_a) != 0) { if (SimbricksNetIfInit(&nsif_a, argv[1], &sync_a) != 0) {
...@@ -154,12 +153,12 @@ int main(int argc, char *argv[]) { ...@@ -154,12 +153,12 @@ int main(int argc, char *argv[]) {
printf("start polling\n"); printf("start polling\n");
while (!exiting) { while (!exiting) {
if (SimbricksNetIfN2DSync(&nsif_a, cur_ts, eth_latency, sync_period, if (SimbricksNetIfN2DSync(&nsif_a, cur_ts, eth_latency, sync_period,
sync_mode) != 0) { sync_mode) != 0) {
fprintf(stderr, "SimbricksNetIfN2DSync(nsif_a) failed\n"); fprintf(stderr, "SimbricksNetIfN2DSync(nsif_a) failed\n");
abort(); abort();
} }
if (SimbricksNetIfN2DSync(&nsif_b, cur_ts, eth_latency, sync_period, if (SimbricksNetIfN2DSync(&nsif_b, cur_ts, eth_latency, sync_period,
sync_mode) != 0) { sync_mode) != 0) {
fprintf(stderr, "SimbricksNetIfN2DSync(nsif_a) failed\n"); fprintf(stderr, "SimbricksNetIfN2DSync(nsif_a) failed\n");
abort(); abort();
} }
...@@ -175,7 +174,7 @@ int main(int argc, char *argv[]) { ...@@ -175,7 +174,7 @@ int main(int argc, char *argv[]) {
if (sync_a && sync_b) if (sync_a && sync_b)
cur_ts = SimbricksNetIfAdvanceTime(ts_a <= ts_b ? ts_a : ts_b, cur_ts = SimbricksNetIfAdvanceTime(ts_a <= ts_b ? ts_a : ts_b,
sync_period, sync_mode); sync_period, sync_mode);
else if (sync_a) else if (sync_a)
cur_ts = SimbricksNetIfAdvanceTime(ts_a, sync_period, sync_mode); cur_ts = SimbricksNetIfAdvanceTime(ts_a, sync_period, sync_mode);
else if (sync_b) else if (sync_b)
......
...@@ -370,18 +370,16 @@ void pci_rwcomp_issue(MMIOOp *op) { ...@@ -370,18 +370,16 @@ void pci_rwcomp_issue(MMIOOp *op) {
wc->req_id = op->id; wc->req_id = op->id;
// WMB(); // WMB();
wc->own_type = wc->own_type = SIMBRICKS_PROTO_PCIE_D2H_MSG_WRITECOMP |
SIMBRICKS_PROTO_PCIE_D2H_MSG_WRITECOMP | SIMBRICKS_PROTO_PCIE_D2H_OWN_HOST;
SIMBRICKS_PROTO_PCIE_D2H_OWN_HOST;
} else { } else {
rc = &msg->readcomp; rc = &msg->readcomp;
memcpy((void *)rc->data, &op->value, op->len); memcpy((void *)rc->data, &op->value, op->len);
rc->req_id = op->id; rc->req_id = op->id;
// WMB(); // WMB();
rc->own_type = rc->own_type = SIMBRICKS_PROTO_PCIE_D2H_MSG_READCOMP |
SIMBRICKS_PROTO_PCIE_D2H_MSG_READCOMP | SIMBRICKS_PROTO_PCIE_D2H_OWN_HOST;
SIMBRICKS_PROTO_PCIE_D2H_OWN_HOST;
} }
delete op; delete op;
...@@ -499,9 +497,8 @@ static void h2d_read(MMIOInterface &mmio, ...@@ -499,9 +497,8 @@ static void h2d_read(MMIOInterface &mmio,
rc->req_id = read->req_id; rc->req_id = read->req_id;
// WMB(); // WMB();
rc->own_type = rc->own_type = SIMBRICKS_PROTO_PCIE_D2H_MSG_READCOMP |
SIMBRICKS_PROTO_PCIE_D2H_MSG_READCOMP | SIMBRICKS_PROTO_PCIE_D2H_OWN_HOST;
SIMBRICKS_PROTO_PCIE_D2H_OWN_HOST;
} else { } else {
/*printf("read(bar=%u, off=%lu, len=%u) = %lu\n", read->bar, read->offset, /*printf("read(bar=%u, off=%lu, len=%u) = %lu\n", read->bar, read->offset,
read->len, val);*/ read->len, val);*/
...@@ -530,9 +527,8 @@ static void h2d_write(MMIOInterface &mmio, ...@@ -530,9 +527,8 @@ static void h2d_write(MMIOInterface &mmio,
wc->req_id = write->req_id; wc->req_id = write->req_id;
// WMB(); // WMB();
wc->own_type = wc->own_type = SIMBRICKS_PROTO_PCIE_D2H_MSG_WRITECOMP |
SIMBRICKS_PROTO_PCIE_D2H_MSG_WRITECOMP | SIMBRICKS_PROTO_PCIE_D2H_OWN_HOST;
SIMBRICKS_PROTO_PCIE_D2H_OWN_HOST;
} else { } else {
mmio.issueWrite(write->req_id, write->offset, write->len, val); mmio.issueWrite(write->req_id, write->offset, write->len, val);
} }
...@@ -608,8 +604,8 @@ class EthernetTx { ...@@ -608,8 +604,8 @@ class EthernetTx {
send->timestamp = main_time + eth_latency; send->timestamp = main_time + eth_latency;
// WMB(); // WMB();
send->own_type = SIMBRICKS_PROTO_NET_D2N_MSG_SEND | send->own_type =
SIMBRICKS_PROTO_NET_D2N_OWN_NET; 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
...@@ -656,7 +652,8 @@ class EthernetRx { ...@@ -656,7 +652,8 @@ class EthernetRx {
public: public:
explicit EthernetRx(Vinterface &top_) explicit EthernetRx(Vinterface &top_)
: top(top_), fifo_pos_rd(0), fifo_pos_wr(0), packet_off(0) { : top(top_), fifo_pos_rd(0), fifo_pos_wr(0), packet_off(0) {
for (size_t i = 0; i < FIFO_SIZE; i++) fifo_lens[i] = 0; for (size_t i = 0; i < FIFO_SIZE; i++)
fifo_lens[i] = 0;
} }
void packet_received(const void *data, size_t len) { void packet_received(const void *data, size_t len) {
...@@ -771,9 +768,8 @@ void pci_msi_issue(uint8_t vec) { ...@@ -771,9 +768,8 @@ void pci_msi_issue(uint8_t vec) {
intr->inttype = SIMBRICKS_PROTO_PCIE_INT_MSI; intr->inttype = SIMBRICKS_PROTO_PCIE_INT_MSI;
// WMB(); // WMB();
intr->own_type = intr->own_type = SIMBRICKS_PROTO_PCIE_D2H_MSG_INTERRUPT |
SIMBRICKS_PROTO_PCIE_D2H_MSG_INTERRUPT | SIMBRICKS_PROTO_PCIE_D2H_OWN_HOST;
SIMBRICKS_PROTO_PCIE_D2H_OWN_HOST;
} }
static void msi_step(Vinterface &top, PCICoordinator &coord) { static void msi_step(Vinterface &top, PCICoordinator &coord) {
...@@ -842,7 +838,7 @@ int main(int argc, char *argv[]) { ...@@ -842,7 +838,7 @@ int main(int argc, char *argv[]) {
nsparams.eth_latency = eth_latency; nsparams.eth_latency = eth_latency;
nsparams.sync_delay = sync_period; nsparams.sync_delay = sync_period;
assert(sync_mode == SIMBRICKS_PROTO_SYNC_SIMBRICKS || assert(sync_mode == SIMBRICKS_PROTO_SYNC_SIMBRICKS ||
sync_mode == SIMBRICKS_PROTO_SYNC_BARRIER); sync_mode == SIMBRICKS_PROTO_SYNC_BARRIER);
nsparams.sync_mode = sync_mode; nsparams.sync_mode = sync_mode;
if (SimbricksNicIfInit(&nsparams, &di)) { if (SimbricksNicIfInit(&nsparams, &di)) {
......
...@@ -73,7 +73,8 @@ void MemWriter::step() { ...@@ -73,7 +73,8 @@ void MemWriter::step() {
p.mem_addr[0] = p.mem_addr[1] = p.mem_addr[2] = 0; p.mem_addr[0] = p.mem_addr[1] = p.mem_addr[2] = 0;
p.mem_be[0] = p.mem_be[1] = p.mem_be[2] = p.mem_be[3] = 0; p.mem_be[0] = p.mem_be[1] = p.mem_be[2] = p.mem_be[3] = 0;
p.mem_valid = 0; p.mem_valid = 0;
for (size_t i = 0; i < data_byte_width / 4; i++) p.mem_data[i] = 0; for (size_t i = 0; i < data_byte_width / 4; i++)
p.mem_data[i] = 0;
/* put data bytes in the right places */ /* put data bytes in the right places */
size_t off = data_offset; size_t off = data_offset;
......
...@@ -120,8 +120,8 @@ volatile union SimbricksProtoPcieH2D *h2d_alloc() { ...@@ -120,8 +120,8 @@ volatile union SimbricksProtoPcieH2D *h2d_alloc() {
volatile union SimbricksProtoPcieD2H *d2h_poll() { volatile union SimbricksProtoPcieD2H *d2h_poll() {
volatile union SimbricksProtoPcieD2H *msg; volatile union SimbricksProtoPcieD2H *msg;
msg = (volatile union SimbricksProtoPcieD2H *) msg =
(d2h_queue + d2h_pos * d2h_elen); (volatile union SimbricksProtoPcieD2H *)(d2h_queue + d2h_pos * d2h_elen);
if ((msg->dummy.own_type & SIMBRICKS_PROTO_PCIE_D2H_OWN_MASK) == if ((msg->dummy.own_type & SIMBRICKS_PROTO_PCIE_D2H_OWN_MASK) ==
SIMBRICKS_PROTO_PCIE_D2H_OWN_DEV) { SIMBRICKS_PROTO_PCIE_D2H_OWN_DEV) {
return NULL; return NULL;
...@@ -143,8 +143,8 @@ static void dev_read(uint64_t offset, uint16_t len) { ...@@ -143,8 +143,8 @@ static void dev_read(uint64_t offset, uint16_t len) {
read->offset = offset; read->offset = offset;
read->len = len; read->len = len;
read->bar = 0; read->bar = 0;
read->own_type = SIMBRICKS_PROTO_PCIE_H2D_MSG_READ | read->own_type =
SIMBRICKS_PROTO_PCIE_H2D_OWN_DEV; SIMBRICKS_PROTO_PCIE_H2D_MSG_READ | SIMBRICKS_PROTO_PCIE_H2D_OWN_DEV;
volatile union SimbricksProtoPcieD2H *d2h_msg = NULL; volatile union SimbricksProtoPcieD2H *d2h_msg = NULL;
while (d2h_msg == NULL) { while (d2h_msg == NULL) {
......
...@@ -391,7 +391,8 @@ void queue_admin_tx::admin_desc_ctx::process() { ...@@ -391,7 +391,8 @@ void queue_admin_tx::admin_desc_ctx::process() {
#endif #endif
struct i40e_aqc_query_vsi_bw_config_resp bwc; struct i40e_aqc_query_vsi_bw_config_resp bwc;
memset(&bwc, 0, sizeof(bwc)); memset(&bwc, 0, sizeof(bwc));
for (size_t i = 0; i < 8; i++) bwc.qs_handles[i] = 0xffff; for (size_t i = 0; i < 8; i++)
bwc.qs_handles[i] = 0xffff;
desc_complete_indir(0, &bwc, sizeof(bwc)); desc_complete_indir(0, &bwc, sizeof(bwc));
} else if (d->opcode == i40e_aqc_opc_query_vsi_ets_sla_config) { } else if (d->opcode == i40e_aqc_opc_query_vsi_ets_sla_config) {
#ifdef DEBUG_ADMINQ #ifdef DEBUG_ADMINQ
...@@ -399,7 +400,8 @@ void queue_admin_tx::admin_desc_ctx::process() { ...@@ -399,7 +400,8 @@ void queue_admin_tx::admin_desc_ctx::process() {
#endif #endif
struct i40e_aqc_query_vsi_ets_sla_config_resp sla; struct i40e_aqc_query_vsi_ets_sla_config_resp sla;
memset(&sla, 0, sizeof(sla)); memset(&sla, 0, sizeof(sla));
for (size_t i = 0; i < 8; i++) sla.share_credits[i] = 127; for (size_t i = 0; i < 8; i++)
sla.share_credits[i] = 127;
desc_complete_indir(0, &sla, sizeof(sla)); desc_complete_indir(0, &sla, sizeof(sla));
} else if (d->opcode == i40e_aqc_opc_remove_macvlan) { } else if (d->opcode == i40e_aqc_opc_remove_macvlan) {
#ifdef DEBUG_ADMINQ #ifdef DEBUG_ADMINQ
......
...@@ -114,7 +114,7 @@ uint32_t i40e_bm::RegRead32(uint8_t bar, uint64_t addr) { ...@@ -114,7 +114,7 @@ uint32_t i40e_bm::RegRead32(uint8_t bar, uint64_t addr) {
} }
void i40e_bm::RegWrite(uint8_t bar, uint64_t addr, const void *src, void i40e_bm::RegWrite(uint8_t bar, uint64_t addr, const void *src,
size_t len) { size_t len) {
const uint32_t *src_p = reinterpret_cast<const uint32_t *>(src); const uint32_t *src_p = reinterpret_cast<const uint32_t *>(src);
if (len == 4) { if (len == 4) {
......
...@@ -585,8 +585,8 @@ class i40e_bm : public nicbm::Runner::Device { ...@@ -585,8 +585,8 @@ class i40e_bm : public nicbm::Runner::Device {
void SetupIntro(struct SimbricksProtoPcieDevIntro &di) override; void SetupIntro(struct SimbricksProtoPcieDevIntro &di) override;
void RegRead(uint8_t bar, uint64_t addr, void *dest, size_t len) override; void RegRead(uint8_t bar, uint64_t addr, void *dest, size_t len) override;
virtual uint32_t RegRead32(uint8_t bar, uint64_t addr); virtual uint32_t RegRead32(uint8_t bar, uint64_t addr);
void RegWrite(uint8_t bar, uint64_t addr, const void *src, size_t len) void RegWrite(uint8_t bar, uint64_t addr, const void *src,
override; size_t len) override;
virtual void RegWrite32(uint8_t bar, uint64_t addr, uint32_t val); virtual void RegWrite32(uint8_t bar, uint64_t addr, uint32_t val);
void DmaComplete(nicbm::DMAOp &op) override; void DmaComplete(nicbm::DMAOp &op) override;
void EthRx(uint8_t port, const void *data, size_t len) override; void EthRx(uint8_t port, const void *data, size_t len) override;
......
...@@ -169,8 +169,8 @@ void lan_queue_base::enable() { ...@@ -169,8 +169,8 @@ void lan_queue_base::enable() {
qctx_fetch *qf = new qctx_fetch(*this); qctx_fetch *qf = new qctx_fetch(*this);
qf->write_ = false; qf->write_ = false;
qf->dma_addr_ = ((fpm_basereg & I40E_GLHMC_LANTXBASE_FPMLANTXBASE_MASK) >> qf->dma_addr_ = ((fpm_basereg & I40E_GLHMC_LANTXBASE_FPMLANTXBASE_MASK) >>
I40E_GLHMC_LANTXBASE_FPMLANTXBASE_SHIFT) * I40E_GLHMC_LANTXBASE_FPMLANTXBASE_SHIFT) *
512; 512;
qf->dma_addr_ += ctx_size * idx; qf->dma_addr_ += ctx_size * idx;
qf->len_ = ctx_size; qf->len_ = ctx_size;
qf->data_ = ctx; qf->data_ = ctx;
......
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