Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
f9a3a2e6
Commit
f9a3a2e6
authored
Jun 24, 2022
by
Antoine Kaufmann
Committed by
Antoine Kaufmann
Jul 08, 2022
Browse files
reformat with clang-format
parent
e51835d1
Changes
38
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
227 additions
and
239 deletions
+227
-239
lib/simbricks/nicif/nicif.c
lib/simbricks/nicif/nicif.c
+3
-6
lib/simbricks/nicif/nicif.h
lib/simbricks/nicif/nicif.h
+7
-8
lib/simbricks/pcie/if.c
lib/simbricks/pcie/if.c
+1
-2
lib/simbricks/pcie/if.h
lib/simbricks/pcie/if.h
+3
-3
lib/simbricks/pcie/proto.h
lib/simbricks/pcie/proto.h
+0
-1
sims/net/menshen/menshen_hw.cc
sims/net/menshen/menshen_hw.cc
+19
-24
sims/net/pktgen/pktgen.cc
sims/net/pktgen/pktgen.cc
+72
-80
sims/net/switch/net_switch.cc
sims/net/switch/net_switch.cc
+48
-49
sims/net/tofino/tofino.cc
sims/net/tofino/tofino.cc
+5
-4
sims/net/wire/net_wire.c
sims/net/wire/net_wire.c
+0
-1
sims/nic/corundum/corundum_verilator.cc
sims/nic/corundum/corundum_verilator.cc
+22
-20
sims/nic/corundum_bm/corundum_bm.cc
sims/nic/corundum_bm/corundum_bm.cc
+14
-7
sims/nic/i40e_bm/i40e_bm.cc
sims/nic/i40e_bm/i40e_bm.cc
+4
-4
sims/nic/i40e_bm/i40e_lan.cc
sims/nic/i40e_bm/i40e_lan.cc
+3
-1
sims/nic/i40e_bm/logger.cc
sims/nic/i40e_bm/logger.cc
+2
-2
trace/events.h
trace/events.h
+2
-3
trace/log_parser.cc
trace/log_parser.cc
+5
-6
trace/process.cc
trace/process.cc
+17
-18
No files found.
lib/simbricks/nicif/nicif.c
View file @
f9a3a2e6
...
@@ -28,12 +28,10 @@
...
@@ -28,12 +28,10 @@
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
int
SimbricksNicIfInit
(
struct
SimbricksNicIf
*
nicif
,
int
SimbricksNicIfInit
(
struct
SimbricksNicIf
*
nicif
,
const
char
*
shm_path
,
const
char
*
shm_path
,
struct
SimbricksBaseIfParams
*
netParams
,
struct
SimbricksBaseIfParams
*
netParams
,
struct
SimbricksBaseIfParams
*
pcieParams
,
struct
SimbricksBaseIfParams
*
pcieParams
,
struct
SimbricksProtoPcieDevIntro
*
di
)
struct
SimbricksProtoPcieDevIntro
*
di
)
{
{
struct
SimbricksBaseIf
*
netif
=
&
nicif
->
net
.
base
;
struct
SimbricksBaseIf
*
netif
=
&
nicif
->
net
.
base
;
struct
SimbricksBaseIf
*
pcieif
=
&
nicif
->
pcie
.
base
;
struct
SimbricksBaseIf
*
pcieif
=
&
nicif
->
pcie
.
base
;
...
@@ -97,8 +95,7 @@ int SimbricksNicIfInit(struct SimbricksNicIf *nicif,
...
@@ -97,8 +95,7 @@ int SimbricksNicIfInit(struct SimbricksNicIf *nicif,
return
SimBricksBaseIfEstablish
(
ests
,
n_bifs
);
return
SimBricksBaseIfEstablish
(
ests
,
n_bifs
);
}
}
int
SimbricksNicIfCleanup
(
struct
SimbricksNicIf
*
nicif
)
int
SimbricksNicIfCleanup
(
struct
SimbricksNicIf
*
nicif
)
{
{
SimbricksBaseIfClose
(
&
nicif
->
pcie
.
base
);
SimbricksBaseIfClose
(
&
nicif
->
pcie
.
base
);
SimbricksBaseIfClose
(
&
nicif
->
net
.
base
);
SimbricksBaseIfClose
(
&
nicif
->
net
.
base
);
/* TODO: unlink? */
/* TODO: unlink? */
...
...
lib/simbricks/nicif/nicif.h
View file @
f9a3a2e6
...
@@ -37,9 +37,7 @@ struct SimbricksNicIf {
...
@@ -37,9 +37,7 @@ struct SimbricksNicIf {
struct
SimbricksPcieIf
pcie
;
struct
SimbricksPcieIf
pcie
;
};
};
int
SimbricksNicIfInit
(
struct
SimbricksNicIf
*
nicif
,
const
char
*
shmPath
,
int
SimbricksNicIfInit
(
struct
SimbricksNicIf
*
nicif
,
const
char
*
shmPath
,
struct
SimbricksBaseIfParams
*
netParams
,
struct
SimbricksBaseIfParams
*
netParams
,
struct
SimbricksBaseIfParams
*
pcieParams
,
struct
SimbricksBaseIfParams
*
pcieParams
,
struct
SimbricksProtoPcieDevIntro
*
di
);
struct
SimbricksProtoPcieDevIntro
*
di
);
...
@@ -47,14 +45,15 @@ int SimbricksNicIfInit(struct SimbricksNicIf *nicif,
...
@@ -47,14 +45,15 @@ int SimbricksNicIfInit(struct SimbricksNicIf *nicif,
int
SimbricksNicIfCleanup
(
struct
SimbricksNicIf
*
nicif
);
int
SimbricksNicIfCleanup
(
struct
SimbricksNicIf
*
nicif
);
static
inline
int
SimbricksNicIfSync
(
struct
SimbricksNicIf
*
nicif
,
static
inline
int
SimbricksNicIfSync
(
struct
SimbricksNicIf
*
nicif
,
uint64_t
cur_ts
)
uint64_t
cur_ts
)
{
{
return
((
SimbricksNetIfOutSync
(
&
nicif
->
net
,
cur_ts
)
==
0
&&
return
((
SimbricksNetIfOutSync
(
&
nicif
->
net
,
cur_ts
)
==
0
&&
SimbricksPcieIfD2HOutSync
(
&
nicif
->
pcie
,
cur_ts
)
==
0
)
?
0
:
-
1
);
SimbricksPcieIfD2HOutSync
(
&
nicif
->
pcie
,
cur_ts
)
==
0
)
?
0
:
-
1
);
}
}
static
inline
uint64_t
SimbricksNicIfNextTimestamp
(
struct
SimbricksNicIf
*
nicif
)
static
inline
uint64_t
SimbricksNicIfNextTimestamp
(
{
struct
SimbricksNicIf
*
nicif
)
{
uint64_t
net_in
=
SimbricksNetIfInTimestamp
(
&
nicif
->
net
);
uint64_t
net_in
=
SimbricksNetIfInTimestamp
(
&
nicif
->
net
);
uint64_t
net_out
=
SimbricksNetIfOutNextSync
(
&
nicif
->
net
);
uint64_t
net_out
=
SimbricksNetIfOutNextSync
(
&
nicif
->
net
);
uint64_t
net
=
(
net_in
<=
net_out
?
net_in
:
net_out
);
uint64_t
net
=
(
net_in
<=
net_out
?
net_in
:
net_out
);
...
...
lib/simbricks/pcie/if.c
View file @
f9a3a2e6
...
@@ -24,8 +24,7 @@
...
@@ -24,8 +24,7 @@
#include "lib/simbricks/pcie/if.h"
#include "lib/simbricks/pcie/if.h"
void
SimbricksPcieIfDefaultParams
(
struct
SimbricksBaseIfParams
*
params
)
void
SimbricksPcieIfDefaultParams
(
struct
SimbricksBaseIfParams
*
params
)
{
{
SimbricksBaseIfDefaultParams
(
params
);
SimbricksBaseIfDefaultParams
(
params
);
params
->
upper_layer_proto
=
SIMBRICKS_PROTO_ID_PCIE
;
params
->
upper_layer_proto
=
SIMBRICKS_PROTO_ID_PCIE
;
params
->
in_entries_size
=
params
->
out_entries_size
=
9024
+
64
;
params
->
in_entries_size
=
params
->
out_entries_size
=
9024
+
64
;
...
...
lib/simbricks/pcie/if.h
View file @
f9a3a2e6
...
@@ -28,8 +28,8 @@
...
@@ -28,8 +28,8 @@
#include <stddef.h>
#include <stddef.h>
#include <stdint.h>
#include <stdint.h>
#include <simbricks/base/if.h>
#include <simbricks/base/generic.h>
#include <simbricks/base/generic.h>
#include <simbricks/base/if.h>
#include <simbricks/pcie/proto.h>
#include <simbricks/pcie/proto.h>
void
SimbricksPcieIfDefaultParams
(
struct
SimbricksBaseIfParams
*
params
);
void
SimbricksPcieIfDefaultParams
(
struct
SimbricksBaseIfParams
*
params
);
...
@@ -40,8 +40,8 @@ struct SimbricksPcieIf {
...
@@ -40,8 +40,8 @@ struct SimbricksPcieIf {
/** Generate queue access functions for both directions */
/** Generate queue access functions for both directions */
SIMBRICKS_BASEIF_GENERIC
(
SimbricksPcieIfH2D
,
SimbricksProtoPcieH2D
,
SIMBRICKS_BASEIF_GENERIC
(
SimbricksPcieIfH2D
,
SimbricksProtoPcieH2D
,
SimbricksPcieIf
);
SimbricksPcieIf
);
SIMBRICKS_BASEIF_GENERIC
(
SimbricksPcieIfD2H
,
SimbricksProtoPcieD2H
,
SIMBRICKS_BASEIF_GENERIC
(
SimbricksPcieIfD2H
,
SimbricksProtoPcieD2H
,
SimbricksPcieIf
);
SimbricksPcieIf
);
#endif // SIMBRICKS_PCIE_IF_H_
#endif // SIMBRICKS_PCIE_IF_H_
lib/simbricks/pcie/proto.h
View file @
f9a3a2e6
...
@@ -89,7 +89,6 @@ struct SimbricksProtoPcieDevIntro {
...
@@ -89,7 +89,6 @@ struct SimbricksProtoPcieDevIntro {
uint16_t
psi_msix_cap_offset
;
uint16_t
psi_msix_cap_offset
;
}
__attribute__
((
packed
));
}
__attribute__
((
packed
));
/** welcome message sent by host to device */
/** welcome message sent by host to device */
struct
SimbricksProtoPcieHostIntro
{
struct
SimbricksProtoPcieHostIntro
{
uint32_t
dummy
;
/* not used, but need to avoid empty struct for standard C */
uint32_t
dummy
;
/* not used, but need to avoid empty struct for standard C */
...
...
sims/net/menshen/menshen_hw.cc
View file @
f9a3a2e6
#include <signal.h>
#include <verilated.h>
#include <verilated.h>
#include <verilated_fst_c.h>
#include <verilated_fst_c.h>
#include <iostream>
#include <iostream>
#include <signal.h>
#include <vector>
#include <vector>
#include "sims/net/menshen/obj_dir/Vrmt_wrapper.h"
#include "sims/net/menshen/obj_dir/Vrmt_wrapper.h"
...
@@ -21,7 +21,7 @@ int synchronized = 0;
...
@@ -21,7 +21,7 @@ int synchronized = 0;
uint64_t
sync_period
=
(
500
*
1000ULL
);
// 500ns
uint64_t
sync_period
=
(
500
*
1000ULL
);
// 500ns
uint64_t
eth_latency
=
(
500
*
1000ULL
);
// 500ns
uint64_t
eth_latency
=
(
500
*
1000ULL
);
// 500ns
int
sync_mode
=
SIMBRICKS_PROTO_SYNC_SIMBRICKS
;
int
sync_mode
=
SIMBRICKS_PROTO_SYNC_SIMBRICKS
;
static
uint64_t
clock_period
=
4
*
1000ULL
;
// 4ns -> 250MHz
static
uint64_t
clock_period
=
4
*
1000ULL
;
// 4ns -> 250MHz
uint64_t
main_time
=
0
;
uint64_t
main_time
=
0
;
int
exiting
=
0
;
int
exiting
=
0
;
EthernetTx
*
txMAC
;
EthernetTx
*
txMAC
;
...
@@ -61,19 +61,16 @@ static void dump_if(Vrmt_wrapper *top) {
...
@@ -61,19 +61,16 @@ static void dump_if(Vrmt_wrapper *top) {
std
::
cout
<<
" vlan_drop_flags = "
<<
top
->
vlan_drop_flags
<<
std
::
endl
;
std
::
cout
<<
" vlan_drop_flags = "
<<
top
->
vlan_drop_flags
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
" s_axis_tdata = { "
;
std
::
cout
<<
" s_axis_tdata = { "
;
for
(
size_t
i
=
0
;
for
(
size_t
i
=
0
;
i
<
sizeof
(
top
->
s_axis_tdata
)
/
sizeof
(
top
->
s_axis_tdata
[
0
]);
i
<
sizeof
(
top
->
s_axis_tdata
)
/
sizeof
(
top
->
s_axis_tdata
[
0
]);
i
++
)
{
i
++
)
{
std
::
cout
<<
top
->
s_axis_tdata
[
i
]
<<
" "
;
std
::
cout
<<
top
->
s_axis_tdata
[
i
]
<<
" "
;
}
}
std
::
cout
<<
"}"
<<
std
::
endl
;
std
::
cout
<<
"}"
<<
std
::
endl
;
std
::
cout
<<
" s_axis_tkeep = "
<<
top
->
s_axis_tkeep
<<
std
::
endl
;
std
::
cout
<<
" s_axis_tkeep = "
<<
top
->
s_axis_tkeep
<<
std
::
endl
;
std
::
cout
<<
" s_axis_tuser = { "
;
std
::
cout
<<
" s_axis_tuser = { "
;
for
(
size_t
i
=
0
;
for
(
size_t
i
=
0
;
i
<
sizeof
(
top
->
s_axis_tuser
)
/
sizeof
(
top
->
s_axis_tuser
[
0
]);
i
<
sizeof
(
top
->
s_axis_tuser
)
/
sizeof
(
top
->
s_axis_tuser
[
0
]);
i
++
)
{
i
++
)
{
std
::
cout
<<
top
->
s_axis_tuser
[
i
]
<<
" "
;
std
::
cout
<<
top
->
s_axis_tuser
[
i
]
<<
" "
;
}
}
std
::
cout
<<
"}"
<<
std
::
endl
;
std
::
cout
<<
"}"
<<
std
::
endl
;
...
@@ -82,19 +79,16 @@ static void dump_if(Vrmt_wrapper *top) {
...
@@ -82,19 +79,16 @@ static void dump_if(Vrmt_wrapper *top) {
std
::
cout
<<
" s_axis_tlast = "
<<
top
->
s_axis_tlast
<<
std
::
endl
;
std
::
cout
<<
" s_axis_tlast = "
<<
top
->
s_axis_tlast
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
" m_axis_tdata = { "
;
std
::
cout
<<
" m_axis_tdata = { "
;
for
(
size_t
i
=
0
;
for
(
size_t
i
=
0
;
i
<
sizeof
(
top
->
m_axis_tdata
)
/
sizeof
(
top
->
m_axis_tdata
[
0
]);
i
<
sizeof
(
top
->
m_axis_tdata
)
/
sizeof
(
top
->
m_axis_tdata
[
0
]);
i
++
)
{
i
++
)
{
std
::
cout
<<
top
->
m_axis_tdata
[
i
]
<<
" "
;
std
::
cout
<<
top
->
m_axis_tdata
[
i
]
<<
" "
;
}
}
std
::
cout
<<
"}"
<<
std
::
endl
;
std
::
cout
<<
"}"
<<
std
::
endl
;
std
::
cout
<<
" m_axis_tkeep = "
<<
top
->
m_axis_tkeep
<<
std
::
endl
;
std
::
cout
<<
" m_axis_tkeep = "
<<
top
->
m_axis_tkeep
<<
std
::
endl
;
std
::
cout
<<
" m_axis_tuser = { "
;
std
::
cout
<<
" m_axis_tuser = { "
;
for
(
size_t
i
=
0
;
for
(
size_t
i
=
0
;
i
<
sizeof
(
top
->
m_axis_tuser
)
/
sizeof
(
top
->
m_axis_tuser
[
0
]);
i
<
sizeof
(
top
->
m_axis_tuser
)
/
sizeof
(
top
->
m_axis_tuser
[
0
]);
i
++
)
{
i
++
)
{
std
::
cout
<<
top
->
m_axis_tuser
[
i
]
<<
" "
;
std
::
cout
<<
top
->
m_axis_tuser
[
i
]
<<
" "
;
}
}
std
::
cout
<<
"}"
<<
std
::
endl
;
std
::
cout
<<
"}"
<<
std
::
endl
;
...
@@ -116,7 +110,8 @@ class EthernetTx {
...
@@ -116,7 +110,8 @@ class EthernetTx {
void
packet_done
(
uint16_t
port_id
)
{
void
packet_done
(
uint16_t
port_id
)
{
if
(
port_id
>=
ports
.
size
())
{
if
(
port_id
>=
ports
.
size
())
{
#ifdef ETH_DEBUG
#ifdef ETH_DEBUG
std
::
cerr
<<
"EthernetTx: invalid port set ("
<<
port_id
<<
"), setting to 0"
<<
std
::
endl
;
std
::
cerr
<<
"EthernetTx: invalid port set ("
<<
port_id
<<
"), setting to 0"
<<
std
::
endl
;
#endif
#endif
port_id
=
0
;
port_id
=
0
;
}
}
...
@@ -138,7 +133,7 @@ class EthernetTx {
...
@@ -138,7 +133,7 @@ class EthernetTx {
if
(
top
.
m_axis_tvalid
)
{
if
(
top
.
m_axis_tvalid
)
{
/* iterate over all bytes on the bus */
/* iterate over all bytes on the bus */
uint8_t
*
txbus
=
(
uint8_t
*
)
&
top
.
m_axis_tdata
;
uint8_t
*
txbus
=
(
uint8_t
*
)
&
top
.
m_axis_tdata
;
for
(
size_t
i
=
0
;
i
<
sizeof
(
top
.
m_axis_tdata
);
i
++
)
{
for
(
size_t
i
=
0
;
i
<
sizeof
(
top
.
m_axis_tdata
);
i
++
)
{
if
((
top
.
m_axis_tkeep
&
(
1ULL
<<
i
))
!=
0
)
{
if
((
top
.
m_axis_tkeep
&
(
1ULL
<<
i
))
!=
0
)
{
assert
(
packet_len
<
2048
);
assert
(
packet_len
<
2048
);
...
@@ -205,7 +200,8 @@ class EthernetRx {
...
@@ -205,7 +200,8 @@ class EthernetRx {
if
(
packet_off
!=
0
&&
!
top
.
s_axis_tready
)
{
if
(
packet_off
!=
0
&&
!
top
.
s_axis_tready
)
{
// no ready signal, can't advance
// no ready signal, can't advance
#ifdef ETH_DEBUG
#ifdef ETH_DEBUG
std
::
cerr
<<
"eth rx: no ready "
<<
fifo_pos_rd
<<
" "
<<
packet_off
<<
std
::
endl
;
std
::
cerr
<<
"eth rx: no ready "
<<
fifo_pos_rd
<<
" "
<<
packet_off
<<
std
::
endl
;
#endif
#endif
}
else
if
(
packet_off
==
fifo_lens
[
fifo_pos_rd
])
{
}
else
if
(
packet_off
==
fifo_lens
[
fifo_pos_rd
])
{
// done with packet
// done with packet
...
@@ -228,7 +224,7 @@ class EthernetRx {
...
@@ -228,7 +224,7 @@ class EthernetRx {
std
::
cout
<<
"rx from "
<<
fifo_pos_rd
<<
std
::
endl
;
std
::
cout
<<
"rx from "
<<
fifo_pos_rd
<<
std
::
endl
;
#endif
#endif
top
.
s_axis_tkeep
=
0
;
top
.
s_axis_tkeep
=
0
;
uint8_t
*
rdata
=
(
uint8_t
*
)
&
top
.
s_axis_tdata
;
uint8_t
*
rdata
=
(
uint8_t
*
)
&
top
.
s_axis_tdata
;
size_t
i
;
size_t
i
;
/*if (packet_off == 0) {
/*if (packet_off == 0) {
...
@@ -236,13 +232,14 @@ class EthernetRx {
...
@@ -236,13 +232,14 @@ class EthernetRx {
}*/
}*/
if
(
packet_off
==
0
)
if
(
packet_off
==
0
)
top
.
s_axis_tuser
[
0
]
=
fifo_lens
[
fifo_pos_rd
]
|
top
.
s_axis_tuser
[
0
]
=
fifo_lens
[
fifo_pos_rd
]
|
(((
uint64_t
)
fifo_ports
[
fifo_pos_rd
])
<<
16
)
|
(((
uint64_t
)
fifo_ports
[
fifo_pos_rd
])
<<
16
)
|
(((
uint64_t
)
fifo_ports
[
fifo_pos_rd
])
<<
24
);
(((
uint64_t
)
fifo_ports
[
fifo_pos_rd
])
<<
24
);
else
else
top
.
s_axis_tuser
[
0
]
=
0
;
top
.
s_axis_tuser
[
0
]
=
0
;
for
(
i
=
0
;
i
<
sizeof
(
top
.
s_axis_tdata
)
&&
for
(
i
=
0
;
i
<
sizeof
(
top
.
s_axis_tdata
)
&&
packet_off
<
fifo_lens
[
fifo_pos_rd
];
i
++
)
{
packet_off
<
fifo_lens
[
fifo_pos_rd
];
i
++
)
{
rdata
[
i
]
=
fifo_bufs
[
fifo_pos_rd
][
packet_off
];
rdata
[
i
]
=
fifo_bufs
[
fifo_pos_rd
][
packet_off
];
top
.
s_axis_tkeep
|=
(
1ULL
<<
i
);
top
.
s_axis_tkeep
|=
(
1ULL
<<
i
);
packet_off
++
;
packet_off
++
;
...
@@ -298,8 +295,8 @@ int main(int argc, char *argv[]) {
...
@@ -298,8 +295,8 @@ int main(int argc, char *argv[]) {
reset_inputs
(
top
);
reset_inputs
(
top
);
top
->
aresetn
=
0
;
top
->
aresetn
=
0
;
for
(
int
i
=
0
;
i
<
16
;
i
++
)
{
for
(
int
i
=
0
;
i
<
16
;
i
++
)
{
top
->
eval
();
top
->
eval
();
top
->
clk
=
!
top
->
clk
;
top
->
clk
=
!
top
->
clk
;
}
}
top
->
aresetn
=
1
;
top
->
aresetn
=
1
;
...
@@ -321,7 +318,7 @@ int main(int argc, char *argv[]) {
...
@@ -321,7 +318,7 @@ int main(int argc, char *argv[]) {
}
}
ports
.
push_back
(
np
);
ports
.
push_back
(
np
);
}
}
txMAC
=
new
EthernetTx
(
*
top
);
txMAC
=
new
EthernetTx
(
*
top
);
rxMAC
=
new
EthernetRx
(
*
top
);
rxMAC
=
new
EthernetRx
(
*
top
);
...
@@ -363,7 +360,5 @@ int main(int argc, char *argv[]) {
...
@@ -363,7 +360,5 @@ int main(int argc, char *argv[]) {
#endif
#endif
dump_if
(
top
);
dump_if
(
top
);
return
0
;
return
0
;
}
}
sims/net/pktgen/pktgen.cc
View file @
f9a3a2e6
...
@@ -22,11 +22,11 @@
...
@@ -22,11 +22,11 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
*/
#include <unistd.h>
#include <pcap/pcap.h>
#include <linux/ip.h>
#include <linux/if_ether.h>
#include <arpa/inet.h>
#include <arpa/inet.h>
#include <linux/if_ether.h>
#include <linux/ip.h>
#include <pcap/pcap.h>
#include <unistd.h>
#include <cassert>
#include <cassert>
#include <climits>
#include <climits>
...
@@ -49,15 +49,15 @@ extern "C" {
...
@@ -49,15 +49,15 @@ extern "C" {
struct
SimbricksBaseIfParams
netParams
;
struct
SimbricksBaseIfParams
netParams
;
static
pcap_dumper_t
*
dumpfile
=
nullptr
;
static
pcap_dumper_t
*
dumpfile
=
nullptr
;
#define PKT_LEN 1500 //byte
#define PKT_LEN 1500
//
byte
static
uint64_t
bit_rate
=
100
*
1000ULL
*
1000ULL
*
1000ULL
;
// 100 Gbps
static
uint64_t
bit_rate
=
100
*
1000ULL
*
1000ULL
*
1000ULL
;
// 100 Gbps
static
uint64_t
target_tick
=
1
*
1000ULL
*
1000ULL
*
1000ULL
*
1000ULL
;
// 1s
static
uint64_t
target_tick
=
1
*
1000ULL
*
1000ULL
*
1000ULL
*
1000ULL
;
// 1s
static
uint64_t
last_pkt_sent
=
0
;
static
uint64_t
last_pkt_sent
=
0
;
static
uint64_t
pkt_recv_num
=
0
;
static
uint64_t
pkt_recv_num
=
0
;
static
uint64_t
pkt_recv_byte
=
0
;
static
uint64_t
pkt_recv_byte
=
0
;
static
uint64_t
pkt_tx_num
=
0
;
static
uint64_t
pkt_tx_num
=
0
;
static
uint64_t
pkt_tx_byte
=
0
;
static
uint64_t
pkt_tx_byte
=
0
;
static
uint64_t
period
=
(
1E12
*
8
*
PKT_LEN
)
/
bit_rate
;
// per packet
static
uint64_t
period
=
(
1E12
*
8
*
PKT_LEN
)
/
bit_rate
;
// per packet
static
uint8_t
packet
[
PKT_LEN
];
static
uint8_t
packet
[
PKT_LEN
];
#ifdef NETSWITCH_STAT
#ifdef NETSWITCH_STAT
...
@@ -92,7 +92,7 @@ struct MAC {
...
@@ -92,7 +92,7 @@ struct MAC {
}
}
};
};
struct
mac_addr
{
struct
mac_addr
{
uint8_t
addr
[
6
];
uint8_t
addr
[
6
];
};
};
...
@@ -109,7 +109,6 @@ struct hash<MAC> {
...
@@ -109,7 +109,6 @@ struct hash<MAC> {
};
};
}
// namespace std
}
// namespace std
/** Abstract base switch port */
/** Abstract base switch port */
class
Port
{
class
Port
{
public:
public:
...
@@ -128,13 +127,12 @@ class Port {
...
@@ -128,13 +127,12 @@ class Port {
virtual
bool
IsSync
()
=
0
;
virtual
bool
IsSync
()
=
0
;
virtual
void
Sync
(
uint64_t
cur_ts
)
=
0
;
virtual
void
Sync
(
uint64_t
cur_ts
)
=
0
;
virtual
uint64_t
NextTimestamp
()
=
0
;
virtual
uint64_t
NextTimestamp
()
=
0
;
virtual
enum
RxPollState
RxPacket
(
virtual
enum
RxPollState
RxPacket
(
const
void
*&
data
,
size_t
&
len
,
const
void
*&
data
,
size_t
&
len
,
uint64_t
cur_ts
)
=
0
;
uint64_t
cur_ts
)
=
0
;
virtual
void
RxDone
()
=
0
;
virtual
void
RxDone
()
=
0
;
virtual
bool
TxPacket
(
const
void
*
data
,
size_t
len
,
uint64_t
cur_ts
)
=
0
;
virtual
bool
TxPacket
(
const
void
*
data
,
size_t
len
,
uint64_t
cur_ts
)
=
0
;
};
};
/** Normal network switch port (conneting to a NIC) */
/** Normal network switch port (conneting to a NIC) */
class
NetPort
:
public
Port
{
class
NetPort
:
public
Port
{
protected:
protected:
...
@@ -150,8 +148,12 @@ class NetPort : public Port {
...
@@ -150,8 +148,12 @@ class NetPort : public Port {
memset
(
&
dest_mac
,
0
,
sizeof
(
dest_mac
));
memset
(
&
dest_mac
,
0
,
sizeof
(
dest_mac
));
}
}
NetPort
(
const
NetPort
&
other
)
:
netifObj_
(
other
.
netifObj_
),
NetPort
(
const
NetPort
&
other
)
netif_
(
&
netifObj_
),
rx_
(
other
.
rx_
),
sync_
(
other
.
sync_
)
{}
:
netifObj_
(
other
.
netifObj_
),
netif_
(
&
netifObj_
),
rx_
(
other
.
rx_
),
sync_
(
other
.
sync_
)
{
}
virtual
bool
Connect
(
const
char
*
path
,
int
sync
)
override
{
virtual
bool
Connect
(
const
char
*
path
,
int
sync
)
override
{
sync_
=
sync
;
sync_
=
sync
;
...
@@ -163,15 +165,16 @@ class NetPort : public Port {
...
@@ -163,15 +165,16 @@ class NetPort : public Port {
}
}
virtual
void
Sync
(
uint64_t
cur_ts
)
override
{
virtual
void
Sync
(
uint64_t
cur_ts
)
override
{
while
(
SimbricksNetIfOutSync
(
netif_
,
cur_ts
));
while
(
SimbricksNetIfOutSync
(
netif_
,
cur_ts
))
;
}
}
virtual
uint64_t
NextTimestamp
()
override
{
virtual
uint64_t
NextTimestamp
()
override
{
return
SimbricksNetIfInTimestamp
(
netif_
);
return
SimbricksNetIfInTimestamp
(
netif_
);
}
}
virtual
enum
RxPollState
RxPacket
(
virtual
enum
RxPollState
RxPacket
(
const
void
*&
data
,
size_t
&
len
,
const
void
*&
data
,
size_t
&
len
,
uint64_t
cur_ts
)
override
{
uint64_t
cur_ts
)
override
{
assert
(
rx_
==
nullptr
);
assert
(
rx_
==
nullptr
);
rx_
=
SimbricksNetIfInPoll
(
netif_
,
cur_ts
);
rx_
=
SimbricksNetIfInPoll
(
netif_
,
cur_ts
);
...
@@ -198,10 +201,10 @@ class NetPort : public Port {
...
@@ -198,10 +201,10 @@ class NetPort : public Port {
rx_
=
nullptr
;
rx_
=
nullptr
;
}
}
virtual
bool
TxPacket
(
virtual
bool
TxPacket
(
const
void
*
data
,
size_t
len
,
const
void
*
data
,
size_t
len
,
uint64_t
cur_ts
)
override
{
uint64_t
cur_ts
)
override
{
volatile
union
SimbricksProtoNetMsg
*
msg_to
=
volatile
union
SimbricksProtoNetMsg
*
msg_to
=
SimbricksNetIfOutAlloc
(
netif_
,
cur_ts
);
SimbricksNetIfOutAlloc
(
netif_
,
cur_ts
);
if
(
!
msg_to
&&
!
sync_
)
{
if
(
!
msg_to
&&
!
sync_
)
{
return
false
;
return
false
;
}
else
if
(
!
msg_to
&&
sync_
)
{
}
else
if
(
!
msg_to
&&
sync_
)
{
...
@@ -219,7 +222,6 @@ class NetPort : public Port {
...
@@ -219,7 +222,6 @@ class NetPort : public Port {
}
}
};
};
/** Hosting network switch port (connected to another network) */
/** Hosting network switch port (connected to another network) */
class
NetHostPort
:
public
NetPort
{
class
NetHostPort
:
public
NetPort
{
protected:
protected:
...
@@ -244,7 +246,7 @@ class NetHostPort : public NetPort {
...
@@ -244,7 +246,7 @@ class NetHostPort : public NetPort {
if
(
!
sync
)
if
(
!
sync
)
params
.
sync_mode
=
kSimbricksBaseIfSyncDisabled
;
params
.
sync_mode
=
kSimbricksBaseIfSyncDisabled
;
int
ret
=
SimbricksNicIfInit
(
&
nicif_
,
shm_path
.
c_str
(),
&
params
,
nullptr
,
int
ret
=
SimbricksNicIfInit
(
&
nicif_
,
shm_path
.
c_str
(),
&
params
,
nullptr
,
nullptr
);
nullptr
);
sync_
=
SimbricksBaseIfSyncEnabled
(
&
netif_
->
base
);
sync_
=
SimbricksBaseIfSyncEnabled
(
&
netif_
->
base
);
return
ret
==
0
;
return
ret
==
0
;
}
}
...
@@ -254,7 +256,6 @@ class NetHostPort : public NetPort {
...
@@ -254,7 +256,6 @@ class NetHostPort : public NetPort {
}
}
};
};
/* Global variables */
/* Global variables */
static
uint64_t
cur_ts
=
0
;
static
uint64_t
cur_ts
=
0
;
static
int
exiting
=
0
;
static
int
exiting
=
0
;
...
@@ -283,12 +284,12 @@ static void forward_pkt(const void *pkt_data, size_t pkt_len, size_t port_id) {
...
@@ -283,12 +284,12 @@ static void forward_pkt(const void *pkt_data, size_t pkt_len, size_t port_id) {
// log to pcap file if initialized
// log to pcap file if initialized
if
(
dumpfile
)
{
if
(
dumpfile
)
{
memset
(
&
ph
,
0
,
sizeof
(
ph
));
memset
(
&
ph
,
0
,
sizeof
(
ph
));
ph
.
ts
.
tv_sec
=
cur_ts
/
1000000000000ULL
;
ph
.
ts
.
tv_sec
=
cur_ts
/
1000000000000ULL
;
ph
.
ts
.
tv_usec
=
(
cur_ts
%
1000000000000ULL
)
/
1000ULL
;
ph
.
ts
.
tv_usec
=
(
cur_ts
%
1000000000000ULL
)
/
1000ULL
;
ph
.
caplen
=
pkt_len
;
ph
.
caplen
=
pkt_len
;
ph
.
len
=
pkt_len
;
ph
.
len
=
pkt_len
;
pcap_dump
((
unsigned
char
*
)
dumpfile
,
&
ph
,
(
unsigned
char
*
)
pkt_data
);
pcap_dump
((
unsigned
char
*
)
dumpfile
,
&
ph
,
(
unsigned
char
*
)
pkt_data
);
}
}
// print sending tick: [packet type] source_IP -> dest_IP len:
// print sending tick: [packet type] source_IP -> dest_IP len:
...
@@ -296,22 +297,21 @@ static void forward_pkt(const void *pkt_data, size_t pkt_len, size_t port_id) {
...
@@ -296,22 +297,21 @@ static void forward_pkt(const void *pkt_data, size_t pkt_len, size_t port_id) {
uint16_t
eth_proto
;
uint16_t
eth_proto
;
struct
ethhdr
*
hdr
;
struct
ethhdr
*
hdr
;
struct
iphdr
*
iph
;
struct
iphdr
*
iph
;
hdr
=
(
struct
ethhdr
*
)
pkt_data
;
hdr
=
(
struct
ethhdr
*
)
pkt_data
;
eth_proto
=
ntohs
(
hdr
->
h_proto
);
eth_proto
=
ntohs
(
hdr
->
h_proto
);
iph
=
(
struct
iphdr
*
)(
hdr
+
1
);
iph
=
(
struct
iphdr
*
)(
hdr
+
1
);
fprintf
(
stderr
,
"%20lu: "
,
cur_ts
);
fprintf
(
stderr
,
"%20lu: "
,
cur_ts
);
if
(
eth_proto
==
ETH_P_IP
){
if
(
eth_proto
==
ETH_P_IP
)
{
fprintf
(
stderr
,
"[ IP] "
);
fprintf
(
stderr
,
"[ IP] "
);
}
}
else
if
(
eth_proto
==
ETH_P_ARP
)
{
else
if
(
eth_proto
==
ETH_P_ARP
){
fprintf
(
stderr
,
"[ARP] "
);
fprintf
(
stderr
,
"[ARP] "
);
}
}
else
{
else
{
fprintf
(
stderr
,
"unkwon eth type
\n
"
);
fprintf
(
stderr
,
"unkwon eth type
\n
"
);
}
}
fprintf
(
stderr
,
"%8X -> %8X len: %lu
\n
"
,
iph
->
saddr
,
iph
->
daddr
,
iph
->
tot_len
+
sizeof
(
struct
ethhdr
));
fprintf
(
stderr
,
"%8X -> %8X len: %lu
\n
"
,
iph
->
saddr
,
iph
->
daddr
,
iph
->
tot_len
+
sizeof
(
struct
ethhdr
));
#endif
#endif
if
(
!
dest_port
.
TxPacket
(
pkt_data
,
pkt_len
,
cur_ts
))
if
(
!
dest_port
.
TxPacket
(
pkt_data
,
pkt_len
,
cur_ts
))
...
@@ -326,26 +326,25 @@ static void pollq(Port &port, size_t iport) {
...
@@ -326,26 +326,25 @@ static void pollq(Port &port, size_t iport) {
#ifdef NETSWITCH_STAT
#ifdef NETSWITCH_STAT
d2n_poll_total
+=
1
;
d2n_poll_total
+=
1
;
if
(
stat_flag
){
if
(
stat_flag
)
{
s_d2n_poll_total
+=
1
;
s_d2n_poll_total
+=
1
;
}
}
#endif
#endif
#ifdef NETSWITCH_STAT
#ifdef NETSWITCH_STAT
d2n_poll_suc
+=
1
;
d2n_poll_suc
+=
1
;
if
(
stat_flag
){
if
(
stat_flag
)
{
s_d2n_poll_suc
+=
1
;
s_d2n_poll_suc
+=
1
;
}
}
#endif
#endif
enum
Port
::
RxPollState
poll
=
port
.
RxPacket
(
pkt_data
,
pkt_len
,
cur_ts
);
enum
Port
::
RxPollState
poll
=
port
.
RxPacket
(
pkt_data
,
pkt_len
,
cur_ts
);
if
(
poll
==
Port
::
kRxPollFail
)
{
if
(
poll
==
Port
::
kRxPollFail
)
{
return
;
// do nothing
return
;
// do nothing
}
}
if
(
poll
==
Port
::
kRxPollSuccess
)
{
if
(
poll
==
Port
::
kRxPollSuccess
)
{
// stat received bytes
//stat received bytes
pkt_recv_num
++
;
pkt_recv_num
++
;
pkt_recv_byte
+=
pkt_len
;
pkt_recv_byte
+=
pkt_len
;
...
@@ -372,7 +371,7 @@ static void pollq(Port &port, size_t iport) {
...
@@ -372,7 +371,7 @@ static void pollq(Port &port, size_t iport) {
}
else
if
(
poll
==
Port
::
kRxPollSync
)
{
}
else
if
(
poll
==
Port
::
kRxPollSync
)
{
#ifdef NETSWITCH_STAT
#ifdef NETSWITCH_STAT
d2n_poll_sync
+=
1
;
d2n_poll_sync
+=
1
;
if
(
stat_flag
){
if
(
stat_flag
)
{
s_d2n_poll_sync
+=
1
;
s_d2n_poll_sync
+=
1
;
}
}
#endif
#endif
...
@@ -381,31 +380,26 @@ static void pollq(Port &port, size_t iport) {
...
@@ -381,31 +380,26 @@ static void pollq(Port &port, size_t iport) {
abort
();
abort
();
}
}
port
.
RxDone
();
port
.
RxDone
();
}
}
static
void
sendq
(
Port
&
port
,
size_t
iport
)
{
static
void
sendq
(
Port
&
port
,
size_t
iport
){
// then send
//then send
if
(
port
.
IsSync
())
{
if
(
port
.
IsSync
()){
while
((
last_pkt_sent
+
period
)
<=
cur_ts
)
{
while
((
last_pkt_sent
+
period
)
<=
cur_ts
){
port
.
TxPacket
(
packet
,
PKT_LEN
,
last_pkt_sent
+
period
);
port
.
TxPacket
(
packet
,
PKT_LEN
,
last_pkt_sent
+
period
);
last_pkt_sent
+=
period
;
last_pkt_sent
+=
period
;
pkt_tx_num
++
;
pkt_tx_num
++
;
pkt_tx_byte
+=
PKT_LEN
;
pkt_tx_byte
+=
PKT_LEN
;
}
}
}
}
else
{
else
{
port
.
TxPacket
(
packet
,
PKT_LEN
,
last_pkt_sent
+
period
);
port
.
TxPacket
(
packet
,
PKT_LEN
,
last_pkt_sent
+
period
);
}
}
// if not sync: send packet
// if not sync: send packet
// else: send packet periodically until allowed time
// else: send packet periodically until allowed time
// while(allowed_timestamp){ since_last_send + period = to_send_time <= curtick
// while(allowed_timestamp){ since_last_send + period = to_send_time <=
// curtick
// txpacket(todest)
// txpacket(todest)
// }
// }
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
...
@@ -459,8 +453,8 @@ int main(int argc, char *argv[]) {
...
@@ -459,8 +453,8 @@ int main(int argc, char *argv[]) {
pc
=
pcap_open_dead_with_tstamp_precision
(
DLT_EN10MB
,
65535
,
pc
=
pcap_open_dead_with_tstamp_precision
(
DLT_EN10MB
,
65535
,
PCAP_TSTAMP_PRECISION_NANO
);
PCAP_TSTAMP_PRECISION_NANO
);
if
(
pc
==
nullptr
)
{
if
(
pc
==
nullptr
)
{
perror
(
"pcap_open_dead failed"
);
perror
(
"pcap_open_dead failed"
);
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
dumpfile
=
pcap_dump_open
(
pc
,
optarg
);
dumpfile
=
pcap_dump_open
(
pc
,
optarg
);
...
@@ -474,13 +468,12 @@ int main(int argc, char *argv[]) {
...
@@ -474,13 +468,12 @@ int main(int argc, char *argv[]) {
case
'b'
:
case
'b'
:
brate
=
strtol
(
optarg
,
NULL
,
0
);
brate
=
strtol
(
optarg
,
NULL
,
0
);
fprintf
(
stderr
,
"bit rate set to: %d Gbps
\n
"
,
brate
);
fprintf
(
stderr
,
"bit rate set to: %d Gbps
\n
"
,
brate
);
if
(
brate
==
0
){
if
(
brate
==
0
)
{
period
=
ULLONG_MAX
;
period
=
ULLONG_MAX
;
}
else
{
bit_rate
=
brate
*
1000ULL
*
1000ULL
*
1000ULL
;
period
=
(
1E12
*
8
*
PKT_LEN
)
/
bit_rate
;
// per packet
}
}
else
{
bit_rate
=
brate
*
1000ULL
*
1000ULL
*
1000ULL
;
period
=
(
1E12
*
8
*
PKT_LEN
)
/
bit_rate
;
// per packet
}
assert
(
brate
<
200
);
assert
(
brate
<
200
);
break
;
break
;
...
@@ -498,22 +491,20 @@ int main(int argc, char *argv[]) {
...
@@ -498,22 +491,20 @@ int main(int argc, char *argv[]) {
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
Port
*
pkt_port
=
ports
.
front
();
Port
*
pkt_port
=
ports
.
front
();
pkt_port
->
my_mac
.
addr
[
5
]
=
my_num
;
pkt_port
->
my_mac
.
addr
[
5
]
=
my_num
;
if
(
my_num
%
2
)
{
// odd num
if
(
my_num
%
2
)
{
// odd num
pkt_port
->
dest_mac
.
addr
[
5
]
=
my_num
-
1
;
pkt_port
->
dest_mac
.
addr
[
5
]
=
my_num
-
1
;
}
}
else
{
// even number
else
{
// even number
pkt_port
->
dest_mac
.
addr
[
5
]
=
my_num
+
1
;
pkt_port
->
dest_mac
.
addr
[
5
]
=
my_num
+
1
;
}
}
struct
mac_addr
*
mac_tmp
=
(
struct
mac_addr
*
)(
&
packet
[
0
]);
struct
mac_addr
*
mac_tmp
=
(
struct
mac_addr
*
)(
&
packet
[
0
]);
mac_tmp
->
addr
[
5
]
=
pkt_port
->
dest_mac
.
addr
[
5
];
//dest mac
mac_tmp
->
addr
[
5
]
=
pkt_port
->
dest_mac
.
addr
[
5
];
//
dest mac
mac_tmp
=
(
struct
mac_addr
*
)(
&
packet
[
6
]);
mac_tmp
=
(
struct
mac_addr
*
)(
&
packet
[
6
]);
mac_tmp
->
addr
[
5
]
=
pkt_port
->
my_mac
.
addr
[
5
];
//source mac
mac_tmp
->
addr
[
5
]
=
pkt_port
->
my_mac
.
addr
[
5
];
//
source mac
int
kk
;
int
kk
;
for
(
kk
=
12
;
kk
<
PKT_LEN
-
12
;
kk
++
){
for
(
kk
=
12
;
kk
<
PKT_LEN
-
12
;
kk
++
)
{
packet
[
kk
]
=
0xFF
;
packet
[
kk
]
=
0xFF
;
}
}
...
@@ -525,7 +516,6 @@ int main(int argc, char *argv[]) {
...
@@ -525,7 +516,6 @@ int main(int argc, char *argv[]) {
signal
(
SIGUSR2
,
sigusr2_handler
);
signal
(
SIGUSR2
,
sigusr2_handler
);
#endif
#endif
printf
(
"start polling
\n
"
);
printf
(
"start polling
\n
"
);
while
(
!
exiting
)
{
while
(
!
exiting
)
{
// Sync all interfaces
// Sync all interfaces
...
@@ -551,7 +541,7 @@ int main(int argc, char *argv[]) {
...
@@ -551,7 +541,7 @@ int main(int argc, char *argv[]) {
if
(
min_ts
<
ULLONG_MAX
)
{
if
(
min_ts
<
ULLONG_MAX
)
{
// a bit broken but should probably do
// a bit broken but should probably do
cur_ts
=
min_ts
;
cur_ts
=
min_ts
;
if
(
cur_ts
>=
target_tick
){
if
(
cur_ts
>=
target_tick
)
{
printf
(
"run to %lu tics
\n
"
,
cur_ts
);
printf
(
"run to %lu tics
\n
"
,
cur_ts
);
exiting
=
1
;
exiting
=
1
;
}
}
...
@@ -559,8 +549,10 @@ int main(int argc, char *argv[]) {
...
@@ -559,8 +549,10 @@ int main(int argc, char *argv[]) {
}
}
#ifdef NETSWITCH_STAT
#ifdef NETSWITCH_STAT
fprintf
(
stderr
,
"sent packet: %20lu [%20lu Byte]
\n
"
,
pkt_tx_num
,
pkt_tx_byte
);
fprintf
(
stderr
,
"sent packet: %20lu [%20lu Byte]
\n
"
,
pkt_tx_num
,
fprintf
(
stderr
,
"recv packet: %20lu [%20lu Byte]
\n
"
,
pkt_recv_num
,
pkt_recv_byte
);
pkt_tx_byte
);
fprintf
(
stderr
,
"recv packet: %20lu [%20lu Byte]
\n
"
,
pkt_recv_num
,
pkt_recv_byte
);
#endif
#endif
...
...
sims/net/switch/net_switch.cc
View file @
f9a3a2e6
...
@@ -22,11 +22,11 @@
...
@@ -22,11 +22,11 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
*/
#include <unistd.h>
#include <pcap/pcap.h>
#include <linux/ip.h>
#include <linux/if_ether.h>
#include <arpa/inet.h>
#include <arpa/inet.h>
#include <linux/if_ether.h>
#include <linux/ip.h>
#include <pcap/pcap.h>
#include <unistd.h>
#include <cassert>
#include <cassert>
#include <climits>
#include <climits>
...
@@ -94,7 +94,6 @@ struct hash<MAC> {
...
@@ -94,7 +94,6 @@ struct hash<MAC> {
};
};
}
// namespace std
}
// namespace std
/** Normal network switch port (conneting to a NIC) */
/** Normal network switch port (conneting to a NIC) */
class
NetPort
{
class
NetPort
{
public:
public:
...
@@ -112,8 +111,8 @@ class NetPort {
...
@@ -112,8 +111,8 @@ class NetPort {
bool
Init
()
{
bool
Init
()
{
struct
SimbricksBaseIfParams
params
=
netParams
;
struct
SimbricksBaseIfParams
params
=
netParams
;
params
.
sync_mode
=
(
sync_
?
kSimbricksBaseIfSyncOptional
params
.
sync_mode
=
:
kSimbricksBaseIfSyncDisabled
);
(
sync_
?
kSimbricksBaseIfSyncOptional
:
kSimbricksBaseIfSyncDisabled
);
params
.
sock_path
=
path_
;
params
.
sock_path
=
path_
;
params
.
blocking_conn
=
false
;
params
.
blocking_conn
=
false
;
...
@@ -130,8 +129,12 @@ class NetPort {
...
@@ -130,8 +129,12 @@ class NetPort {
memset
(
&
netif_
,
0
,
sizeof
(
netif_
));
memset
(
&
netif_
,
0
,
sizeof
(
netif_
));
}
}
NetPort
(
const
NetPort
&
other
)
:
netif_
(
other
.
netif_
),
NetPort
(
const
NetPort
&
other
)
rx_
(
other
.
rx_
),
sync_
(
other
.
sync_
),
path_
(
other
.
path_
)
{}
:
netif_
(
other
.
netif_
),
rx_
(
other
.
rx_
),
sync_
(
other
.
sync_
),
path_
(
other
.
path_
)
{
}
virtual
bool
Prepare
()
{
virtual
bool
Prepare
()
{
if
(
!
Init
())
if
(
!
Init
())
...
@@ -154,15 +157,15 @@ class NetPort {
...
@@ -154,15 +157,15 @@ class NetPort {
}
}
void
Sync
(
uint64_t
cur_ts
)
{
void
Sync
(
uint64_t
cur_ts
)
{
while
(
SimbricksNetIfOutSync
(
&
netif_
,
cur_ts
));
while
(
SimbricksNetIfOutSync
(
&
netif_
,
cur_ts
))
;
}
}
uint64_t
NextTimestamp
()
{
uint64_t
NextTimestamp
()
{
return
SimbricksNetIfInTimestamp
(
&
netif_
);
return
SimbricksNetIfInTimestamp
(
&
netif_
);
}
}
enum
RxPollState
RxPacket
(
enum
RxPollState
RxPacket
(
const
void
*&
data
,
size_t
&
len
,
uint64_t
cur_ts
)
{
const
void
*&
data
,
size_t
&
len
,
uint64_t
cur_ts
)
{
assert
(
rx_
==
nullptr
);
assert
(
rx_
==
nullptr
);
rx_
=
SimbricksNetIfInPoll
(
&
netif_
,
cur_ts
);
rx_
=
SimbricksNetIfInPoll
(
&
netif_
,
cur_ts
);
...
@@ -189,10 +192,9 @@ class NetPort {
...
@@ -189,10 +192,9 @@ class NetPort {
rx_
=
nullptr
;
rx_
=
nullptr
;
}
}
bool
TxPacket
(
bool
TxPacket
(
const
void
*
data
,
size_t
len
,
uint64_t
cur_ts
)
{
const
void
*
data
,
size_t
len
,
uint64_t
cur_ts
)
{
volatile
union
SimbricksProtoNetMsg
*
msg_to
=
volatile
union
SimbricksProtoNetMsg
*
msg_to
=
SimbricksNetIfOutAlloc
(
&
netif_
,
cur_ts
);
SimbricksNetIfOutAlloc
(
&
netif_
,
cur_ts
);
if
(
!
msg_to
&&
!
sync_
)
{
if
(
!
msg_to
&&
!
sync_
)
{
return
false
;
return
false
;
}
else
if
(
!
msg_to
&&
sync_
)
{
}
else
if
(
!
msg_to
&&
sync_
)
{
...
@@ -210,7 +212,6 @@ class NetPort {
...
@@ -210,7 +212,6 @@ class NetPort {
}
}
};
};
/** Listening switch port (connected to by another network) */
/** Listening switch port (connected to by another network) */
class
NetListenPort
:
public
NetPort
{
class
NetListenPort
:
public
NetPort
{
protected:
protected:
...
@@ -221,8 +222,8 @@ class NetListenPort : public NetPort {
...
@@ -221,8 +222,8 @@ class NetListenPort : public NetPort {
memset
(
&
pool_
,
0
,
sizeof
(
pool_
));
memset
(
&
pool_
,
0
,
sizeof
(
pool_
));
}
}
NetListenPort
(
const
NetListenPort
&
other
)
:
NetPort
(
other
),
NetListenPort
(
const
NetListenPort
&
other
)
pool_
(
other
.
pool_
)
{
:
NetPort
(
other
),
pool_
(
other
.
pool_
)
{
}
}
virtual
bool
Prepare
()
override
{
virtual
bool
Prepare
()
override
{
...
@@ -232,8 +233,9 @@ class NetListenPort : public NetPort {
...
@@ -232,8 +233,9 @@ class NetListenPort : public NetPort {
std
::
string
shm_path
=
path_
;
std
::
string
shm_path
=
path_
;
shm_path
+=
"-shm"
;
shm_path
+=
"-shm"
;
if
(
SimbricksBaseIfSHMPoolCreate
(
&
pool_
,
shm_path
.
c_str
(),
if
(
SimbricksBaseIfSHMPoolCreate
(
SimbricksBaseIfSHMSize
(
&
netif_
.
base
.
params
))
!=
0
)
{
&
pool_
,
shm_path
.
c_str
(),
SimbricksBaseIfSHMSize
(
&
netif_
.
base
.
params
))
!=
0
)
{
perror
(
"Prepare: SimbricksBaseIfSHMPoolCreate failed"
);
perror
(
"Prepare: SimbricksBaseIfSHMPoolCreate failed"
);
return
false
;
return
false
;
}
}
...
@@ -247,8 +249,7 @@ class NetListenPort : public NetPort {
...
@@ -247,8 +249,7 @@ class NetListenPort : public NetPort {
}
}
};
};
static
bool
ConnectAll
(
std
::
vector
<
NetPort
*>
ports
)
static
bool
ConnectAll
(
std
::
vector
<
NetPort
*>
ports
)
{
{
size_t
n
=
ports
.
size
();
size_t
n
=
ports
.
size
();
struct
SimBricksBaseIfEstablishData
ests
[
n
];
struct
SimBricksBaseIfEstablishData
ests
[
n
];
struct
SimbricksProtoNetIntro
intro
;
struct
SimbricksProtoNetIntro
intro
;
...
@@ -266,10 +267,10 @@ static bool ConnectAll(std::vector<NetPort *> ports)
...
@@ -266,10 +267,10 @@ static bool ConnectAll(std::vector<NetPort *> ports)
return
false
;
return
false
;
}
}
if
(
SimBricksBaseIfEstablish
(
ests
,
n
))
{
if
(
SimBricksBaseIfEstablish
(
ests
,
n
))
{
fprintf
(
stderr
,
"ConnectAll: SimBricksBaseIfEstablish failed
\n
"
);
fprintf
(
stderr
,
"ConnectAll: SimBricksBaseIfEstablish failed
\n
"
);
return
false
;
return
false
;
}
}
printf
(
"done connecting
\n
"
);
printf
(
"done connecting
\n
"
);
return
true
;
return
true
;
...
@@ -304,12 +305,12 @@ static void forward_pkt(const void *pkt_data, size_t pkt_len, size_t port_id,
...
@@ -304,12 +305,12 @@ static void forward_pkt(const void *pkt_data, size_t pkt_len, size_t port_id,
// log to pcap file if initialized
// log to pcap file if initialized
if
(
dumpfile
)
{
if
(
dumpfile
)
{
memset
(
&
ph
,
0
,
sizeof
(
ph
));
memset
(
&
ph
,
0
,
sizeof
(
ph
));
ph
.
ts
.
tv_sec
=
cur_ts
/
1000000000000ULL
;
ph
.
ts
.
tv_sec
=
cur_ts
/
1000000000000ULL
;
ph
.
ts
.
tv_usec
=
(
cur_ts
%
1000000000000ULL
)
/
1000ULL
;
ph
.
ts
.
tv_usec
=
(
cur_ts
%
1000000000000ULL
)
/
1000ULL
;
ph
.
caplen
=
pkt_len
;
ph
.
caplen
=
pkt_len
;
ph
.
len
=
pkt_len
;
ph
.
len
=
pkt_len
;
pcap_dump
((
unsigned
char
*
)
dumpfile
,
&
ph
,
(
unsigned
char
*
)
pkt_data
);
pcap_dump
((
unsigned
char
*
)
dumpfile
,
&
ph
,
(
unsigned
char
*
)
pkt_data
);
}
}
// print sending tick: [packet type] source_IP -> dest_IP len:
// print sending tick: [packet type] source_IP -> dest_IP len:
...
@@ -317,24 +318,22 @@ static void forward_pkt(const void *pkt_data, size_t pkt_len, size_t port_id,
...
@@ -317,24 +318,22 @@ static void forward_pkt(const void *pkt_data, size_t pkt_len, size_t port_id,
uint16_t
eth_proto
;
uint16_t
eth_proto
;
struct
ethhdr
*
hdr
;
struct
ethhdr
*
hdr
;
struct
iphdr
*
iph
;
struct
iphdr
*
iph
;
hdr
=
(
struct
ethhdr
*
)
pkt_data
;
hdr
=
(
struct
ethhdr
*
)
pkt_data
;
eth_proto
=
ntohs
(
hdr
->
h_proto
);
eth_proto
=
ntohs
(
hdr
->
h_proto
);
iph
=
(
struct
iphdr
*
)(
hdr
+
1
);
iph
=
(
struct
iphdr
*
)(
hdr
+
1
);
uint64_t
dmac
=
(
*
(
uint64_t
*
)
hdr
->
h_dest
)
&
0xFFFFFFFFFFULL
;
uint64_t
dmac
=
(
*
(
uint64_t
*
)
hdr
->
h_dest
)
&
0xFFFFFFFFFFULL
;
uint64_t
smac
=
(
*
(
uint64_t
*
)
hdr
->
h_source
)
&
0xFFFFFFFFFFULL
;
uint64_t
smac
=
(
*
(
uint64_t
*
)
hdr
->
h_source
)
&
0xFFFFFFFFFFULL
;
fprintf
(
stderr
,
"%20lu: [P %zu -> %zu] %lx -> %lx "
,
cur_ts
,
iport_id
,
fprintf
(
stderr
,
"%20lu: [P %zu -> %zu] %lx -> %lx "
,
cur_ts
,
iport_id
,
port_id
,
smac
,
dmac
);
port_id
,
smac
,
dmac
);
if
(
eth_proto
==
ETH_P_IP
){
if
(
eth_proto
==
ETH_P_IP
)
{
fprintf
(
stderr
,
"[ IP] "
);
fprintf
(
stderr
,
"[ IP] "
);
fprintf
(
stderr
,
"%8X -> %8X len: %lu
\n
"
,
iph
->
saddr
,
iph
->
daddr
,
fprintf
(
stderr
,
"%8X -> %8X len: %lu
\n
"
,
iph
->
saddr
,
iph
->
daddr
,
ntohs
(
iph
->
tot_len
)
+
sizeof
(
struct
ethhdr
));
ntohs
(
iph
->
tot_len
)
+
sizeof
(
struct
ethhdr
));
}
}
else
if
(
eth_proto
==
ETH_P_ARP
)
{
else
if
(
eth_proto
==
ETH_P_ARP
){
fprintf
(
stderr
,
"[ARP] %8X -> %8X
\n
"
,
fprintf
(
stderr
,
"[ARP] %8X -> %8X
\n
"
,
*
(
uint32_t
*
)
((
uint8_t
*
)
pkt_data
+
28
),
*
(
uint32_t
*
)((
uint8_t
*
)
pkt_data
+
28
),
*
(
uint32_t
*
)
((
uint8_t
*
)
pkt_data
+
38
)
);
*
(
uint32_t
*
)((
uint8_t
*
)
pkt_data
+
38
));
}
}
else
{
else
{
fprintf
(
stderr
,
"unknown eth type
\n
"
);
fprintf
(
stderr
,
"unknown eth type
\n
"
);
}
}
#endif
#endif
...
@@ -349,7 +348,7 @@ static void switch_pkt(NetPort &port, size_t iport) {
...
@@ -349,7 +348,7 @@ static void switch_pkt(NetPort &port, size_t iport) {
#ifdef NETSWITCH_STAT
#ifdef NETSWITCH_STAT
d2n_poll_total
+=
1
;
d2n_poll_total
+=
1
;
if
(
stat_flag
){
if
(
stat_flag
)
{
s_d2n_poll_total
+=
1
;
s_d2n_poll_total
+=
1
;
}
}
#endif
#endif
...
@@ -361,7 +360,7 @@ static void switch_pkt(NetPort &port, size_t iport) {
...
@@ -361,7 +360,7 @@ static void switch_pkt(NetPort &port, size_t iport) {
#ifdef NETSWITCH_STAT
#ifdef NETSWITCH_STAT
d2n_poll_suc
+=
1
;
d2n_poll_suc
+=
1
;
if
(
stat_flag
){
if
(
stat_flag
)
{
s_d2n_poll_suc
+=
1
;
s_d2n_poll_suc
+=
1
;
}
}
#endif
#endif
...
@@ -391,7 +390,7 @@ static void switch_pkt(NetPort &port, size_t iport) {
...
@@ -391,7 +390,7 @@ static void switch_pkt(NetPort &port, size_t iport) {
}
else
if
(
poll
==
NetPort
::
kRxPollSync
)
{
}
else
if
(
poll
==
NetPort
::
kRxPollSync
)
{
#ifdef NETSWITCH_STAT
#ifdef NETSWITCH_STAT
d2n_poll_sync
+=
1
;
d2n_poll_sync
+=
1
;
if
(
stat_flag
){
if
(
stat_flag
)
{
s_d2n_poll_sync
+=
1
;
s_d2n_poll_sync
+=
1
;
}
}
#endif
#endif
...
@@ -443,8 +442,8 @@ int main(int argc, char *argv[]) {
...
@@ -443,8 +442,8 @@ int main(int argc, char *argv[]) {
pc
=
pcap_open_dead_with_tstamp_precision
(
DLT_EN10MB
,
65535
,
pc
=
pcap_open_dead_with_tstamp_precision
(
DLT_EN10MB
,
65535
,
PCAP_TSTAMP_PRECISION_NANO
);
PCAP_TSTAMP_PRECISION_NANO
);
if
(
pc
==
nullptr
)
{
if
(
pc
==
nullptr
)
{
perror
(
"pcap_open_dead failed"
);
perror
(
"pcap_open_dead failed"
);
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
dumpfile
=
pcap_dump_open
(
pc
,
optarg
);
dumpfile
=
pcap_dump_open
(
pc
,
optarg
);
...
@@ -509,8 +508,8 @@ int main(int argc, char *argv[]) {
...
@@ -509,8 +508,8 @@ int main(int argc, char *argv[]) {
d2n_poll_sync
,
(
double
)
d2n_poll_sync
/
d2n_poll_suc
);
d2n_poll_sync
,
(
double
)
d2n_poll_sync
/
d2n_poll_suc
);
fprintf
(
stderr
,
"%20s: %22lu %20s: %22lu poll_suc_rate: %f
\n
"
,
fprintf
(
stderr
,
"%20s: %22lu %20s: %22lu poll_suc_rate: %f
\n
"
,
"s_d2n_poll_total"
,
s_d2n_poll_total
,
"s_d2n_poll_suc"
,
s_d2n_poll_suc
,
"s_d2n_poll_total"
,
s_d2n_poll_total
,
"s_d2n_poll_suc"
,
(
double
)
s_d2n_poll_suc
/
s_d2n_poll_total
);
s_d2n_poll_suc
,
(
double
)
s_d2n_poll_suc
/
s_d2n_poll_total
);
fprintf
(
stderr
,
"%65s: %22lu sync_rate: %f
\n
"
,
"s_d2n_poll_sync"
,
fprintf
(
stderr
,
"%65s: %22lu sync_rate: %f
\n
"
,
"s_d2n_poll_sync"
,
s_d2n_poll_sync
,
(
double
)
s_d2n_poll_sync
/
s_d2n_poll_suc
);
s_d2n_poll_sync
,
(
double
)
s_d2n_poll_sync
/
s_d2n_poll_suc
);
#endif
#endif
...
...
sims/net/tofino/tofino.cc
View file @
f9a3a2e6
...
@@ -41,9 +41,9 @@
...
@@ -41,9 +41,9 @@
#include <fstream>
#include <fstream>
#include <iostream>
#include <iostream>
#include <queue>
#include <queue>
#include <set>
#include <string>
#include <string>
#include <vector>
#include <vector>
#include <set>
#include <simbricks/base/cxxatomicfix.h>
#include <simbricks/base/cxxatomicfix.h>
extern
"C"
{
extern
"C"
{
...
@@ -87,7 +87,8 @@ struct classcomp {
...
@@ -87,7 +87,8 @@ struct classcomp {
return
lhs
.
time
>
rhs
.
time
;
return
lhs
.
time
>
rhs
.
time
;
}
}
};
};
std
::
priority_queue
<
struct
event
,
std
::
vector
<
struct
event
>
,
classcomp
>
event_queue
;
std
::
priority_queue
<
struct
event
,
std
::
vector
<
struct
event
>
,
classcomp
>
event_queue
;
static
bool
get_tofino_log_line
(
int
limit_ms
)
{
static
bool
get_tofino_log_line
(
int
limit_ms
)
{
using
std
::
chrono
::
system_clock
;
using
std
::
chrono
::
system_clock
;
...
@@ -237,8 +238,8 @@ static void recv_from_peer(int port) {
...
@@ -237,8 +238,8 @@ static void recv_from_peer(int port) {
e
.
time
=
msg_from
->
packet
.
timestamp
;
e
.
time
=
msg_from
->
packet
.
timestamp
;
e
.
to_switch
=
true
;
e
.
to_switch
=
true
;
e
.
port
=
port
;
e
.
port
=
port
;
e
.
msg
=
std
::
string
((
const
char
*
)
msg_from
->
packet
.
data
,
e
.
msg
=
msg_from
->
packet
.
len
);
std
::
string
((
const
char
*
)
msg_from
->
packet
.
data
,
msg_from
->
packet
.
len
);
#ifdef DEBUG
#ifdef DEBUG
printf
(
"received packet from peer %u at time %llu
\n
"
,
port
,
e
.
time
);
printf
(
"received packet from peer %u at time %llu
\n
"
,
port
,
e
.
time
);
#endif
#endif
...
...
sims/net/wire/net_wire.c
View file @
f9a3a2e6
...
@@ -116,7 +116,6 @@ int main(int argc, char *argv[]) {
...
@@ -116,7 +116,6 @@ int main(int argc, char *argv[]) {
signal
(
SIGTERM
,
sigint_handler
);
signal
(
SIGTERM
,
sigint_handler
);
signal
(
SIGUSR1
,
sigusr1_handler
);
signal
(
SIGUSR1
,
sigusr1_handler
);
if
(
argc
>=
5
)
if
(
argc
>=
5
)
params
.
sync_interval
=
strtoull
(
argv
[
4
],
NULL
,
0
)
*
1000ULL
;
params
.
sync_interval
=
strtoull
(
argv
[
4
],
NULL
,
0
)
*
1000ULL
;
...
...
sims/nic/corundum/corundum_verilator.cc
View file @
f9a3a2e6
...
@@ -46,7 +46,7 @@ extern "C" {
...
@@ -46,7 +46,7 @@ extern "C" {
struct
DMAOp
;
struct
DMAOp
;
static
uint64_t
clock_period
=
4
*
1000ULL
;
// 4ns -> 250MHz
static
uint64_t
clock_period
=
4
*
1000ULL
;
// 4ns -> 250MHz
static
volatile
int
exiting
=
0
;
static
volatile
int
exiting
=
0
;
uint64_t
main_time
=
0
;
uint64_t
main_time
=
0
;
...
@@ -373,14 +373,14 @@ void pci_rwcomp_issue(MMIOOp *op) {
...
@@ -373,14 +373,14 @@ void pci_rwcomp_issue(MMIOOp *op) {
wc
->
req_id
=
op
->
id
;
wc
->
req_id
=
op
->
id
;
SimbricksPcieIfD2HOutSend
(
&
nicif
.
pcie
,
msg
,
SimbricksPcieIfD2HOutSend
(
&
nicif
.
pcie
,
msg
,
SIMBRICKS_PROTO_PCIE_D2H_MSG_WRITECOMP
);
SIMBRICKS_PROTO_PCIE_D2H_MSG_WRITECOMP
);
}
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
;
SimbricksPcieIfD2HOutSend
(
&
nicif
.
pcie
,
msg
,
SimbricksPcieIfD2HOutSend
(
&
nicif
.
pcie
,
msg
,
SIMBRICKS_PROTO_PCIE_D2H_MSG_READCOMP
);
SIMBRICKS_PROTO_PCIE_D2H_MSG_READCOMP
);
}
}
delete
op
;
delete
op
;
...
@@ -409,7 +409,7 @@ void pci_dma_issue(DMAOp *op) {
...
@@ -409,7 +409,7 @@ void pci_dma_issue(DMAOp *op) {
memcpy
((
void
*
)
write
->
data
,
op
->
data
,
op
->
len
);
memcpy
((
void
*
)
write
->
data
,
op
->
data
,
op
->
len
);
SimbricksPcieIfD2HOutSend
(
&
nicif
.
pcie
,
msg
,
SimbricksPcieIfD2HOutSend
(
&
nicif
.
pcie
,
msg
,
SIMBRICKS_PROTO_PCIE_D2H_MSG_WRITE
);
SIMBRICKS_PROTO_PCIE_D2H_MSG_WRITE
);
}
else
{
}
else
{
volatile
struct
SimbricksProtoPcieD2HRead
*
read
=
&
msg
->
read
;
volatile
struct
SimbricksProtoPcieD2HRead
*
read
=
&
msg
->
read
;
read
->
req_id
=
(
uintptr_t
)
op
;
read
->
req_id
=
(
uintptr_t
)
op
;
...
@@ -417,7 +417,7 @@ void pci_dma_issue(DMAOp *op) {
...
@@ -417,7 +417,7 @@ void pci_dma_issue(DMAOp *op) {
read
->
len
=
op
->
len
;
read
->
len
=
op
->
len
;
SimbricksPcieIfD2HOutSend
(
&
nicif
.
pcie
,
msg
,
SimbricksPcieIfD2HOutSend
(
&
nicif
.
pcie
,
msg
,
SIMBRICKS_PROTO_PCIE_D2H_MSG_READ
);
SIMBRICKS_PROTO_PCIE_D2H_MSG_READ
);
}
}
pci_dma_pending
.
insert
(
op
);
pci_dma_pending
.
insert
(
op
);
...
@@ -500,7 +500,7 @@ static void h2d_read(MMIOInterface &mmio,
...
@@ -500,7 +500,7 @@ static void h2d_read(MMIOInterface &mmio,
rc
->
req_id
=
read
->
req_id
;
rc
->
req_id
=
read
->
req_id
;
SimbricksPcieIfD2HOutSend
(
&
nicif
.
pcie
,
msg
,
SimbricksPcieIfD2HOutSend
(
&
nicif
.
pcie
,
msg
,
SIMBRICKS_PROTO_PCIE_D2H_MSG_READCOMP
);
SIMBRICKS_PROTO_PCIE_D2H_MSG_READCOMP
);
}
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);*/
...
@@ -529,7 +529,7 @@ static void h2d_write(MMIOInterface &mmio,
...
@@ -529,7 +529,7 @@ static void h2d_write(MMIOInterface &mmio,
wc
->
req_id
=
write
->
req_id
;
wc
->
req_id
=
write
->
req_id
;
SimbricksPcieIfD2HOutSend
(
&
nicif
.
pcie
,
msg
,
SimbricksPcieIfD2HOutSend
(
&
nicif
.
pcie
,
msg
,
SIMBRICKS_PROTO_PCIE_D2H_MSG_WRITECOMP
);
SIMBRICKS_PROTO_PCIE_D2H_MSG_WRITECOMP
);
}
else
{
}
else
{
mmio
.
issueWrite
(
write
->
req_id
,
write
->
offset
,
write
->
len
,
val
);
mmio
.
issueWrite
(
write
->
req_id
,
write
->
offset
,
write
->
len
,
val
);
}
}
...
@@ -624,7 +624,7 @@ class EthernetTx {
...
@@ -624,7 +624,7 @@ class EthernetTx {
if
(
top
.
tx_axis_tvalid
)
{
if
(
top
.
tx_axis_tvalid
)
{
/* iterate over all bytes on the bus */
/* iterate over all bytes on the bus */
uint8_t
*
txbus
=
(
uint8_t
*
)
&
top
.
tx_axis_tdata
;
uint8_t
*
txbus
=
(
uint8_t
*
)
&
top
.
tx_axis_tdata
;
for
(
size_t
i
=
0
;
i
<
sizeof
(
top
.
tx_axis_tdata
);
i
++
)
{
for
(
size_t
i
=
0
;
i
<
sizeof
(
top
.
tx_axis_tdata
);
i
++
)
{
if
((
top
.
tx_axis_tkeep
&
(
1ULL
<<
i
))
!=
0
)
{
if
((
top
.
tx_axis_tkeep
&
(
1ULL
<<
i
))
!=
0
)
{
assert
(
packet_len
<
2048
);
assert
(
packet_len
<
2048
);
...
@@ -689,7 +689,8 @@ class EthernetRx {
...
@@ -689,7 +689,8 @@ class EthernetRx {
if
(
packet_off
!=
0
&&
!
top
.
rx_axis_tready
)
{
if
(
packet_off
!=
0
&&
!
top
.
rx_axis_tready
)
{
// no ready signal, can't advance
// no ready signal, can't advance
#ifdef ETH_DEBUG
#ifdef ETH_DEBUG
std
::
cerr
<<
"eth rx: no ready "
<<
fifo_pos_rd
<<
" "
<<
packet_off
<<
std
::
endl
;
std
::
cerr
<<
"eth rx: no ready "
<<
fifo_pos_rd
<<
" "
<<
packet_off
<<
std
::
endl
;
#endif
#endif
}
else
if
(
packet_off
==
fifo_lens
[
fifo_pos_rd
])
{
}
else
if
(
packet_off
==
fifo_lens
[
fifo_pos_rd
])
{
// done with packet
// done with packet
...
@@ -711,10 +712,11 @@ class EthernetRx {
...
@@ -711,10 +712,11 @@ class EthernetRx {
std
::
cout
<<
"rx from "
<<
fifo_pos_rd
<<
std
::
endl
;
std
::
cout
<<
"rx from "
<<
fifo_pos_rd
<<
std
::
endl
;
#endif
#endif
top
.
rx_axis_tkeep
=
0
;
top
.
rx_axis_tkeep
=
0
;
uint8_t
*
rdata
=
(
uint8_t
*
)
&
top
.
rx_axis_tdata
;
uint8_t
*
rdata
=
(
uint8_t
*
)
&
top
.
rx_axis_tdata
;
size_t
i
;
size_t
i
;
for
(
i
=
0
;
i
<
sizeof
(
top
.
rx_axis_tdata
)
&&
for
(
i
=
0
;
i
<
sizeof
(
top
.
rx_axis_tdata
)
&&
packet_off
<
fifo_lens
[
fifo_pos_rd
];
i
++
)
{
packet_off
<
fifo_lens
[
fifo_pos_rd
];
i
++
)
{
rdata
[
i
]
=
fifo_bufs
[
fifo_pos_rd
][
packet_off
];
rdata
[
i
]
=
fifo_bufs
[
fifo_pos_rd
][
packet_off
];
top
.
rx_axis_tkeep
|=
(
1ULL
<<
i
);
top
.
rx_axis_tkeep
|=
(
1ULL
<<
i
);
packet_off
++
;
packet_off
++
;
...
@@ -776,7 +778,7 @@ void pci_msi_issue(uint8_t vec) {
...
@@ -776,7 +778,7 @@ void pci_msi_issue(uint8_t vec) {
intr
->
inttype
=
SIMBRICKS_PROTO_PCIE_INT_MSI
;
intr
->
inttype
=
SIMBRICKS_PROTO_PCIE_INT_MSI
;
SimbricksPcieIfD2HOutSend
(
&
nicif
.
pcie
,
msg
,
SimbricksPcieIfD2HOutSend
(
&
nicif
.
pcie
,
msg
,
SIMBRICKS_PROTO_PCIE_D2H_MSG_INTERRUPT
);
SIMBRICKS_PROTO_PCIE_D2H_MSG_INTERRUPT
);
}
}
static
void
msi_step
(
Vinterface
&
top
,
PCICoordinator
&
coord
)
{
static
void
msi_step
(
Vinterface
&
top
,
PCICoordinator
&
coord
)
{
...
@@ -822,7 +824,7 @@ int main(int argc, char *argv[]) {
...
@@ -822,7 +824,7 @@ int main(int argc, char *argv[]) {
if
(
argc
>=
8
)
if
(
argc
>=
8
)
pcieParams
.
link_latency
=
strtoull
(
argv
[
7
],
NULL
,
0
)
*
1000ULL
;
pcieParams
.
link_latency
=
strtoull
(
argv
[
7
],
NULL
,
0
)
*
1000ULL
;
if
(
argc
>=
9
)
if
(
argc
>=
9
)
netParams
.
link_latency
=
strtoull
(
argv
[
8
],
NULL
,
0
)
*
1000ULL
;
netParams
.
link_latency
=
strtoull
(
argv
[
8
],
NULL
,
0
)
*
1000ULL
;
if
(
argc
>=
10
)
if
(
argc
>=
10
)
clock_period
=
1000000ULL
/
strtoull
(
argv
[
9
],
NULL
,
0
);
clock_period
=
1000000ULL
/
strtoull
(
argv
[
9
],
NULL
,
0
);
...
@@ -957,12 +959,12 @@ int main(int argc, char *argv[]) {
...
@@ -957,12 +959,12 @@ int main(int argc, char *argv[]) {
done
=
1
;
done
=
1
;
if
(
SimbricksPcieIfD2HOutSync
(
&
nicif
.
pcie
,
main_time
)
<
0
)
{
if
(
SimbricksPcieIfD2HOutSync
(
&
nicif
.
pcie
,
main_time
)
<
0
)
{
std
::
cerr
<<
"warn: SimbricksPcieIfD2HOutSync failed (t="
<<
main_time
std
::
cerr
<<
"warn: SimbricksPcieIfD2HOutSync failed (t="
<<
main_time
<<
")"
<<
std
::
endl
;
<<
")"
<<
std
::
endl
;
done
=
0
;
done
=
0
;
}
}
if
(
SimbricksNetIfOutSync
(
&
nicif
.
net
,
main_time
)
<
0
)
{
if
(
SimbricksNetIfOutSync
(
&
nicif
.
net
,
main_time
)
<
0
)
{
std
::
cerr
<<
"warn: SimbricksNetIfOutSync failed (t="
<<
main_time
std
::
cerr
<<
"warn: SimbricksNetIfOutSync failed (t="
<<
main_time
<<
")"
<<
std
::
endl
;
<<
")"
<<
std
::
endl
;
done
=
0
;
done
=
0
;
}
}
}
while
(
!
done
);
}
while
(
!
done
);
...
@@ -970,11 +972,11 @@ int main(int argc, char *argv[]) {
...
@@ -970,11 +972,11 @@ int main(int argc, char *argv[]) {
do
{
do
{
poll_h2d
(
mmio
);
poll_h2d
(
mmio
);
poll_n2d
(
rx
);
poll_n2d
(
rx
);
}
while
(
!
exiting
&&
}
while
(
((
sync_pci
&&
!
exiting
&&
SimbricksPcieIfH2DInTimestamp
(
&
nicif
.
pcie
)
<=
main_time
)
||
((
sync_pci
&&
(
sync_eth
&&
SimbricksPcieIfH2DInTimestamp
(
&
nicif
.
pcie
)
<=
main_time
)
||
SimbricksNetIfInTimestamp
(
&
nicif
.
net
)
<=
main_time
)));
(
sync_eth
&&
SimbricksNetIfInTimestamp
(
&
nicif
.
net
)
<=
main_time
)));
/* falling edge */
/* falling edge */
top
->
clk
=
!
top
->
clk
;
top
->
clk
=
!
top
->
clk
;
...
...
sims/nic/corundum_bm/corundum_bm.cc
View file @
f9a3a2e6
...
@@ -193,7 +193,8 @@ void EventRing::issueEvent(unsigned type, unsigned source) {
...
@@ -193,7 +193,8 @@ void EventRing::issueEvent(unsigned type, unsigned source) {
event
->
type
=
type
;
event
->
type
=
type
;
event
->
source
=
source
;
event
->
source
=
source
;
#ifdef DEBUG
#ifdef DEBUG
printf
(
"corundum_bm: event ring issue dma addr %lx index %lu len %lu
\n
"
,
op
->
dma_addr_
,
op
->
tag
,
op
->
len_
);
printf
(
"corundum_bm: event ring issue dma addr %lx index %lu len %lu
\n
"
,
op
->
dma_addr_
,
op
->
tag
,
op
->
len_
);
#endif
#endif
runner
->
IssueDma
(
*
op
);
runner
->
IssueDma
(
*
op
);
this
->
_currHead
++
;
this
->
_currHead
++
;
...
@@ -279,7 +280,8 @@ void TxRing::setHeadPtr(ptr_t ptr) {
...
@@ -279,7 +280,8 @@ void TxRing::setHeadPtr(ptr_t ptr) {
op
->
tag
=
this
->
_currTail
;
op
->
tag
=
this
->
_currTail
;
op
->
write_
=
false
;
op
->
write_
=
false
;
#ifdef DEBUG
#ifdef DEBUG
printf
(
"corundum_bm: tx issue dma addr %lx index %lu len %lu
\n
"
,
op
->
dma_addr_
,
op
->
tag
,
op
->
len_
);
printf
(
"corundum_bm: tx issue dma addr %lx index %lu len %lu
\n
"
,
op
->
dma_addr_
,
op
->
tag
,
op
->
len_
);
#endif
#endif
runner
->
IssueDma
(
*
op
);
runner
->
IssueDma
(
*
op
);
this
->
_currTail
++
;
this
->
_currTail
++
;
...
@@ -292,7 +294,8 @@ void TxRing::dmaDone(DMAOp *op) {
...
@@ -292,7 +294,8 @@ void TxRing::dmaDone(DMAOp *op) {
assert
(
!
op
->
write_
);
assert
(
!
op
->
write_
);
Desc
*
desc
=
(
Desc
*
)
op
->
data_
;
Desc
*
desc
=
(
Desc
*
)
op
->
data_
;
#ifdef DEBUG
#ifdef DEBUG
printf
(
"corundum_bm: tx dma desc done addr %lx index %lu len %u
\n
"
,
desc
->
addr
,
op
->
tag
,
desc
->
len
);
printf
(
"corundum_bm: tx dma desc done addr %lx index %lu len %u
\n
"
,
desc
->
addr
,
op
->
tag
,
desc
->
len
);
#endif
#endif
op
->
type
=
DMA_TYPE_MEM
;
op
->
type
=
DMA_TYPE_MEM
;
op
->
dma_addr_
=
desc
->
addr
;
op
->
dma_addr_
=
desc
->
addr
;
...
@@ -304,7 +307,8 @@ void TxRing::dmaDone(DMAOp *op) {
...
@@ -304,7 +307,8 @@ void TxRing::dmaDone(DMAOp *op) {
case
DMA_TYPE_MEM
:
case
DMA_TYPE_MEM
:
assert
(
!
op
->
write_
);
assert
(
!
op
->
write_
);
#ifdef DEBUG
#ifdef DEBUG
printf
(
"corundum_bm: tx dma memory done index %lu len %lu
\n
"
,
op
->
tag
,
op
->
len_
);
printf
(
"corundum_bm: tx dma memory done index %lu len %lu
\n
"
,
op
->
tag
,
op
->
len_
);
#endif
#endif
runner
->
EthSend
(
op
->
data_
,
op
->
len_
);
runner
->
EthSend
(
op
->
data_
,
op
->
len_
);
updatePtr
((
ptr_t
)
op
->
tag
,
false
);
updatePtr
((
ptr_t
)
op
->
tag
,
false
);
...
@@ -329,7 +333,8 @@ void RxRing::dmaDone(DMAOp *op) {
...
@@ -329,7 +333,8 @@ void RxRing::dmaDone(DMAOp *op) {
assert
(
!
op
->
write_
);
assert
(
!
op
->
write_
);
Desc
*
desc
=
(
Desc
*
)
op
->
data_
;
Desc
*
desc
=
(
Desc
*
)
op
->
data_
;
#ifdef DEBUG
#ifdef DEBUG
printf
(
"corundum_bm: rx dma desc done addr %lx index %lu len %lu
\n
"
,
desc
->
addr
,
op
->
tag
,
op
->
rx_data
->
len
);
printf
(
"corundum_bm: rx dma desc done addr %lx index %lu len %lu
\n
"
,
desc
->
addr
,
op
->
tag
,
op
->
rx_data
->
len
);
#endif
#endif
op
->
type
=
DMA_TYPE_MEM
;
op
->
type
=
DMA_TYPE_MEM
;
op
->
dma_addr_
=
desc
->
addr
;
op
->
dma_addr_
=
desc
->
addr
;
...
@@ -343,7 +348,8 @@ void RxRing::dmaDone(DMAOp *op) {
...
@@ -343,7 +348,8 @@ void RxRing::dmaDone(DMAOp *op) {
case
DMA_TYPE_MEM
:
case
DMA_TYPE_MEM
:
assert
(
op
->
write_
);
assert
(
op
->
write_
);
#ifdef DEBUG
#ifdef DEBUG
printf
(
"corundum_bm: rx dma memory done index %lu len %lu
\n
"
,
op
->
tag
,
op
->
len_
);
printf
(
"corundum_bm: rx dma memory done index %lu len %lu
\n
"
,
op
->
tag
,
op
->
len_
);
#endif
#endif
updatePtr
((
ptr_t
)
op
->
tag
,
false
);
updatePtr
((
ptr_t
)
op
->
tag
,
false
);
this
->
rxCplRing
->
complete
(
op
->
tag
,
op
->
len_
,
false
);
this
->
rxCplRing
->
complete
(
op
->
tag
,
op
->
len_
,
false
);
...
@@ -372,7 +378,8 @@ void RxRing::rx(RxData *rx_data) {
...
@@ -372,7 +378,8 @@ void RxRing::rx(RxData *rx_data) {
op
->
tag
=
this
->
_currTail
;
op
->
tag
=
this
->
_currTail
;
op
->
write_
=
false
;
op
->
write_
=
false
;
#ifdef DEBUG
#ifdef DEBUG
printf
(
"corundum_bm: rx issue dma addr %lx index %lu len %lu
\n
"
,
op
->
dma_addr_
,
op
->
tag
,
op
->
len_
);
printf
(
"corundum_bm: rx issue dma addr %lx index %lu len %lu
\n
"
,
op
->
dma_addr_
,
op
->
tag
,
op
->
len_
);
#endif
#endif
runner
->
IssueDma
(
*
op
);
runner
->
IssueDma
(
*
op
);
this
->
_currTail
++
;
this
->
_currTail
++
;
...
...
sims/nic/i40e_bm/i40e_bm.cc
View file @
f9a3a2e6
...
@@ -826,10 +826,10 @@ int_ev::int_ev() {
...
@@ -826,10 +826,10 @@ int_ev::int_ev() {
}
// namespace i40e
}
// namespace i40e
class
i40e_factory
:
public
nicbm
::
MultiNicRunner
::
DeviceFactory
{
class
i40e_factory
:
public
nicbm
::
MultiNicRunner
::
DeviceFactory
{
public:
public:
virtual
nicbm
::
Runner
::
Device
&
create
()
override
{
virtual
nicbm
::
Runner
::
Device
&
create
()
override
{
return
*
new
i40e
::
i40e_bm
;
return
*
new
i40e
::
i40e_bm
;
}
}
};
};
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
sims/nic/i40e_bm/i40e_lan.cc
View file @
f9a3a2e6
...
@@ -36,7 +36,9 @@
...
@@ -36,7 +36,9 @@
namespace
i40e
{
namespace
i40e
{
lan
::
lan
(
i40e_bm
&
dev_
,
size_t
num_qs_
)
lan
::
lan
(
i40e_bm
&
dev_
,
size_t
num_qs_
)
:
dev
(
dev_
),
log
(
"lan"
,
dev_
.
runner_
),
rss_kc
(
dev_
.
regs
.
pfqf_hkey
),
:
dev
(
dev_
),
log
(
"lan"
,
dev_
.
runner_
),
rss_kc
(
dev_
.
regs
.
pfqf_hkey
),
num_qs
(
num_qs_
)
{
num_qs
(
num_qs_
)
{
rxqs
=
new
lan_queue_rx
*
[
num_qs
];
rxqs
=
new
lan_queue_rx
*
[
num_qs
];
txqs
=
new
lan_queue_tx
*
[
num_qs
];
txqs
=
new
lan_queue_tx
*
[
num_qs
];
...
...
sims/nic/i40e_bm/logger.cc
View file @
f9a3a2e6
...
@@ -28,8 +28,8 @@
...
@@ -28,8 +28,8 @@
namespace
i40e
{
namespace
i40e
{
logger
::
logger
(
const
std
::
string
&
label_
,
nicbm
::
Runner
*
runner_
)
:
logger
::
logger
(
const
std
::
string
&
label_
,
nicbm
::
Runner
*
runner_
)
label
(
label_
),
runner
(
runner_
)
{
:
label
(
label_
),
runner
(
runner_
)
{
ss
<<
std
::
hex
;
ss
<<
std
::
hex
;
}
}
...
...
trace/events.h
View file @
f9a3a2e6
...
@@ -48,8 +48,8 @@ class EHostInstr : public event {
...
@@ -48,8 +48,8 @@ class EHostInstr : public event {
bool
fMemR
;
bool
fMemR
;
bool
fMemW
;
bool
fMemW
;
EHostInstr
(
uint64_t
ts_
,
uint64_t
pc_
)
:
event
(
ts_
),
pc
(
pc_
),
fMemR
(
false
),
EHostInstr
(
uint64_t
ts_
,
uint64_t
pc_
)
fMemW
(
false
)
{
:
event
(
ts_
),
pc
(
pc_
),
fMemR
(
false
),
fMemW
(
false
)
{
}
}
virtual
~
EHostInstr
()
{
virtual
~
EHostInstr
()
{
...
@@ -64,7 +64,6 @@ class EHostHalt : public event {
...
@@ -64,7 +64,6 @@ class EHostHalt : public event {
public:
public:
uint64_t
pc
;
uint64_t
pc
;
EHostHalt
(
uint64_t
ts_
,
uint64_t
pc_
)
:
event
(
ts_
),
pc
(
pc_
)
{
EHostHalt
(
uint64_t
ts_
,
uint64_t
pc_
)
:
event
(
ts_
),
pc
(
pc_
)
{
}
}
...
...
trace/log_parser.cc
View file @
f9a3a2e6
...
@@ -33,9 +33,8 @@
...
@@ -33,9 +33,8 @@
namespace
bio
=
boost
::
iostreams
;
namespace
bio
=
boost
::
iostreams
;
log_parser
::
log_parser
()
:
inf
(
nullptr
),
gz_file
(
nullptr
),
gz_in
(
nullptr
),
log_parser
::
log_parser
()
buf_len
(
0
),
buf_pos
(
0
)
:
inf
(
nullptr
),
gz_file
(
nullptr
),
gz_in
(
nullptr
),
buf_len
(
0
),
buf_pos
(
0
)
{
{
buf
=
new
char
[
block_size
];
buf
=
new
char
[
block_size
];
}
}
...
@@ -125,11 +124,11 @@ bool log_parser::next_event() {
...
@@ -125,11 +124,11 @@ bool log_parser::next_event() {
void
log_parser
::
read_coro
(
coro_t
::
push_type
&
sink_
)
{
void
log_parser
::
read_coro
(
coro_t
::
push_type
&
sink_
)
{
sink
=
&
sink_
;
sink
=
&
sink_
;
while
(
next_event
());
while
(
next_event
())
;
}
}
void
log_parser
::
yield
(
std
::
shared_ptr
<
event
>
ev
)
void
log_parser
::
yield
(
std
::
shared_ptr
<
event
>
ev
)
{
{
got_event
=
true
;
got_event
=
true
;
ev
->
source
=
this
;
ev
->
source
=
this
;
(
*
sink
)(
ev
);
(
*
sink
)(
ev
);
...
...
trace/process.cc
View file @
f9a3a2e6
...
@@ -80,14 +80,13 @@ void MergeEvents(coro_t::push_type &sink,
...
@@ -80,14 +80,13 @@ void MergeEvents(coro_t::push_type &sink,
void
Printer
(
coro_t
::
pull_type
&
source
)
{
void
Printer
(
coro_t
::
pull_type
&
source
)
{
uint64_t
ts_off
=
0
;
uint64_t
ts_off
=
0
;
for
(
auto
ev
:
source
)
{
for
(
auto
ev
:
source
)
{
std
::
shared_ptr
<
EHostCall
>
hc
;
std
::
shared_ptr
<
EHostCall
>
hc
;
std
::
shared_ptr
<
EHostInstr
>
hi
;
std
::
shared_ptr
<
EHostInstr
>
hi
;
if
((
hi
=
std
::
dynamic_pointer_cast
<
EHostInstr
>
(
ev
)))
{
if
((
hi
=
std
::
dynamic_pointer_cast
<
EHostInstr
>
(
ev
)))
{
continue
;
continue
;
}
else
if
((
hc
=
std
::
dynamic_pointer_cast
<
EHostCall
>
(
ev
))
&&
}
else
if
((
hc
=
std
::
dynamic_pointer_cast
<
EHostCall
>
(
ev
))
&&
strcmp
(
ev
->
source
->
label
,
"C"
)
&&
strcmp
(
ev
->
source
->
label
,
"C"
)
&&
hc
->
fun
==
"__sys_sendto"
)
{
hc
->
fun
==
"__sys_sendto"
)
{
std
::
cout
<<
"---------- REQ START:"
<<
ev
->
ts
<<
std
::
endl
;
std
::
cout
<<
"---------- REQ START:"
<<
ev
->
ts
<<
std
::
endl
;
ts_off
=
ev
->
ts
;
ts_off
=
ev
->
ts
;
}
}
...
@@ -101,7 +100,7 @@ void Printer(coro_t::pull_type &source) {
...
@@ -101,7 +100,7 @@ void Printer(coro_t::pull_type &source) {
}
}
void
Consumer
(
coro_t
::
pull_type
&
source
)
{
void
Consumer
(
coro_t
::
pull_type
&
source
)
{
for
(
auto
ev
:
source
)
{
for
(
auto
ev
:
source
)
{
}
}
}
}
...
@@ -111,15 +110,15 @@ struct InstStatsData {
...
@@ -111,15 +110,15 @@ struct InstStatsData {
uint64_t
tMin
;
uint64_t
tMin
;
uint64_t
tMax
;
uint64_t
tMax
;
uint64_t
tMean
;
uint64_t
tMean
;
std
::
vector
<
uint64_t
>
tAll
;
std
::
vector
<
uint64_t
>
tAll
;
};
};
void
InstStats
(
coro_t
::
push_type
&
sink
,
coro_t
::
pull_type
&
source
,
void
InstStats
(
coro_t
::
push_type
&
sink
,
coro_t
::
pull_type
&
source
,
struct
InstStatsData
&
data
)
{
struct
InstStatsData
&
data
)
{
uint64_t
last_ts
=
0
;
uint64_t
last_ts
=
0
;
uint64_t
first_ts
=
0
;
uint64_t
first_ts
=
0
;
data
.
nInsts
=
0
;
data
.
nInsts
=
0
;
for
(
auto
ev
:
source
)
{
for
(
auto
ev
:
source
)
{
std
::
shared_ptr
<
EHostInstr
>
hi
;
std
::
shared_ptr
<
EHostInstr
>
hi
;
if
((
hi
=
std
::
dynamic_pointer_cast
<
EHostInstr
>
(
ev
)))
{
if
((
hi
=
std
::
dynamic_pointer_cast
<
EHostInstr
>
(
ev
)))
{
if
(
!
last_ts
)
{
if
(
!
last_ts
)
{
...
@@ -140,9 +139,9 @@ void InstStats(coro_t::push_type &sink, coro_t::pull_type &source,
...
@@ -140,9 +139,9 @@ void InstStats(coro_t::push_type &sink, coro_t::pull_type &source,
/*if (lat > 4000)
/*if (lat > 4000)
std::cout << "ILAT: " << lat << " " << std::hex << hi->pc <<
std::cout << "ILAT: " << lat << " " << std::hex << hi->pc <<
std::dec << " " << hi->ts << std::endl;*/
std::dec << " " << hi->ts << std::endl;*/
}
}
last_ts
=
hi
->
ts
;
last_ts
=
hi
->
ts
;
//last_pc = hi->pc;
//
last_pc = hi->pc;
}
}
sink
(
ev
);
sink
(
ev
);
}
}
...
@@ -153,11 +152,11 @@ void InstStats(coro_t::push_type &sink, coro_t::pull_type &source,
...
@@ -153,11 +152,11 @@ void InstStats(coro_t::push_type &sink, coro_t::pull_type &source,
data
.
tMean
=
0
;
data
.
tMean
=
0
;
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
5
)
{
if
(
argc
!=
5
)
{
std
::
cerr
<<
"Usage: process CLIENT_HLOG CLIENT_NLOG SERVER_HLOG "
std
::
cerr
<<
"Usage: process CLIENT_HLOG CLIENT_NLOG SERVER_HLOG "
"SERVER_CLOG"
<<
std
::
endl
;
"SERVER_CLOG"
<<
std
::
endl
;
return
1
;
return
1
;
}
}
...
@@ -211,11 +210,11 @@ int main(int argc, char *argv[]) {
...
@@ -211,11 +210,11 @@ int main(int argc, char *argv[]) {
std
::
set
<
InstStatsData
*>
isds
;
std
::
set
<
InstStatsData
*>
isds
;
for
(
auto
p
:
all_parsers
)
{
for
(
auto
p
:
all_parsers
)
{
coro_t
::
pull_type
*
src
=
new
coro_t
::
pull_type
(
coro_t
::
pull_type
*
src
=
new
coro_t
::
pull_type
(
boost
::
bind
(
&
log_parser
::
read_coro
,
boost
::
ref
(
*
p
),
_1
));
boost
::
bind
(
&
log_parser
::
read_coro
,
boost
::
ref
(
*
p
),
_1
));
InstStatsData
*
isd
=
new
InstStatsData
;
InstStatsData
*
isd
=
new
InstStatsData
;
isd
->
label
=
p
->
label
;
isd
->
label
=
p
->
label
;
coro_t
::
pull_type
*
istat
=
new
coro_t
::
pull_type
(
coro_t
::
pull_type
*
istat
=
new
coro_t
::
pull_type
(
boost
::
bind
(
InstStats
,
_1
,
boost
::
ref
(
*
src
),
boost
::
ref
(
*
isd
)));
boost
::
bind
(
InstStats
,
_1
,
boost
::
ref
(
*
src
),
boost
::
ref
(
*
isd
)));
sources
.
insert
(
istat
);
sources
.
insert
(
istat
);
isds
.
insert
(
isd
);
isds
.
insert
(
isd
);
}
}
...
@@ -234,8 +233,8 @@ int main(int argc, char *argv[]) {
...
@@ -234,8 +233,8 @@ int main(int argc, char *argv[]) {
std
::
cout
<<
" Instrs: "
<<
isd
->
nInsts
<<
std
::
endl
;
std
::
cout
<<
" Instrs: "
<<
isd
->
nInsts
<<
std
::
endl
;
std
::
cout
<<
" Mean instr time: "
<<
isd
->
tMean
<<
std
::
endl
;
std
::
cout
<<
" Mean instr time: "
<<
isd
->
tMean
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<=
100
;
i
+=
1
)
for
(
int
i
=
0
;
i
<=
100
;
i
+=
1
)
std
::
cout
<<
" P["
<<
i
<<
"] instr time: "
<<
std
::
cout
<<
" P["
<<
i
<<
"] instr time: "
isd
->
tAll
[
isd
->
tAll
.
size
()
*
i
/
100
-
(
i
==
100
?
1
:
0
)]
<<
<<
isd
->
tAll
[
isd
->
tAll
.
size
()
*
i
/
100
-
(
i
==
100
?
1
:
0
)]
std
::
endl
;
<<
std
::
endl
;
}
}
}
}
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment