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
b8ee51f5
"git@developer.sourcefind.cn:OpenDAS/torch-spline-conv.git" did not exist on "72a9c0cf32bb8bdc9bfa6a1e6996886a6b91988a"
Commit
b8ee51f5
authored
Oct 01, 2022
by
Hejing Li
Browse files
memswitch: statically generate mac table for netmems
parent
86d70837
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
1 deletion
+29
-1
sims/net/mem_switch/mem_switch.cc
sims/net/mem_switch/mem_switch.cc
+29
-1
No files found.
sims/net/mem_switch/mem_switch.cc
View file @
b8ee51f5
...
@@ -125,11 +125,11 @@ class NetPort {
...
@@ -125,11 +125,11 @@ class NetPort {
kRxPollSync
=
2
,
kRxPollSync
=
2
,
};
};
struct
SimbricksNetIf
netif_
;
struct
SimbricksNetIf
netif_
;
const
char
*
path_
;
protected:
protected:
volatile
union
SimbricksProtoNetMsg
*
rx_
;
volatile
union
SimbricksProtoNetMsg
*
rx_
;
int
sync_
;
int
sync_
;
const
char
*
path_
;
bool
Init
()
{
bool
Init
()
{
struct
SimbricksBaseIfParams
params
=
netParams
;
struct
SimbricksBaseIfParams
params
=
netParams
;
...
@@ -471,6 +471,9 @@ int main(int argc, char *argv[]) {
...
@@ -471,6 +471,9 @@ int main(int argc, char *argv[]) {
int
bad_option
=
0
;
int
bad_option
=
0
;
int
sync_eth
=
1
;
int
sync_eth
=
1
;
pcap_t
*
pc
=
nullptr
;
pcap_t
*
pc
=
nullptr
;
int
netmem_idx
=
0
;
size_t
port_i
;
std
::
string
netmem_name
;
SimbricksNetIfDefaultParams
(
&
netParams
);
SimbricksNetIfDefaultParams
(
&
netParams
);
...
@@ -519,6 +522,7 @@ int main(int argc, char *argv[]) {
...
@@ -519,6 +522,7 @@ int main(int argc, char *argv[]) {
int
idx
;
int
idx
;
struct
table_entry
ent
;
struct
table_entry
ent
;
token
=
strtok
(
optarg
,
","
);
token
=
strtok
(
optarg
,
","
);
idx
=
0
;
idx
=
0
;
while
(
token
){
while
(
token
){
...
@@ -549,6 +553,26 @@ int main(int argc, char *argv[]) {
...
@@ -549,6 +553,26 @@ int main(int argc, char *argv[]) {
#endif
#endif
map_table
.
push_back
(
ent
);
map_table
.
push_back
(
ent
);
// we match this mac address with port number manualy
// and statically generate mac table for netmems.
netmem_name
=
std
::
string
(
"netmem"
)
+
std
::
to_string
(
netmem_idx
);
for
(
port_i
=
0
;
port_i
<
ports
.
size
();
port_i
++
)
{
auto
&
port
=
*
ports
[
port_i
];
std
::
string
sockpath
=
port
.
path_
;
if
(
sockpath
.
find
(
netmem_name
)
!=
std
::
string
::
npos
){
printf
(
"port id for %s is %lu
\n
"
,
netmem_name
.
c_str
(),
port_i
);
uint8_t
*
temp
=
(
uint8_t
*
)
malloc
(
6
);
memcpy
(
temp
,
(
const
uint8_t
*
)
ent
.
node_mac
.
ether_addr_octet
,
6
);
MAC
node_mac
((
const
uint8_t
*
)
temp
);
mac_table
.
insert
({
node_mac
,
port_i
});
printf
(
"mac_8: %X:%X:%X:%X:%X:%X
\n
"
,
node_mac
.
data
[
0
],
node_mac
.
data
[
1
],
node_mac
.
data
[
2
],
node_mac
.
data
[
3
],
node_mac
.
data
[
4
],
node_mac
.
data
[
5
]);
}
}
netmem_idx
++
;
break
;
break
;
default:
default:
...
@@ -562,7 +586,11 @@ int main(int argc, char *argv[]) {
...
@@ -562,7 +586,11 @@ int main(int argc, char *argv[]) {
// printf("as_id: %d vaddr_start: %lu vadd_end: %lu phys_start: %lu\n", i.as_id, i.vaddr_start, i.vaddr_end, i.phys_start);
// printf("as_id: %d vaddr_start: %lu vadd_end: %lu phys_start: %lu\n", i.as_id, i.vaddr_start, i.vaddr_end, i.phys_start);
// printf("mac_byte: %lx\n", i.node_mac.ether_addr_64);
// printf("mac_byte: %lx\n", i.node_mac.ether_addr_64);
// }
// }
for
(
auto
&
i
:
mac_table
){
printf
(
"port id: %d: "
,
i
.
second
);
printf
(
"mac_8: %X:%X:%X:%X:%X:%X
\n
"
,
i
.
first
.
data
[
0
],
i
.
first
.
data
[
1
],
i
.
first
.
data
[
2
],
i
.
first
.
data
[
3
],
i
.
first
.
data
[
4
],
i
.
first
.
data
[
5
]);
}
if
(
ports
.
empty
()
||
bad_option
)
{
if
(
ports
.
empty
()
||
bad_option
)
{
fprintf
(
stderr
,
fprintf
(
stderr
,
...
...
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