Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
targets
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Feed
targets
Commits
cd5fbb89
Commit
cd5fbb89
authored
5 years ago
by
Benjamin Larsson
Browse files
Options
Downloads
Patches
Plain Diff
panther: wan switch logic framework
parent
1b3176a8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
iopsys-brcm63xx-arm/panther/base-files/lib/functions/marvell.sh
+46
-2
46 additions, 2 deletions
...-brcm63xx-arm/panther/base-files/lib/functions/marvell.sh
iopsys-brcm63xx-arm/panther/base-files/usr/sbin/fiber_wan
+45
-19
45 additions, 19 deletions
iopsys-brcm63xx-arm/panther/base-files/usr/sbin/fiber_wan
with
91 additions
and
21 deletions
iopsys-brcm63xx-arm/panther/base-files/lib/functions/marvell.sh
+
46
−
2
View file @
cd5fbb89
...
...
@@ -2,8 +2,9 @@
disable_addr_learn
()
{
# Disable Address Learning on P0 and P6. Not sure why this is
# needed.
ethctl phy ext 0x10 0xb 0x0000
ethctl phy ext 0x16 0xb 0x0000
# ethctl phy ext 0x10 0xb 0x0000
# ethctl phy ext 0x16 0xb 0x0000
echo test
}
port_mapping
()
{
...
...
@@ -20,6 +21,20 @@ port_mapping() {
ethctl phy ext 0x16 0x6 0x0810
}
port_mapping_copper_wan
()
{
# Dissallow any traffic from P6 (0x16) to any port
ethctl phy ext 0x16 0x6 0x0800
# Dissallow any traffic from P1 (0x11) to any port
ethctl phy ext 0x11 0x6 0x0800
#P0 <-> P4
# Allow port 0 (0x10) to send to port 4
ethctl phy ext 0x10 0x6 0x0810
# Allow port 4 (0x14) to send to port 0
ethctl phy ext 0x14 0x6 0x0801
}
sfp_100
()
{
# Set port to 100BASE-FX
ethctl phy ext 0x11 0x17 0x8504
...
...
@@ -89,3 +104,32 @@ has_power() {
local POWER=
$((
1
<<
4
))
fiber_status
$POWER
}
wan_sfp_mode () {
# check if there is a sfp-rom present and return 0 if so
# returns 2 if there is an error
i2cget -y 0 0x50 0x0 >/dev/null 2>&1
return
$?
}
disable_ext_led () {
ethctl phy ext 0x14 0x16 0x80ee > /dev/null
}
enable_ext_led () {
ethctl phy ext 0x14 0x16 0x8022 > /dev/null
}
copper_speed100() {
local BIT=
$((
1
<<
8
))
local copper_status_reg
copper_status_reg=
$(
ethctl phy ext 0x14 0x00 |
grep
mii |
awk
'{ print $5 }'
)
[
$((
copper_status_reg
&
BIT
))
==
$BIT
] && return 0 || return 1
}
copper_speed1000() {
local BIT=
$((
2
<<
8
))
local copper_status_reg
copper_status_reg=
$(
ethctl phy ext 0x14 0x00 |
grep
mii |
awk
'{ print $5 }'
)
[
$((
copper_status_reg
&
BIT
))
==
$BIT
] && return 0 || return 1
}
This diff is collapsed.
Click to expand it.
iopsys-brcm63xx-arm/panther/base-files/usr/sbin/fiber_wan
+
45
−
19
View file @
cd5fbb89
...
...
@@ -3,26 +3,52 @@
.
/lib/functions/marvell.sh
get_link
()
{
# Start with 1000 Mbps
local
speed
=
1000
sfp_1000
# Start with 1000 Mbps
local
speed
=
1000
sfp_1000
# Toggle between 100 and 1000 Mbps until we get a link when we detect
# fiber energy.
while
true
;
do
if
has_power
;
then
if
no_link
;
then
if
[
$speed
==
1000
]
;
then
sfp_100
speed
=
100
else
sfp_1000
speed
=
1000
fi
fi
fi
sleep
5
done
# Toggle between 100 and 1000 Mbps until we get a link when we detect
# fiber energy.
while
true
;
do
if
wan_sfp_mode
;
then
#map ports for sfp wan mode
port_mapping
# handle ext and wan led
enable_ext_led
if
has_power
;
then
if
no_link
;
then
ubus call led.wan_speed
set
{
\"
state
\"
:
\"
OFF
\"
}
if
[
$speed
==
1000
]
;
then
sfp_100
speed
=
100
else
sfp_1000
speed
=
1000
fi
else
# handle sfp leds
if
[
$speed
==
1000
]
;
then
ubus call led.wan_speed
set
{
\"
state
\"
:
\"
OK
\"
}
else
ubus call led.wan_speed
set
{
\"
state
\"
:
\"
NOTICE
\"
}
fi
fi
sleep
5
else
#wan copper mode
disable_ext_led
port_mapping_copper_wan
if
copper_speed1000
;
then
ubus call led.wan_speed
set
{
\"
state
\"
:
\"
OK
\"
}
elif
copper_speed100
;
then
ubus call led.wan_speed
set
{
\"
state
\"
:
\"
NOTICE
\"
}
else
ubus call led.wan_speed
set
{
\"
state
\"
:
\"
OFF
\"
}
fi
sleep
5
fi
done
}
get_link
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment