Commit 5aab07da authored by Antoine Kaufmann's avatar Antoine Kaufmann
Browse files

netsim,wire: ethernet sync fixes

parent 272710ee
...@@ -66,6 +66,7 @@ static void move_pkt(uint64_t cur_ts, struct netsim_interface *from, ...@@ -66,6 +66,7 @@ static void move_pkt(uint64_t cur_ts, struct netsim_interface *from,
} 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 { } else {
fprintf(stderr, "move_pkt: unsupported type=%u\n", type); fprintf(stderr, "move_pkt: unsupported type=%u\n", type);
abort(); abort();
...@@ -107,8 +108,8 @@ int main(int argc, char *argv[]) ...@@ -107,8 +108,8 @@ int main(int argc, char *argv[])
do { do {
move_pkt(cur_ts, &nsif_a, &nsif_b); move_pkt(cur_ts, &nsif_a, &nsif_b);
move_pkt(cur_ts, &nsif_b, &nsif_a); move_pkt(cur_ts, &nsif_b, &nsif_a);
ts_a = netsim_n2d_timestamp(&nsif_a); ts_a = netsim_d2n_timestamp(&nsif_a);
ts_b = netsim_n2d_timestamp(&nsif_b); ts_b = netsim_d2n_timestamp(&nsif_b);
} while ((sync_a && ts_a <= cur_ts) || } while ((sync_a && ts_a <= cur_ts) ||
(sync_b && ts_b <= cur_ts)); (sync_b && ts_b <= cur_ts));
......
...@@ -52,15 +52,15 @@ volatile union cosim_eth_proto_d2n *netsim_d2n_poll( ...@@ -52,15 +52,15 @@ volatile union cosim_eth_proto_d2n *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 cosim_eth_proto_d2n *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 cosim_eth_proto_n2d *netsim_n2d_alloc(
struct netsim_interface *nsif, uint64_t timestamp, struct netsim_interface *nsif, uint64_t timestamp,
uint64_t latency); 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); uint64_t latency, uint64_t sync_delay);
static inline uint64_t netsim_n2d_timestamp(struct netsim_interface *nsif)
{
return nsif->n2d_timestamp;
}
#endif /* ndef COSIM_NETSIM_H_ */ #endif /* ndef COSIM_NETSIM_H_ */
...@@ -350,7 +350,7 @@ volatile union cosim_pcie_proto_d2h *nicsim_d2h_alloc( ...@@ -350,7 +350,7 @@ volatile union cosim_pcie_proto_d2h *nicsim_d2h_alloc(
return NULL; return NULL;
} }
msg->dummy.timestamp = timestamp + params->pci_latency;; msg->dummy.timestamp = timestamp + params->pci_latency;
pci_last_tx_time = timestamp; pci_last_tx_time = timestamp;
d2h_pos = (d2h_pos + 1) % D2H_ENUM; d2h_pos = (d2h_pos + 1) % D2H_ENUM;
......
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