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
2b9910c9
"driver/include/conv_common.hpp" did not exist on "8a4b59785b4f5ba48468d53618ca270c5da599a7"
Commit
2b9910c9
authored
Oct 05, 2022
by
Hejing Li
Browse files
mem_switch.cc: add mem address translation in switch
parent
32c30c3b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
0 deletions
+8
-0
sims/net/mem_switch/mem_switch.cc
sims/net/mem_switch/mem_switch.cc
+8
-0
No files found.
sims/net/mem_switch/mem_switch.cc
View file @
2b9910c9
...
@@ -415,11 +415,19 @@ static void switch_pkt(NetPort &port, size_t iport) {
...
@@ -415,11 +415,19 @@ static void switch_pkt(NetPort &port, size_t iport) {
// Broadcast
// Broadcast
struct
ethhdr
*
eth_hdr
=
(
struct
ethhdr
*
)
pkt_data
;
struct
ethhdr
*
eth_hdr
=
(
struct
ethhdr
*
)
pkt_data
;
struct
MemOp
*
memop
=
(
struct
MemOp
*
)(((
const
uint8_t
*
)
pkt_data
)
+
42
);
struct
MemOp
*
memop
=
(
struct
MemOp
*
)(((
const
uint8_t
*
)
pkt_data
)
+
42
);
uint64_t
phy_addr
=
0
;
for
(
size_t
i
=
0
;
i
<
map_table
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
map_table
.
size
();
i
++
)
{
{
if
(
memop
->
as_id
==
map_table
[
i
].
as_id
&&
if
(
memop
->
as_id
==
map_table
[
i
].
as_id
&&
memop
->
addr
>=
map_table
[
i
].
vaddr_start
&&
memop
->
addr
>=
map_table
[
i
].
vaddr_start
&&
memop
->
addr
<=
map_table
[
i
].
vaddr_end
){
memop
->
addr
<=
map_table
[
i
].
vaddr_end
){
// Translate the virtual address to physical address
phy_addr
=
map_table
[
i
].
phys_start
+
(
memop
->
addr
-
map_table
[
i
].
vaddr_start
);
memop
->
addr
=
phy_addr
;
// modify the destination MAC address
for
(
int
k
=
0
;
k
<
ETH_ALEN
;
k
++
){
for
(
int
k
=
0
;
k
<
ETH_ALEN
;
k
++
){
eth_hdr
->
h_dest
[
k
]
=
map_table
[
i
].
node_mac
.
ether_addr_octet
[
k
];
eth_hdr
->
h_dest
[
k
]
=
map_table
[
i
].
node_mac
.
ether_addr_octet
[
k
];
}
}
...
...
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