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
34b17f08
Commit
34b17f08
authored
Jan 23, 2022
by
Jialin Li
Browse files
tofino: switch drops dummy packet
parent
459609d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
31 deletions
+12
-31
sims/tofino/p4/nopaxos_setup.py
sims/tofino/p4/nopaxos_setup.py
+6
-0
sims/tofino/p4/switch_setup.py
sims/tofino/p4/switch_setup.py
+6
-31
No files found.
sims/tofino/p4/nopaxos_setup.py
View file @
34b17f08
...
@@ -193,6 +193,11 @@ class l2_switch():
...
@@ -193,6 +193,11 @@ class l2_switch():
port
=
port
).
push
()
port
=
port
).
push
()
return
0
return
0
def
l2_add_smac_drop
(
self
,
vid
,
mac_addr
):
mac_addr
=
mac
(
mac_addr
)
self
.
p4
.
Ingress
.
smac
.
entry_with_smac_drop
(
src_addr
=
mac_addr
).
push
()
def
set_mcast
(
num_groups
=
1
,
num_sequencers
=
1
):
def
set_mcast
(
num_groups
=
1
,
num_sequencers
=
1
):
all_ports
=
[
p
for
p
in
range
(
8
)]
all_ports
=
[
p
for
p
in
range
(
8
)]
mcast_ports
=
[
0
,
1
,
2
]
mcast_ports
=
[
0
,
1
,
2
]
...
@@ -213,6 +218,7 @@ def set_mcast(num_groups=1, num_sequencers=1):
...
@@ -213,6 +218,7 @@ def set_mcast(num_groups=1, num_sequencers=1):
### Setup L2 learning
### Setup L2 learning
sl2
=
l2_switch
(
default_ttl
=
10000
)
sl2
=
l2_switch
(
default_ttl
=
10000
)
sl2
.
setup
()
sl2
.
setup
()
sl2
.
l2_add_smac_drop
(
1
,
"00:00:00:00:00:00"
)
bfrt
.
complete_operations
()
bfrt
.
complete_operations
()
p4
=
bfrt
.
nopaxos
.
pipe
p4
=
bfrt
.
nopaxos
.
pipe
...
...
sims/tofino/p4/switch_setup.py
View file @
34b17f08
...
@@ -414,36 +414,10 @@ class l2_switch():
...
@@ -414,36 +414,10 @@ class l2_switch():
return
(
dmac_entry
,
smac_entry
)
return
(
dmac_entry
,
smac_entry
)
def
l2_add
(
self
,
vid
,
mac_addr
,
port
,
def
l2_add_smac_drop
(
self
,
vid
,
mac_addr
):
static
=
False
,
pending
=
False
,
ttl
=
None
,
mac_addr
=
mac
(
mac_addr
)
dst_drop
=
False
,
src_drop
=
False
):
self
.
p4
.
Ingress
.
smac
.
entry_with_smac_drop
(
vid
=
vid
,
src_addr
=
mac_addr
).
push
()
# mac_addr = mac(mac_addr)
# Program DMAC
if
pending
:
self
.
p4
.
Ingress
.
dmac
.
entry_with_dmac_miss
(
vid
=
vid
,
dst_addr
=
mac_addr
).
push
()
elif
dst_drop
:
self
.
p4
.
Ingress
.
dmac
.
entry_with_dmac_drop
(
vid
=
vid
,
dst_addr
=
mac_addr
).
push
()
else
:
self
.
p4
.
Ingress
.
dmac
.
entry_with_dmac_unicast
(
vid
=
vid
,
dst_addr
=
mac_addr
,
port
=
port
).
push
()
# Program SMAC
if
src_drop
:
self
.
p4
.
Ingress
.
smac
.
entry_with_smac_drop
(
vid
=
vid
,
src_addr
=
mac_addr
).
push
()
else
:
if
static
:
ttl
=
0
elif
ttl
==
None
:
ttl
=
self
.
l2_age_ttl
self
.
p4
.
Ingress
.
smac
.
entry_with_smac_hit
(
vid
=
vid
,
src_addr
=
mac_addr
,
is_static
=
static
,
ENTRY_TTL
=
ttl
).
push
()
def
l2_del
(
self
,
vid
,
mac_addr
):
def
l2_del
(
self
,
vid
,
mac_addr
):
mac_addr
=
mac
(
mac_addr
)
mac_addr
=
mac
(
mac_addr
)
...
@@ -496,7 +470,7 @@ class l2_switch():
...
@@ -496,7 +470,7 @@ class l2_switch():
if
smac_entry
.
data
[
b
'is_static'
]:
if
smac_entry
.
data
[
b
'is_static'
]:
static
=
"Y"
static
=
"Y"
elif
smac_entry
.
action
.
name
.
endswith
(
"smac_drop"
):
elif
smac_entry
.
action
.
endswith
(
"smac_drop"
):
src_drop
=
"Y"
src_drop
=
"Y"
if
dmac_entry
or
smac_entry
:
if
dmac_entry
or
smac_entry
:
...
@@ -563,6 +537,7 @@ sl2.port_vlan_default_set(0, 1)
...
@@ -563,6 +537,7 @@ sl2.port_vlan_default_set(0, 1)
sl2
.
port_vlan_default_set
(
1
,
1
)
sl2
.
port_vlan_default_set
(
1
,
1
)
sl2
.
port_vlan_default_set
(
2
,
1
)
sl2
.
port_vlan_default_set
(
2
,
1
)
sl2
.
port_vlan_default_set
(
3
,
1
)
sl2
.
port_vlan_default_set
(
3
,
1
)
sl2
.
l2_add_smac_drop
(
1
,
"00:00:00:00:00:00"
)
bfrt
.
complete_operations
()
bfrt
.
complete_operations
()
sl2
.
vlan_show
()
sl2
.
vlan_show
()
...
...
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