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
766849a7
Commit
766849a7
authored
Sep 24, 2024
by
Hejing Li
Browse files
pcidev.py: fix NICSim basic_args
parent
182a02b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
25 deletions
+33
-25
experiments/simbricks/orchestration/simulation/base.py
experiments/simbricks/orchestration/simulation/base.py
+2
-2
experiments/simbricks/orchestration/simulation/pcidev.py
experiments/simbricks/orchestration/simulation/pcidev.py
+31
-23
No files found.
experiments/simbricks/orchestration/simulation/base.py
View file @
766849a7
...
...
@@ -295,11 +295,11 @@ class Simulation(utils_base.IdObj):
def
is_channel_instantiated
(
self
,
chan
:
sys_conf
.
Channel
)
->
bool
:
return
chan
in
self
.
_chan_map
def
retrieve_or_create_channel
(
self
,
chan
:
sys_conf
.
Channel
)
->
Channel
:
def
retrieve_or_create_channel
(
self
,
chan
:
sys_conf
.
Channel
)
->
sim_chan
.
Channel
:
if
self
.
is_channel_instantiated
(
chan
):
return
self
.
_chan_map
[
chan
]
channel
=
Channel
(
self
,
chan
)
channel
=
sim_chan
.
Channel
(
chan
)
self
.
_chan_map
[
chan
]
=
channel
return
channel
...
...
experiments/simbricks/orchestration/simulation/pcidev.py
View file @
766849a7
...
...
@@ -22,7 +22,7 @@
import
simbricks.orchestration.system
as
sys_conf
import
typing
as
tp
from
simbricks.orchestration.
experiment.experiment_environment_new
import
ExpEnv
from
simbricks.orchestration.
instantiation
import
base
as
inst_base
from
simbricks.orchestration.simulation
import
base
...
...
@@ -45,11 +45,11 @@ class PCIDevSim(base.Simulator):
def
is_nic
(
self
)
->
bool
:
return
False
def
sockets_cleanup
(
self
,
env
:
ExpEnv
)
->
tp
.
List
[
str
]:
return
[
env
.
dev_pci_path
(
self
),
env
.
dev_shm_path
(
self
)]
def
sockets_cleanup
(
self
,
inst
:
inst_base
.
Instantiation
)
->
tp
.
List
[
str
]:
return
[
inst
.
dev_pci_path
(
self
),
inst
.
dev_shm_path
(
self
)]
def
sockets_wait
(
self
,
env
:
ExpEnv
)
->
tp
.
List
[
str
]:
return
[
env
.
dev_pci_path
(
self
)]
def
sockets_wait
(
self
,
inst
:
inst_base
.
Instantiation
)
->
tp
.
List
[
str
]:
return
[
inst
.
dev_pci_path
(
self
)]
...
...
@@ -64,23 +64,31 @@ class NICSim(PCIDevSim):
def
add
(
self
,
nic
:
sys_conf
.
SimplePCIeNIC
):
super
().
add
(
nic
)
def
basic_args
(
self
,
env
:
ExpEnv
,
extra
:
tp
.
Optional
[
str
]
=
None
)
->
str
:
def
basic_args
(
self
,
inst
:
inst_base
.
Instantiation
,
extra
:
tp
.
Optional
[
str
]
=
None
)
->
str
:
# TODO: need some fix. how to handle multiple nics in one simulator?
nic_comp
=
self
.
_components
.
pop
()
nic_pci_chan_comp
=
nic_comp
.
_pci_if
.
channel
nic_eth_chan_comp
=
nic_comp
.
_eth_if
.
channel
nic_pci_chan_sim
=
self
.
_simulation
.
retrieve_or_create_channel
(
nic_pci_chan_comp
)
nic_eth_chan_sim
=
self
.
_simulation
.
retrieve_or_create_channel
(
nic_eth_chan_comp
)
cmd
=
(
f
'
{
env
.
dev_pci_path
(
self
)
}
{
env
.
nic_eth_path
(
self
)
}
'
f
'
{
env
.
dev
_shm_
path
(
self
)
}
{
self
.
nics
[
0
].
sync
}
{
self
.
start_tick
}
'
f
'
{
self
.
nics
[
0
]
.
sync_period
}
{
self
.
nics
[
0
].
pci_chan
nel
.
latency
}
{
self
.
nics
[
0
].
eth_chan
nel
.
latency
}
'
f
'
{
inst
.
get_socket
(
nic_comp
.
_pci_if
,
set
([
inst_base
.
SockType
.
LISTEN
]))
}
{
inst
.
get_socket
(
nic_comp
.
_eth_if
,
set
([
inst_base
.
SockType
.
LISTEN
])
)
}
'
f
'
{
inst
.
_
env
.
_shm_
base
}
/dev.shm.
{
self
.
name
}
{
nic_pci_chan_sim
.
_synchronized
}
{
self
.
start_tick
}
'
f
'
{
nic_pci_chan_sim
.
sync_period
}
{
nic_
pci_chan
_comp
.
latency
}
{
nic_
eth_chan
_comp
.
latency
}
'
)
if
self
.
nics
[
0
]
.
mac
is
not
None
:
cmd
+=
' '
+
(
''
.
join
(
reversed
(
self
.
nics
[
0
]
.
mac
.
split
(
':'
))))
#
if
nic_comp
.mac is not None:
#
cmd += ' ' + (''.join(reversed(
nic_comp
.mac.split(':'))))
if
extra
is
not
None
:
cmd
+=
' '
+
extra
return
cmd
def
basic_run_cmd
(
self
,
env
:
ExpEnv
,
name
:
str
,
extra
:
tp
.
Optional
[
str
]
=
None
self
,
inst
:
inst_base
.
Instantiation
,
name
:
str
,
extra
:
tp
.
Optional
[
str
]
=
None
)
->
str
:
cmd
=
f
'
{
env
.
repodir
}
/sims/nic/
{
name
}
{
self
.
basic_args
(
env
,
extra
)
}
'
cmd
=
f
'
{
inst
.
_
env
.
_
repodir
}
/sims/nic/
{
name
}
{
self
.
basic_args
(
inst
,
extra
)
}
'
return
cmd
def
full_name
(
self
)
->
str
:
...
...
@@ -89,11 +97,11 @@ class NICSim(PCIDevSim):
def
is_nic
(
self
)
->
bool
:
return
True
def
sockets_cleanup
(
self
,
env
:
ExpEnv
)
->
tp
.
List
[
str
]:
return
super
().
sockets_cleanup
(
env
)
+
[
env
.
nic_eth_path
(
self
)]
def
sockets_cleanup
(
self
,
inst
:
inst_base
.
Instantiation
)
->
tp
.
List
[
str
]:
return
super
().
sockets_cleanup
(
inst
)
+
[
inst
.
nic_eth_path
(
self
)]
def
sockets_wait
(
self
,
env
:
ExpEnv
)
->
tp
.
List
[
str
]:
return
super
().
sockets_wait
(
env
)
+
[
env
.
nic_eth_path
(
self
)]
def
sockets_wait
(
self
,
inst
:
inst_base
.
Instantiation
)
->
tp
.
List
[
str
]:
return
super
().
sockets_wait
(
inst
)
+
[
inst
.
nic_eth_path
(
self
)]
class
I40eNicSim
(
NICSim
):
...
...
@@ -101,16 +109,16 @@ class I40eNicSim(NICSim):
def
__init__
(
self
,
e
:
'Simulation'
):
super
().
__init__
(
e
)
def
run_cmd
(
self
,
env
:
ExpEnv
)
->
str
:
return
self
.
basic_run_cmd
(
env
,
'/i40e_bm/i40e_bm'
)
def
run_cmd
(
self
,
inst
:
inst_base
.
Instantiation
)
->
str
:
return
self
.
basic_run_cmd
(
inst
,
'/i40e_bm/i40e_bm'
)
class
CorundumBMNICSim
(
NICSim
):
def
__init__
(
self
,
e
:
'Simulation'
):
super
().
__init__
(
e
)
def
run_cmd
(
self
,
env
:
ExpEnv
)
->
str
:
return
self
.
basic_run_cmd
(
env
,
'/corundum_bm/corundum_bm'
)
def
run_cmd
(
self
,
inst
:
inst_base
.
Instantiation
)
->
str
:
return
self
.
basic_run_cmd
(
inst
,
'/corundum_bm/corundum_bm'
)
...
...
@@ -125,7 +133,7 @@ class CorundumVerilatorNICSim(NICSim):
# this is a guess
return
512
def
run_cmd
(
self
,
env
:
ExpEnv
)
->
str
:
def
run_cmd
(
self
,
inst
:
inst_base
.
Instantiation
)
->
str
:
return
self
.
basic_run_cmd
(
env
,
'/corundum/corundum_verilator'
,
str
(
self
.
clock_freq
)
inst
,
'/corundum/corundum_verilator'
,
str
(
self
.
clock_freq
)
)
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